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
484ac7eb605773e28334035b1fcb6b80ff57defc
a20cdf79751f9b92a873393dbc2e5ae455820773
/src/main/java/egovframework/let/utl/fcc/service/UniSelectInfo.java
b5cc049b8e75fd68bc2ff06787ce5d3f7464f04c
[]
no_license
sohoki/cmsDisplay
afc3b831600356485616531b765cda1bf8e1170d
411e11d93786bf9953f434b2371ad8ccd45a067a
refs/heads/master
2022-06-07T16:32:48.880176
2020-03-03T08:32:56
2020-03-03T08:32:56
239,928,925
0
0
null
2020-02-12T04:50:07
2020-02-12T04:45:02
Java
UTF-8
Java
false
false
865
java
package egovframework.let.utl.fcc.service; //공용 테이블 조회 public class UniSelectInfo { private String inResult; private String inTable; private String inColumn; private String inValue; private String vResult; public String getInResult() { return inResult; } public void setInResult(String inResult) { this.inResult = inResult; } public String getInTable() { return inTable; } public void setInTable(String inTable) { this.inTable = inTable; } public String getInColumn() { return inColumn; } public void setInColumn(String inColumn) { this.inColumn = inColumn; } public String getInValue() { return inValue; } public void setInValue(String inValue) { this.inValue = inValue; } public String getvResult() { return vResult; } public void setvResult(String vResult) { this.vResult = vResult; } }
697c7f8858167469ed309638a300945deec44d4c
b35e88d1551035c1142a4d7a5e6e7d8d1b3c0a0f
/src/edu/usf/experiment/subject/affordance/Affordance.java
87146e7843e0969970e6d8d6992912c716a4e323
[]
no_license
mllofriu/experiment
90f7ab85e4f94ba9f34d2624b55b92e5b97d7e36
bc5c666226aa000643cefeb9891dc2f033926eb7
refs/heads/master
2016-09-05T11:00:30.584544
2015-09-01T21:44:59
2015-09-01T21:44:59
30,930,832
0
0
null
null
null
null
UTF-8
Java
false
false
801
java
package edu.usf.experiment.subject.affordance; public abstract class Affordance implements Comparable<Affordance> { boolean realizable; float value; public Affordance() { realizable = false; value = 0; } public boolean isRealizable() { return realizable; } public void setRealizable(boolean realizable) { this.realizable = realizable; } public float getValue() { return value; } public void setValue(float value) { this.value = value; } @Override public int compareTo(Affordance a) { if (realizable == a.realizable) if (value < a.value) return -1; else if (value == a.value) return 0; else return 1; else if (!realizable) return -1; else return 1; } public abstract String toString(); public abstract int getIndex(); }
088b9da3b453e992b0424ee864e3a5bc87e66e4a
cf0ed9851c778f5c9f1864f5e03907ebab89ef0f
/Module5/src/com/threads/LifeCycle.java
c17d2ec226abbd3b10cf9f823f6b30367c345afc
[]
no_license
asthanas/CoreJava
3810ca2e8a6f812975ae539703722f15a32ab6d4
b1bc61d96b5edfb778a2e1e08ed6ae49236dbddd
refs/heads/master
2020-08-08T21:58:45.370141
2020-03-06T18:57:32
2020-03-06T18:57:32
213,929,798
1
0
null
null
null
null
UTF-8
Java
false
false
259
java
package com.threads; public class LifeCycle { public static void main(String[] args) throws InterruptedException { Thread mt = Thread.currentThread(); for(int i =1; i<=10;i++) { System.out.println(i); Thread.sleep(2000); } } }
b4a44bef2492b670febdd1f033d34f9fb64f1857
f88cc89f1fffce2728e8f0590e3ddba53429ce0e
/app/src/main/java/de/mchllngr/androidplayground/module/blank/BlankView.java
9d112937c25a4ae75b00cc97426e4b4efb8cee6d
[ "Apache-2.0" ]
permissive
mchllngr/AndroidPlayground
382997fd1de21896a9c5e63f76c5badbb93aa809
96e7442c8adec2b2b8e5b8228f13398dc06d50fe
refs/heads/master
2021-03-24T12:41:38.057026
2017-12-29T19:35:08
2017-12-29T19:35:08
100,072,032
0
0
null
null
null
null
UTF-8
Java
false
false
205
java
package de.mchllngr.androidplayground.module.blank; import de.mchllngr.androidplayground.base.BaseView; /** * Interface for the {@link BlankActivity} */ public interface BlankView extends BaseView { }
5726c9d6590b4a050dcc749953632c21ddd942b1
d2e201b961885de1f5c4fb85e720bf1e0d1068d7
/Spring-Core/AnnotationConfig_BeanLifeCycle/src/com/beanLifeCycle/MyAnnotationApplication.java
99d36cb18d1c4c81cf62f16df1300581eacb3832
[]
no_license
khasakinil/Spring
32cd310ee215c3074b0708ee463ef331d1f4532e
aa77cb968d75f4820f4f6376b59f9a02226949a7
refs/heads/master
2022-12-21T10:22:19.432195
2020-02-13T18:27:08
2020-02-13T18:27:08
240,329,280
0
0
null
null
null
null
UTF-8
Java
false
false
549
java
package com.beanLifeCycle; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MyAnnotationApplication { public static void main(String... args) { // read spring config file ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); // get the bean from spring container Coach theCoach1 = context.getBean("myCoachTrack", Coach.class); System.out.println(theCoach1.getDailyWorkout()); // close the context context.close(); } }
4e9b66f774d16ded4071bb166426e9789e426ccd
ffeaf567e9b1aadb4c00d95cd3df4e6484f36dcd
/Talagram/org/telegram/ui/Adapters/-$$Lambda$MentionsAdapter$RtUwcbbmysCllxWaHytbPO9oFzY.java
a6153d408952f2824b0574fbb78be51690d011bb
[]
no_license
danielperez9430/Third-party-Telegram-Apps-Spy
dfe541290c8512ca366e401aedf5cc5bfcaa6c3e
f6fc0f9c677bd5d5cd3585790b033094c2f0226d
refs/heads/master
2020-04-11T23:26:06.025903
2018-12-18T10:07:20
2018-12-18T10:07:20
162,166,647
0
0
null
null
null
null
UTF-8
Java
false
false
615
java
package org.telegram.ui.Adapters; import android.util.SparseArray; import java.util.ArrayList; import java.util.Comparator; import org.telegram.tgnet.TLRPC$User; public final class -$$Lambda$MentionsAdapter$RtUwcbbmysCllxWaHytbPO9oFzY implements Comparator { public -$$Lambda$MentionsAdapter$RtUwcbbmysCllxWaHytbPO9oFzY(SparseArray arg1, ArrayList arg2) { super(); this.f$0 = arg1; this.f$1 = arg2; } public final int compare(Object arg3, Object arg4) { return MentionsAdapter.lambda$searchUsernameOrHashtag$5(this.f$0, this.f$1, ((User)arg3), ((User)arg4)); } }
ee16bb4bdfd43187680dfbaba7aa54b0fc682c49
566ca6e31e90571bc37c4f64f634f09a9fcfafdc
/src/main/java/ru/dedateam/innorumors/data/entities/content/Comment.java
f2a20fe5ae2b61a8a2767c56118a88085fc6452c
[]
no_license
ElenaGayazova/InnorumorsDEDA
81b85bc5c2b6220a17b15abaa2fdd4aa818155e7
ecfff8a77ffa3651ba9cbbd52f3443d5a63a627c
refs/heads/master
2020-11-29T16:41:52.422875
2019-12-26T00:58:37
2019-12-26T00:58:37
230,170,486
0
0
null
null
null
null
UTF-8
Java
false
false
1,604
java
package ru.dedateam.innorumors.data.entities.content; import lombok.Data; import lombok.NoArgsConstructor; import ru.dedateam.innorumors.data.entities.profiles.User; import ru.dedateam.innorumors.service.DateFormater; import javax.persistence.*; import java.time.LocalDateTime; @Entity @Table(name = "comments") @Data @NoArgsConstructor public class Comment { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "comments_seq") @SequenceGenerator(name = "comments_seq", sequenceName = "comments_id_seq", allocationSize = 1) @Column(name = "id", updatable = false, nullable = false) private Long id; @Column(name = "body", nullable = false) private String body; @Column(name = "posted_time", nullable = false) private LocalDateTime postedTime; // // @OneToOne // @JoinColumn(name = "comment") // private Comment comment; // комент на который мы отвчемаем @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "post") private Post post; // ссылка на пост под которым написан проект @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "author") private User author; @Column(name = "is_deleted", nullable = false) private Boolean isDeleted; @Transient private Integer rat = 0; public Comment(String body) { this.body = body; this.postedTime = LocalDateTime.now(); this.isDeleted = false; } public String getFormatPostedTime() { return DateFormater.format(postedTime); } }
fd2666295a0176d122c9c85d3438076b78df3927
7bea7fb60b5f60f89f546a12b43ca239e39255b5
/src/com/sun/org/apache/xml/internal/serializer/TreeWalker.java
56026bbd4bbeb8dafaf815f9797851a59fee2d3c
[]
no_license
sorakeet/fitcorejdk
67623ab26f1defb072ab473f195795262a8ddcdd
f946930a826ddcd688b2ddbb5bc907d2fc4174c3
refs/heads/master
2021-01-01T05:52:19.696053
2017-07-15T01:33:41
2017-07-15T01:33:41
97,292,673
0
0
null
null
null
null
UTF-8
Java
false
false
13,941
java
/** * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * <p> * 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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. */ /** * 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.sun.org.apache.xml.internal.serializer; import com.sun.org.apache.xml.internal.serializer.utils.AttList; import com.sun.org.apache.xml.internal.serializer.utils.DOM2Helper; import org.w3c.dom.*; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.LocatorImpl; public final class TreeWalker{ // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON! // DOM2Helper m_dh = new DOM2Helper(); final protected DOM2Helper m_dh; final private ContentHandler m_contentHandler; final private SerializationHandler m_Serializer; final private LocatorImpl m_locator=new LocatorImpl(); boolean nextIsRaw=false; public TreeWalker(ContentHandler ch){ this(ch,null); } public TreeWalker(ContentHandler contentHandler,String systemId){ // Set the content handler m_contentHandler=contentHandler; if(m_contentHandler instanceof SerializationHandler){ m_Serializer=(SerializationHandler)m_contentHandler; }else{ m_Serializer=null; } // Set the system ID, if it is given m_contentHandler.setDocumentLocator(m_locator); if(systemId!=null){ m_locator.setSystemId(systemId); } m_dh=new DOM2Helper(); } public ContentHandler getContentHandler(){ return m_contentHandler; } public void traverse(Node pos) throws org.xml.sax.SAXException{ this.m_contentHandler.startDocument(); Node top=pos; while(null!=pos){ startNode(pos); Node nextNode=pos.getFirstChild(); while(null==nextNode){ endNode(pos); if(top.equals(pos)) break; nextNode=pos.getNextSibling(); if(null==nextNode){ pos=pos.getParentNode(); if((null==pos)||(top.equals(pos))){ if(null!=pos) endNode(pos); nextNode=null; break; } } } pos=nextNode; } this.m_contentHandler.endDocument(); } protected void startNode(Node node) throws org.xml.sax.SAXException{ // TODO: <REVIEW> // A Serializer implements ContentHandler, but not NodeConsumer // so drop this reference to NodeConsumer which would otherwise // pull in all sorts of things // if (m_contentHandler instanceof NodeConsumer) // { // ((NodeConsumer) m_contentHandler).setOriginatingNode(node); // } // TODO: </REVIEW> if(node instanceof Locator){ Locator loc=(Locator)node; m_locator.setColumnNumber(loc.getColumnNumber()); m_locator.setLineNumber(loc.getLineNumber()); m_locator.setPublicId(loc.getPublicId()); m_locator.setSystemId(loc.getSystemId()); }else{ m_locator.setColumnNumber(0); m_locator.setLineNumber(0); } switch(node.getNodeType()){ case Node.COMMENT_NODE:{ String data=((Comment)node).getData(); if(m_contentHandler instanceof LexicalHandler){ LexicalHandler lh=((LexicalHandler)this.m_contentHandler); lh.comment(data.toCharArray(),0,data.length()); } } break; case Node.DOCUMENT_FRAGMENT_NODE: // ??; break; case Node.DOCUMENT_NODE: break; case Node.ELEMENT_NODE: Element elem_node=(Element)node; { // Make sure the namespace node // for the element itself is declared // to the ContentHandler String uri=elem_node.getNamespaceURI(); if(uri!=null){ String prefix=elem_node.getPrefix(); if(prefix==null) prefix=""; this.m_contentHandler.startPrefixMapping(prefix,uri); } } NamedNodeMap atts=elem_node.getAttributes(); int nAttrs=atts.getLength(); // System.out.println("TreeWalker#startNode: "+node.getNodeName()); // Make sure the namespace node of // each attribute is declared to the ContentHandler for(int i=0;i<nAttrs;i++){ final Node attr=atts.item(i); final String attrName=attr.getNodeName(); final int colon=attrName.indexOf(':'); final String prefix; // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue()); if(attrName.equals("xmlns")||attrName.startsWith("xmlns:")){ // Use "" instead of null, as Xerces likes "" for the // name of the default namespace. Fix attributed // to "Steven Murray" <[email protected]>. if(colon<0) prefix=""; else prefix=attrName.substring(colon+1); this.m_contentHandler.startPrefixMapping(prefix, attr.getNodeValue()); }else if(colon>0){ prefix=attrName.substring(0,colon); String uri=attr.getNamespaceURI(); if(uri!=null) this.m_contentHandler.startPrefixMapping(prefix,uri); } } String ns=m_dh.getNamespaceOfNode(node); if(null==ns) ns=""; this.m_contentHandler.startElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName(), new AttList(atts,m_dh)); break; case Node.PROCESSING_INSTRUCTION_NODE:{ ProcessingInstruction pi=(ProcessingInstruction)node; String name=pi.getNodeName(); // String data = pi.getData(); if(name.equals("xslt-next-is-raw")){ nextIsRaw=true; }else{ this.m_contentHandler.processingInstruction(pi.getNodeName(), pi.getData()); } } break; case Node.CDATA_SECTION_NODE:{ boolean isLexH=(m_contentHandler instanceof LexicalHandler); LexicalHandler lh=isLexH ?((LexicalHandler)this.m_contentHandler):null; if(isLexH){ lh.startCDATA(); } dispatachChars(node); { if(isLexH){ lh.endCDATA(); } } } break; case Node.TEXT_NODE:{ //String data = ((Text) node).getData(); if(nextIsRaw){ nextIsRaw=false; m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING,""); dispatachChars(node); m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING,""); }else{ dispatachChars(node); } } break; case Node.ENTITY_REFERENCE_NODE:{ EntityReference eref=(EntityReference)node; if(m_contentHandler instanceof LexicalHandler){ ((LexicalHandler)this.m_contentHandler).startEntity( eref.getNodeName()); }else{ // warning("Can not output entity to a pure SAX ContentHandler"); } } break; default: } } private final void dispatachChars(Node node) throws org.xml.sax.SAXException{ if(m_Serializer!=null){ this.m_Serializer.characters(node); }else{ String data=((Text)node).getData(); this.m_contentHandler.characters(data.toCharArray(),0,data.length()); } } protected void endNode(Node node) throws org.xml.sax.SAXException{ switch(node.getNodeType()){ case Node.DOCUMENT_NODE: break; case Node.ELEMENT_NODE: String ns=m_dh.getNamespaceOfNode(node); if(null==ns) ns=""; this.m_contentHandler.endElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName()); if(m_Serializer==null){ // Don't bother with endPrefixMapping calls if the ContentHandler is a // SerializationHandler because SerializationHandler's ignore the // endPrefixMapping() calls anyways. . . . This is an optimization. Element elem_node=(Element)node; NamedNodeMap atts=elem_node.getAttributes(); int nAttrs=atts.getLength(); // do the endPrefixMapping calls in reverse order // of the startPrefixMapping calls for(int i=(nAttrs-1);0<=i;i--){ final Node attr=atts.item(i); final String attrName=attr.getNodeName(); final int colon=attrName.indexOf(':'); final String prefix; if(attrName.equals("xmlns")||attrName.startsWith("xmlns:")){ // Use "" instead of null, as Xerces likes "" for the // name of the default namespace. Fix attributed // to "Steven Murray" <[email protected]>. if(colon<0) prefix=""; else prefix=attrName.substring(colon+1); this.m_contentHandler.endPrefixMapping(prefix); }else if(colon>0){ prefix=attrName.substring(0,colon); this.m_contentHandler.endPrefixMapping(prefix); } } { String uri=elem_node.getNamespaceURI(); if(uri!=null){ String prefix=elem_node.getPrefix(); if(prefix==null) prefix=""; this.m_contentHandler.endPrefixMapping(prefix); } } } break; case Node.CDATA_SECTION_NODE: break; case Node.ENTITY_REFERENCE_NODE:{ EntityReference eref=(EntityReference)node; if(m_contentHandler instanceof LexicalHandler){ LexicalHandler lh=((LexicalHandler)this.m_contentHandler); lh.endEntity(eref.getNodeName()); } } break; default: } } public void traverse(Node pos,Node top) throws org.xml.sax.SAXException{ this.m_contentHandler.startDocument(); while(null!=pos){ startNode(pos); Node nextNode=pos.getFirstChild(); while(null==nextNode){ endNode(pos); if((null!=top)&&top.equals(pos)) break; nextNode=pos.getNextSibling(); if(null==nextNode){ pos=pos.getParentNode(); if((null==pos)||((null!=top)&&top.equals(pos))){ nextNode=null; break; } } } pos=nextNode; } this.m_contentHandler.endDocument(); } } //TreeWalker
[ "panxiaoping@9af151c5-2e68-9a40-a710-8967c58c11f7" ]
panxiaoping@9af151c5-2e68-9a40-a710-8967c58c11f7
0c8eea1274b88328609615d978368355302b9215
1b61f4471be77df7635bbb19dfc2ead46309dec7
/app/src/main/java/com/example/gmach4u/SecondFragment.java
868ea98e76030274e972fb26621246f8a1073e5e
[]
no_license
noayair/Gmach4U
c4e49bbc9ccbdbc114c5cf411ac9eed6cefd8dc2
e229128b25376d22f86354d459e849bbdc84f8aa
refs/heads/master
2023-04-08T13:42:04.628391
2021-01-13T11:25:16
2021-01-13T11:25:16
362,137,086
1
1
null
null
null
null
UTF-8
Java
false
false
1,087
java
package com.example.gmach4u; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.navigation.fragment.NavHostFragment; public class SecondFragment extends Fragment { @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_second, container, false); } public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { NavHostFragment.findNavController(SecondFragment.this) .navigate(R.id.action_SecondFragment_to_FirstFragment); } }); } }
d58f7d0b395d608089998cfa1418c1b2c851f6e9
51602b78391acc955a76f9713fc6b59bd256f863
/aula44_46/exercicios/Piramide.java
c4b657e6bd3bf3bba39cdbcde986b03a9962e957
[]
no_license
Emanuellysac/Projeto-Loiane-Groner-Java-Basico
a0b27da79cd7d956cb348736d728c125f3278cf5
2d58e2c6196926e704cded78e5418c2b956ba009
refs/heads/master
2020-03-19T05:46:21.287683
2018-06-04T03:12:51
2018-06-04T03:12:51
135,960,743
0
0
null
null
null
null
UTF-8
Java
false
false
1,209
java
package br.com.aula44_46.exercicios; public class Piramide extends Figura3D { private double altura; private double arestaBase; private double apotema; private int numPoliBase; private Figura2D base; public double getAltura() { return altura; } public void setAltura(double altura) { this.altura = altura; } public double getArestaBase() { return arestaBase; } public void setArestaBase(double arestaBase) { this.arestaBase = arestaBase; } public double getApotema() { return apotema; } public void setApotema(double apotema) { this.apotema = apotema; } public Figura2D getBase() { return base; } public void setBase(Figura2D base) { this.base = base; } public int getNumPoliBase() { return numPoliBase; } public void setNumPoliBase(int numPoliBase) { this.numPoliBase = numPoliBase; } @Override public double calcularArea() { if (base != null) { return (numPoliBase * ((arestaBase * apotema)/2)) + base.calcularArea(); } return 0; } @Override public double calcularVolume() { if (base != null) { return (base.calcularArea() * altura)/3; } return 0; } }
bc3fd1ef35fc3b884501c30eb80c78d38f34031a
b9d5157b4f6052e068fa0bc66312356d3d55ac99
/src/com/hncainiao/fubao/ui/adapter/DoctorAdapter.java
6beae5de9de360f39b8c08c0b9c3a93b3b6829e0
[]
no_license
liujie007/cainiao
315e3cc094b892beabaa2fedc9f49eba0d7d535e
f5af11dcd7f958d8231e00db9cf36ff2240359ca
refs/heads/master
2021-01-10T08:44:20.156312
2015-10-29T03:48:31
2015-10-29T03:48:31
44,724,140
0
0
null
null
null
null
UTF-8
Java
false
false
3,610
java
package com.hncainiao.fubao.ui.adapter; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import android.content.Context; import android.graphics.Bitmap; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.hncainiao.fubao.R; import com.hncainiao.fubao.properties.Constant; import com.hncainiao.fubao.ui.activity.BaseActivity; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; /** * @author zhaojing * @version 2010年8月7日 下午12:30:38 * */ public class DoctorAdapter extends Adapter<Map<String, Object>> { private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener(); private Context mContext; private LayoutInflater inflater; public DoctorAdapter(Context Context) { super(Context); this.mContext = Context; this.inflater = LayoutInflater.from(mContext); } static class ViewHolder { ImageView ivPic; TextView tvName; TextView tvLevel; TextView tvLocate; ImageView ivState; } @SuppressWarnings("deprecation") @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub HashMap<String, Object> map = (HashMap<String, Object>) mList .get(position); ViewHolder holder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.item_list_doctor, null); holder = new ViewHolder(); holder.ivPic = (ImageView) convertView .findViewById(R.id.img_item_doctor); holder.tvName = (TextView) convertView .findViewById(R.id.tv_item_doctor_name); holder.tvLevel = (TextView) convertView .findViewById(R.id.tv_item_doctor_level); holder.tvLocate = (TextView) convertView .findViewById(R.id.tv_item_doctor_locate); holder.ivState = (ImageView) convertView .findViewById(R.id.iv_doctor_state); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tvName.setText(map.get("name") + ""); holder.tvLevel.setText(map.get("level") + ""); holder.tvLocate.setText(map.get("locate") + ""); String state=map.get("doctor_status")+""; if (state.equals("1")) { // 有号 holder.ivState.setImageResource(R.drawable.available_order); } else if(state.equals("4")){ holder.ivState.setVisibility(ViewGroup.GONE); } else{ holder.ivState.setImageResource(R.drawable.nohao); } BaseActivity.imageLoader.displayImage(Constant.URL_IMAGE_HOST_STRING+map.get("img"), holder.ivPic, BaseActivity.options, animateFirstListener); return convertView; } private static class AnimateFirstDisplayListener extends SimpleImageLoadingListener { static final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>()); @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if (loadedImage != null) { ImageView imageView = (ImageView) view; // 是否第一次显示 boolean firstDisplay = !displayedImages.contains(imageUri); if (firstDisplay) { // 图片淡入效果 FadeInBitmapDisplayer.animate(imageView, 500); displayedImages.add(imageUri); } } } } }
069f084c02b1cfb0931a85ac531805f44415ec8b
e7a4d6068f276af6e17f0209d85b9496aacd2f5c
/code/spring-security-parent/csrf-1/src/main/java/com/zync/security/csrf1/Csrf1Application.java
ff4a790cfcbf4cb5b2d9d52d55aa9840155a972c
[ "Apache-2.0" ]
permissive
luocong2013/study
be8e3d1b658e84734b02d64cf8506da80cf69747
7b2243a7e921671675d96d0b753c882762c5556f
refs/heads/master
2023-08-30T22:52:11.857988
2023-08-10T08:11:48
2023-08-10T08:11:48
148,992,527
0
1
Apache-2.0
2023-07-23T14:22:38
2018-09-16T12:16:22
HTML
UTF-8
Java
false
false
353
java
package com.zync.security.csrf1; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @author luocong */ @SpringBootApplication public class Csrf1Application { public static void main(String[] args) { SpringApplication.run(Csrf1Application.class, args); } }
8ac29e84831a399990599b95a20c5ae73c318298
2adb2bdb8bfcb7e857adc452855df241f4e9ca32
/src/main/java/com/cmlteam/model/lun/State.java
e34f9f5ad6cd027fb8d9a30d8b696c69ef2c76c0
[ "MIT" ]
permissive
CMLTeam/REA
f24ea585e63adf366c59133505833a55a6dbdbf8
55ade4e9e97df59c528e07fa148fa908f4f71342
refs/heads/master
2021-01-22T08:02:38.608755
2017-06-05T14:40:52
2017-06-05T14:40:52
92,599,018
0
0
null
null
null
null
UTF-8
Java
false
false
349
java
package com.cmlteam.model.lun; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** * @author vgorin * file created on 5/27/17 10:14 PM */ @XmlRootElement public class State { @XmlElement public String stateType; @XmlElement public String constant; @XmlElement public String text; }
5e4394fd2f1d1d2d56c04e8b9b08bf9949053f26
1158919b8fa88501b8a0c9c6d630a656bf11e4f7
/UserDetails/src/com/practoce/testCases/RestApiTest.java
c8b072acfdfc54e86d82fc070ada0696f061d6b0
[]
no_license
MustuShaik123/TestProjectForServiceNow
0f5af53521f40dd4f2760d78d77be3c4867954a6
f20cb486e1c6338f09714ad9899f04002391bee2
refs/heads/master
2020-05-02T16:12:30.748641
2019-03-27T19:43:21
2019-03-27T19:43:21
178,062,650
0
0
null
null
null
null
UTF-8
Java
false
false
1,432
java
package com.practoce.testCases; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import org.jboss.weld.junit4.WeldInitiator; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; import com.practice.users.UserDetailsList; import com.practice.users.UsersDTO; import com.practice.users.impl.UserDetailsApiImpl; @RunWith(MockitoJUnitRunner.class) public class RestApiTest { @Inject UserDetailsApiImpl userDetailsApiImpl; @Rule public WeldInitiator weld = WeldInitiator.from( UserDetailsApiImpl.class, UserDetailsList.class, UsersDTO.class //@formatter:on ).inject(this).build(); @Before public void initialize() { } @Before public void init() { } @Test public void TestSearchFunctionality() { List<UserDetailsList> users =new ArrayList<>(); users.addAll(userDetailsApiImpl.getUsersBySearch("Dieter")); for(UserDetailsList user :users) { assertTrue(user.getName().equalsIgnoreCase("Dieter")); } } @Test public void TestPagination() { List<UserDetailsList> users =new ArrayList<>(); UsersDTO dto=userDetailsApiImpl.getListOfUsersByPagination(2L); assertTrue(dto.getListOfUsers().size()<=10); } }
d2fe1f66d33ce6a81725a22278149c51d62f79a1
df1a582f2ac4da486e0c5ca8154efccf38044440
/src/main/java/com/portfolio/postgreslocks/PostgresLocksApplication.java
2407b37c557990923576304a6be700dda8c07096
[]
no_license
scorpfrog/postgres-locks
af422894277547ed861e94a5394021abc1681b87
6efb50af95e55028b3169c43de907a16a96df20f
refs/heads/main
2023-04-04T09:05:53.999093
2021-04-18T18:47:23
2021-04-18T18:47:23
359,226,402
0
0
null
null
null
null
UTF-8
Java
false
false
334
java
package com.portfolio.postgreslocks; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class PostgresLocksApplication { public static void main(String[] args) { SpringApplication.run(PostgresLocksApplication.class, args); } }
143c1a2caaa131a7349fb4bd62e1bcbfd586a18b
7c1c27bcf92a9a66d90f0174491bf9cacd9faaf7
/src/main/java/com/dip/rent/model/response/OrderByFlatListDTO.java
b41d6961f111758a3439cc20f7fe6bfdb88321c1
[]
no_license
fogyn/rent
ec6a8abafe4384c2ad1c81dde92c498403f24644
4476011f2f9a497a9c3d703c17e3e2e2ada33e74
refs/heads/main
2023-07-22T10:08:45.087034
2021-09-02T23:26:36
2021-09-02T23:26:36
395,395,801
0
0
null
null
null
null
UTF-8
Java
false
false
876
java
package com.dip.rent.model.response; import com.dip.rent.model.Flat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class OrderByFlatListDTO { //private List<Long> listFlatId; private List<Flat> listFlat; //private Date dateNow; private boolean dateBoolean; public OrderByFlatListDTO() { } // public List<Long> getListFlatId() { // return listFlatId; // } // // public void setListFlatId(List<Long> listFlatId) { // this.listFlatId = listFlatId; // } public boolean isDateBoolean() { return dateBoolean; } public void setDateBoolean(boolean dateBoolean) { this.dateBoolean = dateBoolean; } public List<Flat> getListFlat() { return listFlat; } public void setListFlat(List<Flat> listFlat) { this.listFlat = listFlat; } }
e4536a5f021bd5c0c82264e35dff9fe50a9b4bb1
65052e3dff56ee647a0534b1963b6918cc1b39a0
/src/main/java/api/domain/ExpirationDate.java
acb88155b76fc0e75ef7e2c992121babcb42f409
[]
no_license
evan-mcclaugherty/spring-rest
5217be038db9ead55984a1954f181bb4fd66138b
ab9acee20a0f0653eec450303cc26c9abdad243b
refs/heads/master
2020-03-24T02:40:10.158506
2018-07-26T03:52:26
2018-07-26T03:52:26
142,385,820
0
0
null
null
null
null
UTF-8
Java
false
false
1,101
java
package api.domain; import java.io.Serializable; import java.util.HashMap; import java.util.Map; public class ExpirationDate implements Serializable { private String date; private Integer timezoneType; private String timezone; private Map<String, Object> additionalProperties = new HashMap<String, Object>(); private final static long serialVersionUID = 7657623211359896925L; public String getDate() { return date; } public void setDate(String date) { this.date = date; } public Integer getTimezoneType() { return timezoneType; } public void setTimezoneType(Integer timezoneType) { this.timezoneType = timezoneType; } public String getTimezone() { return timezone; } public void setTimezone(String timezone) { this.timezone = timezone; } public Map<String, Object> getAdditionalProperties() { return this.additionalProperties; } public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } }
00a96cbc8abb5e6f07ac9a82279b949752d3a23c
3b22a684e1540d58d07bc6a12ab09584884c273d
/hybris/bin/platform/bootstrap/gensrc/de/hybris/platform/core/model/type/MapTypeModel.java
300891a7eb92a0f919604b281ea81cb9d78654cb
[]
no_license
ScottGledhill/HYB
955221b824b8f0d1b0e584d3f80c2e48bc0c19d9
0c91735fe889bc47878c851445220dbcae7ca281
refs/heads/master
2021-07-25T20:00:36.924559
2017-10-27T14:17:02
2017-10-27T14:17:02
108,548,668
0
0
null
null
null
null
UTF-8
Java
false
false
5,381
java
/* * ---------------------------------------------------------------- * --- WARNING: THIS FILE IS GENERATED AND WILL BE OVERWRITTEN! --- * --- Generated at 27-Oct-2017 13:57:00 --- * ---------------------------------------------------------------- * * [y] hybris Platform * * Copyright (c) 2000-2016 SAP SE * All rights reserved. * * This software is the confidential and proprietary information of SAP * Hybris ("Confidential Information"). You shall not disclose such * Confidential Information and shall use it only in accordance with the * terms of the license agreement you entered into with SAP Hybris. * */ package de.hybris.platform.core.model.type; import de.hybris.bootstrap.annotations.Accessor; import de.hybris.platform.core.model.ItemModel; import de.hybris.platform.core.model.type.TypeModel; import de.hybris.platform.servicelayer.model.ItemModelContext; /** * Generated model class for type MapType first defined at extension core. */ @SuppressWarnings("all") public class MapTypeModel extends TypeModel { /**<i>Generated model type code constant.</i>*/ public final static String _TYPECODE = "MapType"; /** <i>Generated constant</i> - Attribute key of <code>MapType.argumentType</code> attribute defined at extension <code>core</code>. */ public static final String ARGUMENTTYPE = "argumentType"; /** <i>Generated constant</i> - Attribute key of <code>MapType.returntype</code> attribute defined at extension <code>core</code>. */ public static final String RETURNTYPE = "returntype"; /** * <i>Generated constructor</i> - Default constructor for generic creation. */ public MapTypeModel() { super(); } /** * <i>Generated constructor</i> - Default constructor for creation with existing context * @param ctx the model context to be injected, must not be null */ public MapTypeModel(final ItemModelContext ctx) { super(ctx); } /** * <i>Generated constructor</i> - Constructor with all mandatory attributes. * @deprecated Since 4.1.1 Please use the default constructor without parameters * @param _argumentType initial attribute declared by type <code>MapType</code> at extension <code>core</code> * @param _code initial attribute declared by type <code>Type</code> at extension <code>core</code> * @param _generate initial attribute declared by type <code>TypeManagerManaged</code> at extension <code>core</code> * @param _returntype initial attribute declared by type <code>MapType</code> at extension <code>core</code> */ @Deprecated public MapTypeModel(final TypeModel _argumentType, final String _code, final Boolean _generate, final TypeModel _returntype) { super(); setArgumentType(_argumentType); setCode(_code); setGenerate(_generate); setReturntype(_returntype); } /** * <i>Generated constructor</i> - for all mandatory and initial attributes. * @deprecated Since 4.1.1 Please use the default constructor without parameters * @param _argumentType initial attribute declared by type <code>MapType</code> at extension <code>core</code> * @param _code initial attribute declared by type <code>Type</code> at extension <code>core</code> * @param _generate initial attribute declared by type <code>TypeManagerManaged</code> at extension <code>core</code> * @param _owner initial attribute declared by type <code>Item</code> at extension <code>core</code> * @param _returntype initial attribute declared by type <code>MapType</code> at extension <code>core</code> */ @Deprecated public MapTypeModel(final TypeModel _argumentType, final String _code, final Boolean _generate, final ItemModel _owner, final TypeModel _returntype) { super(); setArgumentType(_argumentType); setCode(_code); setGenerate(_generate); setOwner(_owner); setReturntype(_returntype); } /** * <i>Generated method</i> - Getter of the <code>MapType.argumentType</code> attribute defined at extension <code>core</code>. * @return the argumentType */ @Accessor(qualifier = "argumentType", type = Accessor.Type.GETTER) public TypeModel getArgumentType() { return getPersistenceContext().getPropertyValue(ARGUMENTTYPE); } /** * <i>Generated method</i> - Getter of the <code>MapType.returntype</code> attribute defined at extension <code>core</code>. * @return the returntype */ @Accessor(qualifier = "returntype", type = Accessor.Type.GETTER) public TypeModel getReturntype() { return getPersistenceContext().getPropertyValue(RETURNTYPE); } /** * <i>Generated method</i> - Initial setter of <code>MapType.argumentType</code> attribute defined at extension <code>core</code>. Can only be used at creation of model - before first save. * * @param value the argumentType */ @Accessor(qualifier = "argumentType", type = Accessor.Type.SETTER) public void setArgumentType(final TypeModel value) { getPersistenceContext().setPropertyValue(ARGUMENTTYPE, value); } /** * <i>Generated method</i> - Initial setter of <code>MapType.returntype</code> attribute defined at extension <code>core</code>. Can only be used at creation of model - before first save. * * @param value the returntype */ @Accessor(qualifier = "returntype", type = Accessor.Type.SETTER) public void setReturntype(final TypeModel value) { getPersistenceContext().setPropertyValue(RETURNTYPE, value); } }
857cc6d17916d88f3d88387d2c7342379956fae8
5bbe533351d16888939e84acf4331c4a6a4fbee6
/spring-di/src/main/java/nmw/springframework/manualdi/service/PropertyGreetingServiceImpl.java
3c272368792ad600059b93eb58104450bb33d6d1
[]
no_license
nageshwankhade1/Spring
370c6f76025be43b26a6e1eae80910fd58ba9693
1622704e3752d34f0d9a51bd48e96a53f7ff3a77
refs/heads/main
2023-04-17T21:17:10.253516
2021-04-28T15:45:41
2021-04-28T15:45:41
362,428,870
0
0
null
2021-04-28T15:45:42
2021-04-28T10:33:04
Java
UTF-8
Java
false
false
275
java
package nmw.springframework.manualdi.service; import org.springframework.stereotype.Service; @Service public class PropertyGreetingServiceImpl implements GreetingService { @Override public String sayGreetings() { return "HelloWorld-Property"; } }
f9d8c5480932f1e3b580a2b8d1c235054c0b5452
277c1a17195a98cc8a2e991e6f38bf6d3ceaffff
/src/test/java/de/mwg/web/web/rest/TestUtil.java
09974d90a3a59df33ff31ad7a42ebc14983963ab
[ "MIT" ]
permissive
MoWeg/webRTC-firstTry
c0ecffd4e122c8fa07a715ae8f7411d883060861
8d62f7780eece16a50fd0bf48ed3d9b3210115b9
refs/heads/master
2021-01-23T08:20:19.363317
2017-12-09T16:29:22
2017-12-09T16:29:22
86,495,477
0
0
null
null
null
null
UTF-8
Java
false
false
4,412
java
package de.mwg.web.web.rest; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.http.MediaType; import java.io.IOException; import java.nio.charset.Charset; import java.time.ZonedDateTime; import java.time.format.DateTimeParseException; import static org.assertj.core.api.Assertions.assertThat; /** * Utility class for testing REST controllers. */ public class TestUtil { /** MediaType for JSON UTF8 */ public static final MediaType APPLICATION_JSON_UTF8 = new MediaType( MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); /** * Convert an object to JSON byte array. * * @param object * the object to convert * @return the JSON byte array * @throws IOException */ public static byte[] convertObjectToJsonBytes(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); JavaTimeModule module = new JavaTimeModule(); mapper.registerModule(module); return mapper.writeValueAsBytes(object); } /** * Create a byte array with a specific size filled with specified data. * * @param size the size of the byte array * @param data the data to put in the byte array * @return the JSON byte array */ public static byte[] createByteArray(int size, String data) { byte[] byteArray = new byte[size]; for (int i = 0; i < size; i++) { byteArray[i] = Byte.parseByte(data, 2); } return byteArray; } /** * A matcher that tests that the examined string represents the same instant as the reference datetime. */ public static class ZonedDateTimeMatcher extends TypeSafeDiagnosingMatcher<String> { private final ZonedDateTime date; public ZonedDateTimeMatcher(ZonedDateTime date) { this.date = date; } @Override protected boolean matchesSafely(String item, Description mismatchDescription) { try { if (!date.isEqual(ZonedDateTime.parse(item))) { mismatchDescription.appendText("was ").appendValue(item); return false; } return true; } catch (DateTimeParseException e) { mismatchDescription.appendText("was ").appendValue(item) .appendText(", which could not be parsed as a ZonedDateTime"); return false; } } @Override public void describeTo(Description description) { description.appendText("a String representing the same Instant as ").appendValue(date); } } /** * Creates a matcher that matches when the examined string reprensents the same instant as the reference datetime * @param date the reference datetime against which the examined string is checked */ public static ZonedDateTimeMatcher sameInstant(ZonedDateTime date) { return new ZonedDateTimeMatcher(date); } /** * Verifies the equals/hashcode contract on the domain object. */ @SuppressWarnings("unchecked") public static void equalsVerifier(Class clazz) throws Exception { Object domainObject1 = clazz.getConstructor().newInstance(); assertThat(domainObject1.toString()).isNotNull(); assertThat(domainObject1).isEqualTo(domainObject1); assertThat(domainObject1.hashCode()).isEqualTo(domainObject1.hashCode()); // Test with an instance of another class Object testOtherObject = new Object(); assertThat(domainObject1).isNotEqualTo(testOtherObject); // Test with an instance of the same class Object domainObject2 = clazz.getConstructor().newInstance(); assertThat(domainObject1).isNotEqualTo(domainObject2); // HashCodes are equals because the objects are not persisted yet assertThat(domainObject1.hashCode()).isEqualTo(domainObject2.hashCode()); } }
2d617ee44b884fdb6671da55edce22837141228c
646c5860c00543ee5e47c73edea709940596dc6c
/Project/src/game/action/simple/gym/Train.java
68ff27284b7db7e04d3b718e3ca9e10311d11c4b
[]
no_license
amirasem3/AP
32c89d7777a4b3749d7f24970e153f5466436825
ca4ad3b2cf7c3eedb3d152227be74b814e673dc6
refs/heads/master
2021-06-20T06:14:19.741491
2017-07-13T14:40:20
2017-07-13T14:40:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
310
java
package game.action.simple.gym; import game.interactable.AbstractInteractable; import ui.UI; import ui.interactable.gym.TrainUI; /** * Created by Amir on 5/12/2017. * AHAY */ public class Train extends AbstractInteractable { @Override public UI getUI() { return new TrainUI(this); } }
859b55d6049f7abc552b38d2b9d4be1c2cb8aa2e
f7a2886f06ae977c55addf99334fdbf099275756
/cuckoo-example-war/src/main/java/de/akquinet/jbosscc/cuckoo/example/ui/CustomerEdit.java
905f5ea9dacbdf59d0e4ec39ba66af3cf675335a
[]
no_license
cerker/cuckoo-example
59415aac1bfc051de0f3c530472bf51332bf01b6
3624926a0927604d04dc78667183a74562fd7623
refs/heads/master
2021-01-25T08:54:05.574630
2012-02-13T20:14:04
2012-02-13T20:14:04
3,073,883
1
0
null
null
null
null
UTF-8
Java
false
false
2,512
java
package de.akquinet.jbosscc.cuckoo.example.ui; import de.akquinet.jbosscc.cuckoo.example.ejb.CustomerService; import de.akquinet.jbosscc.cuckoo.example.model.Customer; import de.akquinet.jbosscc.cuckoo.example.model.ReturnMessages; import javax.ejb.EJB; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import java.io.Serializable; import static javax.faces.application.FacesMessage.SEVERITY_ERROR; import static javax.faces.application.FacesMessage.SEVERITY_FATAL; import static javax.faces.application.FacesMessage.SEVERITY_INFO; import static javax.faces.application.FacesMessage.SEVERITY_WARN; @SuppressWarnings( {"UnusedDeclaration"} ) @Named @SessionScoped public class CustomerEdit implements Serializable { @EJB private CustomerService customerService; @Inject private CustomerSearch customerSearch; private Customer customer; public Customer getCustomer() { return customer; } public void setCustomer( Customer customer ) { this.customer = customer; } public void store() { ReturnMessages result = customerService.store( customer ); // Show messages returned by SAP for ( ReturnMessages.ReturnMessage returnMessage : result.getReturnMessages() ) { FacesMessage.Severity severity = getSeverity( returnMessage.getSeverity() ); String message = returnMessage.getMessage(); FacesMessage facesMessage = new FacesMessage( severity, message, null ); FacesContext.getCurrentInstance().addMessage( null, facesMessage ); } // Update the list of customers, if there was no error; else we remain in the edit popup. if ( FacesContext.getCurrentInstance().getMaximumSeverity().getOrdinal() < SEVERITY_ERROR.getOrdinal() ) { customerSearch.search(); } } private FacesMessage.Severity getSeverity( ReturnMessages.Severity severity ) { switch ( severity ) { case INFO: return SEVERITY_INFO; case SUCCESS: return SEVERITY_INFO; case WARNING: return SEVERITY_WARN; case ERROR: return SEVERITY_ERROR; case ABORT: return SEVERITY_FATAL; default: return null; } } }
66326c35f835c4bb4d22f2b3ca1012721503dddf
17d15fc2f99f8c5d0ac298237eeca44110e5a6f2
/src/main/java/com/oi/financialoilservices/exception/InputDataException.java
fa38c402dbebac616dac525358d80f9735fb08c4
[]
no_license
rafaelSoaresAlmeida/financial-oil-services
1024cf5b97f5c1f9c972436f1d123ed7f0e513b5
f0da473e91432022c1db100a3f055b7ecd1eaad0
refs/heads/master
2022-03-30T11:14:18.315260
2020-01-14T05:43:12
2020-01-14T05:43:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
108
java
package com.oi.financialoilservices.exception; public class InputDataException extends RuntimeException { }
269ba949aecec426a44e680651e804cd404edd4d
c23ee3e51a41ba0867cbc973c3127a47b66b0cdc
/src/main/java/service/ContentMetaMasterServiceImp.java
f68bbc17343f34ccf3ab63dc5acc34266b529e55
[]
no_license
matthewadedayo/bluesparrow
e2199fd2b09d348797f2d646fc5bfea986c4bccf
75e133b96628565d00464b3397caf737f17fa8c2
refs/heads/master
2022-12-21T07:54:34.119355
2019-09-05T10:10:34
2019-09-05T10:10:34
199,807,808
0
0
null
2022-12-16T03:14:51
2019-07-31T07:54:22
Java
UTF-8
Java
false
false
737
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package service; import dao.ContentMetaMasterDao; import java.util.List; /** * * @author OLAWALE */ public class ContentMetaMasterServiceImp implements ContentMetaMasterService{ private ContentMetaMasterDao contentMetaMasterDao; public void setContentMetaMasterDao(ContentMetaMasterDao contentMetaMasterDao) { this.contentMetaMasterDao = contentMetaMasterDao; } @Override public List<Object[]> readAll() { return contentMetaMasterDao.readAll(); } }
bc1769fd791be80aea4ac7c685a3e1a0828c1ea2
a148903b36b0a7ea42a357c5592aebac74c873f8
/crui_pojo/src/main/java/com/crui/pojo/goods/Para.java
67ba65d139688a3fb95de84c03f5424116306c7a
[]
no_license
chengrui990/crui_parent
f90bab45cfff2839dc9c51d266ff0d5f16a6a682
cc7e1617fc75986984b1e1e1b33d10fa7e7a390b
refs/heads/master
2022-12-22T16:35:06.056745
2020-04-17T09:02:20
2020-04-17T09:02:20
230,453,071
0
0
null
null
null
null
UTF-8
Java
false
false
984
java
package com.crui.pojo.goods; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable; /** * para实体类 * @author Administrator * */ @Table(name="tb_para") public class Para implements Serializable{ @Id private Integer id;//id private String name;//名称 private String options;//选项 private Integer seq;//排序 private Integer templateId;//模板ID public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getOptions() { return options; } public void setOptions(String options) { this.options = options; } public Integer getSeq() { return seq; } public void setSeq(Integer seq) { this.seq = seq; } public Integer getTemplateId() { return templateId; } public void setTemplateId(Integer templateId) { this.templateId = templateId; } }
a87a30a2d71ad8239f050228b32c4bdbb33380cd
6aa7c9cdd37bc2242e2464889e87c4575ea3dd06
/src/main/java/jsug/portside/api/dto/UpdateAttendRequestForm.java
27e8a4a8dfe1dc4ab8ae5668d8598949b437d14d
[]
no_license
b1a9id/portside-api
74d05850490ba9c98022510f0efbd991bc7cf003
01ce8da377c96c2b40a76fcd29633b18cccfc53e
refs/heads/master
2021-05-09T18:05:28.345747
2017-10-23T04:55:08
2017-10-23T04:55:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
412
java
package jsug.portside.api.dto; import java.util.ArrayList; import java.util.List; import java.util.UUID; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; public class UpdateAttendRequestForm { @Size(min=1) public List<UUID> ids = new ArrayList<>(); public String toString() { return ToStringBuilder.reflectionToString(this); } }
88473e725a820adba3a6b44ad0d52802d665c125
a8906130b441b794cdc709ba75a12ef2444b6ce2
/app/src/main/java/com/example/lucas/androidquiz/Helper/Base64Custom.java
2e309332fd0334d25bd685fcd9b3aa9f3a008e35
[]
no_license
lucasbelles/AndroidQuiz
d2230749964cfc2af42602c626c7bd24d6b933e0
47db8d34e7cd16cdab9d02be893e3e1aa22909f9
refs/heads/master
2020-03-21T04:11:45.977690
2018-06-23T22:29:13
2018-06-23T22:29:13
138,096,172
0
1
null
null
null
null
UTF-8
Java
false
false
457
java
package com.example.lucas.androidquiz.Helper; import android.support.annotation.NonNull; import android.util.Base64; public class Base64Custom { public static String coficadorBase64(String texto){ return Base64.encodeToString(texto.getBytes(), Base64.DEFAULT).replaceAll("(\\n/\\r)",""); } public static String decoficadarBase64(String textoCodificado){ return new String(textoCodificado.getBytes(), Base64.DEFAULT); } }
9e2a61ab1c4f4ab77ea58017126557283ff48eb3
6482753b5eb6357e7fe70e3057195e91682db323
/org/apache/logging/log4j/core/filter/ThresholdFilter.java
b350f04aa27a5510a3221dafd3d72e0eb73ad1cf
[]
no_license
TheShermanTanker/Server-1.16.3
45cf9996afa4cd4d8963f8fd0588ae4ee9dca93c
48cc08cb94c3094ebddb6ccfb4ea25538492bebf
refs/heads/master
2022-12-19T02:20:01.786819
2020-09-18T21:29:40
2020-09-18T21:29:40
296,730,962
0
1
null
null
null
null
UTF-8
Java
false
false
6,015
java
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 5 at java.base/java.util.Vector.get(Vector.java:749) at com.strobel.assembler.metadata.MetadataResolver.resolve(MetadataResolver.java:82) at com.strobel.assembler.metadata.CoreMetadataFactory$UnresolvedType.resolve(CoreMetadataFactory.java:616) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.searchUpScope(JavaNameResolver.java:247) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.searchUpScope(JavaNameResolver.java:268) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.searchUpScope(JavaNameResolver.java:250) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.visitTypeDeclaration(JavaNameResolver.java:702) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.visitTypeDeclaration(JavaNameResolver.java:63) at com.strobel.decompiler.languages.java.ast.TypeDeclaration.acceptVisitor(TypeDeclaration.java:90) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.visitCompilationUnit(JavaNameResolver.java:739) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.visitCompilationUnit(JavaNameResolver.java:63) at com.strobel.decompiler.languages.java.ast.CompilationUnit.acceptVisitor(CompilationUnit.java:81) at com.strobel.decompiler.languages.java.ast.JavaNameResolver$FindDeclarationVisitor.resolveName(JavaNameResolver.java:94) at com.strobel.decompiler.languages.java.ast.JavaNameResolver.resolveCore(JavaNameResolver.java:54) at com.strobel.decompiler.languages.java.ast.JavaNameResolver.resolveAsType(JavaNameResolver.java:45) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.resolveName(AddReferenceQualifiersTransform.java:230) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.visitSimpleType(AddReferenceQualifiersTransform.java:159) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.visitSimpleType(AddReferenceQualifiersTransform.java:35) at com.strobel.decompiler.languages.java.ast.SimpleType.acceptVisitor(SimpleType.java:78) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitChildren(DepthFirstAstVisitor.java:41) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitParameterDeclaration(DepthFirstAstVisitor.java:234) at com.strobel.decompiler.languages.java.ast.ParameterDeclaration.acceptVisitor(ParameterDeclaration.java:84) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitChildren(DepthFirstAstVisitor.java:41) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitMethodDeclaration(DepthFirstAstVisitor.java:214) at com.strobel.decompiler.languages.java.ast.ContextTrackingVisitor.visitMethodDeclaration(ContextTrackingVisitor.java:64) at com.strobel.decompiler.languages.java.ast.ContextTrackingVisitor.visitMethodDeclaration(ContextTrackingVisitor.java:28) at com.strobel.decompiler.languages.java.ast.MethodDeclaration.acceptVisitor(MethodDeclaration.java:85) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitChildren(DepthFirstAstVisitor.java:41) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitTypeDeclaration(DepthFirstAstVisitor.java:244) at com.strobel.decompiler.languages.java.ast.ContextTrackingVisitor.visitTypeDeclaration(ContextTrackingVisitor.java:52) at com.strobel.decompiler.languages.java.ast.ContextTrackingVisitor.visitTypeDeclaration(ContextTrackingVisitor.java:28) at com.strobel.decompiler.languages.java.ast.TypeDeclaration.acceptVisitor(TypeDeclaration.java:90) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitChildren(DepthFirstAstVisitor.java:41) at com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor.visitCompilationUnit(DepthFirstAstVisitor.java:249) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.visitCompilationUnit(AddReferenceQualifiersTransform.java:174) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.visitCompilationUnit(AddReferenceQualifiersTransform.java:35) at com.strobel.decompiler.languages.java.ast.CompilationUnit.acceptVisitor(CompilationUnit.java:81) at com.strobel.decompiler.languages.java.ast.ContextTrackingVisitor.run(ContextTrackingVisitor.java:84) at com.strobel.decompiler.languages.java.ast.transforms.AddReferenceQualifiersTransform.run(AddReferenceQualifiersTransform.java:47) at com.strobel.decompiler.languages.java.ast.transforms.TransformationPipeline.runTransformationsUntil(TransformationPipeline.java:93) at com.strobel.decompiler.languages.java.ast.AstBuilder.runTransformations(AstBuilder.java:119) at cuchaz.enigma.source.procyon.ProcyonDecompiler.getSource(ProcyonDecompiler.java:76) at cuchaz.enigma.EnigmaProject$JarExport.decompileClass(EnigmaProject.java:270) at cuchaz.enigma.EnigmaProject$JarExport.lambda$decompileStream$1(EnigmaProject.java:246) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1624) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290) at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
19868dde3854376012d34a07bd24b8aa20a81bed
a58dd4534a10577c60df31b1b73a23b4243d2e2c
/src/main/java/com/core/service/process/order/IOrderProcessService.java
903bd46d7f46243623b7a1d407af7328e61ff4f8
[]
no_license
dk2n8806/WeaztWeb
1744c3b9801b84b2f3454235784eaaffe745cdd3
9a0fd595d5de4dd9f6e5360e580039c68f4e265f
refs/heads/master
2021-06-26T12:07:07.356916
2017-09-12T05:36:54
2017-09-12T05:36:54
103,226,535
0
1
null
null
null
null
UTF-8
Java
false
false
632
java
package com.core.service.process.order; import com.common.entity.order.OrderBundle; import com.common.entity.product.Product; import com.common.exception.MerchantException; import com.common.exception.OrderException; import com.common.exception.ProductException; import com.common.util.date.DateInterval; /** * <p>A service to process order</p> * @author dk2n_ * */ public interface IOrderProcessService { /** {@link OrderProcessServiceImpl#generateOrder(Product, DateInterval)} */ OrderBundle generateOrder(Product product, DateInterval dateInterval) throws ProductException, OrderException, MerchantException; }
23ddb4ef0895530df1c9ed823b3d1822cb6948d5
69ed9bc50c0ce1f0290fbe4bf1313ea567daa633
/app/src/main/java/com/furqoncreative/mevent/adapter/ImageSliderAdapter.java
c1c17e2fb17447425eecc4c3582592b0fbbe6ce2
[]
no_license
furqoncreative/MEvent
1c8767c6c2cb0452bf7550fc0531ba28e1c9002a
aedb95227eb453769d2a5792d332c88d314d4b4e
refs/heads/master
2020-05-24T23:32:24.059077
2019-05-23T00:48:16
2019-05-23T00:48:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,867
java
package com.furqoncreative.mevent.adapter; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.viewpager.widget.PagerAdapter; import com.furqoncreative.mevent.R; import com.furqoncreative.mevent.model.ImageSliderModel; import com.squareup.picasso.Picasso; import java.util.List; public class ImageSliderAdapter extends PagerAdapter { private Context mContext; private String mUrl; private List<ImageSliderModel> imageList; private LayoutInflater inflater; public ImageSliderAdapter(Context context, List<ImageSliderModel> list, String url) { mContext = context; imageList = list; mUrl = url; if (mContext != null) { inflater = LayoutInflater.from(context); } } @Override public Object instantiateItem(ViewGroup collection, int position) { ViewGroup imageLayout = (ViewGroup) inflater.inflate(R.layout.slider_home, collection, false); ImageView imageView = imageLayout.findViewById(R.id.imageView); String imageUrl = mUrl + imageList.get(position).getImage_drawable(); Picasso.get().load(imageUrl).into(imageView); collection.addView(imageLayout); return imageLayout; } @Override public void destroyItem(ViewGroup collection, int position, Object view) { collection.removeView((View) view); } @Override public int getCount() { return imageList.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public CharSequence getPageTitle(int position) { return imageList.get(position).getName(); } }
155d607a6b85477b279f65d33c7d9f378d35ea2f
b1adb5f094e0f46ba469f08408e6336108c85bb8
/MiniMax.java
631746b33e9e36147ace598d8b33c6819da3f731
[]
no_license
anmolsaxena10/TicTacToe
b7e74bbc13afa2603ef5090d6d6f599fec69d58e
69be64e512cbd2f65c8b29dc2eca71010a280cc0
refs/heads/master
2021-05-15T16:08:50.460533
2017-10-18T17:07:08
2017-10-18T17:07:08
107,438,019
0
0
null
null
null
null
UTF-8
Java
false
false
2,481
java
class MiniMax{ int bestRow,bestCol; char player = 'X',opponent = 'O'; boolean isMoveLeft(char board[][]){ for(int i=0 ; i<3 ; i++){ for(int j=0 ; j<3 ; j++){ if(board[i][j] == '_'){ return true; } } } return false; } int evaluate(char board[][]){ for(int row=0 ; row<3 ; row++){ if(board[row][0] == board[row][1] && board[row][1] == board[row][2]){ if(board[row][0] == player)return(10); else if(board[row][0] == opponent)return(-10); } } for(int col=0 ; col<3 ; col++){ if(board[0][col] == board[1][col] && board[1][col] == board[2][col]){ if(board[0][col] == player)return(10); else if(board[0][col] == opponent)return(-10); } } if(board[0][0] == board[1][1] && board[2][2] == board[1][1]){ if(board[0][0] == player)return(10); else if(board[0][0] == opponent)return(-10); } if(board[0][2] == board[1][1] && board[2][0] == board[1][1]){ if(board[0][2] == player)return(10); else if(board[0][2] == opponent)return(-10); } return(0); } int minimax(char board[][], int depth, boolean isMax){ int score = evaluate(board); if(score == 10 || score == -10){ return(score); } if(!isMoveLeft(board)){ return(0); } if(isMax){ int best = -1000; for(int i=0 ; i<3 ; i++){ for(int j=0 ; j<3 ; j++){ if(board[i][j] == '_'){ board[i][j] = player; best = max(best, minimax(board,depth+1,!isMax)); board[i][j] = '_'; } } } return(best); } else{ int best = 1000; for(int i=0 ; i<3 ; i++){ for(int j=0 ; j<3 ; j++){ if(board[i][j] == '_'){ board[i][j] = opponent; best = min(best, minimax(board,depth+1,!isMax)); board[i][j] = '_'; } } } return(best); } } void findBestMove(char board[][]){ int bestVal = -1000; bestCol = -1; bestRow = -1; for(int i=0 ; i<3 ; i++){ for(int j=0 ; j<3 ; j++){ if(board[i][j] == '_'){ board[i][j] = player; int moveVal = minimax(board, 0, false); board[i][j] = '_'; if(moveVal > bestVal){ bestRow = i; bestCol = j; bestVal = moveVal; } } } } } int max(int a, int b){ if(a>b)return(a); else return(b); } int min(int a, int b){ if(a<b)return(a); else return(b); } }
4629f921d7bedc06bcd8a6b0fd2253a37ece5175
aeb99a228fef669c74f7ba17a8a226d62e95a9e0
/Librari/progra librerias/Criptografia/Encryp proyecs/aesh-master/aesh-master/src/test/java/org/jboss/aesh/console/aesh/AeshScriptTest.java
63abfcb20838300f40802df527b3fb2c4c4e7ef3
[ "Apache-2.0" ]
permissive
D3nnis99/ras
b7fc677a5e7b002a3deac5bedfeff5fcb68f4b1b
9ff8e0022a59243356a1294e9016cb08052c7d92
refs/heads/master
2022-12-15T14:35:27.379443
2020-08-26T02:17:49
2020-08-26T02:17:49
290,372,060
0
0
null
null
null
null
UTF-8
Java
false
false
8,323
java
/* * JBoss, Home of Professional Open Source * Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors * as indicated by the @authors tag. All rights reserved. * See the copyright.txt in the distribution for a * full listing of individual contributors. * * 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.jboss.aesh.console.aesh; import org.jboss.aesh.cl.CommandDefinition; import org.jboss.aesh.cl.internal.ProcessedCommandBuilder; import org.jboss.aesh.cl.parser.CommandLineParserException; import org.jboss.aesh.cl.internal.ProcessedCommand; import org.jboss.aesh.cl.result.ResultHandler; import org.jboss.aesh.console.AeshConsole; import org.jboss.aesh.console.AeshConsoleBuilder; import org.jboss.aesh.console.Config; import org.jboss.aesh.console.Prompt; import org.jboss.aesh.console.Shell; import org.jboss.aesh.console.command.Command; import org.jboss.aesh.console.command.CommandResult; import org.jboss.aesh.console.command.invocation.CommandInvocation; import org.jboss.aesh.console.command.registry.AeshCommandRegistryBuilder; import org.jboss.aesh.console.command.registry.CommandRegistry; import org.jboss.aesh.console.settings.CommandNotFoundHandler; import org.jboss.aesh.console.settings.Settings; import org.jboss.aesh.console.settings.SettingsBuilder; import org.junit.Test; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * the idea of this test is to show how aesh could work reading a script file. * this impl will only accept "foo" commands, * if any other commands are found it should jump out and exit. * * the scriptfile: * foo //this is accepted * foo // also accepted * * exit //should exit * * @author <a href="mailto:[email protected]">Ståle W. Pedersen</a> */ public class AeshScriptTest { private static CountDownLatch counter = new CountDownLatch(3); @Test public void scriptPoc() throws IOException, CommandLineParserException, InterruptedException { PipedOutputStream outputStream = new PipedOutputStream(); PipedInputStream pipedInputStream = new PipedInputStream(outputStream); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Settings settings = new SettingsBuilder() .inputStream(pipedInputStream) .outputStream(new PrintStream(byteArrayOutputStream)) .logging(true) .create(); CommandResultHandler resultHandler = new CommandResultHandler(); ProcessedCommand fooCommand = new ProcessedCommandBuilder() .name("foo") .resultHandler(resultHandler) .command(FooCommand.class) .create(); CommandRegistry registry = new AeshCommandRegistryBuilder() .command(fooCommand) .command(BarCommand.class) .command(new RunCommand(resultHandler)) .command(ExitCommand.class) .create(); AeshConsoleBuilder consoleBuilder = new AeshConsoleBuilder() .settings(settings) .commandRegistry(registry) .commandNotFoundHandler(resultHandler) .prompt(new Prompt("")); AeshConsole aeshConsole = consoleBuilder.create(); aeshConsole.start(); outputStream.write("run".getBytes()); outputStream.write(Config.getLineSeparator().getBytes()); outputStream.flush(); counter.await(1, TimeUnit.SECONDS); assertEquals(0, counter.getCount()); } private List<String> readScriptFile() throws IOException { List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(new FileReader("src/test/resources/script1")); String line = br.readLine(); while (line != null) { if (line.trim().length() > 0 && !line.trim().startsWith("#")) lines.add(line); line = br.readLine(); } return lines; } @CommandDefinition(name = "run", description = "") private class RunCommand implements Command { private final CommandResultHandler resultHandler; public RunCommand(CommandResultHandler resultHandler) { this.resultHandler = resultHandler; } @Override public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { // commandInvocation.putProcessInBackground(); List<String> script = readScriptFile(); for(String line : script) { commandInvocation.executeCommand(line + Config.getLineSeparator()); } return CommandResult.SUCCESS; } } @CommandDefinition(name ="exit", description = "") private static class ExitCommand implements Command { @Override public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { commandInvocation.getShell().out().println("EXITING"); commandInvocation.stop(); return CommandResult.SUCCESS; } } @CommandDefinition(name = "foo", description = "") private static class FooCommand implements Command { @Override public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { if(counter.getCount() > 1) { commandInvocation.getShell().out().println("computing...." + Config.getLineSeparator() + "finished computing, returning..."); counter.countDown(); return CommandResult.SUCCESS; } else { assertTrue(false); return CommandResult.FAILURE; } } } @CommandDefinition(name = "bar", description = "") private static class BarCommand implements Command { @Override public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { if(counter.getCount() == 1) { commandInvocation.getShell().out().println("baring...." + Config.getLineSeparator() + "finished baring, returning..."); counter.countDown(); return CommandResult.SUCCESS; } else { assertTrue(false); return CommandResult.FAILURE; } } } private static class CommandResultHandler implements ResultHandler, CommandNotFoundHandler { private boolean failed = false; private String failedString; @Override public void onSuccess() { } @Override public void onFailure(CommandResult result) { failed = true; } @Override public void onValidationFailure(CommandResult result, Exception exception) { failed = true; failedString = exception.toString(); } public void setFailed(boolean f) { failed = f; } public boolean hasFailed() { return failed; } public String getFailedReason() { return failedString; } @Override public void handleCommandNotFound(String line, Shell shell) { failed = true; failedString = line; } } }
eb9f64825a2fbdf1419cd81448614a5e3ae76e43
5e3235edf3de262f4d10b9e9e1fcc3bd13d6b8b1
/Code Snippet Repository/Hibernate/Hibernate2482.java
38cc76565eb6f6c54d9a6f9143e5ef54def608d4
[]
no_license
saber13812002/DeepCRM
3336a244d4852a364800af3181e03e868cf6f9f5
be3e5e50e34a042d5ba7259ff5ff75c08ab32bb9
refs/heads/master
2023-03-16T00:08:06.473699
2018-04-18T05:29:50
2018-04-18T05:29:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
256
java
public void clear() { if ( managedToMergeEntitiesXref != null ) { managedToMergeEntitiesXref.clear(); managedToMergeEntitiesXref = null; } if ( countsByEntityName != null ) { countsByEntityName.clear(); countsByEntityName = null; } }
4803b20e5a7b19e6d1d4536fb3127facbf784bf7
74a2ef6ace8a63e1d52aa8a5b9907b06e0b7469c
/lab3/lab3_code/app/src/main/java/com/example/dg123/shopping/MainActivity.java
dc69caa3df4a3045fcb4bb1b9a1bc81dbc9c35d9
[]
no_license
namelessmonster/Android_lab
3bc5863eda438f2a6e1300f0a0c682ad0c2b86aa
e7d4464a4f1c51c30cb6dfa6ce0989f9f410be7f
refs/heads/master
2021-09-12T03:13:23.553442
2018-01-23T06:55:46
2018-01-23T06:55:46
106,246,248
0
0
null
null
null
null
UTF-8
Java
false
false
9,312
java
package com.example.dg123.shopping; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.provider.ContactsContract; import android.support.design.widget.FloatingActionButton; //import android.support.v4.app.ActivityCompatApi23; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; public class MainActivity extends AppCompatActivity { private RecyclerView mRecyclerView; private CommonAdapter commonAdapter; public static List<Map<String, Object>> listItems; public List<Integer> p1, p2; private Map<String, Object> map; private FloatingActionButton fab; private ListView mListView; private ListAdapter listAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); mListView = (ListView) findViewById(R.id.list_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); getList(); commonAdapter = new CommonAdapter(this, R.layout.goods_list_item, p1) { @Override public void convert(ViewHolder holder, int pos){ TextView name = holder.getView(R.id.name); name.setText(listItems.get(pos).get("name").toString()); TextView first = holder.getView(R.id.first); first.setText(listItems.get(pos).get("firstLetter").toString()); } }; commonAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() { @Override public void onClick(int position) { if (commonAdapter.tag == false) return; Intent intent = new Intent(MainActivity.this, InfoActivity.class); intent.putExtra("name", listItems.get(commonAdapter.mDatas.get(position)).get("name").toString()); intent.putExtra("type", listItems.get(commonAdapter.mDatas.get(position)).get("type").toString()); intent.putExtra("price", listItems.get(commonAdapter.mDatas.get(position)).get("price").toString()); intent.putExtra("info", listItems.get(commonAdapter.mDatas.get(position)).get("info").toString()); intent.putExtra("pos", commonAdapter.mDatas.get(position)); intent.putExtra("tag", (Boolean) listItems.get(commonAdapter.mDatas.get(position)).get("tag")); startActivityForResult(intent, 1); } @Override public void onLongClick(final int position) { if (commonAdapter.tag == false) return; commonAdapter.tag = false; check(commonAdapter.mDatas.get(position)); commonAdapter.mDatas.remove(position); commonAdapter.notifyDataSetChanged(); Toast.makeText(MainActivity.this, "移除第" + position + "个商品", Toast.LENGTH_SHORT).show(); commonAdapter.tag = true; } }); mRecyclerView.setAdapter(commonAdapter); listAdapter = new ListAdapter(this, p2); mListView.setAdapter(listAdapter); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 0) return; if (mListView.getTag().equals("1")) return; Intent intent = new Intent(MainActivity.this, InfoActivity.class); intent.putExtra("name", listItems.get(listAdapter.goods.get(position)).get("name").toString()); intent.putExtra("type", listItems.get(listAdapter.goods.get(position)).get("type").toString()); intent.putExtra("price", listItems.get(listAdapter.goods.get(position)).get("price").toString()); intent.putExtra("info", listItems.get(listAdapter.goods.get(position)).get("info").toString()); intent.putExtra("pos", listAdapter.goods.get(position)); intent.putExtra("tag", (Boolean) listItems.get(listAdapter.goods.get(position)).get("tag")); startActivityForResult(intent, 1); } }); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { if (position == 0) return false; if (mListView.getTag().equals("1")) return false; mListView.setTag("1"); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("移除商品"); builder.setMessage("从购物车移除" + listItems.get(listAdapter.goods.get(position)).get("name").toString() + "?"); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mListView.setTag("0"); } }); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); listAdapter.goods.remove(position); listAdapter.notifyDataSetChanged(); mListView.setTag("0"); } }); builder.create().show(); return false; } }); } public void check(int pos){ int i = 1; while (i < listAdapter.goods.size()){ if (listAdapter.goods.get(i).equals(pos)) listAdapter.goods.remove(i); else ++i; } listAdapter.notifyDataSetChanged(); } public void getList(){ listItems = new ArrayList<>(); p1 = new ArrayList<>(); p2 = new ArrayList<>(); String[] goodsName = new String[]{"Enchated Forest", "Arla Milk", "Devondale Milk", "Kindle Oasis", "waitrose 早餐麦片", "Mcvitie's 饼干", "Ferrero Rocher", "Maltesers", "Lindt", "Borggreve"}; String[] goodsPrice = new String[]{"¥5.00", "¥59.00", "¥79.00", "¥2399.00", "¥179.00", "¥14.90", "¥132.59", "¥141.43", "¥139.43", "¥28.90"}; String[] goodsType = new String[]{"作者", "产地", "产地", "版本", "重量", "产地", "重量", "重量", "重量", "重量"}; String[] goodsInfo = new String[]{"Johanna Basford", "德国", "澳大利亚", "8GB", "2Kg", "英国", "300g", "118g", "249g", "640g"}; map = new HashMap<>(); map.put("name", "购物车"); map.put("firstLetter", "*"); map.put("price", "价格"); map.put("tag", false); listItems.add(map); p2.add(0); for (int i=0;i<goodsName.length;++i){ map = new HashMap<>(); map.put("name", goodsName[i]); map.put("price", goodsPrice[i]); map.put("type", goodsType[i]); map.put("info", goodsInfo[i]); map.put("firstLetter", goodsName[i].charAt(0)); map.put("tag", false); listItems.add(map); p1.add(i+1); } } public void fabClick(View view){ fab = (FloatingActionButton) findViewById(R.id.fab); if (fab.getTag().equals("0")){ fab.setImageResource(R.mipmap.mainpage); fab.setTag("1"); mRecyclerView.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); } else{ fab.setImageResource(R.mipmap.shoplist); fab.setTag("0"); mRecyclerView.setVisibility(View.VISIBLE); mListView.setVisibility(View.GONE); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ if (resultCode == RESULT_OK){ Bundle extras = data.getExtras(); int pos = extras.getInt("pos"); int num = extras.getInt("num"); boolean tag = extras.getBoolean("tag"); listItems.get(pos).put("tag", tag); for (int i=0;i<num;++i){ listAdapter.goods.add(pos); } listAdapter.notifyDataSetChanged(); } } }
7dad09c579fc0842969e2901f730decf23655d8d
a8907c32e6c54f893cf3863685ca94f2f5ad33d6
/mylibrary/src/main/java/org/w3c/doms/events/EventListener.java
9237328199b3fa180d35c8dcd9e31ed2275b3a59
[]
no_license
stevie658jjh/lib2
6438e99d47a6696da03bcef2821069c8912cbc08
20231a5c4f4621da588232d80dbc001f60c4454c
refs/heads/master
2022-08-14T06:06:32.237178
2020-05-08T07:40:59
2020-05-08T07:40:59
262,249,969
0
0
null
null
null
null
UTF-8
Java
false
false
2,048
java
/* * Copyright (c) 2000 World Wide Web Consortium, * (Massachusetts Institute of Technology, Institut National de * Recherche en Informatique et en Automatique, Keio University). All * Rights Reserved. This program is distributed under the W3C's Software * Intellectual Property License. This program is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. * See W3C License http://www.w3.org/Consortium/Legal/ for more details. */ package org.w3c.doms.events; /** * The <code>EventListener</code> interface is the primary method for * handling events. Users implement the <code>EventListener</code> interface * and register their listener on an <code>EventTarget</code> using the * <code>AddEventListener</code> method. The users should also remove their * <code>EventListener</code> from its <code>EventTarget</code> after they * have completed using the listener. * <p> When a <code>Node</code> is copied using the <code>cloneNode</code> * method the <code>EventListener</code>s attached to the source * <code>Node</code> are not attached to the copied <code>Node</code>. If * the user wishes the same <code>EventListener</code>s to be added to the * newly created copy the user must add them manually. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113'>Document Object Model (DOM) Level 2 Events Specification</a>. * @since DOM Level 2 */ public interface EventListener { /** * This method is called whenever an event occurs of the type for which * the <code> EventListener</code> interface was registered. * @param evt The <code>Event</code> contains contextual information * about the event. It also contains the <code>stopPropagation</code> * and <code>preventDefault</code> methods which are used in * determining the event's flow and default action. */ public void handleEvent(Event evt); }
c2b8141322f36d8f04c595a6ded4f8497c2f2379
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/google--guava/7d5825f96a618f0b7edf3054019e22dfd1910902/before/CharMatcher.java
5e4cbd01bb427dbfb1109760dab1bca3a25e9a52
[]
no_license
fracz/refactor-extractor
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
dd5e82bfcc376e74a99e18c2bf54c95676914272
refs/heads/master
2021-01-19T06:50:08.211003
2018-11-30T13:00:57
2018-11-30T13:00:57
87,353,478
0
0
null
null
null
null
UTF-8
Java
false
false
41,047
java
/* * Copyright (C) 2008 The Guava 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 com.google.common.base; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.annotation.CheckReturnValue; /** * Determines a true or false value for any Java {@code char} value, just as {@link Predicate} does * for any {@link Object}. Also offers basic text processing methods based on this function. * Implementations are strongly encouraged to be side-effect-free and immutable. * * <p>Throughout the documentation of this class, the phrase "matching character" is used to mean * "any character {@code c} for which {@code this.matches(c)} returns {@code true}". * * <p><b>Note:</b> This class deals only with {@code char} values; it does not understand * supplementary Unicode code points in the range {@code 0x10000} to {@code 0x10FFFF}. Such logical * characters are encoded into a {@code String} using surrogate pairs, and a {@code CharMatcher} * treats these just as two separate characters. * * <p>Example usages: <pre> * String trimmed = {@link #WHITESPACE WHITESPACE}.{@link #trimFrom trimFrom}(userInput); * if ({@link #ASCII ASCII}.{@link #matchesAllOf matchesAllOf}(s)) { ... }</pre> * * <p>See the Guava User Guide article on <a href= * "http://code.google.com/p/guava-libraries/wiki/StringsExplained#CharMatcher"> * {@code CharMatcher}</a>. * * @author Kevin Bourrillion * @since 1.0 */ @Beta // Possibly change from chars to code points; decide constants vs. methods @GwtCompatible public abstract class CharMatcher implements Predicate<Character> { // Constants /** * Determines whether a character is a breaking whitespace (that is, a whitespace which can be * interpreted as a break between words for formatting purposes). See {@link #WHITESPACE} for a * discussion of that term. * * @since 2.0 */ public static final CharMatcher BREAKING_WHITESPACE = anyOf("\t\n\013\f\r \u0085\u1680\u2028\u2029\u205f\u3000") .or(inRange('\u2000', '\u2006')) .or(inRange('\u2008', '\u200a')) .withToString("CharMatcher.BREAKING_WHITESPACE") .precomputed(); /** * Determines whether a character is ASCII, meaning that its code point is less than 128. */ public static final CharMatcher ASCII = inRange('\0', '\u007f') .withToString("CharMatcher.ASCII"); /** * Determines whether a character is a digit according to * <a href="http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5Cp%7Bdigit%7D">Unicode</a>. */ public static final CharMatcher DIGIT; static { CharMatcher digit = inRange('0', '9'); String zeroes = "\u0660\u06f0\u07c0\u0966\u09e6\u0a66\u0ae6\u0b66\u0be6\u0c66" + "\u0ce6\u0d66\u0e50\u0ed0\u0f20\u1040\u1090\u17e0\u1810\u1946" + "\u19d0\u1b50\u1bb0\u1c40\u1c50\ua620\ua8d0\ua900\uaa50\uff10"; for (char base : zeroes.toCharArray()) { digit = digit.or(inRange(base, (char) (base + 9))); } DIGIT = digit.withToString("CharMatcher.DIGIT").precomputed(); } /** * Determines whether a character is a digit according to {@link Character#isDigit(char) Java's * definition}. If you only care to match ASCII digits, you can use {@code inRange('0', '9')}. */ public static final CharMatcher JAVA_DIGIT = new CharMatcher() { @Override public boolean matches(char c) { return Character.isDigit(c); } @Override public String toString() { return "CharMatcher.JAVA_DIGIT"; } }; /** * Determines whether a character is a letter according to {@link Character#isLetter(char) Java's * definition}. If you only care to match letters of the Latin alphabet, you can use {@code * inRange('a', 'z').or(inRange('A', 'Z'))}. */ public static final CharMatcher JAVA_LETTER = new CharMatcher() { @Override public boolean matches(char c) { return Character.isLetter(c); } @Override public String toString() { return "CharMatcher.JAVA_LETTER"; } }; /** * Determines whether a character is a letter or digit according to {@link * Character#isLetterOrDigit(char) Java's definition}. */ public static final CharMatcher JAVA_LETTER_OR_DIGIT = new CharMatcher() { @Override public boolean matches(char c) { return Character.isLetterOrDigit(c); } @Override public String toString() { return "CharMatcher.JAVA_LETTER_OR_DIGIT"; } }; /** * Determines whether a character is upper case according to {@link Character#isUpperCase(char) * Java's definition}. */ public static final CharMatcher JAVA_UPPER_CASE = new CharMatcher() { @Override public boolean matches(char c) { return Character.isUpperCase(c); } @Override public String toString() { return "CharMatcher.JAVA_UPPER_CASE"; } }; /** * Determines whether a character is lower case according to {@link Character#isLowerCase(char) * Java's definition}. */ public static final CharMatcher JAVA_LOWER_CASE = new CharMatcher() { @Override public boolean matches(char c) { return Character.isLowerCase(c); } @Override public String toString() { return "CharMatcher.JAVA_LOWER_CASE"; } }; /** * Determines whether a character is an ISO control character as specified by {@link * Character#isISOControl(char)}. */ public static final CharMatcher JAVA_ISO_CONTROL = inRange('\u0000', '\u001f').or(inRange('\u007f', '\u009f')) .withToString("CharMatcher.JAVA_ISO_CONTROL"); /** * Determines whether a character is invisible; that is, if its Unicode category is any of * SPACE_SEPARATOR, LINE_SEPARATOR, PARAGRAPH_SEPARATOR, CONTROL, FORMAT, SURROGATE, and * PRIVATE_USE according to ICU4J. */ public static final CharMatcher INVISIBLE = inRange('\u0000', '\u0020') .or(inRange('\u007f', '\u00a0')) .or(is('\u00ad')) .or(inRange('\u0600', '\u0604')) .or(anyOf("\u06dd\u070f\u1680\u180e")) .or(inRange('\u2000', '\u200f')) .or(inRange('\u2028', '\u202f')) .or(inRange('\u205f', '\u2064')) .or(inRange('\u206a', '\u206f')) .or(is('\u3000')) .or(inRange('\ud800', '\uf8ff')) .or(anyOf("\ufeff\ufff9\ufffa\ufffb")) .withToString("CharMatcher.INVISIBLE") .precomputed(); /** * Determines whether a character is single-width (not double-width). When in doubt, this matcher * errs on the side of returning {@code false} (that is, it tends to assume a character is * double-width). * * <p><b>Note:</b> as the reference file evolves, we will modify this constant to keep it up to * date. */ public static final CharMatcher SINGLE_WIDTH = inRange('\u0000', '\u04f9') .or(is('\u05be')) .or(inRange('\u05d0', '\u05ea')) .or(is('\u05f3')) .or(is('\u05f4')) .or(inRange('\u0600', '\u06ff')) .or(inRange('\u0750', '\u077f')) .or(inRange('\u0e00', '\u0e7f')) .or(inRange('\u1e00', '\u20af')) .or(inRange('\u2100', '\u213a')) .or(inRange('\ufb50', '\ufdff')) .or(inRange('\ufe70', '\ufeff')) .or(inRange('\uff61', '\uffdc')) .withToString("CharMatcher.SINGLE_WIDTH") .precomputed(); /** Matches any character. */ public static final CharMatcher ANY = new CharMatcher() { @Override public boolean matches(char c) { return true; } @Override public int indexIn(CharSequence sequence) { return (sequence.length() == 0) ? -1 : 0; } @Override public int indexIn(CharSequence sequence, int start) { int length = sequence.length(); Preconditions.checkPositionIndex(start, length); return (start == length) ? -1 : start; } @Override public int lastIndexIn(CharSequence sequence) { return sequence.length() - 1; } @Override public boolean matchesAllOf(CharSequence sequence) { checkNotNull(sequence); return true; } @Override public boolean matchesNoneOf(CharSequence sequence) { return sequence.length() == 0; } @Override public String removeFrom(CharSequence sequence) { checkNotNull(sequence); return ""; } @Override public String replaceFrom(CharSequence sequence, char replacement) { char[] array = new char[sequence.length()]; Arrays.fill(array, replacement); return new String(array); } @Override public String replaceFrom(CharSequence sequence, CharSequence replacement) { StringBuilder retval = new StringBuilder(sequence.length() * replacement.length()); for (int i = 0; i < sequence.length(); i++) { retval.append(replacement); } return retval.toString(); } @Override public String collapseFrom(CharSequence sequence, char replacement) { return (sequence.length() == 0) ? "" : String.valueOf(replacement); } @Override public String trimFrom(CharSequence sequence) { checkNotNull(sequence); return ""; } @Override public int countIn(CharSequence sequence) { return sequence.length(); } @Override public CharMatcher and(CharMatcher other) { return checkNotNull(other); } @Override public CharMatcher or(CharMatcher other) { checkNotNull(other); return this; } @Override public CharMatcher negate() { return NONE; } @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return "CharMatcher.ANY"; } }; /** Matches no characters. */ public static final CharMatcher NONE = new CharMatcher() { @Override public boolean matches(char c) { return false; } @Override public int indexIn(CharSequence sequence) { checkNotNull(sequence); return -1; } @Override public int indexIn(CharSequence sequence, int start) { int length = sequence.length(); Preconditions.checkPositionIndex(start, length); return -1; } @Override public int lastIndexIn(CharSequence sequence) { checkNotNull(sequence); return -1; } @Override public boolean matchesAllOf(CharSequence sequence) { return sequence.length() == 0; } @Override public boolean matchesNoneOf(CharSequence sequence) { checkNotNull(sequence); return true; } @Override public String removeFrom(CharSequence sequence) { return sequence.toString(); } @Override public String replaceFrom(CharSequence sequence, char replacement) { return sequence.toString(); } @Override public String replaceFrom(CharSequence sequence, CharSequence replacement) { checkNotNull(replacement); return sequence.toString(); } @Override public String collapseFrom(CharSequence sequence, char replacement) { return sequence.toString(); } @Override public String trimFrom(CharSequence sequence) { return sequence.toString(); } @Override public int countIn(CharSequence sequence) { checkNotNull(sequence); return 0; } @Override public CharMatcher and(CharMatcher other) { checkNotNull(other); return this; } @Override public CharMatcher or(CharMatcher other) { return checkNotNull(other); } @Override public CharMatcher negate() { return ANY; } @Override void setBits(LookupTable table) {} @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return "CharMatcher.NONE"; } }; // Static factories /** * Returns a {@code char} matcher that matches only one specified character. */ public static CharMatcher is(final char match) { return new CharMatcher() { @Override public boolean matches(char c) { return c == match; } @Override public String replaceFrom(CharSequence sequence, char replacement) { return sequence.toString().replace(match, replacement); } @Override public CharMatcher and(CharMatcher other) { return other.matches(match) ? this : NONE; } @Override public CharMatcher or(CharMatcher other) { return other.matches(match) ? other : super.or(other); } @Override public CharMatcher negate() { return isNot(match); } @Override void setBits(LookupTable table) { table.set(match); } @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return new StringBuilder("CharMatcher.is(") .append(Integer.toHexString(match)) .append(")") .toString(); } }; } /** * Returns a {@code char} matcher that matches any character except the one specified. * * <p>To negate another {@code CharMatcher}, use {@link #negate()}. */ public static CharMatcher isNot(final char match) { return new CharMatcher() { @Override public boolean matches(char c) { return c != match; } @Override public CharMatcher and(CharMatcher other) { return other.matches(match) ? super.and(other) : other; } @Override public CharMatcher or(CharMatcher other) { return other.matches(match) ? ANY : this; } @Override public CharMatcher negate() { return is(match); } @Override public String toString() { return new StringBuilder("CharMatcher.isNot(") .append(Integer.toHexString(match)) .append(")") .toString(); } }; } /** * Returns a {@code char} matcher that matches any character present in the given character * sequence. */ public static CharMatcher anyOf(final CharSequence sequence) { switch (sequence.length()) { case 0: return NONE; case 1: return is(sequence.charAt(0)); case 2: final char match1 = sequence.charAt(0); final char match2 = sequence.charAt(1); return new CharMatcher() { @Override public boolean matches(char c) { return c == match1 || c == match2; } @Override void setBits(LookupTable table) { table.set(match1); table.set(match2); } @Override public CharMatcher precomputed() { return this; } }; } final char[] chars = sequence.toString().toCharArray(); Arrays.sort(chars); // not worth collapsing duplicates return new CharMatcher() { @Override public boolean matches(char c) { return Arrays.binarySearch(chars, c) >= 0; } @Override void setBits(LookupTable table) { for (char c : chars) { table.set(c); } } @Override public String toString() { return new StringBuilder("CharMatcher.anyOf(\"").append(chars).append("\")").toString(); } }; } /** * Returns a {@code char} matcher that matches any character not present in the given character * sequence. */ public static CharMatcher noneOf(CharSequence sequence) { return anyOf(sequence).negate(); } /** * Returns a {@code char} matcher that matches any character in a given range (both endpoints are * inclusive). For example, to match any lowercase letter of the English alphabet, use {@code * CharMatcher.inRange('a', 'z')}. * * @throws IllegalArgumentException if {@code endInclusive < startInclusive} */ public static CharMatcher inRange(final char startInclusive, final char endInclusive) { checkArgument(endInclusive >= startInclusive); return new CharMatcher() { @Override public boolean matches(char c) { return startInclusive <= c && c <= endInclusive; } @Override void setBits(LookupTable table) { char c = startInclusive; while (true) { table.set(c); if (c++ == endInclusive) { break; } } } @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return new StringBuilder("CharMatcher.inRange(") .append(Integer.toHexString(startInclusive)) .append(", ") .append(Integer.toHexString(endInclusive)) .append(")") .toString(); } }; } /** * Returns a matcher with identical behavior to the given {@link Character}-based predicate, but * which operates on primitive {@code char} instances instead. */ public static CharMatcher forPredicate(final Predicate<? super Character> predicate) { checkNotNull(predicate); if (predicate instanceof CharMatcher) { return (CharMatcher) predicate; } return new CharMatcher() { @Override public boolean matches(char c) { return predicate.apply(c); } @Override public boolean apply(Character character) { return predicate.apply(checkNotNull(character)); } @Override public String toString() { return new StringBuilder("CharMatcher.forPredicate(") .append(predicate) .append(')') .toString(); } }; } // Constructors /** * Constructor for use by subclasses. */ protected CharMatcher() {} // Abstract methods /** Determines a true or false value for the given character. */ public abstract boolean matches(char c); // Non-static factories /** * Returns a matcher that matches any character not matched by this matcher. */ public CharMatcher negate() { final CharMatcher original = this; return new CharMatcher() { @Override public boolean matches(char c) { return !original.matches(c); } @Override public boolean matchesAllOf(CharSequence sequence) { return original.matchesNoneOf(sequence); } @Override public boolean matchesNoneOf(CharSequence sequence) { return original.matchesAllOf(sequence); } @Override public int countIn(CharSequence sequence) { return sequence.length() - original.countIn(sequence); } @Override public CharMatcher negate() { return original; } @Override public String toString() { return original + ".negate()"; } }; } /** * Returns a matcher that matches any character matched by both this matcher and {@code other}. */ public CharMatcher and(CharMatcher other) { return new And(Arrays.asList(this, checkNotNull(other))); } private static class And extends CharMatcher { List<CharMatcher> components; And(List<CharMatcher> components) { this.components = components; // Skip defensive copy (private) } @Override public boolean matches(char c) { for (CharMatcher matcher : components) { if (!matcher.matches(c)) { return false; } } return true; } @Override public CharMatcher and(CharMatcher other) { List<CharMatcher> newComponents = new ArrayList<CharMatcher>(components); newComponents.add(checkNotNull(other)); return new And(newComponents); } @Override public String toString() { StringBuilder builder = new StringBuilder("CharMatcher.and("); Joiner.on(", ").appendTo(builder, components); return builder.append(')').toString(); } } /** * Returns a matcher that matches any character matched by either this matcher or {@code other}. */ public CharMatcher or(CharMatcher other) { return new Or(Arrays.asList(this, checkNotNull(other))); } private static class Or extends CharMatcher { List<CharMatcher> components; Or(List<CharMatcher> components) { this.components = components; // Skip defensive copy (private) } @Override public boolean matches(char c) { for (CharMatcher matcher : components) { if (matcher.matches(c)) { return true; } } return false; } @Override public CharMatcher or(CharMatcher other) { List<CharMatcher> newComponents = new ArrayList<CharMatcher>(components); newComponents.add(checkNotNull(other)); return new Or(newComponents); } @Override void setBits(LookupTable table) { for (CharMatcher matcher : components) { matcher.setBits(table); } } @Override public String toString() { StringBuilder builder = new StringBuilder("CharMatcher.or("); Joiner.on(", ").appendTo(builder, components); return builder.append(')').toString(); } } /** * Returns a {@code char} matcher functionally equivalent to this one, but which may be faster to * query than the original; your mileage may vary. Precomputation takes time and is likely to be * worthwhile only if the precomputed matcher is queried many thousands of times. * * <p>This method has no effect (returns {@code this}) when called in GWT: it's unclear whether a * precomputed matcher is faster, but it certainly consumes more memory, which doesn't seem like a * worthwhile tradeoff in a browser. */ public CharMatcher precomputed() { return Platform.precomputeCharMatcher(this); } /** * This is the actual implementation of {@link #precomputed}, but we bounce calls through a method * on {@link Platform} so that we can have different behavior in GWT. * * <p>The default precomputation is to cache the configuration of the original matcher in an * eight-kilobyte bit array. In some situations this produces a matcher which is faster to query * than the original. * * <p>The default implementation creates a new bit array and passes it to {@link * #setBits(LookupTable)}. */ CharMatcher precomputedInternal() { final LookupTable table = new LookupTable(); setBits(table); final CharMatcher outer = this; return new CharMatcher() { @Override public boolean matches(char c) { return table.get(c); } // TODO(kevinb): make methods like negate() smart? @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return outer.toString(); } }; } CharMatcher withToString(final String toString) { final CharMatcher delegate = this; return new CharMatcher() { @Override public boolean matches(char c) { return delegate.matches(c); } @Override void setBits(LookupTable table) { delegate.setBits(table); } @Override public String toString() { return toString; } }; } /** * For use by implementors; sets the bit corresponding to each character ('\0' to '{@literal * \}uFFFF') that matches this matcher in the given bit array, leaving all other bits untouched. * * <p>The default implementation loops over every possible character value, invoking {@link * #matches} for each one. */ void setBits(LookupTable table) { char c = Character.MIN_VALUE; while (true) { if (matches(c)) { table.set(c); } if (c++ == Character.MAX_VALUE) { break; } } } /** * A bit array with one bit per {@code char} value, used by {@link CharMatcher#precomputed}. * * <p>TODO(kevinb): possibly share a common BitArray class with BloomFilter and others... a * simpler java.util.BitSet. */ private static final class LookupTable { int[] data = new int[2048]; void set(char index) { data[index >> 5] |= (1 << index); } boolean get(char index) { return (data[index >> 5] & (1 << index)) != 0; } } // Text processing routines /** * Returns {@code true} if a character sequence contains at least one matching character. * Equivalent to {@code !matchesNoneOf(sequence)}. * * <p>The default implementation iterates over the sequence, invoking {@link #matches} for each * character, until this returns {@code true} or the end is reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches at least one character in the sequence * @since 8.0 */ public boolean matchesAnyOf(CharSequence sequence) { return !matchesNoneOf(sequence); } /** * Returns {@code true} if a character sequence contains only matching characters. * * <p>The default implementation iterates over the sequence, invoking {@link #matches} for each * character, until this returns {@code false} or the end is reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches every character in the sequence, including when * the sequence is empty */ public boolean matchesAllOf(CharSequence sequence) { for (int i = sequence.length() - 1; i >= 0; i--) { if (!matches(sequence.charAt(i))) { return false; } } return true; } /** * Returns {@code true} if a character sequence contains no matching characters. Equivalent to * {@code !matchesAnyOf(sequence)}. * * <p>The default implementation iterates over the sequence, invoking {@link #matches} for each * character, until this returns {@code false} or the end is reached. * * @param sequence the character sequence to examine, possibly empty * @return {@code true} if this matcher matches every character in the sequence, including when * the sequence is empty */ public boolean matchesNoneOf(CharSequence sequence) { return indexIn(sequence) == -1; } /** * Returns the index of the first matching character in a character sequence, or {@code -1} if no * matching character is present. * * <p>The default implementation iterates over the sequence in forward order calling {@link * #matches} for each character. * * @param sequence the character sequence to examine from the beginning * @return an index, or {@code -1} if no character matches */ public int indexIn(CharSequence sequence) { int length = sequence.length(); for (int i = 0; i < length; i++) { if (matches(sequence.charAt(i))) { return i; } } return -1; } /** * Returns the index of the first matching character in a character sequence, starting from a * given position, or {@code -1} if no character matches after that position. * * <p>The default implementation iterates over the sequence in forward order, beginning at {@code * start}, calling {@link #matches} for each character. * * @param sequence the character sequence to examine * @param start the first index to examine; must be nonnegative and no greater than {@code * sequence.length()} * @return the index of the first matching character, guaranteed to be no less than {@code start}, * or {@code -1} if no character matches * @throws IndexOutOfBoundsException if start is negative or greater than {@code * sequence.length()} */ public int indexIn(CharSequence sequence, int start) { int length = sequence.length(); Preconditions.checkPositionIndex(start, length); for (int i = start; i < length; i++) { if (matches(sequence.charAt(i))) { return i; } } return -1; } /** * Returns the index of the last matching character in a character sequence, or {@code -1} if no * matching character is present. * * <p>The default implementation iterates over the sequence in reverse order calling {@link * #matches} for each character. * * @param sequence the character sequence to examine from the end * @return an index, or {@code -1} if no character matches */ public int lastIndexIn(CharSequence sequence) { for (int i = sequence.length() - 1; i >= 0; i--) { if (matches(sequence.charAt(i))) { return i; } } return -1; } /** * Returns the number of matching characters found in a character sequence. */ public int countIn(CharSequence sequence) { int count = 0; for (int i = 0; i < sequence.length(); i++) { if (matches(sequence.charAt(i))) { count++; } } return count; } /** * Returns a string containing all non-matching characters of a character sequence, in order. For * example: <pre> {@code * * CharMatcher.is('a').removeFrom("bazaar")}</pre> * * ... returns {@code "bzr"}. */ @CheckReturnValue public String removeFrom(CharSequence sequence) { String string = sequence.toString(); int pos = indexIn(string); if (pos == -1) { return string; } char[] chars = string.toCharArray(); int spread = 1; // This unusual loop comes from extensive benchmarking OUT: while (true) { pos++; while (true) { if (pos == chars.length) { break OUT; } if (matches(chars[pos])) { break; } chars[pos - spread] = chars[pos]; pos++; } spread++; } return new String(chars, 0, pos - spread); } /** * Returns a string containing all matching characters of a character sequence, in order. For * example: <pre> {@code * * CharMatcher.is('a').retainFrom("bazaar")}</pre> * * ... returns {@code "aaa"}. */ @CheckReturnValue public String retainFrom(CharSequence sequence) { return negate().removeFrom(sequence); } /** * Returns a string copy of the input character sequence, with each character that matches this * matcher replaced by a given replacement character. For example: <pre> {@code * * CharMatcher.is('a').replaceFrom("radar", 'o')}</pre> * * ... returns {@code "rodor"}. * * <p>The default implementation uses {@link #indexIn(CharSequence)} to find the first matching * character, then iterates the remainder of the sequence calling {@link #matches(char)} for each * character. * * @param sequence the character sequence to replace matching characters in * @param replacement the character to append to the result string in place of each matching * character in {@code sequence} * @return the new string */ @CheckReturnValue public String replaceFrom(CharSequence sequence, char replacement) { String string = sequence.toString(); int pos = indexIn(string); if (pos == -1) { return string; } char[] chars = string.toCharArray(); chars[pos] = replacement; for (int i = pos + 1; i < chars.length; i++) { if (matches(chars[i])) { chars[i] = replacement; } } return new String(chars); } /** * Returns a string copy of the input character sequence, with each character that matches this * matcher replaced by a given replacement sequence. For example: <pre> {@code * * CharMatcher.is('a').replaceFrom("yaha", "oo")}</pre> * * ... returns {@code "yoohoo"}. * * <p><b>Note:</b> If the replacement is a fixed string with only one character, you are better * off calling {@link #replaceFrom(CharSequence, char)} directly. * * @param sequence the character sequence to replace matching characters in * @param replacement the characters to append to the result string in place of each matching * character in {@code sequence} * @return the new string */ @CheckReturnValue public String replaceFrom(CharSequence sequence, CharSequence replacement) { int replacementLen = replacement.length(); if (replacementLen == 0) { return removeFrom(sequence); } if (replacementLen == 1) { return replaceFrom(sequence, replacement.charAt(0)); } String string = sequence.toString(); int pos = indexIn(string); if (pos == -1) { return string; } int len = string.length(); StringBuilder buf = new StringBuilder((len * 3 / 2) + 16); int oldpos = 0; do { buf.append(string, oldpos, pos); buf.append(replacement); oldpos = pos + 1; pos = indexIn(string, oldpos); } while (pos != -1); buf.append(string, oldpos, len); return buf.toString(); } /** * Returns a substring of the input character sequence that omits all characters this matcher * matches from the beginning and from the end of the string. For example: <pre> {@code * * CharMatcher.anyOf("ab").trimFrom("abacatbab")}</pre> * * ... returns {@code "cat"}. * * <p>Note that: <pre> {@code * * CharMatcher.inRange('\0', ' ').trimFrom(str)}</pre> * * ... is equivalent to {@link String#trim()}. */ @CheckReturnValue public String trimFrom(CharSequence sequence) { int len = sequence.length(); int first; int last; for (first = 0; first < len; first++) { if (!matches(sequence.charAt(first))) { break; } } for (last = len - 1; last > first; last--) { if (!matches(sequence.charAt(last))) { break; } } return sequence.subSequence(first, last + 1).toString(); } /** * Returns a substring of the input character sequence that omits all characters this matcher * matches from the beginning of the string. For example: <pre> {@code * * CharMatcher.anyOf("ab").trimLeadingFrom("abacatbab")}</pre> * * ... returns {@code "catbab"}. */ @CheckReturnValue public String trimLeadingFrom(CharSequence sequence) { int len = sequence.length(); int first; for (first = 0; first < len; first++) { if (!matches(sequence.charAt(first))) { break; } } return sequence.subSequence(first, len).toString(); } /** * Returns a substring of the input character sequence that omits all characters this matcher * matches from the end of the string. For example: <pre> {@code * * CharMatcher.anyOf("ab").trimTrailingFrom("abacatbab")}</pre> * * ... returns {@code "abacat"}. */ @CheckReturnValue public String trimTrailingFrom(CharSequence sequence) { int len = sequence.length(); int last; for (last = len - 1; last >= 0; last--) { if (!matches(sequence.charAt(last))) { break; } } return sequence.subSequence(0, last + 1).toString(); } /** * Returns a string copy of the input character sequence, with each group of consecutive * characters that match this matcher replaced by a single replacement character. For example: * <pre> {@code * * CharMatcher.anyOf("eko").collapseFrom("bookkeeper", '-')}</pre> * * ... returns {@code "b-p-r"}. * * <p>The default implementation uses {@link #indexIn(CharSequence)} to find the first matching * character, then iterates the remainder of the sequence calling {@link #matches(char)} for each * character. * * @param sequence the character sequence to replace matching groups of characters in * @param replacement the character to append to the result string in place of each group of * matching characters in {@code sequence} * @return the new string */ @CheckReturnValue public String collapseFrom(CharSequence sequence, char replacement) { int first = indexIn(sequence); if (first == -1) { return sequence.toString(); } // TODO(kevinb): see if this implementation can be made faster StringBuilder builder = new StringBuilder(sequence.length()) .append(sequence.subSequence(0, first)) .append(replacement); boolean in = true; for (int i = first + 1; i < sequence.length(); i++) { char c = sequence.charAt(i); if (matches(c)) { if (!in) { builder.append(replacement); in = true; } } else { builder.append(c); in = false; } } return builder.toString(); } /** * Collapses groups of matching characters exactly as {@link #collapseFrom} does, except that * groups of matching characters at the start or end of the sequence are removed without * replacement. */ @CheckReturnValue public String trimAndCollapseFrom(CharSequence sequence, char replacement) { int first = negate().indexIn(sequence); if (first == -1) { return ""; // everything matches. nothing's left. } StringBuilder builder = new StringBuilder(sequence.length()); boolean inMatchingGroup = false; for (int i = first; i < sequence.length(); i++) { char c = sequence.charAt(i); if (matches(c)) { inMatchingGroup = true; } else { if (inMatchingGroup) { builder.append(replacement); inMatchingGroup = false; } builder.append(c); } } return builder.toString(); } // Predicate interface /** * Returns {@code true} if this matcher matches the given character. * * @throws NullPointerException if {@code character} is null */ @Override public boolean apply(Character character) { return matches(character); } /** * Returns a string representation of this {@code CharMatcher}, such as * {@code CharMatcher.or(WHITESPACE, JAVA_DIGIT)}. */ @Override public String toString() { return super.toString(); } /** * Determines whether a character is whitespace according to the latest Unicode standard, as * illustrated * <a href="http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5Cp%7Bwhitespace%7D">here</a>. * This is not the same definition used by other Java APIs. (See a * <a href="http://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">comparison of several * definitions of "whitespace"</a>.) * * <p><b>Note:</b> as the Unicode definition evolves, we will modify this constant to keep it up * to date. */ public static final CharMatcher WHITESPACE = new CharMatcher() { /** * A special-case CharMatcher for Unicode whitespace characters that is extremely * efficient both in space required and in time to check for matches. * * Implementation details. * It turns out that all current (early 2012) Unicode characters are unique modulo 79: * so we can construct a lookup table of exactly 79 entries, and just check the character code * mod 79, and see if that character is in the table. * * There is a 1 at the beginning of the table so that the null character is not listed * as whitespace. * * Other things we tried that did not prove to be beneficial, mostly due to speed concerns: * * * Binary search into the sorted list of characters, i.e., what * CharMatcher.anyOf() does</li> * * Perfect hash function into a table of size 26 (using an offset table and a special * Jenkins hash function)</li> * * Perfect-ish hash function that required two lookups into a single table of size 26.</li> * * Using a power-of-2 sized hash table (size 64) with linear probing.</li> * * --Christopher Swenson, February 2012. */ // Mod-79 lookup table. private final char[] table = {1, 0, 160, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 0, 8232, 8233, 0, 0, 0, 0, 0, 8239, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 0, 0, 0, 0, 0, 8287, 5760, 0, 0, 6158, 0, 0, 0}; @Override public boolean matches(char c) { return table[c % 79] == c; } @Override public CharMatcher precomputed() { return this; } @Override public String toString() { return "CharMatcher.WHITESPACE"; } }; }
a8022fdb24721f23cff5f64135f5e0971f234b7a
d624b8e0f5d0d0cd5959babee44e1a4fe7ec5f40
/src/amata1219/collector/hands/CollectorHands.java
20f2fd896ad8924ab0d728ff4b4d18292130bccf
[]
no_license
amata1219/CollectorHands
f2569ad9b0ed38c6a94ce3f4d1867c2035ba8d75
6946bbf0990f5facbda630404acca4bef8ad05a6
refs/heads/master
2023-01-18T21:55:18.099180
2020-11-24T14:31:36
2020-11-24T14:31:36
315,657,830
0
0
null
null
null
null
UTF-8
Java
false
false
10,337
java
package amata1219.collector.hands; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; import org.bukkit.entity.Wolf; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SpawnEggMeta; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; public class CollectorHands extends JavaPlugin implements Listener, CommandExecutor { public void onEnable() { this.getServer().getPluginManager().registerEvents(this, this); this.getCommand("givemc").setExecutor(this); } public void onDisable() { HandlerList.unregisterAll((Plugin) this); } public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "ゲーム内から実行して下さい。"); return true; } else { Player player = (Player)sender; int i; if (args.length == 0) { i = 1; } else { try { i = Integer.valueOf(args[0]); if (i > 64) { i = 64; } } catch (NumberFormatException var8) { player.sendMessage(ChatColor.RED + "個数は半角数字で入力して下さい。"); return true; } } this.giveMobCatcher(player, i); player.sendMessage(ChatColor.GRAY + "Given [MobCatcher] * " + i + " to " + player.getName()); return true; } } public void giveMobCatcher(Player player, int amount) { if (amount > 64) { amount = 64; } ItemStack item = new ItemStack(Material.MONSTER_EGG); item.setAmount(amount); SpawnEggMeta meta = (SpawnEggMeta)item.getItemMeta(); meta.setSpawnedType(EntityType.SNOWMAN); meta.setDisplayName("§fモブキャッチャー"); meta.setLore(new ArrayList(Arrays.asList("§7友好的なMobをLShift+右クリックで捕獲!"))); item.setItemMeta(meta); player.getInventory().addItem(new ItemStack[]{item}); } @EventHandler( priority = EventPriority.HIGH ) public void onAttack(EntityDamageByEntityEvent e) { if (!e.isCancelled()) { Entity damager = e.getDamager(); if (damager instanceof Player) { Player player = (Player)damager; if (player.isSneaking()) { PlayerInventory inventory = player.getInventory(); ItemStack hand = inventory.getItemInMainHand(); if (this.isMobCatcher(hand)) { e.setCancelled(true); boolean one = hand.getAmount() == 1; if (!one || inventory.firstEmpty() != -1) { Entity entity = e.getEntity(); if (entity instanceof LivingEntity) { LivingEntity target = (LivingEntity)entity; UUID uuid = player.getUniqueId(); ItemStack item = null; switch(e.getEntityType().ordinal()) { case 31: case 32: case 74: case 76: case 79: case 81: Tameable ent1 = (Tameable)entity; if (!this.canCatch(uuid, ent1.getOwner())) { return; } item = Util.mobToItemStack(target); break; case 61: case 66: case 67: case 68: case 69: case 70: case 72: case 77: case 82: item = Util.mobToItemStack(target); break; case 71: Wolf wolf = (Wolf)entity; if (wolf.isAngry()) { return; } if (!this.canCatch(uuid, wolf.getOwner())) { return; } item = Util.mobToItemStack(target); break; case 78: if (this.isTarget(player, ((Creature)entity).getTarget())) { return; } item = Util.mobToItemStack(target); break; default: return; } target.remove(); if (one) { inventory.setItemInMainHand(item); } else { hand.setAmount(hand.getAmount() - 1); inventory.addItem(new ItemStack[]{item}); } } } } } } } } @EventHandler public void onInteract(PlayerInteractEvent e) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { if (e.hasBlock()) { if (e.hasItem()) { Block block = e.getClickedBlock(); Material material = block.getType(); if (block != null && material != Material.AIR) { ItemStack item = e.getItem(); if (item != null && item.getType() == Material.MONSTER_EGG) { if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); if (meta.hasLore()) { List<String> lore = meta.getLore(); if (meta.getLore().contains("§7友好的なMobをLShift+右クリックで捕獲!")) { e.setCancelled(true); } else { if (material == Material.MOB_SPAWNER && lore.contains("§7ブロックに向かって右クリックで捕獲したMobを召喚!")) { e.setCancelled(true); } } } } } } } } } } @EventHandler public void onDispench(BlockDispenseEvent e) { Block block = e.getBlock(); if (block != null && block.getType() == Material.DISPENSER) { if (this.isMobCatcher(e.getItem())) { e.setCancelled(true); } } } @EventHandler public void onClick(InventoryClickEvent e) { Inventory inventory = e.getClickedInventory(); if (inventory != null && inventory instanceof AnvilInventory) { if (this.isMobCatcher(e.getCurrentItem())) { e.setCancelled(true); } } } public boolean isMobCatcher(ItemStack item) { if (item != null && item.getType() == Material.MONSTER_EGG) { if (!item.hasItemMeta()) { return false; } else { ItemMeta meta = item.getItemMeta(); if (!meta.hasLore()) { return false; } else { List<String> lore = meta.getLore(); if (meta.getLore().contains("§7ブロックに向かって右クリックで捕獲したMobを召喚!")) { return false; } else { return lore.contains("§7友好的なMobをLShift+右クリックで捕獲!"); } } } } else { return false; } } private boolean canCatch(UUID uuid, AnimalTamer tamer) { return tamer == null || tamer.getUniqueId().equals(uuid); } private boolean isTarget(Player player, LivingEntity target) { return target != null && target.equals(player); } }
bff391b618cf662124aefbd26204853974d3d4b1
64ab254321c6338de7f68548c4d49112130e1410
/app/src/main/java/com/beforevisit/beforevisitapp/Activities/AboutBrandActivity.java
f5a98a85e51510949ded110d4c1a005566e583b6
[]
no_license
Khushboo1028/Before-Visit-App
74c539024129e5d26b4af69a14083ce4f596b605
dab8d652b58f5066254b7a9186f927484da15ee1
refs/heads/master
2022-11-21T03:43:25.879768
2020-07-14T17:46:06
2020-07-14T17:46:06
267,920,639
0
0
null
null
null
null
UTF-8
Java
false
false
46,784
java
package com.beforevisit.beforevisitapp.Activities; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.core.widget.NestedScrollView; import androidx.recyclerview.widget.RecyclerView; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RatingBar; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import com.beforevisit.beforevisitapp.Adapters.GridImagePlaceAdapter; import com.beforevisit.beforevisitapp.Adapters.RecyclerRatingAdapter; import com.beforevisit.beforevisitapp.Model.Places; import com.beforevisit.beforevisitapp.Model.RatingAndReviews; import com.beforevisit.beforevisitapp.Model.VisitorCount; import com.beforevisit.beforevisitapp.R; import com.beforevisit.beforevisitapp.Utility.DefaultTextConfig; import com.beforevisit.beforevisitapp.Utility.ExpandableHeightGridView; import com.beforevisit.beforevisitapp.Utility.Utils; import com.bumptech.glide.Glide; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnSuccessListener; import com.google.firebase.Timestamp; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.DocumentSnapshot; import com.google.firebase.firestore.EventListener; import com.google.firebase.firestore.FieldValue; import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestoreException; import com.google.firebase.firestore.ListenerRegistration; import com.google.firebase.firestore.Query; import com.google.firebase.firestore.QueryDocumentSnapshot; import com.google.firebase.firestore.QuerySnapshot; import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener; import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerFullScreenListener; import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.YouTubePlayerUtils; import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView; import com.stfalcon.imageviewer.StfalconImageViewer; import com.stfalcon.imageviewer.loader.ImageLoader; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Map; public class AboutBrandActivity extends AppCompatActivity { public static final String TAG = "AboutBrandActivity"; public static final String VisitorSharedPreference = "VisitorCount"; RelativeLayout main_rel, call_rel, location_rel, share_rel, save_rel; TextView tv_place_name, tv_place_address, tv_about_store, tv_phone, tv_rating_avg, tv_rating_user, tv_total_reviews; ExpandableHeightGridView images_grid_view; GridImagePlaceAdapter gridImagePlaceAdapter; RatingBar ratingBarAvg, rating_bar_user; String place_id; FirebaseFirestore db; ListenerRegistration listenerRegistration; ArrayList<Places> placesArrayList; TextView text_phone; EditText et_review; ImageView img_done,img_save,img_share; Utils utils; String rating; int int_rating; FirebaseAuth mAuth; FirebaseUser firebaseUser; AlertDialog.Builder builder; AlertDialog alert; String name, review, location_url; double total_reviews; int avg_rating; ProgressBar progressBar; String doc_update_id; Boolean isSaved = false; ArrayList<RatingAndReviews> ratingAndReviewsArrayList; RecyclerView recycler_view_ratings; RecyclerRatingAdapter ratingAdapter; int previous_rating = 0; String share_link, share_text; Button btn_show_more; ArrayList<VisitorCount> visitorCountArrayList; float current_seconds; YouTubePlayerView youTubePlayerView; NestedScrollView scrollView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DefaultTextConfig defaultTextConfig = new DefaultTextConfig(); defaultTextConfig.adjustFontScale(getResources().getConfiguration(), AboutBrandActivity.this); setContentView(R.layout.activity_about_brand); init(); call_rel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { customCallDialog(placesArrayList.get(0).getMobile_no_array()); } }); location_rel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(Intent.ACTION_VIEW); Log.i(TAG,"Location url is "+location_url); if(!location_url.isEmpty() && location_url.contains("http")){ i.setData(Uri.parse(location_url)); startActivity(i); } } }); tv_phone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String tel = "tel:+91" + tv_phone.getText().toString(); Intent acCall = new Intent(Intent.ACTION_DIAL); acCall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); acCall.setData(Uri.parse(tel)); startActivity(acCall); } }); if (place_id != null && !place_id.isEmpty()) { getPlaceData(place_id); getAllReviews(); getUserReviews(); getUserData(); getTotalReviews(); } storeVisitorCount(); rating_bar_user.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float v, boolean b) { rating = String.valueOf(v); int_rating = (int)v; tv_rating_user.setText((int) v + "/5"); } }); img_share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { share_text = "Check out this place:\n"+placesArrayList.get(0).getPlace_name()+"\n\nDownload from Play Store:\n"+ share_link +"\n\nBefore you visit, check out Before Visit :)"; Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, share_text); sendIntent.setType("text/plain"); Intent shareIntent = Intent.createChooser(sendIntent, null); startActivity(shareIntent); } }); img_done.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.i(TAG, "img_done pressed"); review = et_review.getText().toString().trim(); if (utils.isInternetAvailable(AboutBrandActivity.this)) { if (rating==null || rating.isEmpty()) { utils.alertDialog(AboutBrandActivity.this, "Uh-Oh", "Seems like you haven't provided any rating!"); } else if (review.isEmpty()) { builder = new AlertDialog.Builder(AboutBrandActivity.this); builder.setMessage("You didn't give the review. Do you want to proceed?") .setCancelable(true) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { sendReview(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); et_review.requestFocus(); } }); alert = builder.create(); alert.setTitle("Review Missing!"); alert.show(); } else { sendReview(); } } } }); images_grid_view.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if(i == 5){ Intent intent = new Intent(getApplicationContext(), ShowAllImagesActivity.class); intent.putStringArrayListExtra("images_url",placesArrayList.get(0).getImages_url()); intent.putExtra("place_name",placesArrayList.get(0).getPlace_name()); startActivity(intent); overridePendingTransition(0,0); }else{ new StfalconImageViewer.Builder<>(AboutBrandActivity.this, placesArrayList.get(0).getImages_url(), new ImageLoader<String>() { @Override public void loadImage(ImageView imageView, String imageUrl) { Glide.with(getApplicationContext()).load(imageUrl).into(imageView); } }) .withStartPosition(i) .show(); } } }); save_rel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(isSaved){ savePlace(place_id, false); }else{ savePlace(place_id, true); } } }); btn_show_more.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplicationContext(),ShowAllReviewsActivity.class); intent.putExtra("place_name",placesArrayList.get(0).getPlace_name()); intent.putExtra("place_id",placesArrayList.get(0).getDoc_id()); startActivity(intent); } }); ImageView top_logo = (ImageView) findViewById(R.id.top_logo); top_logo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplicationContext(),MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); overridePendingTransition(0,0); } }); } private void init() { main_rel = (RelativeLayout) findViewById(R.id.main_rel); call_rel = (RelativeLayout) findViewById(R.id.call_rel); location_rel = (RelativeLayout) findViewById(R.id.location_rel); share_rel = (RelativeLayout) findViewById(R.id.share_rel); save_rel = (RelativeLayout) findViewById(R.id.save_rel); tv_place_name = (TextView) findViewById(R.id.tv_place_name); tv_place_address = (TextView) findViewById(R.id.tv_place_address); tv_about_store = (TextView) findViewById(R.id.tv_about_store); tv_phone = (TextView) findViewById(R.id.tv_phone); tv_total_reviews = (TextView) findViewById(R.id.tv_total_reviews); text_phone = (TextView) findViewById(R.id.text_phone); tv_rating_avg = (TextView) findViewById(R.id.tv_rating_avg); tv_rating_user = (TextView) findViewById(R.id.tv_rating_user); et_review = (EditText) findViewById(R.id.et_review); images_grid_view = (ExpandableHeightGridView) findViewById(R.id.images_grid_view); img_done = (ImageView) findViewById(R.id.img_done); img_share = (ImageView) findViewById(R.id.img_share); ratingBarAvg = (RatingBar) findViewById(R.id.ratingBarAvg); rating_bar_user = (RatingBar) findViewById(R.id.rating_bar_user); progressBar = (ProgressBar) findViewById(R.id.progress_bar); scrollView = (NestedScrollView) findViewById(R.id.scrollView); btn_show_more = (Button)findViewById(R.id.btn_show_more); place_id = getIntent().getStringExtra("place_id"); Log.i(TAG, "Place id is " + place_id); db = FirebaseFirestore.getInstance(); placesArrayList = new ArrayList<>(); ratingAndReviewsArrayList = new ArrayList<>(); visitorCountArrayList = new ArrayList<>(); recycler_view_ratings = (RecyclerView) findViewById(R.id.recycler_view_ratings); ratingAdapter = new RecyclerRatingAdapter(ratingAndReviewsArrayList,AboutBrandActivity.this); recycler_view_ratings.setAdapter(ratingAdapter); utils = new Utils(); img_save = (ImageView) findViewById(R.id.img_save); youTubePlayerView = findViewById(R.id.youtube_player_view); current_seconds =0; mAuth = FirebaseAuth.getInstance(); firebaseUser = mAuth.getCurrentUser(); } public void customCallDialog(ArrayList<String> mobile_arrray_list) { if(mobile_arrray_list!=null && !mobile_arrray_list.isEmpty()) { final CharSequence[] items = new CharSequence[mobile_arrray_list.size()]; for (int i = 0; i < mobile_arrray_list.size(); i++) { items[i] = mobile_arrray_list.get(i); } final android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(AboutBrandActivity.this); builder.setTitle("Select Number"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { String tel = (String) items[item]; tel = "tel:" + tel; Intent acCall = new Intent(Intent.ACTION_DIAL); acCall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); acCall.setData(Uri.parse(tel)); startActivity(acCall); } }); builder.show(); builder.setCancelable(true); } } private void getPlaceData(final String place_id) { listenerRegistration = db.collection(getString(R.string.places)).document(place_id) .addSnapshotListener(new EventListener<DocumentSnapshot>() { @Override public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirebaseFirestoreException e) { if (e != null) { Log.i(TAG, "An error occurred in getting place" + e.getMessage()); } else { String about_Store; String place_address; String category_id; String home_image_url; ArrayList<String> images_url = new ArrayList<>(); ArrayList<String> images_url_5 = new ArrayList<>(); Boolean is_offering_promo; Boolean is_sponsored; ArrayList<String> mobile_no_array = new ArrayList<>(); String place_name; String offer_image_url; long saved_count; String search_keywords; final String video_url; long visitor_count; int avg_rating; double latitude,longitude; if (snapshot != null && snapshot.exists()) { if (snapshot.getString(getString(R.string.place_name)) != null) { place_name = snapshot.getString(getString(R.string.place_name)); tv_place_name.setText(place_name); } else { place_name = ""; } if (snapshot.getString(getString(R.string.home_image_url)) != null) { home_image_url = snapshot.getString(getString(R.string.home_image_url)); } else { home_image_url = ""; } if (snapshot.getString(getString(R.string.about_store)) != null) { about_Store = snapshot.getString(getString(R.string.about_store)); tv_about_store.setText(about_Store); } else { about_Store = ""; } if (snapshot.getString(getString(R.string.address)) != null) { place_address = snapshot.getString(getString(R.string.address)); tv_place_address.setText(place_address); } else { place_address = ""; } if (snapshot.getString(getString(R.string.category_id)) != null) { category_id = snapshot.getString(getString(R.string.category_id)); } else { category_id = ""; } if (snapshot.get(getString(R.string.images_url)) != null) { images_url = (ArrayList<String>) snapshot.get(getString(R.string.images_url)); for(int i = 0; i<images_url.size();i++) { if(images_url_5.size() < 5) { images_url_5.add(images_url.get(i)); } } if(images_url_5.size() == 5) { images_url_5.add("https://firebasestorage.googleapis.com/v0/b/before-visit.appspot.com/o/view_more_text.png?alt=media&token=0c840df9-3d3c-4c58-a3d3-9e93d76057ef"); } } if (snapshot.get(getString(R.string.is_offering_promo)) != null) { is_offering_promo = snapshot.getBoolean(getString(R.string.is_offering_promo)); } else { is_offering_promo = false; } if (snapshot.get(getString(R.string.is_sponsored)) != null) { is_sponsored = snapshot.getBoolean(getString(R.string.is_sponsored)); } else { is_sponsored = false; } if (snapshot.get(getString(R.string.mobile_no_array)) != null) { mobile_no_array = (ArrayList<String>) snapshot.get(getString(R.string.mobile_no_array)); tv_phone.setText(String.valueOf(mobile_no_array.get(0))); }else{ tv_phone.setVisibility(View.GONE); text_phone.setVisibility(View.GONE); } if (snapshot.getString(getString(R.string.offer_image_url)) != null) { offer_image_url = snapshot.getString(getString(R.string.offer_image_url)); } else { offer_image_url = ""; } if (snapshot.get(getString(R.string.saved_count)) != null) { saved_count = Long.parseLong(String.valueOf(snapshot.get(getString(R.string.saved_count)))); } else { saved_count = 0; } if (snapshot.get(getString(R.string.search_keywords)) != null) { search_keywords = snapshot.getString(getString(R.string.search_keywords)); } else { search_keywords = ""; } if (snapshot.getString(getString(R.string.video_url)) != null) { video_url = snapshot.getString(getString(R.string.video_url)); } else { video_url = ""; } if (snapshot.get(getString(R.string.visitor_count)) != null) { visitor_count = Long.parseLong(String.valueOf(snapshot.get(getString(R.string.visitor_count)))); } else { visitor_count = 0; } if (snapshot.get(getString(R.string.avg_rating)) != null) { avg_rating = Integer.parseInt(String.valueOf(snapshot.getLong(getString(R.string.avg_rating)))); ratingBarAvg.setRating(avg_rating); tv_rating_avg.setText((int) ratingBarAvg.getRating() + "/5"); } else { avg_rating = 0; } if(snapshot.get(getString(R.string.latitude))!=null){ latitude = snapshot.getDouble(getString(R.string.latitude)); }else{ latitude = 0.0; } if(snapshot.get(getString(R.string.longitude))!=null){ longitude = snapshot.getDouble(getString(R.string.longitude)); }else{ longitude = 0.0; } if (snapshot.getString(getString(R.string.location_url)) != null) { location_url = snapshot.getString(getString(R.string.location_url)); } else { location_url = ""; } placesArrayList.add(new Places( place_id, about_Store, place_address, category_id, home_image_url, images_url, is_offering_promo, is_sponsored, mobile_no_array, place_name, offer_image_url, saved_count, search_keywords, video_url, visitor_count, avg_rating, latitude, longitude )); initYouTubePlayerView(video_url); gridImagePlaceAdapter = new GridImagePlaceAdapter(AboutBrandActivity.this, images_url_5); images_grid_view.setAdapter(gridImagePlaceAdapter); } } } }); //getting share link listenerRegistration = db.collection(getString(R.string.share_link)) .addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirebaseFirestoreException e) { if(e!=null){ Log.i(TAG,"Error is "+e.getMessage()); }else{ if(snapshots!=null && !snapshots.isEmpty()) { for (final QueryDocumentSnapshot doc : snapshots) { share_link = doc.getString(getString(R.string.share_link)); } } } } }); } private void initYouTubePlayerView(final String video_url) { // The player will automatically release itself when the fragment is destroyed. // The player will automatically pause when the fragment is stopped // If you don't add YouTubePlayerView as a lifecycle observer, you will have to release it manually. // getLifecycle().addObserver(youTubePlayerView); youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() { @Override public void onReady(@NonNull com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer youTubePlayer) { String url_cue = video_url.substring(video_url.lastIndexOf("=")+1); YouTubePlayerUtils.loadOrCueVideo( youTubePlayer, getLifecycle(), url_cue,0f ); youTubePlayer.pause(); } @Override public void onCurrentSecond(com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer youTubePlayer, float second) { super.onCurrentSecond(youTubePlayer, second); current_seconds = Math.abs(second-1); } }); youTubePlayerView.addFullScreenListener(new YouTubePlayerFullScreenListener() { @Override public void onYouTubePlayerEnterFullScreen() { Intent intent = new Intent(getApplicationContext(), FullScreenActivity.class); intent.putExtra("current_seconds", current_seconds); intent.putExtra("video_url",video_url); startActivity(intent); } @Override public void onYouTubePlayerExitFullScreen() { Intent intent = new Intent(getApplicationContext(), FullScreenActivity.class); intent.putExtra("current_seconds", current_seconds); intent.putExtra("video_url",video_url); startActivity(intent); } }); } private void getUserData() { if (firebaseUser != null) { DocumentReference docref = db.collection(getString(R.string.users)).document(firebaseUser.getUid()); listenerRegistration = docref.addSnapshotListener(new EventListener<DocumentSnapshot>() { @Override public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirebaseFirestoreException e) { if (e != null) { Log.i(TAG, "An error occurred " + e.getMessage()); } else { ArrayList<String> places_saved = new ArrayList<>(); if (snapshot != null && snapshot.exists()) { Log.i(TAG, "Data is here "); if (snapshot.get(getString(R.string.name)) != null) { name = snapshot.getString(getString(R.string.name)); } else { name = ""; } if(snapshot.get(getString(R.string.places_saved))!=null){ places_saved = (ArrayList<String>) snapshot.get(getString(R.string.places_saved)); } } if(places_saved.contains(place_id)){ isSaved = true; img_save.setImageResource(R.drawable.ic_heart_filled); }else{ isSaved = false; img_save.setImageResource(R.drawable.ic_heart_unfilled); } } } }); } } private void sendReview() { utils.hideKeyboard(AboutBrandActivity.this); img_done.setEnabled(false); progressBar.setVisibility(View.VISIBLE); Map<String, Object> data = new HashMap<>(); if (!name.isEmpty()) { data.put(getString(R.string.user_name), name); } if (review != null && !review.isEmpty()) { data.put(getString(R.string.review), review); } if (place_id != null && !place_id.isEmpty()) { data.put(getString(R.string.place_id), place_id); } if (placesArrayList.get(0).getPlace_name() != null && !placesArrayList.get(0).getPlace_name().isEmpty()) { data.put(getString(R.string.place_name_review), placesArrayList.get(0).getPlace_name()); } data.put(getString(R.string.userid), firebaseUser.getUid()); data.put(getString(R.string.date_created), new Timestamp(new Date())); if (firebaseUser != null) { if (doc_update_id == null || doc_update_id.isEmpty()) { if (rating != null || !rating.isEmpty()) { data.put(getString(R.string.rating), int_rating); avg_rating = (int)Math.round((((placesArrayList.get(0).getAvg_rating() * total_reviews) + (int_rating)) / (total_reviews + 1))); placesArrayList.get(0).setAvg_rating(avg_rating); } db.collection(getString(R.string.ratings_and_reviews)).document() .set(data) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Log.d(TAG, "DocumentSnapshot successfully written!"); progressBar.setVisibility(View.GONE); img_done.setEnabled(true); utils.alertDialog(AboutBrandActivity.this, "Thank You!", "Your feedback is valuable to us!"); scrollView.fullScroll(View.FOCUS_UP); if(rating!=null && !rating.isEmpty()) { //Updating average Review in places db.collection(getString(R.string.places)).document(place_id) .update(getString(R.string.avg_rating), avg_rating) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Log.i(TAG, "avg rating under places updated"); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.i(TAG, "An error occurred in updating avg_rating in places " + e.getMessage()); } }); } } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Error writing document", e); progressBar.setVisibility(View.GONE); utils.alertDialog(AboutBrandActivity.this, "Uh-Oh", e.getLocalizedMessage()); img_done.setEnabled(true); } }); }else{ //update review if (rating != null && !rating.isEmpty()) { data.put(getString(R.string.rating), int_rating); avg_rating = (int)Math.round((((placesArrayList.get(0).getAvg_rating() * total_reviews) + (int_rating - previous_rating)) / (total_reviews))); placesArrayList.get(0).setAvg_rating(avg_rating); } db.collection(getString(R.string.ratings_and_reviews)) .document(doc_update_id) .update(data) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { img_done.setEnabled(true); utils.alertDialog(AboutBrandActivity.this, "Thank You!", "Your feedback is valuable to us!"); progressBar.setVisibility(View.GONE); scrollView.fullScroll(View.FOCUS_UP); if(rating!=null && !rating.isEmpty()) { //Updating average Review in places db.collection(getString(R.string.places)).document(place_id) .update(getString(R.string.avg_rating), avg_rating) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Log.i(TAG, "avg rating under places updated"); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.i(TAG, "An error occurred in updating avg_rating in places " + e.getMessage()); } }); } } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Error writing document", e); progressBar.setVisibility(View.GONE); utils.alertDialog(AboutBrandActivity.this, "Uh-Oh", e.getLocalizedMessage()); img_done.setEnabled(true); } }); } } } private void getTotalReviews(){ listenerRegistration = db.collection(getString(R.string.ratings_and_reviews)) .whereEqualTo(getString(R.string.place_id),place_id) .addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirebaseFirestoreException e) { if(e!=null){ Log.i(TAG,"error"+e.getMessage()); }else{ total_reviews = snapshots.size(); if(snapshots.isEmpty()){ total_reviews = 0; btn_show_more.setVisibility(View.GONE); } tv_total_reviews.setText("( "+ Math.round(total_reviews) + " reviews )"); } } }); } private void getUserReviews(){ if(firebaseUser!=null) { listenerRegistration = db.collection(getString(R.string.ratings_and_reviews)) .whereEqualTo(getString(R.string.userid), firebaseUser.getUid()) .whereEqualTo(getString(R.string.place_id),place_id) .addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirebaseFirestoreException e) { if (e != null) { Log.i(TAG, "getUserReviews: error " + e.getMessage()); } else { for (final QueryDocumentSnapshot doc : snapshots) { if (doc.get(getString(R.string.rating)) != null) { previous_rating = Math.round(doc.getLong(getString(R.string.rating))); tv_rating_user.setText(previous_rating + "/5"); rating_bar_user.setRating(previous_rating); } if (doc.get(getString(R.string.review)) != null) { et_review.setText((doc.get(getString(R.string.review)).toString())); } doc_update_id = doc.getId(); } } } }); } } private void getAllReviews(){ listenerRegistration = db.collection(getString(R.string.ratings_and_reviews)) .whereEqualTo(getString(R.string.place_id),place_id) .orderBy(getString(R.string.date_created), Query.Direction.DESCENDING) .limit(5) .addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirebaseFirestoreException e) { if(e != null){ Log.i(TAG,"An error occurred in getting reviews" +e.getMessage()); }else{ String doc_id; float rating; String review; String date_created; String user_name; if(snapshots!=null && !snapshots.isEmpty()){ ratingAndReviewsArrayList.clear(); for(final QueryDocumentSnapshot doc: snapshots){ doc_id = doc.getId(); if (doc.get(getString(R.string.rating)) != null) { rating = Float.parseFloat(doc.get(getString(R.string.rating)).toString()); }else{ rating = 0; } if (doc.get(getString(R.string.review)) != null) { review = doc.get(getString(R.string.review)).toString(); }else{ review = ""; } if(doc.getTimestamp(getString(R.string.date_created))!=null){ Timestamp date_created_ts = doc.getTimestamp(getString(R.string.date_created)); SimpleDateFormat sfd_viewFormat = new SimpleDateFormat("d MMMM yyyy"); date_created = sfd_viewFormat.format(date_created_ts.toDate()); }else{ date_created = ""; } if (doc.get(getString(R.string.user_name)) != null) { user_name = doc.get(getString(R.string.user_name)).toString(); }else{ user_name = ""; } ratingAndReviewsArrayList.add(new RatingAndReviews( doc_id, rating, review, date_created, user_name )); } ratingAdapter.notifyDataSetChanged(); } } } }); } private void savePlace(final String place_id, Boolean isSaved){ if(firebaseUser!=null){ Log.i(TAG,"userid is "+firebaseUser.getUid()); Log.i(TAG,"placeid is "+place_id); if(isSaved) { db.collection(getString(R.string.users)).document(firebaseUser.getUid()) .update(getString(R.string.places_saved),FieldValue.arrayUnion(place_id)) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Toast.makeText(getApplicationContext(),"Added to your favourites",Toast.LENGTH_SHORT).show(); db.collection(getString(R.string.places)).document(place_id) .update(getString(R.string.saved_count),FieldValue.increment(1)) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.i(TAG,"Could not update saved count"+e.getMessage()); } }); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(getApplicationContext(),"An error occurred",Toast.LENGTH_SHORT).show(); } }); }else{ db.collection(getString(R.string.users)).document(firebaseUser.getUid()) .update(getString(R.string.places_saved),FieldValue.arrayRemove(place_id)) .addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void aVoid) { Toast.makeText(getApplicationContext(),"Removed from your favourites",Toast.LENGTH_SHORT).show(); db.collection(getString(R.string.places)).document(place_id) .update(getString(R.string.saved_count),FieldValue.increment(-1)) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.i(TAG,"Could not update saved count"+e.getMessage()); } }); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(getApplicationContext(),"An error occurred",Toast.LENGTH_SHORT).show(); } }); } } } private void storeVisitorCount(){ if(firebaseUser!=null){ db.collection(getString(R.string.places)).document(place_id) .update(getString(R.string.visitor_count),FieldValue.increment(1)); } } @Override public void onBackPressed() { super.onBackPressed(); finish(); } @Override protected void onStop() { super.onStop(); if(listenerRegistration!=null){ listenerRegistration=null; } } @Override protected void onStart() { super.onStart(); if(firebaseUser == null){ finish(); Intent intent = new Intent(getApplicationContext(),LoginMainActivity.class); startActivity(intent); overridePendingTransition(0,0); } } }
f0417852b9a3c09991c3e4ee8df2cecc2605431e
4e858b3276daf45b0bf6bc95c22b52b3aa07c2bc
/src/OriginalUkrNet.java
adeade54434676412b4e543be1fa65a2aa3b6b8b
[]
no_license
torraze/CodeDesign
5ac198e43e6af0b8289545b33c9dfa1b34005211
b7b8f2ff880f57915f5818385fc1d7346da665d4
refs/heads/master
2021-01-19T05:47:25.174771
2017-04-06T16:55:54
2017-04-06T16:55:54
87,447,959
0
0
null
null
null
null
UTF-8
Java
false
false
1,235
java
import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class OriginalUkrNet { public WebDriver driver; public String baseUrl = "https://www.ukr.net/"; @Test public void main() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\AsusK53sc\\IdeaProjects\\CodeDesign\\drivers\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get(baseUrl + "/");//begin test - correct logout ukr.net driver.findElement(By.name("Login")).click(); driver.findElement(By.name("Login")).clear(); driver.findElement(By.name("Login")).sendKeys("guerro"); driver.findElement(By.name("Password")).clear(); driver.findElement(By.name("Password")).sendKeys("unoparole"); driver.findElement(By.cssSelector("button[type=\"submit\"]")).click(); Thread.sleep(2000);//if delele this string - test is NOT working driver.findElement(By.linkText("Вийти")).click(); Thread.sleep(2000); driver.quit();//close driver System.out.println("test passed"); } }
[ "asgard55" ]
asgard55
1f2a3ae2797a506546e50d95949bb6569e2aa0a3
cacdeee7eb54ab763aba0b36cc410a3ab0458dd0
/core/src/main/java/se_ii/gruppe2/moving_maze/network/messages/out/InitGameStart.java
43483ebe516806a79812b71a6a8b486c3261b9f8
[]
no_license
SE2-SS21-Gruppe2/moving-maze
1d8ae2f8847b5ea8ab506097b0e6d6894cd17460
eb7292e5dd95426fe1ddb5548214f92b0b1b9985
refs/heads/main
2023-06-06T13:33:23.730604
2021-06-22T21:47:46
2021-06-22T21:47:46
357,562,623
3
0
null
2021-06-22T21:47:47
2021-04-13T13:25:46
Java
UTF-8
Java
false
false
2,178
java
package se_ii.gruppe2.moving_maze.network.messages.out; import se_ii.gruppe2.moving_maze.gameboard.GameBoard; import se_ii.gruppe2.moving_maze.item.ItemLogical; import java.util.ArrayList; import java.util.Arrays; /** * Sent to the server by a game host in order to signal that a game can be started. * In addition to the session-key, a generated board and the chosen name of the session-creator is submitted. */ public class InitGameStart { private String key; private int itemsPerPlayer; private GameBoard board; private String oldHostName; private String finalHostName; private ArrayList<ItemLogical> itemsToDistribute; public InitGameStart() { } public InitGameStart(String key, GameBoard board, String oldHostName, String finalHostName, int itemsPerPlayer, ItemLogical[] availableItems) { this.key = key; this.board = board; this.oldHostName = oldHostName; this.finalHostName = finalHostName; this.itemsPerPlayer = itemsPerPlayer; this.itemsToDistribute = new ArrayList<>(Arrays.asList(availableItems)); } // GETTER & SETTER public String getKey() { return key; } public void setKey(String key) { this.key = key; } public GameBoard getBoard() { return board; } public void setBoard(GameBoard board) { this.board = board; } public String getOldHostName() { return oldHostName; } public void setOldHostName(String oldHostName) { this.oldHostName = oldHostName; } public String getFinalHostName() { return finalHostName; } public void setFinalHostName(String finalHostName) { this.finalHostName = finalHostName; } public ArrayList<ItemLogical> getItemsToDistribute() { return itemsToDistribute; } public void setItemsToDistribute(ArrayList<ItemLogical> itemsToDistribute) { this.itemsToDistribute = itemsToDistribute; } public int getItemsPerPlayer() { return itemsPerPlayer; } public void setItemsPerPlayer(int itemsPerPlayer) { this.itemsPerPlayer = itemsPerPlayer; } }
ce96b8e3065a79a0daa66e9ad6b5bc02a812febb
555207874d9e86e80ebc9e4c05657ccb93b8edb4
/src/org/sample/Pojo.java
67dfd1c0e1cc84ea3b4931f942cb2fdb21c2aa10
[]
no_license
01chandra01/poojitha
04ee4643435ae22e28ddb665e3c256c31397cefc
e7b62cdf7b35d91ae800ad2f8693de5d3e9dba8d
refs/heads/master
2023-07-29T02:00:23.903603
2021-09-09T11:45:09
2021-09-09T11:45:09
404,702,289
0
0
null
null
null
null
UTF-8
Java
false
false
91
java
package org.sample; public class Pojo { public static void main(String[] args) { } }
c699e85c7d45ec0712c87656d12b09092b81f9b5
447794e7242ac99c73ca0ec38ba3be8e1872ba3e
/app/src/test/java/com/example/da08/threadbasic/ExampleUnitTest.java
9b843729e00d959cc11e66199f68a65ae64c9661
[]
no_license
daaa08/ThreadBasic
211fd17a94545e5dfb9d8cc70938c42d775bf2f8
41eb957b9c93218868c23b8dc1792c95b9c87630
refs/heads/master
2021-01-25T06:57:07.273131
2017-06-07T14:23:20
2017-06-07T14:23:20
93,635,349
0
0
null
null
null
null
UTF-8
Java
false
false
406
java
package com.example.da08.threadbasic; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
89059e4dbb53ac6ca6cc2558400d1bdc377658e5
94228df04c8d71ef72d0278ed049e9eac43566bc
/modules/materialsummary/materialsummary-api/src/main/java/com/bjike/goddess/materialsummary/api/InStockAreaYearSumAPI.java
27111163e715c4bc7f0a9660595453e2eca88c01
[]
no_license
yang65700/goddess-java
b1c99ac4626c29651250969d58d346b7a13eb9ad
3f982a3688ee7c97d8916d9cb776151b5af8f04f
refs/heads/master
2021-04-12T11:10:39.345659
2017-09-12T02:32:51
2017-09-12T02:32:51
126,562,737
0
0
null
2018-03-24T03:33:53
2018-03-24T03:33:53
null
UTF-8
Java
false
false
2,082
java
package com.bjike.goddess.materialsummary.api; import com.bjike.goddess.common.api.exception.SerException; import com.bjike.goddess.materialsummary.bo.InStockAreaYearSumBO; import com.bjike.goddess.materialsummary.dto.InStockAreaYearSumDTO; import com.bjike.goddess.materialsummary.to.InStockAreaYearSumTO; import java.util.List; /** * 入库地区年汇总业务接口 * * @Author: [ sunfengtao ] * @Date: [ 2017-05-22 11:11 ] * @Description: [ 入库地区年汇总业务接口 ] * @Version: [ v1.0.0 ] * @Copy: [ com.bjike ] */ public interface InStockAreaYearSumAPI { /** * 根据id查询入库地区年汇总 * * @param id 入库地区年汇总唯一标识 * @return class InStockAreaYearSumBO * @throws SerException */ InStockAreaYearSumBO findById(String id) throws SerException; /** * 计算总条数 * * @param dto 入库地区年汇总dto * @throws SerException */ Long count(InStockAreaYearSumDTO dto) throws SerException; /** * 分页查询入库地区年汇总 * * @param dto 入库地区年汇总dto * @return class InStockAreaYearSumBO * @throws SerException */ List<InStockAreaYearSumBO> list(InStockAreaYearSumDTO dto) throws SerException; /** * 保存入库地区年汇总 * * @param to 入库地区年汇总to * @return class InStockAreaYearSumBO * @throws SerException */ InStockAreaYearSumBO save(InStockAreaYearSumTO to) throws SerException; /** * 根据id删除入库地区年汇总 * * @param id 入库地区年汇总唯一标识 * @throws SerException */ void remove(String id) throws SerException; /** * 更新入库地区年汇总 * * @param to 入库地区年汇总to * @throws SerException */ void update(InStockAreaYearSumTO to) throws SerException; /** * 汇总 * * @return class InStockAreaYearSumBO * @throws SerException */ List<InStockAreaYearSumBO> summary() throws SerException; }
386c17ce1435b3b23b60543b50ac2ef478dfd432
c7772dd35626b343dd2ed40518340aa80b9f618d
/src/testIntegration/java/uk/gov/justice/digital/delius/controller/secure/SmokeTestHelperAPITest.java
4b589436bb0f684f901c3f65e6b52a2fb18393e3
[ "MIT" ]
permissive
ollietreend/community-api
666cab98571160f155bef04ce1703026854f8494
9431b03e93d7540bba2a3b1dfafc5983750d68f1
refs/heads/main
2023-04-17T06:03:18.650521
2021-04-22T08:32:58
2021-04-22T08:32:58
360,905,069
0
0
MIT
2021-04-23T14:07:45
2021-04-23T14:07:44
null
UTF-8
Java
false
false
8,891
java
package uk.gov.justice.digital.delius.controller.secure; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.justice.digital.delius.FlywayRestoreExtension; import uk.gov.justice.digital.delius.data.api.OffenderDetail; import uk.gov.justice.digital.delius.data.api.ReplaceCustodyKeyDates; import uk.gov.justice.digital.delius.data.api.UpdateCustody; import java.time.LocalDate; import static io.restassured.RestAssured.given; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @ExtendWith({SpringExtension.class, FlywayRestoreExtension.class}) @DisplayName("Smoke test update helpers") public class SmokeTestHelperAPITest extends IntegrationTestBase { private static final String NOMS_NUMBER = "G9542VP"; private static final String CRN = "X320741"; private static final long CONVICTION_ID = 2500295345L; private static final String PRISON_BOOKING_NUMBER = "V74111"; @Nested @DisplayName("POST smoketest/offenders/crn/{crn}/custody/reset") class CustodyReset { @Test @DisplayName("must have `ROLE_SMOKE_TEST` to access this service") public void mustHaveCommunityRole() { final var token = createJwt("ROLE_COMMUNITY"); given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .when() .post("smoketest/offenders/crn/{crn}/custody/reset", CRN) .then() .statusCode(403); } @Test @DisplayName("Can reset custody data") public void canResetCustodyData() { final var token = createJwt("ROLE_COMMUNITY_CUSTODY_UPDATE", "ROLE_COMMUNITY", "ROLE_SMOKE_TEST"); // Given current location is HMP Moorland given() .auth().oauth2(token) .contentType("application/json") .body(createUpdateCustody("MDI")) .when() .put(format("offenders/nomsNumber/%s/custody/bookingNumber/%s", NOMS_NUMBER, PRISON_BOOKING_NUMBER)) .then() .statusCode(200); // AND the conviction has some keys dates given() .auth().oauth2(token) .contentType("application/json") .body(createReplaceCustodyKeyDates(ReplaceCustodyKeyDates .builder() .conditionalReleaseDate(LocalDate.now()) .licenceExpiryDate(LocalDate.now()) .hdcEligibilityDate(LocalDate.now()) .paroleEligibilityDate(LocalDate.now()) .sentenceExpiryDate(LocalDate.now()) .expectedReleaseDate(LocalDate.now()) .postSentenceSupervisionEndDate(LocalDate.now()) .build())) .when() .post(String.format("offenders/nomsNumber/%s/bookingNumber/%s/custody/keyDates", NOMS_NUMBER, PRISON_BOOKING_NUMBER)) .then() .statusCode(200); // AND I verify that data has been set given() .auth().oauth2(token) .contentType("application/json") .when() .get("offenders/crn/{crn}/custody/convictionId/{convictionId}", CRN, CONVICTION_ID) .then() .statusCode(200) .body("bookingNumber", equalTo("V74111")) .body("institution.code", equalTo("MDIHMP")) .body("status.code", equalTo("D")) .body("status.description", equalTo("In Custody")) .body("keyDates.size()", equalTo(7)) ; // WHEN when I reset this data given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .when() .post("/smoketest/offenders/crn/{crn}/custody/reset", CRN) .then() .statusCode(200); // THEN the custody data is set to initial defaults given() .auth().oauth2(token) .contentType("application/json") .when() .get("offenders/crn/{crn}/custody/convictionId/{convictionId}", CRN, CONVICTION_ID) .then() .statusCode(200) .body("bookingNumber", nullValue()) .body("institution.code", equalTo("UNKNOW")) .body("status.code", equalTo("A")) .body("keyDates.size()", equalTo(0)); // AND the offender no longer has a NOMS number given() .auth() .oauth2(tokenWithRoleCommunity()) .contentType(APPLICATION_JSON_VALUE) .when() .get("/offenders/nomsNumber/{nomsNumber}/all", NOMS_NUMBER) .then() .statusCode(404); // AND I can reset again with no errors given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .when() .post("/smoketest/offenders/crn/{crn}/custody/reset", CRN) .then() .statusCode(200); } private String createUpdateCustody(@SuppressWarnings("SameParameterValue") String prisonCode) { return writeValueAsString(UpdateCustody .builder() .nomsPrisonInstitutionCode(prisonCode) .build()); } private String createReplaceCustodyKeyDates(ReplaceCustodyKeyDates replaceCustodyKeyDates) { return writeValueAsString(replaceCustodyKeyDates); } } @Nested @DisplayName("POST smoketest/offenders/crn/{crn}/details") class UpdateOffenderDetails { @Test @DisplayName("must have `ROLE_SMOKE_TEST` to access this service") public void mustHaveCommunityRole() { final var token = createJwt("ROLE_COMMUNITY"); given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .body(createOffenderDetails("Betty", "Boop")) .when() .post("/smoketest/offenders/crn/{crn}/details", CRN) .then() .statusCode(403); } @Test @DisplayName("will reject updates with no names") public void mustHaveNamesInBody() { final var token = createJwt("ROLE_SMOKE_TEST"); given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .body(createOffenderDetails("", "")) .when() .post("/smoketest/offenders/crn/{crn}/details", CRN) .then() .statusCode(400); } @Test @DisplayName("Can set first name and surname") public void canUpdateOffenderDetails() { final var token = createJwt("ROLE_SMOKE_TEST"); // GIVEN I change the name given() .auth().oauth2(token) .contentType(APPLICATION_JSON_VALUE) .body(createOffenderDetails("Betty", "Boop")) .when() .post("smoketest/offenders/crn/{crn}/details", CRN) .then() .statusCode(200); // WHEN I the retrieve the details final var offenderDetail = given() .auth() .oauth2(tokenWithRoleCommunity()) .contentType(APPLICATION_JSON_VALUE) .when() .get("/offenders/crn/{crn}/all", CRN) .then() .statusCode(200) .extract() .body() .as(OffenderDetail.class); // THEN the name would reflect the name previously saved assertThat(offenderDetail.getFirstName()).isEqualTo("Betty"); assertThat(offenderDetail.getSurname()).isEqualTo("Boop"); } private String createOffenderDetails(@SuppressWarnings("SameParameterValue") String firstName, @SuppressWarnings("SameParameterValue") String surname) { return writeValueAsString(uk.gov.justice.digital.delius.data.api.UpdateOffenderDetails .builder() .firstName(firstName) .surname(surname) .build()); } } }
a84a8dd7694042ddf820d2d84e63bb69b3a22b69
912da7578855b4db0a95f8cf82ea215ed512082f
/src/main/java/dto/SubjectDTO.java
3acf6e5eaaa3e254372787378f61d4bd21b884f6
[]
no_license
zeoops/attendancemanagement
266b96706b2aac1ad396e978cf0449b8939c8955
c654057ed824d7bf2662c82213a356b0e95addb1
refs/heads/master
2023-07-20T22:07:26.037329
2021-09-03T13:41:32
2021-09-03T13:41:32
347,347,460
0
0
null
null
null
null
UTF-8
Java
false
false
434
java
package dto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import java.io.Serializable; import java.util.Date; import java.util.List; @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class SubjectDTO implements Serializable { private String subjectName; private String semesterId; private String subjectCode; private List<Date> dates; }
b1307d5f2c5c3a69fc2b4c9ff2ce9f0a1cd0469f
6b5fecfbdc7e001138daa268b9cc60c95a70ea9a
/Herencia/PrubAbstracta.java
039d81a8f727e00a1f284676bf830465a60a8569
[]
no_license
LHPH/FIUAEMEXLPOOEV
f65e8d2ec50ff3802d61fa24a13142ab59f1c733
7f214b84f7140763636bd5294e519343dae0011a
refs/heads/master
2023-04-08T22:10:11.526432
2021-04-19T00:26:51
2021-04-19T00:26:51
359,282,058
0
0
null
null
null
null
UTF-8
Java
false
false
1,450
java
package Herencia; /** Las clases que hereden de clases abstractas * deben implementar todos los metodos que sean abstractos * de la clase abstracta * si no se implementan todos la subclase debe declararse como abstracta tambien*/ public class PrubAbstracta extends Abstracta { public PrubAbstracta() { super(); } @Override public void contar() { } public int contar(int inf,int sup){ int sum=0; for(int cont=inf;cont<sup;cont++){ sum++; System.out.println(sum); } return sum; } @Override public String getNombre() { return null; } @Override public void dibujar() { } public void pintar(Abstracta abs){ super.pintar(abs,"Rojo"); System.out.println("Se Pintara de color "+abs.color); } /** Las clases abstractas no pueden crear objetos pero pueden usarse si se les asigna a una referencia * un objeto de la sublcase * el objeto de la superclase ejecuta solo sus propios metodos si estos no se sobreescribieron en la subclase * y si no son privados, sino es asi el objeto de la superclase ejecutara los metodos sobreescritos*/ public static void main(String[] args) { Abstracta abs = new PrubAbstracta(); int num=abs.contar(0, 10); System.out.println(num); } }
8acb414209c50b65b82ef22d2dd6f684fe6c34b6
83a5f2b2787503c9217240dc2f2e52f3191279ad
/blog-ribbon-server/src/main/java/com/springcloud/blog/TestService.java
9c736b59c1de97fd135213f1826d3ad27c7ea9de
[]
no_license
developers-youcong/blog-springcloud-pro-demo
4e14b33eed73203bcd400a31d1900875b17eb0c0
3bd1c266a89a60a6fe6b321f5f92434b54dceeef
refs/heads/master
2022-04-07T06:56:36.775672
2020-02-29T15:50:58
2020-02-29T15:50:58
null
0
0
null
null
null
null
UTF-8
Java
false
false
753
java
package com.springcloud.blog; import javax.xml.crypto.dsig.XMLObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; @Service public class TestService { @Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "returnError") public String get48HoursTopViewPosts(String itemCount) { return restTemplate.getForObject("http://cnblogs-client/cnblogs/get48HoursTopViewPosts/"+itemCount,String.class); } public String returnError(String itemCount) { return itemCount+" error"; } }
000223dbde747d6be7104d3dd5c9e8594c4ed076
3f2d793dccdb8ddce0c15e14e94b8622231c9929
/src/main/java/com/mediaflex/controller/WatchController.java
c18b5ea5774d670cb924a112017afa3c278f24ff
[]
no_license
nadurious/origin
81b3df82f804bd20674d425ec157cedb0edd3e83
34bd25e331a8d52e1b66ee2c840c4ed2d39d6d7b
refs/heads/master
2022-12-27T11:50:00.713562
2020-10-02T07:36:14
2020-10-02T07:36:14
300,580,316
0
0
null
null
null
null
UTF-8
Java
false
false
1,091
java
package com.mediaflex.controller; import java.io.File; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.apache.commons.io.monitor.FileAlterationListener; import org.apache.commons.io.monitor.FileAlterationMonitor; import org.apache.commons.io.monitor.FileAlterationObserver; import com.mediaflex.Listener.WatchMonitorListener; public class WatchController implements FileController { public static ExecutorService watchThreadPool = Executors.newFixedThreadPool(30); private static File watchDir; public WatchController(File watchDir) { this.watchDir = watchDir; } @Override public void run() { try { FileAlterationObserver observer = new FileAlterationObserver(watchDir); FileAlterationMonitor monitor = new FileAlterationMonitor(5000); FileAlterationListener listener = new WatchMonitorListener(); observer.addListener(listener); monitor.addObserver(observer); monitor.start(); } catch (Exception e) { e.printStackTrace(); } } }
91084bdf5c87f023bdef983bf1aaeae26e5d6a2f
2c42ff8e677790139f972934d0604ed9baf61930
/JavaIdea/handwrite/src/main/java/com/cxz/Service/IUserRoleService.java
1a66d36ac931c1380120f18a9394520734cdaf0c
[]
no_license
DukeTiny/education
ee845c0e5b0d171337c6f52052e054379e1ddc1b
8ec8aaec07897ca93d16b08a7ef431beb680eaf3
refs/heads/master
2022-12-25T03:46:06.741009
2019-10-15T17:11:04
2019-10-15T17:11:04
215,351,747
0
0
null
2022-12-16T09:59:04
2019-10-15T16:56:27
TSQL
UTF-8
Java
false
false
138
java
package com.cxz.Service; import com.cxz.domain.User_Role_Key; public interface IUserRoleService { void save(User_Role_Key urk); }
abacb97a45b3fc2175dc0ab2af8afbf363c4f969
94dafb3bf3b6919bf4fcb3d460173077bfa29676
/platform/src/main/java/com/wdcloud/lms/business/strategy/modulecontentmove/ModuleContentMoveStrategy.java
5ed731c859ef35b2b2bceec49c7d66b52e7003ac
[]
no_license
Miaosen1202/1126Java
b0fbe58e51b821b1ec8a8ffcfb24b21d578f1b5f
7c896cffa3c51a25658b76fbef76b83a8963b050
refs/heads/master
2022-06-24T12:33:14.369136
2019-11-26T05:49:55
2019-11-26T05:49:55
224,112,546
0
0
null
2021-02-03T19:37:54
2019-11-26T05:48:48
Java
UTF-8
Java
false
false
627
java
package com.wdcloud.lms.business.strategy.modulecontentmove; import com.wdcloud.lms.base.enums.MoveStrategyEnum; import com.wdcloud.lms.business.strategy.Strategy; /** * @author 赵秀非 */ @SuppressWarnings({"JavaDoc", "SpringJavaAutowiredFieldsWarningInspection"}) public interface ModuleContentMoveStrategy extends Strategy { /** * 本组移动或跨组移动 * * @param id moduleId * @param targetModuleId 目标moduleId * @param targetItemId 目标itemId */ void move(Long sourceModuleId, Long targetModuleId, Long targetItemId); MoveStrategyEnum support(); }
dbcd2c233ec3dae18ff46f7ffeb844c526d6cc7e
6f180f73964e5ec828ceb247592e38c10d935325
/src/aap/Pessoa.java
9d7babd8f4cd2c31958a7548caa88204132f61a0
[]
no_license
Rivanildo/aap
3f47b09635886c62d44ee4dab6e2e18d3bf117f9
0e5a3d555be746cabe1181b98ceeb2e87629c2a0
refs/heads/master
2021-01-19T17:11:57.590376
2014-03-26T18:29:33
2014-03-26T18:29:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
39
java
package aap; public class Pessoa { }
294753b74a2b47ffbf0aea99b70b7e3d092aaee4
3cf75cbc469dd7a8e9803ab2fd49bc96e6439f8b
/src/test/java/com/josh/code/Samples/ChallengeSnippetsTests.java
aca1b7b9b469afa6202c5f4f1eab310b0c5b0106
[]
no_license
jbloy91/Samples
bfd8156cf4fdef82693709efc7f8c8799fd7d0f1
7c15bfad2db598b7e44fad5ffbba944b722138d6
refs/heads/master
2020-04-04T16:59:53.865609
2018-11-04T16:28:31
2018-11-04T16:28:31
156,102,165
0
0
null
null
null
null
UTF-8
Java
false
false
985
java
package com.josh.code.Samples; import org.junit.Test; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertFalse; public class ChallengeSnippetsTests { @Test public void testFibonacciSequence(){ assertTrue(ChallengeSnippets.fib(3) == 2); assertTrue(ChallengeSnippets.fib(0) == 0); assertTrue(ChallengeSnippets.fib(10) == 55); System.out.print(ChallengeSnippets.fib(12)); } public void testListNodeShit(){ } @Test public void areStrUniques(){ assertTrue(ChallengeSnippets.areAllCharactersUnique(null)); assertTrue(ChallengeSnippets.areAllCharactersUnique("spdofi")); assertFalse(ChallengeSnippets.areAllCharactersUnique("aassddd")); assertTrue(ChallengeSnippets.altAreCharactersUnique(null)); assertTrue(ChallengeSnippets.altAreCharactersUnique("spdofi")); assertFalse(ChallengeSnippets.altAreCharactersUnique("aassddd")); } }
c691917c5b6ab78f1070f72a4e523a937d3117c7
e868a70f184b603896070116a6ca010e410dd651
/prototipo/1_1_netbeans/image/src/image/GridJPanel.java
2413e457d7389bf26d3893301648562c75dcdb9f
[]
no_license
thullyo/creating-calc-image-diffs
77256af355db440ff36c8593c833b4bf91afda80
59b7466d6ccfc2ac77fc19d86cb980b8608cfb07
refs/heads/master
2020-12-24T18:03:01.630045
2011-06-28T20:20:47
2011-06-28T20:20:47
1,966,102
0
0
null
null
null
null
UTF-8
Java
false
false
709
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package image; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; import javax.swing.JPanel; import java.awt.Image; import java.awt.Toolkit; /** * * @author thullyo.ferreira */ public class GridJPanel extends JPanel { private String _path; public void GridJPanel(String path) { _path = path; } @Override protected void paintComponent(Graphics g) { Image img = Toolkit.getDefaultToolkit().getImage(_path); g.drawImage(img, 0, 0, 800, 600, this); } }
9c651be31d1e434ffa01dbf22e8e9d99f3972f56
e9b9afd703384323dddabad6cf560309b1cabe0a
/Drawing.java
65711a77a3d0aaae090fd0cbbd5ac63327362ad0
[]
no_license
yrvaibhav/Java-Programming-Basics-
608afc5da7242404408b8438e913692250f71795
34e504e8b3216142060fb23256642e92523978df
refs/heads/master
2020-06-13T14:18:42.257896
2019-07-01T15:53:12
2019-07-01T15:53:12
194,685,329
0
0
null
null
null
null
UTF-8
Java
false
false
643
java
package Overridding; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; public class Drawing extends JFrame { public static void main(String[] args) { new Drawing(); } public Drawing() { setSize(500, 500); setVisible(true); } @Override public void paint(Graphics g) { // TODO Auto-generated method stub super.paint(g); g.drawRect(50, 50, 100, 25); g.setColor(Color.blue); g.drawOval(200, 50, 50, 50); g.setColor(Color.green); g.fillRect(50, 200, 100, 25); g.setColor(Color.BLACK); g.drawString("My String", 200, 200); } }
295793da3be2f3cce2d7e3c5e9c6e5f5a5e5f2b6
499eab59db576aa3c89136c747aef005f37c1e58
/src/main/java/cn/bingoogolapple/qrcode/zxing/QRCodeDecoder.java
f7313eedd60d8db951822587f1cc2f8bc2011b7a
[ "Apache-2.0" ]
permissive
ijero/zbar
5d8cccd9c4a2dd86ecde6bdd729a7f2f17f78bc2
ea6f484faa04d31e0564a4afe66edd50bd20a976
refs/heads/master
2020-03-18T23:26:27.410538
2018-05-30T07:24:45
2018-05-30T07:24:45
135,402,980
0
0
null
null
null
null
UTF-8
Java
false
false
4,785
java
package cn.bingoogolapple.qrcode.zxing; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import com.google.zxing.BarcodeFormat; import com.google.zxing.BinaryBitmap; import com.google.zxing.DecodeHintType; import com.google.zxing.MultiFormatReader; import com.google.zxing.RGBLuminanceSource; import com.google.zxing.Result; import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.common.HybridBinarizer; import java.io.File; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; import java.util.Map; /** * 作者:王浩 邮件:[email protected] * 创建时间:16/4/8 下午11:22 * 描述:解析二维码图片 */ public class QRCodeDecoder { public static final Map<DecodeHintType, Object> HINTS = new EnumMap<>(DecodeHintType.class); static { List<BarcodeFormat> allFormats = new ArrayList<>(); // allFormats.add(BarcodeFormat.AZTEC); // allFormats.add(BarcodeFormat.CODABAR); // allFormats.add(BarcodeFormat.CODE_39); // allFormats.add(BarcodeFormat.CODE_93); // allFormats.add(BarcodeFormat.CODE_128); // allFormats.add(BarcodeFormat.DATA_MATRIX); // allFormats.add(BarcodeFormat.EAN_8); // allFormats.add(BarcodeFormat.EAN_13); // allFormats.add(BarcodeFormat.ITF); // allFormats.add(BarcodeFormat.MAXICODE); // allFormats.add(BarcodeFormat.PDF_417); allFormats.add(BarcodeFormat.QR_CODE); // allFormats.add(BarcodeFormat.RSS_14); // allFormats.add(BarcodeFormat.RSS_EXPANDED); // allFormats.add(BarcodeFormat.UPC_A); // allFormats.add(BarcodeFormat.UPC_E); // allFormats.add(BarcodeFormat.UPC_EAN_EXTENSION); HINTS.put(DecodeHintType.TRY_HARDER, BarcodeFormat.QR_CODE); HINTS.put(DecodeHintType.POSSIBLE_FORMATS, allFormats); HINTS.put(DecodeHintType.CHARACTER_SET, "utf-8"); } private QRCodeDecoder() { } /** * 同步解析本地图片二维码。该方法是耗时操作,请在子线程中调用。 * * @param picturePath 要解析的二维码图片本地路径 * @return 返回二维码图片里的内容 或 null */ public static String syncDecodeQRCode(String picturePath) { return syncDecodeQRCode(getDecodeAbleBitmap(picturePath)); } /** * 同步解析bitmap二维码。该方法是耗时操作,请在子线程中调用。 * * @param bitmap 要解析的二维码图片 * @return 返回二维码图片里的内容 或 null */ public static String syncDecodeQRCode(Bitmap bitmap) { Result result = null; RGBLuminanceSource source = null; try { int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); source = new RGBLuminanceSource(width, height, pixels); result = new MultiFormatReader().decode(new BinaryBitmap(new HybridBinarizer(source)), HINTS); return result.getText(); } catch (Exception e) { e.printStackTrace(); if (source != null) { try { result = new MultiFormatReader().decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)), HINTS); return result.getText(); } catch (Throwable e2) { e2.printStackTrace(); } } return null; } } /** * 将本地图片文件转换成可解码二维码的 Bitmap。为了避免图片太大,这里对图片进行了压缩。感谢 https://github.com/devilsen 提的 PR * * @param picturePath 本地图片文件路径 * @return */ private static Bitmap getDecodeAbleBitmap(String picturePath) { try { boolean file = new File(picturePath).isFile(); if(!file){ Uri parse = Uri.parse(picturePath); if(parse.getScheme().contains("file")){ picturePath = parse.getPath(); } } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(picturePath, options); int sampleSize = options.outHeight / 400; if (sampleSize <= 0) { sampleSize = 1; } options.inSampleSize = sampleSize; options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(picturePath, options); } catch (Exception e) { return null; } } }
ea0cbd47d9ecefb032e52d1f8eb7a54326639355
ab75b18fea3ce452fecdae1ef4f61c44962ab13d
/src/main/java/com/santander/gestaogastos/exception/RestExceptionHandler.java
dd9dc8da30d6ec3bbbb255ac86edcff33628ac68
[]
no_license
AngeloSatelite/TestBackJava
ad3556639417a9080f7cf2be71b568045307949e
335834b2cda820f24ed3bd4cd592e1bf0c88413e
refs/heads/master
2020-04-05T01:04:47.053025
2018-11-13T13:12:28
2018-11-13T13:12:28
156,422,339
0
0
null
2018-11-06T17:34:35
2018-11-06T17:34:35
null
UTF-8
Java
false
false
1,040
java
package com.santander.gestaogastos.exception; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; @ControllerAdvice public class RestExceptionHandler { @ExceptionHandler(GastosException.class) public ResponseEntity<ErrorResponse> exceptionToDoHandler(Exception ex) { ErrorResponse error = new ErrorResponse(); error.setErrorCode(HttpStatus.NOT_FOUND.value()); error.setMessage(ex.getMessage()); return new ResponseEntity<ErrorResponse>(error, HttpStatus.NOT_FOUND); } @ExceptionHandler(Exception.class) public ResponseEntity<ErrorResponse> exceptionHandler(Exception ex) { ErrorResponse error = new ErrorResponse(); error.setErrorCode(HttpStatus.BAD_REQUEST.value()); error.setMessage("The request could not be understood by the server due to malformed syntax."); return new ResponseEntity<ErrorResponse>(error, HttpStatus.BAD_REQUEST); } }
f99d6994c0ac2833529a07d97102f37d942feb41
5c29cf87e336f16c4930ef5d971d11fb0cca8f4e
/app/src/main/java/com/example/appmenu/ServiceActivity.java
0ba20e45c56990b018e0d64b96bb8a91e1b26642
[]
no_license
KatoIT/ExampleAndroid
54748e7579c0ebdbc5cc9ae9b6f5d3789e46f02a
c58ae7280fed8bbf7941e75f4d8eeacc30a048ad
refs/heads/main
2023-05-01T05:32:10.747205
2021-05-20T14:32:26
2021-05-20T14:32:26
369,222,745
0
0
null
null
null
null
UTF-8
Java
false
false
1,884
java
package com.example.appmenu; import android.content.Intent; import android.media.MediaPlayer; import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class ServiceActivity extends AppCompatActivity { MediaPlayer player; Button buttonPlay, buttonStop, buttonStartService, buttonStopService; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_service); buttonPlay = (Button) findViewById(R.id.buttonPlay); buttonStop = (Button) findViewById(R.id.buttonStop); buttonStartService = (Button) findViewById(R.id.buttonStartService); buttonStopService = (Button) findViewById(R.id.buttonStopService); buttonPlay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { player = MediaPlayer.create(ServiceActivity.this, Settings.System.DEFAULT_RINGTONE_URI); player.setLooping(true); player.start(); } }); buttonStop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { player.stop(); } }); buttonStartService.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startService(new Intent(ServiceActivity.this, MyService.class)); } }); buttonStopService.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopService(new Intent(ServiceActivity.this, MyService.class)); } }); } }
31630da5750c7f0163b580d61755895ec5268a64
6c5d883dbea7314d15532db9d293c0cf5455757f
/Chess/src/game/TestingFrame.java
30414d5e7373e4df81e9ad13eeb163cfc211451b
[]
no_license
akarshkumar0101/Old-Java-Archive
69fac9952ff40626e6957325cdd48464a4e59bc9
d0f0c0e1edd277cc4978c4b4692f0b5b6889da19
refs/heads/master
2020-04-13T09:40:40.864036
2019-02-19T07:03:00
2019-02-19T07:03:00
147,975,287
0
0
null
null
null
null
UTF-8
Java
false
false
6,793
java
package game; import java.awt.Color; import java.awt.Graphics; import java.awt.GridLayout; import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class TestingFrame extends ChessGameUI { private final JFrame frame; private final GridLayout gridLayout; private final PieceLabel[][] labels; private final Board board; public TestingFrame(ChessGame game, Board board) { super(game); frame = new JFrame("Temporary testing frame"); gridLayout = new GridLayout(8, 8); frame.setContentPane(contentPane); frame.getContentPane().setLayout(gridLayout); labels = new PieceLabel[8][8]; for (int y = 7; y >= 0; y--) { for (int x = 0; x < 8; x++) { labels[x][y] = new PieceLabel(x, y); frame.getContentPane().add(labels[x][y]); } } this.board = board; frame.setSize(1000, 1000); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); revalidateFrame(); frame.setVisible(true); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { repaintFrame(); } }); } private int[] from = null; public void click(int... coor) { if (from == null) { if (board.get(coor) != Piece.NONE) { from = coor; frame.repaint(); } } else { int[][] move = { from, coor }; if (board.playerCanMakeMove(move)) { board.doMove(move); from = null; revalidateFrame(); frame.repaint(); } else { from = null; frame.repaint(); } } } public void repaintFrame() { frame.repaint(); } public void revalidateFrame() { for (int y = 7; y >= 0; y--) { for (int x = 0; x < 8; x++) { // labels[x][y].setText("" + Piece.toChar(board.get(x, y))); labels[x][y].updateImage(); } } possibleMoves.clear(); shifts.clear(); for (int[] from : Board.ALL_LOCALES) { for (int[] to : Board.ALL_LOCALES) { int[][] move = { from, to }; if (board.playerCanMakeMove(move)) { possibleMoves.add(move); shifts.add(new double[] { genRandShift(), genRandShift(), genRandShift(), genRandShift() }); } } } System.out.println(possibleMoves.size()); frame.revalidate(); } @Override protected int promptPawnUpgrade(int side, int... locale) { return 0; } private double genRandShift() { double randShift = (Math.random() / 56); randShift *= ((Math.random() > .5) ? 1 : -1); return randShift; } private static final Color lightSquareColor = Color.lightGray; private static final Color darkSquareColor = Color.gray; private static final Color hoverColor = new Color(150, 100, 100);// orange private static final Color clickColor = new Color(200, 150, 150);// cyan private static final Color availMoveColor = new Color(150, 200, 150);// green private class PieceLabel extends JComponent { private static final long serialVersionUID = -3703647811411435788L; private int[] coor; private Image imageToDraw; boolean mouseIn = false; boolean mousePressed = false; private MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (from == null && board.get(coor) == Piece.NONE) return; click(coor); } @Override public void mousePressed(MouseEvent e) { if (from == null && board.get(coor) == Piece.NONE) return; mousePressed = true; repaint(); } @Override public void mouseReleased(MouseEvent e) { if (from == null && board.get(coor) == Piece.NONE) return; mousePressed = false; repaint(); } @Override public void mouseEntered(MouseEvent e) { mouseIn = true; repaint(); } @Override public void mouseExited(MouseEvent e) { mouseIn = false; repaint(); } }; public PieceLabel(int... coor) { this.coor = coor; addMouseListener(mouseListener); setEnabled(false); setOpaque(false); } public void updateImage() { imageToDraw = Piece.getTempImage(board.get(coor)); } @Override public void paint(Graphics g) { // super.paint(g); // no need for this bc paint will be hidden int piece = board.get(coor); g.setColor(Color.black); g.drawRect(0, 0, getWidth(), getHeight()); g.setColor(lightSquareColor); if ((coor[0] % 2 == 0 && coor[1] % 2 == 0) || ((coor[0] % 2 == 1 && coor[1] % 2 == 1))) { g.setColor(darkSquareColor); } g.fillRect(1, 1, getWidth() - 1, getHeight() - 1); if (from != null && Utility.arrayListContainsMove(possibleMoves, new int[][] { from, coor })) { g.setColor(availMoveColor); g.fillRect(1, 1, getWidth() - 1, getHeight() - 1); } if (from != null && from[0] == coor[0] && from[1] == coor[1]) { g.setColor(clickColor); g.fillRect(1, 1, getWidth() - 1, getHeight() - 1); } if (mouseIn) { g.setColor(hoverColor); g.fillRect(1, 1, getWidth() - 1, getHeight() - 1); } if (mousePressed) { g.setColor(clickColor); g.fillRect(1, 1, getWidth() - 1, getHeight() - 1); } if (piece == Piece.NONE) return; // g.drawImage(imageToDraw, 1, 1, getWidth() - 1, getHeight() - 1, // null); g.drawImage(imageToDraw, (int) (PieceLabel.this.getWidth() * .15), (int) (PieceLabel.this.getHeight() * .15), (int) (PieceLabel.this.getWidth() * .7), (int) (PieceLabel.this.getHeight() * .7), null); } } private ArrayList<Object> possibleMoves = new ArrayList<Object>(); private ArrayList<double[]> shifts = new ArrayList<double[]>(); private final JPanel contentPane = new JPanel() { private static final long serialVersionUID = -5298039325426565984L; @Override public void paint(Graphics g) { super.paint(g); int halfxSquare = getWidth() / Board.WIDTH / 2; int halfySquare = getHeight() / Board.HEIGHT / 2; g.setColor(Color.red); for (int i = 0; i < possibleMoves.size(); i++) { int[][] move = (int[][]) possibleMoves.get(i); // if (from != null && move.fx() == from[0] && move.fy() == // from[1]) { // g.setColor(Color.green); // } else { // g.setColor(Color.red); // } double[] shift = shifts.get(i); if (board.get(move[0]) > 0) { g.setColor(Color.red); } else { g.setColor(Color.blue); } g.drawLine(move[0][0] * getWidth() / 8 + halfxSquare + ((int) (shift[0] * getWidth())), (7 - move[0][1]) * getHeight() / 8 + halfySquare + ((int) (shift[1] * getHeight())), move[1][0] * getWidth() / 8 + halfxSquare + ((int) (shift[2] * getWidth())), (7 - move[1][1]) * getHeight() / 8 + halfySquare + ((int) (shift[3] * getHeight()))); } } }; }
5295d3d93acbea84384b1c481d54e9021aba58bf
0643fc1d290445abfeabd2db4c20a2a3ba4c5550
/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/TargetVpnGateway.java
b86fc8968a7e222ef305234e291fd96506dbc9eb
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
SanowerTamjit/google-cloud-java
98d507530e2e0cf6f5b277d1b8d93e05ebb8eec2
28fab80ed42dcdf56bac22f67b6e262e3ad54cd2
refs/heads/master
2020-04-05T04:08:53.424185
2018-11-07T00:38:35
2018-11-07T00:38:35
156,539,437
1
0
Apache-2.0
2018-11-07T11:55:22
2018-11-07T11:55:22
null
UTF-8
Java
false
false
11,831
java
/* * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.cloud.compute.v1; import com.google.api.core.BetaApi; import com.google.api.gax.httpjson.ApiMessage; import java.util.LinkedList; import java.util.List; import java.util.Objects; import javax.annotation.Generated; import javax.annotation.Nullable; @Generated("by GAPIC") @BetaApi public final class TargetVpnGateway implements ApiMessage { private final String creationTimestamp; private final String description; private final List<String> forwardingRules; private final String id; private final String kind; private final String name; private final String network; private final String region; private final String selfLink; private final String status; private final List<String> tunnels; private TargetVpnGateway() { this.creationTimestamp = null; this.description = null; this.forwardingRules = null; this.id = null; this.kind = null; this.name = null; this.network = null; this.region = null; this.selfLink = null; this.status = null; this.tunnels = null; } private TargetVpnGateway( String creationTimestamp, String description, List<String> forwardingRules, String id, String kind, String name, String network, String region, String selfLink, String status, List<String> tunnels) { this.creationTimestamp = creationTimestamp; this.description = description; this.forwardingRules = forwardingRules; this.id = id; this.kind = kind; this.name = name; this.network = network; this.region = region; this.selfLink = selfLink; this.status = status; this.tunnels = tunnels; } @Override public Object getFieldValue(String fieldName) { if (fieldName.equals("creationTimestamp")) { return creationTimestamp; } if (fieldName.equals("description")) { return description; } if (fieldName.equals("forwardingRules")) { return forwardingRules; } if (fieldName.equals("id")) { return id; } if (fieldName.equals("kind")) { return kind; } if (fieldName.equals("name")) { return name; } if (fieldName.equals("network")) { return network; } if (fieldName.equals("region")) { return region; } if (fieldName.equals("selfLink")) { return selfLink; } if (fieldName.equals("status")) { return status; } if (fieldName.equals("tunnels")) { return tunnels; } return null; } @Nullable @Override public ApiMessage getApiMessageRequestBody() { return null; } @Nullable @Override public List<String> getFieldMask() { return null; } public String getCreationTimestamp() { return creationTimestamp; } public String getDescription() { return description; } public List<String> getForwardingRulesList() { return forwardingRules; } public String getId() { return id; } public String getKind() { return kind; } public String getName() { return name; } public String getNetwork() { return network; } public String getRegion() { return region; } public String getSelfLink() { return selfLink; } public String getStatus() { return status; } public List<String> getTunnelsList() { return tunnels; } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(TargetVpnGateway prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } public static TargetVpnGateway getDefaultInstance() { return DEFAULT_INSTANCE; } private static final TargetVpnGateway DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new TargetVpnGateway(); } public static class Builder { private String creationTimestamp; private String description; private List<String> forwardingRules; private String id; private String kind; private String name; private String network; private String region; private String selfLink; private String status; private List<String> tunnels; Builder() {} public Builder mergeFrom(TargetVpnGateway other) { if (other == TargetVpnGateway.getDefaultInstance()) return this; if (other.getCreationTimestamp() != null) { this.creationTimestamp = other.creationTimestamp; } if (other.getDescription() != null) { this.description = other.description; } if (other.getForwardingRulesList() != null) { this.forwardingRules = other.forwardingRules; } if (other.getId() != null) { this.id = other.id; } if (other.getKind() != null) { this.kind = other.kind; } if (other.getName() != null) { this.name = other.name; } if (other.getNetwork() != null) { this.network = other.network; } if (other.getRegion() != null) { this.region = other.region; } if (other.getSelfLink() != null) { this.selfLink = other.selfLink; } if (other.getStatus() != null) { this.status = other.status; } if (other.getTunnelsList() != null) { this.tunnels = other.tunnels; } return this; } Builder(TargetVpnGateway source) { this.creationTimestamp = source.creationTimestamp; this.description = source.description; this.forwardingRules = source.forwardingRules; this.id = source.id; this.kind = source.kind; this.name = source.name; this.network = source.network; this.region = source.region; this.selfLink = source.selfLink; this.status = source.status; this.tunnels = source.tunnels; } public String getCreationTimestamp() { return creationTimestamp; } public Builder setCreationTimestamp(String creationTimestamp) { this.creationTimestamp = creationTimestamp; return this; } public String getDescription() { return description; } public Builder setDescription(String description) { this.description = description; return this; } public List<String> getForwardingRulesList() { return forwardingRules; } public Builder addAllForwardingRules(List<String> forwardingRules) { if (this.forwardingRules == null) { this.forwardingRules = new LinkedList<>(); } this.forwardingRules.addAll(forwardingRules); return this; } public Builder addForwardingRules(String forwardingRules) { if (this.forwardingRules == null) { this.forwardingRules = new LinkedList<>(); } this.forwardingRules.add(forwardingRules); return this; } public String getId() { return id; } public Builder setId(String id) { this.id = id; return this; } public String getKind() { return kind; } public Builder setKind(String kind) { this.kind = kind; return this; } public String getName() { return name; } public Builder setName(String name) { this.name = name; return this; } public String getNetwork() { return network; } public Builder setNetwork(String network) { this.network = network; return this; } public String getRegion() { return region; } public Builder setRegion(String region) { this.region = region; return this; } public String getSelfLink() { return selfLink; } public Builder setSelfLink(String selfLink) { this.selfLink = selfLink; return this; } public String getStatus() { return status; } public Builder setStatus(String status) { this.status = status; return this; } public List<String> getTunnelsList() { return tunnels; } public Builder addAllTunnels(List<String> tunnels) { if (this.tunnels == null) { this.tunnels = new LinkedList<>(); } this.tunnels.addAll(tunnels); return this; } public Builder addTunnels(String tunnels) { if (this.tunnels == null) { this.tunnels = new LinkedList<>(); } this.tunnels.add(tunnels); return this; } public TargetVpnGateway build() { return new TargetVpnGateway( creationTimestamp, description, forwardingRules, id, kind, name, network, region, selfLink, status, tunnels); } public Builder clone() { Builder newBuilder = new Builder(); newBuilder.setCreationTimestamp(this.creationTimestamp); newBuilder.setDescription(this.description); newBuilder.addAllForwardingRules(this.forwardingRules); newBuilder.setId(this.id); newBuilder.setKind(this.kind); newBuilder.setName(this.name); newBuilder.setNetwork(this.network); newBuilder.setRegion(this.region); newBuilder.setSelfLink(this.selfLink); newBuilder.setStatus(this.status); newBuilder.addAllTunnels(this.tunnels); return newBuilder; } } @Override public String toString() { return "TargetVpnGateway{" + "creationTimestamp=" + creationTimestamp + ", " + "description=" + description + ", " + "forwardingRules=" + forwardingRules + ", " + "id=" + id + ", " + "kind=" + kind + ", " + "name=" + name + ", " + "network=" + network + ", " + "region=" + region + ", " + "selfLink=" + selfLink + ", " + "status=" + status + ", " + "tunnels=" + tunnels + "}"; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof TargetVpnGateway) { TargetVpnGateway that = (TargetVpnGateway) o; return Objects.equals(this.creationTimestamp, that.getCreationTimestamp()) && Objects.equals(this.description, that.getDescription()) && Objects.equals(this.forwardingRules, that.getForwardingRulesList()) && Objects.equals(this.id, that.getId()) && Objects.equals(this.kind, that.getKind()) && Objects.equals(this.name, that.getName()) && Objects.equals(this.network, that.getNetwork()) && Objects.equals(this.region, that.getRegion()) && Objects.equals(this.selfLink, that.getSelfLink()) && Objects.equals(this.status, that.getStatus()) && Objects.equals(this.tunnels, that.getTunnelsList()); } return false; } @Override public int hashCode() { return Objects.hash( creationTimestamp, description, forwardingRules, id, kind, name, network, region, selfLink, status, tunnels); } }
912ea219d0fed36adb9a206e89da672d388b1932
ed435c8ac03da8eb947438969a96e26cbea8065d
/src/com/week3/hometask/Product.java
27d36e188a57e12197c5e8fb16e71a9d7c41980a
[]
no_license
order12a/ITCentre
f62bd0952cd78b25c7764dfb7f584fb86f52db9b
f36c55fa1cd75f8935f7b7f57c20f39f796c88ae
refs/heads/master
2020-06-06T10:08:22.696671
2015-01-05T15:51:41
2015-01-05T15:51:41
27,390,991
0
0
null
null
null
null
UTF-8
Java
false
false
813
java
package com.week3.hometask; public class Product { protected String bar; protected String price; protected String storagePeriod; public Product(String bar, String price, String storagePeriod) { this.bar = bar; this.price = price; this.storagePeriod = storagePeriod; } public void printPrice() { System.out.println(price); } public void printStoragePeriod() { System.out.println(storagePeriod); } public void printBarAndPrice() { System.out.println(bar + " " + price); } } class Fish extends Product{ public Fish(String bar, String price, String storagePeriod) { super(bar, price, storagePeriod); } public void swim() { System.out.println("The fish is swimming!"); } public void cannibalism(Fish fish) { System.out.println(fish.toString() + " was eated!"); } }
ebd8cf0ee84b35810fd010f594950d44c766586b
50db0be82274d30693163e6f021799ec49e90b09
/presentacion/src/main/java/com/example/adn/ActividadPrincipal.java
6ad2ba22dcf834be2a42e5eac0c24d7a1ce3ccbb
[]
no_license
jtrillos19/ADN
175c163e2f66a36abe9b3a348b058c62f9d95292
7ab4a549f7b8b0318a91cda66868380fe28da0a7
refs/heads/master
2023-04-28T22:02:42.427670
2021-05-21T20:43:59
2021-05-21T20:43:59
366,403,719
0
0
null
null
null
null
UTF-8
Java
false
false
2,715
java
package com.example.adn; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; import android.widget.Button; import android.widget.Toast; import com.example.adn.vehiculo.VehiculoDialogo; import com.example.adn.vehiculo.adaptador.VehiculoAdaptador; import com.example.adn.parqueadero.modelovista.ParqueaderoModeloVista; import com.example.domain.vehiculo.entidad.Vehiculo; import java.util.List; import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint public class ActividadPrincipal extends AppCompatActivity { private ParqueaderoModeloVista parqueaderoModeloVista; private RecyclerView vistaReciclada; private VehiculoAdaptador vehiculoAdaptador; private Button btnIngresarVehiculo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iniciarElementos(); btnIngresarVehiculo.setOnClickListener(v -> VehiculoDialogo.crearDialogoGuardarVehiculo(this).show()); parqueaderoModeloVista.obtenerListaVehiculos().observe(this, this::actualizarAdaptador); } private void iniciarElementos() { vistaReciclada = findViewById(R.id.vistaRecicladaVehiculos); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); vistaReciclada.setLayoutManager(linearLayoutManager); btnIngresarVehiculo = findViewById(R.id.btnIngresarVehiculo); parqueaderoModeloVista = new ViewModelProvider(this).get(ParqueaderoModeloVista.class); } private void actualizarAdaptador(List<Vehiculo> vehiculos) { vehiculoAdaptador = new VehiculoAdaptador(vehiculos, this); vistaReciclada.setAdapter(vehiculoAdaptador); } public void cobrarParqueadero(Vehiculo vehiculo) { parqueaderoModeloVista.calcularValorTotalPagarVehiculo(vehiculo).observe(this, totalPagar -> { Toast.makeText(this, "Total a Pagar: " + totalPagar, Toast.LENGTH_SHORT).show(); vistaReciclada.getAdapter().notifyDataSetChanged(); }); } public void guardarVehiculo(Vehiculo vehiculo, AlertDialog dialogo) { parqueaderoModeloVista.guardarVehiculo(vehiculo).observe(this, vehiculoGuardado -> { Toast.makeText(this, vehiculoGuardado, Toast.LENGTH_SHORT).show(); dialogo.dismiss(); vehiculoAdaptador.notifyDataSetChanged(); }); } }
1973880a4431196979b3a81e44d0eda3b3a82749
633c20606e45faa1061dd284bbb5c7baf44c313c
/mattstuff/team-assignment/src/CSPComparator.java
0b37204856a3caee1135c8829fa982625561d267
[]
no_license
ghawk0/ai-final-proj
a553f691df42722d0deb06164df4628b1d919d74
c4b71c307900d70d0d87b08a4c0258f1363d081d
refs/heads/master
2020-05-16T08:14:44.456869
2019-05-15T04:13:28
2019-05-15T04:13:28
182,902,679
0
0
null
null
null
null
UTF-8
Java
false
false
171
java
import java.util.Comparator; public class CSPComparator implements Comparator<CSP> { public int compare(CSP c1, CSP c2) { return c1.getCost() - c2.getCost(); } }
46ba3c4cc376371ee78244341db50b8ee51b7cac
1ec33b5f1bec4a23da2761516af9d7582882e767
/src/main/java/com/greenghost107/ourHouse/web/security/JwtAuthenticationController.java
0c7a57e6113e3be4cc6738977c6efcd395b19e7f
[]
no_license
greenghost107/ourHouse
663dee73da0c54c09f42fc8ac3a3cc96589daa53
ca3a174e8b315d87a337a4af4f8bdef9270852f8
refs/heads/master
2023-01-10T08:08:03.708330
2020-11-08T09:01:39
2020-11-08T09:01:39
299,710,465
3
0
null
null
null
null
UTF-8
Java
false
false
3,431
java
/* * Created by greenghost107 on Oct/2020 */ package com.greenghost107.ourHouse.web.security; import com.greenghost107.ourHouse.config.JwtTokenUtil; import com.greenghost107.ourHouse.model.User; import com.greenghost107.ourHouse.model.security.JwtRequest; import com.greenghost107.ourHouse.model.security.JwtResponse; import com.greenghost107.ourHouse.service.HouseService; import com.greenghost107.ourHouse.service.impl.JwtUserDetailsServiceImpl; import com.greenghost107.ourHouse.service.UserService; import io.jsonwebtoken.impl.DefaultClaims; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.DisabledException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; @RestController @CrossOrigin(origins = { "*"}) public class JwtAuthenticationController { @Autowired private AuthenticationManager authenticationManager; @Autowired private JwtTokenUtil jwtTokenUtil; @Autowired private JwtUserDetailsServiceImpl userDetailsService; @Autowired private UserService userService; @Autowired private HouseService houseService; @RequestMapping(value = "/authenticate", method = RequestMethod.POST) public ResponseEntity<?> createAuthenticationToken(@RequestBody JwtRequest jwtRequest) throws Exception { try { authenticationManager.authenticate(new UsernamePasswordAuthenticationToken( jwtRequest.getUsername(), jwtRequest.getPassword())); } catch (DisabledException e) { throw new Exception("USER_DISABLED", e); } catch (BadCredentialsException e) { throw new Exception("INVALID_CREDENTIALS", e); } User user = userService.findByUserName(jwtRequest.getUsername()); UserDetails userdetails = userDetailsService.loadUserByUsername(jwtRequest.getUsername()); String token = jwtTokenUtil.generateToken(userdetails); String refreshToken = jwtTokenUtil.generateRefreshToken(user.getId()); return ResponseEntity.ok(new JwtResponse(token,refreshToken)); } @RequestMapping(value = "/register", method = RequestMethod.POST) public ResponseEntity<?> saveUser(@RequestBody JwtRequest jwtRequest) throws Exception { return ResponseEntity.ok(userDetailsService.save(jwtRequest)); } @RequestMapping(value = "/refreshtoken", method = RequestMethod.GET) public ResponseEntity<?> refreshtoken(HttpServletRequest request) throws Exception { // From the HttpRequest get the claims // DefaultClaims claims = (io.jsonwebtoken.impl.DefaultClaims) request.getAttribute("claims"); // Map<String, Object> expectedMap = getMapFromIoJsonwebtokenClaims(claims); String token = jwtTokenUtil.refreshToken(request); return ResponseEntity.ok(new JwtResponse(token,"")); } public Map<String, Object> getMapFromIoJsonwebtokenClaims(DefaultClaims claims) { Map<String, Object> expectedMap = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : claims.entrySet()) { expectedMap.put(entry.getKey(), entry.getValue()); } return expectedMap; } }
[ "" ]
a57acf0662d6aa59db5781d82f5ab8944fed95d2
79158a8015e62b03c0f4892c8b655c69218640fe
/GLGameSurfaceView.java
58a16c8712964754db45689d41a2ab8076559b00
[]
no_license
tatdathoang/Android_Tetris3D
6b4ac224e4895fe23596c5a15d722ed8b32a8714
b499e87af732bd9628486ba5279fa7aeb15adaac
refs/heads/master
2021-07-13T22:57:26.097478
2017-10-20T04:00:49
2017-10-20T04:00:49
107,622,829
0
0
null
null
null
null
UTF-8
Java
false
false
2,946
java
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.tdh.Sup; import android.content.Context; import android.opengl.GLSurfaceView; public class GLGameSurfaceView extends GLSurfaceView { private GameRenderer mRenderer; private GameOverlay overlay; public GLGameSurfaceView(Context context,GameOverlay overlay) { super(context); this.overlay = overlay; if (this.mRenderer!=null) { this.mRenderer = null; } //Optical. Dependent on Device which has or has no GPU this.getHolder().setType(android.view.SurfaceHolder.SURFACE_TYPE_GPU); this.mRenderer = new GameRenderer(context,overlay,overlay.getOptions()); this.setRenderer(mRenderer); setFocusableInTouchMode(true); } @Override public void onPause() { super.onPause(); mRenderer.onPause(); } @Override public void onResume() { super.onResume(); mRenderer.onResume(); } public void initGame(int gameType) { switch(gameType) { case GameRenderer.VIEW_INTRO: this.mRenderer.setViewType(GameRenderer.VIEW_INTRO); overlay.setOverlayType(GameOverlay.OVERLAY_TYPE_INTRO); overlay.setDrawType(GameOverlay.DRAW_NORMAL); break; case GameRenderer.VIEW_GAME: this.mRenderer.setViewType(GameRenderer.VIEW_GAME); overlay.setOverlayType(GameOverlay.OVERLAY_TYPE_GAME); overlay.getOptions().setGame(new TetricGameData()); overlay.getOptions().getGame().setLevel(overlay.getOptions().getStartingLevel()); overlay.setLevel(overlay.getOptions().getGame().getLevelName()); overlay.getOptions().getGame().initGame(overlay.getOptions().getStartingLevel()); overlay.setDrawType(GameOverlay.DRAW_NORMAL); break; } this.mRenderer.reinit(); } public GameRenderer getRenderer() { return this.mRenderer; } public GameOverlay getOverlay() { return overlay; } }
044f9d09de4129ba9c0452c4a475d163fc7aabec
92ad4edc208ab942361474e97f6b4d6ca775a01e
/XLib/src/com/jw/view/RoundImageView.java
efc6fa7fb96539a96cbaf38cd8f701247f1e5daa
[]
no_license
jarrahwu/JWLib
76ef512526ff28fc51f4cb0ca73580df65d15a85
8920bce6cbc4f67305ed417fffc4520ac276bdd6
refs/heads/master
2016-09-05T14:03:53.788805
2014-07-25T09:32:31
2014-07-25T09:32:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,973
java
package com.jw.view; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.widget.ImageView; import com.androidquery.AQuery; import com.androidquery.callback.AjaxStatus; import com.androidquery.callback.BitmapAjaxCallback; import com.jw.xlib.R; /** * @author jarrahwu 圆角的ImageView 可以设置圆角图片 */ public class RoundImageView extends ImageView { Path clipPath; private RectF rect; private float radius = 5.0f; // 默认是5px private AQuery mAq; public RoundImageView(Context context) { super(context); init(); } public RoundImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ConnerImage); this.radius = array.getFloat(R.styleable.ConnerImage_radius, 0.0f); array.recycle(); } public RoundImageView(Context context, float radius) { this(context); this.radius = radius; init(); } private void init() { clipPath = new Path(); mAq = new AQuery(getContext()); } // we can get the size here, this is the first time view's appearance @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { rect = new RectF(0, 0, this.getWidth(), this.getHeight()); } @Override protected void onDraw(Canvas canvas) { clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW); canvas.clipPath(clipPath); super.onDraw(canvas); } public void setCornerRadiusSize(int px) { radius = px; invalidate(); } /** * 设置边框 * * @param borderSize * @param res */ public void setPaddingBorder(int borderSize, int res) { setPadding(borderSize, borderSize, borderSize, borderSize); setAdjustViewBounds(true); setBackgroundResource(res); invalidate(); } /** * 设置背景边框 * @param borderSize 背景边框大小 * @param res 背景资源 * @param pixels 需要圆角的大小, 如果 doCorner = true * @param doCorner 是否需要切成圆角 */ public void setBitmapBorder(int borderSize, Bitmap res, int pixels, boolean doCorner) { setPadding(borderSize, borderSize, borderSize, borderSize); setAdjustViewBounds(true); if(doCorner) res = cornerBitmap(res, pixels); BitmapDrawable drawable = new BitmapDrawable(res); if (drawable != null) { setBackgroundDrawable(drawable); invalidate(); } } /** * 切成圆角的图片 * * @param bitmap * 数据源 * @param pixels * 圆角的像素 * @return */ public Bitmap cornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff000000; // final int color = 0x000000; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } /** * 拉取图片方法. * @param imageview * @param url */ public void ajaxImage(String url){ mAq.id(this).image(url, false, true, 600, R.drawable.ic_launcher, new BitmapAjaxCallback(){ @Override protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) { iv.setImageBitmap(bm); } }); } }
6de8e7b0c71cb753f626a8a762ae3b0980ab7c6d
3749312f8e0aeec943af824c2dab17d1a8c9cd71
/app/src/main/java/com/ckmcknight/android/menufi/model/accountvalidation/AccountService.java
825aa5a253e5be50967182177368befb950226e5
[]
no_license
MenuFi/MenuFiAndroidApp
5f228df79021b4a2532ddf2a4f7ef40012b9e17c
af210b48f11d93e3ae4e4f0b45ed383005bc9880
refs/heads/master
2021-05-05T10:33:31.239717
2018-04-23T16:37:55
2018-04-23T16:37:55
118,033,968
0
0
null
null
null
null
UTF-8
Java
false
false
5,997
java
package com.ckmcknight.android.menufi.model.accountvalidation; import android.app.IntentService; import android.content.Intent; import android.support.annotation.WorkerThread; import com.android.volley.Response; import com.android.volley.VolleyError; import com.ckmcknight.android.menufi.MenuFiApplication; import com.ckmcknight.android.menufi.dagger.components.MenuFiComponent; import com.ckmcknight.android.menufi.model.containers.SessionToken; import com.ckmcknight.android.menufi.model.datastores.UserSharedPreferences; import org.json.JSONException; import org.json.JSONObject; import java.util.logging.Logger; public class AccountService extends IntentService { private static Logger logger = Logger.getLogger("AccountService"); public static final String LOGIN_ACTION = "LOGIN_ACTION"; public static final String REGISTER_ACTION = "REGISTER_ACTION"; public static final String LOGOUT_ACTION = "LOGOUT_ACTION"; public static final String EMAIL_EXTRA = "EMAIL_EXTRA"; public static final String PASSWORD_EXTRA = "PASSWORD_EXTRA"; public static final String BROADCAST_LOG_IN = "BROADCAST_LOG_IN"; public static final String BROADCAST_REGISTERED = "BROADCAST_REGISTERED"; public static final String BROADCAST_STATUS = "BROADCAST_STATUS"; public static final String JSON_STATUS_KEY = "status"; public static final String JSON_STATUS_SUCCESS = "success"; public static final String JSON_DATA_KEY = "data"; public static final String JSON_REGISTER_DATA_SUCCESS = "true"; private AccountValidator accountValidator; private UserSharedPreferences userSharedPreferences; public AccountService() { super("AccountService"); } @Override public void onCreate() { super.onCreate(); MenuFiComponent component = ((MenuFiApplication) getApplication()).getMenuFiComponent(); userSharedPreferences = component.getUserSharedPreferences(); accountValidator = component.accountValidator(); } @Override protected void onHandleIntent(Intent intent) { switch(intent.getAction()) { case LOGIN_ACTION: logger.info("Received an Login Intent"); login(intent); break; case REGISTER_ACTION: logger.info("Received an Register Intent"); register(intent); break; case LOGOUT_ACTION: logger.info("Received a Log out Intent"); logout(intent); break; } } @WorkerThread private void login(Intent intent) { String email = intent.getStringExtra(EMAIL_EXTRA); String password = intent.getStringExtra(PASSWORD_EXTRA); logger.info("Attempting to log in with email: " + email); accountValidator.login(loginListener, loginErrorListener, email, password); } @WorkerThread private void register(Intent intent) { String email = intent.getStringExtra(EMAIL_EXTRA); String password = intent.getStringExtra(PASSWORD_EXTRA); logger.info("Attempting to register new user: " + email); accountValidator.register(registerListener, registerErrorListener, email, password); } @WorkerThread private void logout(Intent intent) { userSharedPreferences.logout(); } private Response.Listener<JSONObject> registerListener = new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { logger.info("Got a registration response: " + response.toString()); try { String status = response.getString(JSON_STATUS_KEY); if (JSON_STATUS_SUCCESS.equals(status) && JSON_REGISTER_DATA_SUCCESS.equals(response.getString(JSON_DATA_KEY))) { broadcast(BROADCAST_REGISTERED, true); } else { broadcast(BROADCAST_REGISTERED, false); } } catch (JSONException e) { logger.severe("Error while parsing JSON in AccountService"); logger.severe(e.getMessage()); } } }; private Response.ErrorListener loginErrorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { logger.info("Received an error while loggin in user"); broadcast(BROADCAST_LOG_IN, false); } }; private Response.ErrorListener registerErrorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { logger.info("Received an error while registering user"); broadcast(BROADCAST_REGISTERED, false); } }; private Response.Listener<JSONObject> loginListener = new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { logger.info("Got a LOGIN response: " + response.toString()); try { String status = response.getString(JSON_STATUS_KEY); if (JSON_STATUS_SUCCESS.equals(status)) { String sessionToken = response.getString(JSON_DATA_KEY); userSharedPreferences.restablishCurrentSession(); userSharedPreferences.establishCurrentSession(new SessionToken(sessionToken)); broadcast(BROADCAST_LOG_IN, true); } else { broadcast(BROADCAST_LOG_IN, false); } } catch (JSONException e) { logger.severe("Error while parsing JSON in AccountService"); logger.severe(e.getMessage()); } } }; private void broadcast(String broadcast, boolean status) { Intent intent = new Intent(); intent.setAction(broadcast); intent.putExtra(BROADCAST_STATUS, status); sendBroadcast(intent); } }
104f646a7fa43cb0cfebab7951f968b7ce866cbd
482534d7a29bba19f90a7829fe17b32fd32bdd88
/src/main/java/Reverse.java
579e5961de6073f3364cdad309b79484b82bbb06
[]
no_license
asrajatkaushal/number-reverse
fa0b2e660f0e21d2236b174b422e9a19c625d5a0
dd2dfc151177a6a527cd453b24d08a11d99ff6d8
refs/heads/master
2021-07-10T15:26:53.091876
2017-10-09T10:57:37
2017-10-09T10:57:37
106,267,387
0
1
null
null
null
null
UTF-8
Java
false
false
1,404
java
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Reverse { public List<String> readFile(String fileName) throws IOException { File file = new File(fileName); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); List<String> lines = new ArrayList<String>(); String line = bufferedReader.readLine(); while (line != null) { lines.add(line); line = bufferedReader.readLine(); } return lines; } public String reverse(List<String> lines) { StringBuilder sb = new StringBuilder(); for (String line : lines) { String[] numbers = line.split(","); for (int i = numbers.length - 1; i >= 0; i--) { sb.append(numbers[i]); if (i > 0) { sb.append(","); } } sb.append("\n"); } return sb.toString(); } public static void main(String[] args) throws IOException { Reverse r = new Reverse(); String fileName = "sample.txt"; List<String> lines = r.readFile(fileName); System.out.print(r.reverse(lines)); } }
a095e2f69047ec524766163976b42db83b63e384
b8caaa8acb1f5b690235c39e45b2379bc193f52a
/picture_manage_web/src/test/java/TestUser.java
ae90003dcd3d06155c9d6b1913dc62a50d450abe
[]
no_license
qinguangfeng1992/picture_manage
6df41485e54afa0d588b674422219cef463da9a7
71c656676794fdc1879f71011b440ded4e11bdfb
refs/heads/master
2021-01-11T04:38:21.813958
2016-10-22T09:49:41
2016-10-22T09:49:41
71,122,586
0
0
null
null
null
null
UTF-8
Java
false
false
961
java
import com.qinguangfeng.dao.entity.User; import com.qinguangfeng.web.Start; import com.qinguangfeng.web.service.impl.TypeImpl; import com.qinguangfeng.web.service.impl.UserImpl; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; /** * Created by dengjicheng on 2016/10/12. */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(value = Start.class) public class TestUser { @Autowired private UserImpl userImpl; /** * 测试查詢全部的方法 */ @Test public void findUserAll() { User user = new User(); user.setPassword("asas"); user.setUsername("asas"); boolean a = userImpl.registerUser(user); System.out.println(a); } }
5ad9eaeb10edb42a732ce278335dfdf8f3a6ddb1
731d829058ea7d2073d711a5df194a93b3d4a566
/src/jp/ac/shibaura/it/ie/architecture/invoke/UserCaseInvoker.java
c15800f3687981215b9c47d174ea7e5592aaa2ca
[]
no_license
THEToilet/chatLobbyServer
7b82e7332eeda112103b7f65f322d919f868bfe7
ce62c4e010f65e14df353e40de8629cc5c062b59
refs/heads/master
2023-02-24T01:02:30.435536
2020-12-31T12:00:15
2020-12-31T12:00:15
325,790,995
0
0
null
null
null
null
UTF-8
Java
false
false
293
java
package jp.ac.shibaura.it.ie.architecture.invoke; import jp.ac.shibaura.it.ie.usecases.core.InputData; import jp.ac.shibaura.it.ie.usecases.core.OutputData; public interface UseCaseInvoker { public <TOutputData extends OutputData> TOutputData invoke(InputData<TOutputData> inputData); }
b4d843fdbd89d28ef30179f75708dd9d46083483
122abd72f92e72cd1dfe59b86fe3367f7f9e3226
/code/B3444_ProjetJava_Positif/src/main/java/fr/insalyon/dasi/positif/Metier/Modele/Consultation.java
686f2f1bd2882d953c8f49e4f828a856b371cfc1
[]
no_license
FelixFonteneau/DASI2
b50a607a1de5f77a2c81dfa3eb93343cd72ce5ea
202724e59cb9b3b53dcc5fa5e237a7967db534ac
refs/heads/master
2020-05-24T04:25:42.615796
2019-05-19T11:37:21
2019-05-19T11:37:21
187,091,746
0
0
null
null
null
null
UTF-8
Java
false
false
2,263
java
package fr.insalyon.dasi.positif.Metier.Modele; import java.io.Serializable; import java.util.Date; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Temporal; import javax.persistence.TemporalType; @Entity public class Consultation implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Temporal(TemporalType.TIMESTAMP) private Date dateConsultation; @Temporal(TemporalType.TIMESTAMP) private Date dateFin; private String commentaire; @ManyToOne private Client client; @ManyToOne private Employe employe; @ManyToOne private Medium medium; public Consultation() { } public Consultation(Date dateConsultation, Client client, Employe employe, Medium medium) { this.dateConsultation = dateConsultation; this.client = client; this.employe = employe; this.medium = medium; } public Date getDateConsultation() { return dateConsultation; } public void setDateConsultation(Date dateConsultation) { this.dateConsultation = dateConsultation; } public Date getDateFin() { return dateFin; } public void setDateFin(Date dateFin) { this.dateFin = dateFin; } public String getCommentaire() { return commentaire; } public void setCommentaire(String commentaire) { this.commentaire = commentaire; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Client getClient() { return client; } public void setClient(Client client) { this.client = client; } public Employe getEmploye() { return employe; } public void setEmploye(Employe employe) { this.employe = employe; } public Medium getMedium() { return medium; } public void setMedium(Medium medium) { this.medium = medium; } }
6d191d01f8c9196c848220cf4e129ada0ae85072
8c82e98bcdb09005ac76a5b7b1299b4efe7dc04a
/app/src/main/java/com/cookandroid/moments_diary/ListViewAdapter.java
88a77d7a65151a16171ae3fd0b497d61852a5b3b
[]
no_license
kumass2020/Moments-Diary-App
eb6e5b6be4d7f82fba41d7956b80a006ce12d48f
1601ac9e8da58d6e4425343cf63709fda0ad53be
refs/heads/main
2023-05-30T06:26:56.681702
2021-06-20T22:36:44
2021-06-20T22:36:44
364,482,214
0
0
null
null
null
null
UTF-8
Java
false
false
2,683
java
package com.cookandroid.moments_diary; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; public class ListViewAdapter extends BaseAdapter { // Adapter에 추가된 데이터를 저장하기 위한 ArrayList private ArrayList<Content> listViewContentList = new ArrayList<Content>() ; // ListViewAdapter의 생성자 public ListViewAdapter() { } // Adapter에 사용되는 데이터의 개수를 리턴 @Override public int getCount() { return listViewContentList.size() ; } // position에 위치한 데이터를 화면에 출력하는데 사용될 View를 리턴 @Override public Object getItem(int position) { return listViewContentList.get(position); } // 지정한 위치(position)에 있는 데이터와 관계된 아이템(row)의 ID를 리턴 @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { final int pos = position; final Context context = parent.getContext(); // "listview_item" Layout을 inflate하여 convertView 참조 획득 if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.content_layout, parent, false); } // 화면에 표시될 View(Layout이 inflate된)으로부터 위젯에 대한 참조 획득 TextView dayTextView = (TextView) convertView.findViewById(R.id.tvDay) ; TextView titleTextView = (TextView) convertView.findViewById(R.id.tvTitle) ; // TextView descTextView = (TextView) convertView.findViewById(R.id.textView2) ; // Data Set(listViewItemList)에서 position에 위치한 데이터 참조 획득 Content listViewContent = listViewContentList.get(position); // 아이템 내 각 위젯에 데이터 반영 dayTextView.setText(listViewContent.getDay()); titleTextView.setText(listViewContent.getTitle()); // descTextView.setText(listViewContent.getDesc()); return convertView; } // 아이템 데이터 추가를 위한 함수 public void addItem(String day, String title) { Content item = new Content(); item.setDay(day); item.setTitle(title); // item.setDesc(desc); listViewContentList.add(item); } }
34f4714d700fd5688551026b19c6d4bdfa989d89
c84ec0502ce52c48ba5aa02acd7166b3d4a76e2a
/myweb/src/member/MemberDAO.java
a2889ee36f8a8b939471131cbe2583ddc83f4e2f
[]
no_license
kaimaru07/team1
d70428331d7c10686b22804323bff0a8b0515329
1eb0c7db02f52dae89161255f7009a0df2e3d268
refs/heads/main
2023-06-24T07:51:34.787512
2021-07-26T15:45:08
2021-07-26T15:45:08
356,894,442
0
0
null
null
null
null
UTF-8
Java
false
false
2,056
java
package member; import java.sql.*; public class MemberDAO { private Connection conn = null; // java와 데이터베이스 연결 private PreparedStatement pstmt = null; private ResultSet res; // 기본 생성자에 공통 실행 기능 작성 public MemberDAO() { try { // JDBC 드라이버 로딩 Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.print("JDBC 드라이버 로딩 완료!"); // 접속 정보 작성 String url = "jdbc:oracle:thin:@localhost:1521:xe"; String user = "web_admin"; String password = "admin"; // DB 접속 객체 생성 및 접속 시도 this.conn = DriverManager.getConnection(url, user, password); System.out.println("Oracle DB 접속 완료!"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } // 회원ID, PW를 매개변수로 받아 로그인 동작을 수행하는 메서드 public int login(String memberID, String memberPW) { String sql = ""; sql += "SELECT memberPW FROM member_t WHERE memberID=?"; try { pstmt = conn.prepareStatement(sql); // sql 쿼리문 대기 pstmt.setString(1, memberID); // 첫번째 ?에 매개변수로 받은 memberID를 대입 res = pstmt.executeQuery(); // 쿼리실행 결과를 res에 저장 if (res.next()) { if (res.getString(1).equals(memberPW)) { return 1; // 로그인 성공 } else { return 0; // 비밀번호가 틀림 } } res.close(); pstmt.close(); conn.close(); return -1; // 아이디 없음 } catch (SQLException e) { e.printStackTrace(); } return -2; // 기타 오류 } // 회원정보 객체를 매개변수로 받아 회원가입을 진행하는 메서드 public int join(MemberVO m) { String sql = "INSERT INTO member_t values(?, ?)"; try { pstmt = conn.prepareStatement(sql); pstmt.setString(1, m.getMemberID()); pstmt.setString(2, m.getMemberPW()); return pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } return -1; } }
b96993d15b00e8986410738853e5f3b2a510318a
30c73004c238a24aaf87727fddcc2a0900ea1c0b
/src/view/ViewTextEditor.java
9332c7431a313e41ee5598dfdb8c37a7a6d36003
[]
no_license
frcohenrique/JavaNotepad
3a460826d813e7465b27e76f48a395cbddf7b412
25a854f9949b57fcb1c530546c7b77246548ad22
refs/heads/master
2023-02-28T08:32:05.920705
2021-02-03T22:02:54
2021-02-03T22:02:54
335,768,218
0
0
null
null
null
null
UTF-8
Java
false
false
6,018
java
package view; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.util.Scanner; public class ViewTextEditor extends Component { private JPanel notePanel; private JTextArea textArea1; private JMenuBar MenuBar; private JMenu MyMenu; private JMenu MyMenu2; private JMenuItem MOpen; private JMenuItem MSave; private JMenuItem MNewPage; private JMenuItem MCorTexto; private JMenuItem MCorBackground; public ViewTextEditor() { //Variavel JTextArea String jTextArea; jTextArea = textArea1.getText(); /** * Botão ABRIR arquivo */ MOpen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Abrir(); // javax.swing.JOptionPane.showMessageDialog(null, "Open"); } }); /** * Botão SALVAR arquivo. */ MSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Salvar(); } }); /** * Botão adicionar nova pagina */ MNewPage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NewPagePanel(); } }); /** * Escolher cor de texto nova */ MCorTexto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TextColor(); } }); /** * Botao Alterar cor de fundo */ MCorBackground.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BackgroundColor(); } }); } /** * Método Chamar PANEL */ public static void CallPanel() { JFrame frame = new JFrame(); frame.setContentPane(new ViewTextEditor().notePanel); frame.setSize(600, 600); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.setTitle("Editor de texto"); frame.setVisible(true); } /** * Método abrir nova pagina */ public static void NewPagePanel(){ JFrame frame = new JFrame(); frame.setContentPane(new ViewTextEditor().notePanel); frame.setSize(600, 600); frame.setLocationRelativeTo(null); frame.setTitle("Nova Página"); frame.setVisible(true); } /** * Metodo Salvar arquivo (exportar) */ public void Salvar() { /** String tempTexto = textArea1.getText(); try { //editar depois. String finalTxt = ".txt"; String arquivoText = "Arquivo"; String nomeArquivo = arquivoText + finalTxt; PrintWriter salvarArq = new PrintWriter(nomeArquivo); // salvarArq.print(textArea1.getText()); // salvarArq.close(); File file = new File(nomeArquivo); if (file.exists()){ int optionPane = JOptionPane.showConfirmDialog( null, "Voce gostaria de substituir o arquivo?", "AVISO!!!!!", JOptionPane.YES_NO_OPTION); if (optionPane == JOptionPane.YES_OPTION){ salvarArq.print(textArea1.getText()); salvarArq.close(); } else{ } } } catch (FileNotFoundException ex) { Logger.getLogger(ViewTextEditor.class.getName()).log(Level.SEVERE, null, ex); } */ JFileChooser chooser = new JFileChooser(); // abre a interface de escolher arquivo int option = chooser.showSaveDialog(this); // mostra a opção de salvar e tals if (option == JFileChooser.APPROVE_OPTION) { //se voce apertou o botao de salvar/ok try { BufferedWriter buf = new BufferedWriter(new FileWriter(chooser.getSelectedFile().getAbsolutePath())); buf.write(textArea1.getText()); buf.close(); } catch (IOException e) { e.printStackTrace(); } } } /** * Método Abrir arquivo (txt) */ public void Abrir(){ JFileChooser chooser = new JFileChooser(); // File chooser (escolher arquivo) chooser.setFileFilter(new Filter()); int option = chooser.showOpenDialog(this); // abre as opções (pasta) if(option == JFileChooser.APPROVE_OPTION) { try { Scanner scanner = new Scanner(chooser.getSelectedFile()); // escolher o arquivo while(scanner.hasNext()) { // When the scanner still has stuff to read, do something String data = scanner.nextLine(); // ler o que tem no arquivo textArea1.setText(data); // pega tudo que tem no arquivo (texto) e joga no notepad } scanner.close(); // (fecha o scanner) } catch (FileNotFoundException e) { e.printStackTrace(); } } } /** * filtra para aceitar apenas .txt ou .java */ class Filter extends javax.swing.filechooser.FileFilter implements FileFilter { public boolean accept(File file) { return file.getName().endsWith(".txt") || file.getName().endsWith(".java"); } @Override public String getDescription() { return "Text File (.txt)"; } } /** * Método mudar cor do texto */ public void TextColor(){ Color textColor = JColorChooser.showDialog(null, "Escolha uma cor", Color.white); // textArea1.setBackground(c); textArea1.setForeground(textColor); } /** * Método mudar cor de fundo */ public void BackgroundColor(){ Color backGround = JColorChooser.showDialog(null, "Escolha a cor de fundo", Color.white); textArea1.setBackground(backGround); } }
ad195ecfb26a5e8c2527694fd6f00fdf999e318a
53b4ecfd507924ee1c85dd4739e6131b928d4beb
/app/src/main/java/com/sierra_psec/goadventure/Button.java
5d7e72e07b6394a0c8e50afe37302eea48f52958
[]
no_license
SierraPSEC/GoAdventure
c62f6b9a9ef2ee47b80fdefbb41dae3d3837f911
c3a26187d7a7d8907cd9eb4f9a6807b7446c8f1e
refs/heads/master
2021-01-18T21:27:10.739355
2016-05-25T04:25:54
2016-05-25T04:25:54
52,316,556
2
3
null
2016-03-04T08:53:08
2016-02-23T00:22:03
Java
UTF-8
Java
false
false
1,286
java
package com.sierra_psec.goadventure; /** * Created by Luis on 4/14/2016. */ public class Button { public Vector2 mins; public Vector2 maxs; //center of the button (used as a shortcut for positioning) public Vector2 center; //x and y Size (used as a shortcut for positioning) public Vector2 size; //Half of the size vector (used as a shortcut for positioning) public Vector2 halfSize; //ID for what finger pushed it. public int touchID = -1; Button(Vector2 min, Vector2 max) { mins = new Vector2(min); maxs = new Vector2(max); size = new Vector2(maxs.x - mins.x, maxs.y - mins.y); halfSize = Vector2.mul(size,0.5f); center = new Vector2(mins.x + halfSize.x, mins.y + halfSize.y); } Button(Vector2 pos, float width, float height) { mins = new Vector2(pos); maxs = Vector2.add(pos,new Vector2(width,height)); size = new Vector2(maxs.x - mins.x, maxs.y - mins.y); halfSize = Vector2.mul(size, 0.5f); center = new Vector2(mins.x + halfSize.x, mins.y + halfSize.y); } public boolean isInside(Vector2 pos) { if(pos.x < mins.x || pos.x > maxs.x) return false; if(pos.y < mins.y || pos.y > maxs.y) return false; return true; } //TODO: if we decide on doing polygon based button drawing, add a general-purpose draw function here. }
36b00b661839fdf9a85e1712287b3301e0dbd99c
92a7a2cc5b3ca2746c7aafac502abd5237be1a26
/src/main/java/com/example/excel/model/UserInfo.java
f80012ba2551c965286e8bbddca7e6db70851b67
[]
no_license
movingbrickscoder/excel
e48fd10db97e48706f3ae928ee3852c958f6ed20
661fafb9918fbd7d72c879966d89229e28d8cf57
refs/heads/master
2020-06-03T18:31:50.103112
2019-06-17T02:17:56
2019-06-17T02:17:56
191,677,160
0
0
null
null
null
null
UTF-8
Java
false
false
1,284
java
package com.example.excel.model; import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.handler.inter.IExcelModel; import lombok.Data; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; @Data public class UserInfo implements IExcelModel { @Excel(name = "姓名") @NotNull(message = "姓名不能为空") private String name; @Excel(name = "年龄") @NotNull(message = "年龄不能为空") @Size(max = 3,message = "长度不能超过3") private String age; @Excel(name = "邮箱地址") @NotNull(message = "邮箱地址不能为空") private String email; @Excel(name = "手机号") @NotNull(message = "手机号不能为空") @Pattern(regexp = "^\\d{11}$", message = "手机号格式不正确") private String phoneNumber; @Excel(name = "地址") @NotNull(message = "地址不能为空") @Size(max = 200,message = "长度不能超过200") private String address; @Excel(name = "错误信息") private String errorMsg; @Override public String getErrorMsg() { return errorMsg; } @Override public void setErrorMsg(String s) { this.errorMsg = s; } }
c71c04eab0a4b599a9d07a43659041c9de156592
73131131ff08024474f962d42362b6a4953c1b4d
/Abstract_Classes/A.java
71d7c8856f4f288d5ed753efd2736c4c055c6b73
[]
no_license
ABHISHEK-VM/java_e_lab
10c2adfb25195e615fb33c8cda100d62561b8e88
50405cf84071ece97d030f5bfbd7afa08744402b
refs/heads/master
2023-08-01T06:09:10.939156
2021-09-23T17:23:26
2021-09-23T17:23:26
400,957,556
0
0
null
null
null
null
UTF-8
Java
false
false
168
java
package Abstract_Classes; public abstract class A { String name; A(String name) { this.name = name; } public abstract void callByName(); }
80cfca25b7db2d496ff68107a6b09662e9c4cff2
3894bcad6bbbaa102d8452874e42c2fb58470eb1
/12_Streams_Files/Task3_PersonCharacteristics/src/task3_personcharacteristics/ManipulatePesonsList.java
7ea2cc17d6414f5d5c0a79fcbf0ed86895df2c0f
[]
no_license
StanislavGS/Swift
516eba0293ccef24b897aa757df3e5b92b58e72d
f74ad917bc608dfeef9d119bfc77331c2c3782da
refs/heads/master
2020-02-26T16:22:37.957629
2017-01-25T13:31:36
2017-01-25T13:31:36
71,040,506
0
0
null
null
null
null
UTF-8
Java
false
false
4,187
java
package task3_personcharacteristics; import education.Education; import education.HigherEducation; import education.PrimaryEducation; import education.SecondaryEducation; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Stanislav Stanislavov */ public class ManipulatePesonsList { public static void addPerson (String[] s1,ArrayList<Person> persons ){ Address address; if (!s1[12].trim().equals("") && !s1[13].trim().equals("")) { address = new Address(s1[6], s1[7], s1[8], Integer.parseInt(s1[9]), s1[10], s1[11], Integer.parseInt(s1[12]), Integer.parseInt(s1[13])); } else if (s1[12].trim().equals("") && s1[13].trim().equals("")) { address = new Address(s1[6], s1[7], s1[8], Integer.parseInt(s1[9]), s1[10], s1[11]); } else { address = new Address(s1[6], s1[7], s1[8], Integer.parseInt(s1[9]), s1[10], s1[11], Integer.parseInt(s1[12])); } try { Object education = null; LocalDate graduationDate = LocalDate.parse(s1[17], DateTimeFormatter.ofPattern("d.M.y")); float grade = 0f; if (s1[14].trim().toUpperCase() != "P" && graduationDate.compareTo(LocalDate.now()) <= 0) { grade = Float.parseFloat(s1[18]); } switch (s1[14].trim().toUpperCase()) { case "P": education = new PrimaryEducation(s1[15], LocalDate.parse(s1[16], DateTimeFormatter.ofPattern("d.M.y")), graduationDate); break; case "S": education = new SecondaryEducation(s1[15], LocalDate.parse(s1[16], DateTimeFormatter.ofPattern("d.M.y")), graduationDate, grade); break; case "B": education = new HigherEducation(s1[15], LocalDate.parse(s1[16], DateTimeFormatter.ofPattern("d.M.y")), graduationDate, grade, Education.EducationDegree.Bachelor); break; case "M": education = new HigherEducation(s1[15], LocalDate.parse(s1[16], DateTimeFormatter.ofPattern("d.M.y")), graduationDate, grade, Education.EducationDegree.Master); break; case "D": education = new HigherEducation(s1[15], LocalDate.parse(s1[16], DateTimeFormatter.ofPattern("d.M.y")), graduationDate, grade, Education.EducationDegree.Doctorate); break; default: throw new IllegalArgumentException("Unrecognized education code."); } Person.Gender readGender; if (s1[3].trim().toLowerCase().charAt(0)=='m'){ readGender=Person.Gender.Male; }else if(s1[3].trim().toLowerCase().charAt(0)=='f'){ readGender=Person.Gender.Female; }else{ throw new IllegalArgumentException("Bad genger."); } persons.add( new Person(s1[0], s1[1], s1[2], readGender, LocalDate.parse(s1[4], DateTimeFormatter.ofPattern("d.M.y")), Float.parseFloat(s1[5]), education, address)); } catch (IllegalArgumentException ex) { System.out.println(ex.getMessage()); } } }
2c5bbb63301154455fed79729bc2aecdfd2a574c
f123c92704e5aa15dfd2e3ab0ecb3c7dfb8b87f2
/LOTR/src/main/java/lotr/common/block/LOTRBlockThatchFloor.java
362b592b96a334e0171a50d19f119545764b85d2
[]
no_license
Myrninvollo/LOTR-Minecraft-Mod
2dcaabb659bfc10b41332f975209f2f8cd7e3f55
97843fd05ae9fc7a7f61021fbe288db0f0b4298b
refs/heads/master
2020-12-30T22:58:22.274461
2014-10-12T19:06:55
2014-10-12T19:06:55
24,939,635
1
1
null
2014-10-12T19:06:55
2014-10-08T12:30:52
null
UTF-8
Java
false
false
1,299
java
package lotr.common.block; import lotr.common.LOTRCreativeTabs; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class LOTRBlockThatchFloor extends Block { public LOTRBlockThatchFloor() { super(Material.carpet); setHardness(0.2F); setStepSound(Block.soundTypeGrass); setCreativeTab(LOTRCreativeTabs.tabDeco); setBlockBounds(0F, 0F, 0F, 1F, 0.0625F, 1F); } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } @Override public boolean canBlockStay(World world, int i, int j, int k) { return world.getBlock(i, j - 1, k).isSideSolid(world, i, j - 1, k, ForgeDirection.UP); } @Override public boolean canPlaceBlockAt(World world, int i, int j, int k) { return canBlockStay(world, i, j, k); } @Override public void onNeighborBlockChange(World world, int i, int j, int k, Block block) { if (!canBlockStay(world, i, j, k)) { dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0); world.setBlockToAir(i, j, k); } } }
4484c35e9525ea10087b4414258ee4a596aad3a9
40e99b8b97c65ab36677dda3935255712a1deaef
/solutions/java/src/test/java/playground/algorithm/ContinuousCardsTest.java
6a4d09b5cb7bafb52629feb2ae37158556e83dcb
[ "MIT" ]
permissive
pojozhang/playground
e892e1542f2a7b7295eedb021720f02d6da4ba47
181f2004b04cc97c0bed9d80a9e685217e014b9e
refs/heads/master
2023-08-16T16:18:58.694577
2023-08-10T16:25:13
2023-08-10T16:25:13
128,650,635
8
3
MIT
2023-09-12T19:03:09
2018-04-08T14:39:43
Java
UTF-8
Java
false
false
786
java
package playground.algorithm; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; class ContinuousCardsTest { private ContinuousCards solution = new ContinuousCards(); @Test void case_1() { assertThat(solution.isStraight(new int[]{1, 2, 3, 4, 5})).isTrue(); } @Test void case_2() { assertThat(solution.isStraight(new int[]{0, 0, 1, 2, 5})).isTrue(); } @Test void case_3() { assertThat(solution.isStraight(new int[]{0, 0, 2, 2, 5})).isFalse(); } @Test void case_4() { assertThat(solution.isStraight(new int[]{1, 2, 12, 0, 3})).isFalse(); } @Test void case_5() { assertThat(solution.isStraight(new int[]{0, 0, 8, 5, 4})).isTrue(); } }
6131adf4dcb47b4df375fbe445bcc0230dad90d4
d7713ec38f22ef3a72873bbc814c663f9901a331
/bboss_security/src/main/java/codec/asn1/ASN1RegisteredType.java
5aa8d61410c2542b47adefa3dc20eb8b8d2b229e
[ "Apache-2.0" ]
permissive
besom/bbossgroups-mvn
3a658b4786ca3965a20c484f2f27bb1f56f43431
364defa5bc5fc52e9ac5bc25e491720f697529c6
refs/heads/master
2021-01-15T12:50:42.427585
2014-12-16T03:21:01
2014-12-16T03:21:01
27,861,629
1
1
null
2016-03-09T18:35:23
2014-12-11T08:33:46
Java
UTF-8
Java
false
false
4,637
java
/* ======================================================================== * * This file is part of CODEC, which is a Java package for encoding * and decoding ASN.1 data structures. * * Author: Fraunhofer Institute for Computer Graphics Research IGD * Department A8: Security Technology * Fraunhoferstr. 5, 64283 Darmstadt, Germany * * Rights: Copyright (c) 2004 by Fraunhofer-Gesellschaft * zur Foerderung der angewandten Forschung e.V. * Hansastr. 27c, 80686 Munich, Germany. * * ------------------------------------------------------------------------ * * The software package is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of the * License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software package; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA or obtain a copy of the license at * http://www.fsf.org/licensing/licenses/lgpl.txt. * * ------------------------------------------------------------------------ * * The CODEC library can solely be used and distributed according to * the terms and conditions of the GNU Lesser General Public License for * non-commercial research purposes and shall not be embedded in any * products or services of any user or of any third party and shall not * be linked with any products or services of any user or of any third * party that will be commercially exploited. * * The CODEC library has not been tested for the use or application * for a determined purpose. It is a developing version that can * possibly contain errors. Therefore, Fraunhofer-Gesellschaft zur * Foerderung der angewandten Forschung e.V. does not warrant that the * operation of the CODEC library will be uninterrupted or error-free. * Neither does Fraunhofer-Gesellschaft zur Foerderung der angewandten * Forschung e.V. warrant that the CODEC library will operate and * interact in an uninterrupted or error-free way together with the * computer program libraries of third parties which the CODEC library * accesses and which are distributed together with the CODEC library. * * Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * does not warrant that the operation of the third parties's computer * program libraries themselves which the CODEC library accesses will * be uninterrupted or error-free. * * Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * shall not be liable for any errors or direct, indirect, special, * incidental or consequential damages, including lost profits resulting * from the combination of the CODEC library with software of any user * or of any third party or resulting from the implementation of the * CODEC library in any products, systems or services of any user or * of any third party. * * Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * does not provide any warranty nor any liability that utilization of * the CODEC library will not interfere with third party intellectual * property rights or with any other protected third party rights or will * cause damage to third parties. Fraunhofer Gesellschaft zur Foerderung * der angewandten Forschung e.V. is currently not aware of any such * rights. * * The CODEC library is supplied without any accompanying services. * * ======================================================================== */ package codec.asn1; /** * This class represents an ASN.1 type that is officially registered. In other * words, this type is associated with a unique OID. * * @author Volker Roth * @version "$Id: ASN1RegisteredType.java,v 1.3 2004/08/06 15:14:52 flautens Exp $" */ public interface ASN1RegisteredType extends ASN1Type { /** * This method returns the official OID that identifies this ASN.1 type. * * @return The official ASN.1 OID of this type. */ public ASN1ObjectIdentifier getOID(); }
f5a97bbf6be82d2fb7a5cd5f18c40a268a1b2396
00aaeb0afe6a9c03fdcde05224ae084c6b6f1541
/gcpa/src/main/java/gcda/util/RodDivision.java
110bfbfbaf12644166161d0a137511e9bd4d503c
[]
no_license
agentelegionario/GCDA
9bd2a4f4d904f6fa87272555ac28ee350164baae
611a5448574b30c818edbfaa687e4edc5ed57d47
refs/heads/master
2021-01-01T04:50:01.461019
2016-05-18T00:01:20
2016-05-18T00:01:20
59,068,796
0
0
null
null
null
null
UTF-8
Java
false
false
817
java
package gcda.util; public class RodDivision { public static int divideRod(int[] values, int n){ int[] r = new int[n+1]; r[0] = 0; for (int j = 1; j <= n; j++) { int max = values[j]; for (int i = 1; i < j; i++) { int tmp = values[i] + r[j-i]; if (tmp > max) max = tmp; } r[j] = max; } /*for (int i = 1; i < n; i++) { System.out.println(r[i]); }*/ return r[n]; } public static void main(String[] args) { // TODO Auto-generated method stub int[] values={0,1,3,3,5,5,10,8,3,10,10}; int n=values.length-1; int[] answers = new int[values.length]; for(int i=0;i<answers.length; i++) answers[i]=-1; System.out.println(divideRod(values, 3)); } }
[ "Alcides@NATI-03" ]
Alcides@NATI-03
3bb97bbc6dc1539815686504ef129084a4f36db2
83ccbb69965c243bf63f9a38fe0dfc08d0578a1c
/app/src/main/java/com/nytimes/alex/mynews/Utils/ItemClickSupport.java
67bc67151117ac176b7bfae9bd2f8fd868998c29
[]
no_license
AlexanderTarasyuk/NYTimes
dd954d3d8720f0230b394bff250faf8f0ce979f5
05e192ca2a7e88003fc971641aeb61527fc9e75f
refs/heads/master
2020-04-29T08:23:43.418295
2019-03-16T14:57:43
2019-03-16T14:57:44
175,985,279
0
0
null
null
null
null
UTF-8
Java
false
false
3,328
java
package com.nytimes.alex.mynews.Utils; import android.support.v7.widget.RecyclerView; import android.view.View; public class ItemClickSupport { private final RecyclerView mRecyclerView; private OnItemClickListener mOnItemClickListener; private OnItemLongClickListener mOnItemLongClickListener; private int mItemID; private View.OnClickListener mOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (mOnItemClickListener != null) { RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); mOnItemClickListener.onItemClicked(mRecyclerView, holder.getAdapterPosition(), v); } } }; private View.OnLongClickListener mOnLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (mOnItemLongClickListener != null) { RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); return mOnItemLongClickListener.onItemLongClicked(mRecyclerView, holder.getAdapterPosition(), v); } return false; } }; private RecyclerView.OnChildAttachStateChangeListener mAttachListener = new RecyclerView.OnChildAttachStateChangeListener() { @Override public void onChildViewAttachedToWindow(View view) { if (mOnItemClickListener != null) { view.setOnClickListener(mOnClickListener); } if (mOnItemLongClickListener != null) { view.setOnLongClickListener(mOnLongClickListener); } } @Override public void onChildViewDetachedFromWindow(View view) { } }; private ItemClickSupport(RecyclerView recyclerView, int itemID) { mRecyclerView = recyclerView; mItemID = itemID; mRecyclerView.setTag(itemID, this); mRecyclerView.addOnChildAttachStateChangeListener(mAttachListener); } public static ItemClickSupport addTo(RecyclerView view, int itemID) { ItemClickSupport support = (ItemClickSupport) view.getTag(itemID); if (support == null) { support = new ItemClickSupport(view, itemID); } return support; } public static ItemClickSupport removeFrom(RecyclerView view, int itemID) { ItemClickSupport support = (ItemClickSupport) view.getTag(itemID); if (support != null) { support.detach(view); } return support; } public ItemClickSupport setOnItemClickListener(OnItemClickListener listener) { mOnItemClickListener = listener; return this; } public ItemClickSupport setOnItemLongClickListener(OnItemLongClickListener listener) { mOnItemLongClickListener = listener; return this; } private void detach(RecyclerView view) { view.removeOnChildAttachStateChangeListener(mAttachListener); view.setTag(mItemID, null); } public interface OnItemClickListener { void onItemClicked(RecyclerView recyclerView, int position, View v); } public interface OnItemLongClickListener { boolean onItemLongClicked(RecyclerView recyclerView, int position, View v); } }
14cb7ea371abd17ae7d46a96058c18f9344d5307
cea3c42b1590d204c4923fb649da9c3f173b5295
/src/main/java/com/demo/example/demo/rabbitmq_demo/RabbitMQFactory.java
a5e41641090ea596a2409cd34c417af73148d20e
[]
no_license
CancerLiu/DemoCollection
c96564bcb25898e314061a4316bea437cafb84d1
2124bd04cefde0fd08b73c6a05a0696ae3961823
refs/heads/master
2022-12-16T02:07:06.803875
2020-09-25T03:08:46
2020-09-25T03:08:46
296,506,583
0
0
null
null
null
null
UTF-8
Java
false
false
882
java
package com.demo.example.demo.rabbitmq_demo; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.TimeoutException; public class RabbitMQFactory { private final static Logger logger = LoggerFactory.getLogger(RabbitMQFactory.class); public static Channel construct(ConnectionConfig config) throws IOException, TimeoutException { ConnectionFactory factory = new ConnectionFactory(); factory.setHost(config.getHost()); factory.setPort(config.getPort()); factory.setUsername(config.getUserName()); factory.setPassword(config.getPassword()); Connection connection = factory.newConnection(); return connection.createChannel(); } }
79407a613e381edc169640349ce944c18c19e2c9
a96ce2d9214838bf145a971df874304e3f8c4913
/oes-common/oes-common-core/src/main/java/com/oes/common/core/constant/RegexpConstant.java
11c4082c95904d24188c9c238c8dcb4243002eec
[ "Apache-2.0" ]
permissive
YunShiTiger/OES-Cloud-Testing-Platform
3f22dfa4621907c009894d81e7b2d5a2e5e3a0ef
19205107db6d74e5f8a521ec041799ee51ce2765
refs/heads/master
2023-03-06T10:21:47.850862
2020-11-06T02:20:40
2020-11-06T02:20:40
null
0
0
null
null
null
null
UTF-8
Java
false
false
540
java
package com.oes.common.core.constant; /** * 常用正则表达式常量 * * @author chachae * @since 2020/04/30 14:21 */ public interface RegexpConstant { /** * 移动电话(国内) */ String MOBILE_REG = "^(?:(?:\\+|00)86)?1[3-9]\\d{9}$"; /** * 身份证(1代 / 2代) */ String ID_CARD_REG = "(^\\d{8}(0\\d|10|11|12)([0-2]\\d|30|31)\\d{3}$)|(^\\d{6}(18|19|20)\\d{2}(0[1-9]|10|11|12)([0-2]\\d|30|31)\\d{3}(\\d|X|x)$)"; /** * 包含中文 */ String CONTAINS_CHINESE = "^[\\u4E00-\\u9FA5]+$"; }
881ccee6adc5c2defdeead0e79073093228eee1f
91d7819b18c5d8f05fd9aa65581ed9b632529d5c
/SpringDemoAnnotations/src/com/luv2code/springdemo/CodeConfig.java
d1cbca2ae12bce18a9e3ab851129276497c1d1b3
[]
no_license
derekdunes/Spring-Basics
92bcba7dbcfbc619f6b8b33c7b351c83ecbdd8a3
6ff35bedd8bddea32953de47421707747a1b4360
refs/heads/main
2023-06-24T09:38:54.131271
2021-07-22T12:52:13
2021-07-22T12:52:13
388,460,491
0
0
null
null
null
null
UTF-8
Java
false
false
474
java
package com.luv2code.springdemo; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class CodeConfig { //define the fortune implementation @Bean public FortuneService codeFortuneService() { return new CodeFortuneService(); } //define the coach implementation and inject its dependencies @Bean public Coach dartCoach() { return new DartCoach(codeFortuneService()); } }
5cd53f01556d4b00654c96b282fef10e2fce5825
223af4e85104686685c66b447c8886d3b6201ab1
/src/main/java/com/ystudy/modules/notification/Notifications.java
51079aaa0293dccb018fe440a2b677cfb23923f3
[]
no_license
devYSK/ystudy-studyolle
c2608c879f7bdabfc2a9b78e27b57525f621df4a
bf7dbb01d9badaabcf36609835d5e7ffb1b12c18
refs/heads/master
2023-01-31T10:50:38.673058
2020-12-17T17:12:40
2020-12-17T17:12:40
322,305,502
0
0
null
null
null
null
UTF-8
Java
false
false
365
java
package com.ystudy.modules.notification; import lombok.Data; @Data public class Notifications { private boolean studyCreatedByEmail; private boolean studyCreatedByWeb; private boolean studyEnrollmentResultByEmail; private boolean studyEnrollmentResultByWeb; private boolean studyUpdatedByEmail; private boolean studyUpdatedByWeb; }
c556ed4dfe659245ea34840d8e7b2b6b44b9867c
eb10687e3b707dfe3797159a8834d4cc37e2d86b
/Next Permutation.java
0bf7db2cca51ca8be4ca1c9bf86b901a44677e8f
[]
no_license
zhibolau/lintCodeOfZhiboLiu
7d7bae649b9d8e0e96c82232fe60cc220c5e8636
7fc0a70dcfd6ee7025cd5dab48d2aca4ad4d17b2
refs/heads/master
2021-01-21T04:55:15.148585
2016-06-28T20:07:52
2016-06-28T20:07:52
51,408,069
0
0
null
null
null
null
UTF-8
Java
false
false
2,206
java
找到下一个升序的!!!!!!permutation public class Solution { /** * @param nums: A list of integers * @return: A list of integers that's next permuation */ public ArrayList<Integer> nextPermuation(ArrayList<Integer> nums) { // write your code if (nums == null || nums.size() == 0) { return nums; } for (int i = nums.size() - 2; i >= 0; i--) { for (int j = nums.size() - 1; j >= i; j--) { if (nums.get(j) > nums.get(i)) { swap(nums, i, j); reverse(nums, i + 1, nums.size() - 1); return nums; } } } reverse(nums, 0, nums.size() - 1); return nums; } private void swap(ArrayList<Integer> nums, int i, int j) { int temp = nums.get(i); nums.set(i, nums.get(j)); nums.set(j, temp); } private void reverse(ArrayList<Integer> nums, int left, int right) { while (left < right) { swap(nums, left++, right--); } } } public class Solution { /** * @param nums: an array of integers * @return: return nothing (void), do not return anything, modify nums in-place instead */ public int[] nextPermutation(int[] nums) { int len = nums.length; if (nums == null || len == 0) { return nums; } for (int i = len - 2; i >= 0; i--) {//根据题的例子 倒数第二个数 要是小于最后那个数 就swap他俩 再reverse //此处reverse不是全部reverse 是局部的 注意!!!!!!! for (int j = len - 1; j >= i; j--) {// j得大于等于i!!!!!!!!!!!!!! if (nums[j] > nums[i]) { swap(nums, i, j); reverse(nums, i + 1, len - 1); return nums; } } } reverse(nums, 0, len - 1);// 否则 全部reverse return nums; } private void swap(int[] nums, int i, int j) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } private void reverse(int[] nums, int left, int right) { while (left < right) { swap(nums, left++, right--);// 别忘记更新left right!!!!!!!!!!! } } }
93937a1878cfe5ec8ed194167da53bc90927d2a5
4f9bccb34d6b116040c9780a72048aaba11bce28
/Examples/CA/TestCanadaEncPreauthCustInfo.java
23ff81c5a9290c83807886345a197fdeef8fdb29
[]
no_license
tdharma/eCommerce-Unified-API-Java
7bbc2b096d2a3c1c9bbad47cd07547a69eae3268
72ae52482337e11a4f7f7584966ea9e88f6d391a
refs/heads/master
2020-09-16T15:10:05.933690
2019-10-30T23:31:46
2019-10-30T23:31:46
223,809,851
0
0
null
2019-11-24T21:04:10
2019-11-24T21:04:10
null
UTF-8
Java
false
false
7,403
java
package Canada; import java.util.*; import JavaAPI.*; public class TestCanadaEncPreauthCustInfo { public static void main(String[] args) { String store_id = "moneris"; String api_token = "hurgle"; java.util.Date createDate = new java.util.Date(); String order_id = "Test"+createDate.getTime(); String amount = "10.00"; String device_type = "idtech_bdk"; String crypt = "7"; String enc_track2 = "0284008500000000041608B84D1586DEDBA1F0DB3CECD296C41195AFECE7CA8F3A00E6DBA97A4EFDEF05D3935553E9E24B5AEFC7B2330431393035FFFF3141594047A0009A7FB103"; String processing_country_code = "CA"; boolean status_check = false; /********************* Billing/Shipping Variables ****************************/ String first_name = "Bob"; String last_name = "Smith"; String company_name = "ProLine Inc."; String address = "623 Bears Ave"; String city = "Chicago"; String province = "Illinois"; String postal_code = "M1M2M1"; String country = "Canada"; String phone = "777-999-7777"; String fax = "777-999-7778"; String tax1 = "10.00"; String tax2 = "5.78"; String tax3 = "4.56"; String shipping_cost = "10.00"; /********************* Order Line Item Variables *****************************/ String[] item_description = new String[] { "Chicago Bears Helmet", "Soldier Field Poster" }; String[] item_quantity = new String[] { "1", "1" }; String[] item_product_code = new String[] { "CB3450", "SF998S" }; String[] item_extended_amount = new String[] { "150.00", "19.79" }; /*****************************************************************************/ /* */ /* Customer Information Option 1 */ /* */ /*****************************************************************************/ /********************** Customer Information Object **************************/ CustInfo customer = new CustInfo(); /********************** Set Customer Billing Information **********************/ customer.setBilling(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost); /******************** Set Customer Shipping Information ***********************/ customer.setShipping(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost); /***************************** Order Line Items ******************************/ customer.setItem(item_description[0], item_quantity[0], item_product_code[0], item_extended_amount[0]); customer.setItem(item_description[1], item_quantity[1], item_product_code[1], item_extended_amount[1]); /*****************************************************************************/ /* */ /* Customer Information Option 2 */ /* */ /*****************************************************************************/ /********************** Customer Information Object **************************/ CustInfo customer2 = new CustInfo(); /******************************* Billing Hashtable ***************************/ Hashtable<String, String> b = new Hashtable<String, String>(); //billing hashtable b.put("first_name", first_name); b.put("last_name", last_name); b.put("company_name", company_name); b.put("address", address); b.put("city", city); b.put("province", province); b.put("postal_code", postal_code); b.put("country", country); b.put("phone", phone); b.put("fax", fax); b.put("tax1", tax1); //federal tax b.put("tax2", tax2); //prov tax b.put("tax3", tax3); //luxury tax b.put("shipping_cost", shipping_cost); //shipping cost customer2.setBilling(b); /****************************** Shipping Hashtable ***************************/ Hashtable<String, String> s = new Hashtable<String, String>(); //shipping hashtable s.put("first_name", first_name); s.put("last_name", last_name); s.put("company_name", company_name); s.put("address", address); s.put("city", city); s.put("province", province); s.put("postal_code", postal_code); s.put("country", country); s.put("phone", phone); s.put("fax", fax); s.put("tax1", tax1); //federal tax s.put("tax2", tax2); //prov tax s.put("tax3", tax3); //luxury tax s.put("shipping_cost", shipping_cost); //shipping cost customer2.setShipping(s); /************************* Order Line Item1 Hashtable ************************/ Hashtable<String, String> i1 = new Hashtable<String, String>(); //item hashtable #1 i1.put("name", item_description[0]); i1.put("quantity", item_quantity[0]); i1.put("product_code", item_product_code[0]); i1.put("extended_amount", item_extended_amount[0]); customer2.setItem(i1); /************************* Order Line Item2 Hashtable **************************/ Hashtable<String, String> i2 = new Hashtable<String, String>(); //item hashtable #2 i2.put("name", "item2's name"); i2.put("quantity", "7"); i2.put("product_code", "item2's product code"); i2.put("extended_amount", "5.01"); customer2.setItem(i2); /*************** Miscellaneous Customer Information Methods *******************/ customer.setEmail("[email protected]"); customer.setInstructions("Make it fast!"); /********************** Transactional Request Object **************************/ EncPreauth encpreauth = new EncPreauth(); encpreauth.setOrderId(order_id); encpreauth.setAmount(amount); encpreauth.setEncTrack2(enc_track2); encpreauth.setDeviceType(device_type); encpreauth.setCryptType(crypt); encpreauth.setCustInfo(customer); HttpsPostRequest mpgReq = new HttpsPostRequest(); mpgReq.setProcCountryCode(processing_country_code); mpgReq.setTestMode(true); //false or comment out this line for production transactions mpgReq.setStoreId(store_id); mpgReq.setApiToken(api_token); mpgReq.setTransaction(encpreauth); mpgReq.setStatusCheck(status_check); mpgReq.send(); try { Receipt receipt = mpgReq.getReceipt(); System.out.println("CardType = " + receipt.getCardType()); System.out.println("TransAmount = " + receipt.getTransAmount()); System.out.println("TxnNumber = " + receipt.getTxnNumber()); System.out.println("ReceiptId = " + receipt.getReceiptId()); System.out.println("TransType = " + receipt.getTransType()); System.out.println("ReferenceNum = " + receipt.getReferenceNum()); System.out.println("ResponseCode = " + receipt.getResponseCode()); System.out.println("ISO = " + receipt.getISO()); System.out.println("BankTotals = " + receipt.getBankTotals()); System.out.println("Message = " + receipt.getMessage()); System.out.println("AuthCode = " + receipt.getAuthCode()); System.out.println("Complete = " + receipt.getComplete()); System.out.println("TransDate = " + receipt.getTransDate()); System.out.println("TransTime = " + receipt.getTransTime()); System.out.println("Ticket = " + receipt.getTicket()); System.out.println("TimedOut = " + receipt.getTimedOut()); System.out.println("CardLevelResult = " + receipt.getCardLevelResult()); System.out.println("MaskedPan = " + receipt.getMaskedPan()); } catch (Exception e) { e.printStackTrace(); } } }
94baaf4590db138abaaa6d76f5444e8eee63cc40
752b6e4902f261a241f81525d2d9f58180524f60
/app/src/main/java/com/campuspedia/campuspedia/activity/MainActivity.java
e77a2090da43c8e411f4dd8b3f982e537cfe63c0
[]
no_license
misbahulard/campuspedia-android
340778d27a03aed0b9be85e26dd2aa721999d78b
65b9073a0a8b72d42dddb24abc4a3b6ab5a9019c
refs/heads/master
2021-07-13T06:58:09.385155
2017-10-04T08:03:13
2017-10-04T08:03:13
105,725,438
0
0
null
null
null
null
UTF-8
Java
false
false
388
java
package com.campuspedia.campuspedia.activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.campuspedia.campuspedia.R; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
000e0d668198ff760fdc49c6fc623b60faae558e
98a1394b4167c61b8a58f0e6a1e8fdd9d5ad7764
/src/main/java/com/hollischuang/pattern/Annontation/FruitName.java
4b1ac4b64f7c7e09aa3adde1cfd9b452db5667a7
[]
no_license
CKIA/DesignPattern
db55cc3923580db9d8d8958722129ea1ecce072d
baf10649c39b1da9f6b9a5af4682ec1b638cc590
refs/heads/master
2020-05-31T23:12:01.228640
2019-06-08T07:14:18
2019-06-08T07:14:18
190,534,364
0
0
null
2019-06-06T07:20:47
2019-06-06T07:20:47
null
UTF-8
Java
false
false
511
java
package com.hollischuang.pattern.Annontation; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * @author ckia * @title: FruitName * @projectName DesignPattern * @description: TODO * @date 19-6-6下午10:47 */ @Target(FIELD) @Retention(RUNTIME) @Documented public @interface FruitName { String value() default ""; }
f57e4c1280656ce9f71957afd00f1c887e67130c
d52fc86965764314eef5dc62cfca769c5ac4aac4
/pj4w/pj4w05session/src/main/java/learn/ee/pj4w05session/ActivityServlet.java
5b8462403e37f9463fa8e42f73553f9d121f3b8d
[]
no_license
dpopkov/learnee
8980381fb0469e027fbea828b00a7b3b97fd38da
a4bea58ef59117e979cf2b23a1c706e1e554ecd7
refs/heads/master
2022-12-21T14:31:36.103328
2020-10-19T23:52:44
2020-10-19T23:52:44
231,949,360
0
0
null
2022-12-16T15:51:48
2020-01-05T17:03:46
Java
UTF-8
Java
false
false
2,157
java
package learn.ee.pj4w05session; import learn.ee.pj4w.PageVisit; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @WebServlet( name = "storeServlet", urlPatterns = "/do/*" ) public class ActivityServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { recordSessionActivity(req); viewSessionActivity(req, resp); } private void recordSessionActivity(HttpServletRequest req) { HttpSession session = req.getSession(); if (session.getAttribute("activity") == null) { session.setAttribute("activity", Collections.synchronizedList(new ArrayList<PageVisit>())); } @SuppressWarnings("unchecked") List<PageVisit> visits = (List<PageVisit>) session.getAttribute("activity"); if (!visits.isEmpty()) { PageVisit last = visits.get(visits.size() - 1); last.setLeftTimestamp(System.currentTimeMillis()); } PageVisit now = new PageVisit(); now.setEnteredTimestamp(System.currentTimeMillis()); if (req.getQueryString() == null) { now.setRequest(req.getRequestURL().toString()); } else { now.setRequest(req.getRequestURL() + "?" + req.getQueryString()); } try { now.setIpAddress(InetAddress.getByName(req.getRemoteAddr())); } catch (UnknownHostException e) { e.printStackTrace(); } visits.add(now); } private void viewSessionActivity(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.getRequestDispatcher("/WEB-INF/jsp/view/viewSessionActivity.jsp").forward(req, resp); } }
f3bf95c1186a4a4153277f58bcb28d1dc8347c78
6c584d6b00c91a9696cf34fbdab9787ca4943dbb
/server/src/main/java/com/winsage/constants/Constant.java
09375ee722c96f94c40ce79f6633e3be663c9a14
[]
no_license
amitdoshijain/vicky-parekh-singer
07a6df864a65600cd4e711e0faf0846dad898172
5451f6a75b79d193bf5623e9c24c0ba79c6c285c
refs/heads/master
2021-01-13T03:44:39.488987
2017-01-05T13:21:28
2017-01-05T13:21:28
77,246,984
0
0
null
null
null
null
UTF-8
Java
false
false
430
java
/** * */ package com.winsage.constants; /** * @author msingh * */ public class Constant { public final static String APPLICATION_SESSION_ID = "sessionid"; public static final boolean COOKIE_SECURE = false; public static final int DEFAULT_MAX_AGE = -1; public static final String TRANSACTION_LIMIT = "limit" ; public static final String COMPLETED_ON = "completedon" ; public static final String STATUS = "status" ; }
107a7dba1bd7580bd4020b65de6e8d1dde3545ab
b96f58262a02dcaf1d9c13328d93b4010cf8c5e0
/src/main/java/com/mspark/mongostudy/constant/Code.java
a15d41a0d557d84280f12f675beeb7fc8417307b
[]
no_license
java-dev-mspark/BOOT-MONGO-STUDY
933a7cb07463eb884eea8fb0adaca78b0b1490b1
77780e688be21a50ea7bcdf26da51e06f030ba71
refs/heads/master
2022-11-05T11:27:28.653893
2020-06-05T08:39:49
2020-06-05T08:39:49
268,665,967
0
0
null
null
null
null
UTF-8
Java
false
false
266
java
package com.mspark.mongostudy.constant; import lombok.Getter; @Getter public enum Code { NOERRR(0, "OK"); private int code; private String message; Code(int code, String message){ this.code = code; this.message = message; } }
4945bc84e006f1f981c7ee1a9530e1f00cc1d824
761c40ce8dc5095dd44a36acbd1584c5b3dbdff6
/src/main/java/ru/reksoft/demo/repository/CurrentBasketRepository.java
6f8d84fff47e4fd210b0e0213a0b514cda4418f1
[]
no_license
4val0v/REKSOFT-DEMO
b34cd8d2980c394f674c6db77dfce714b8fe084e
78c9576eab8e0ef8bca5f339dc8bc6704c52a6a8
refs/heads/master
2020-04-07T06:49:59.642919
2018-09-03T12:48:41
2018-09-03T12:48:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
670
java
package ru.reksoft.demo.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import ru.reksoft.demo.domain.CurrentBasketEntity; import ru.reksoft.demo.domain.CurrentBasketEntityPK; public interface CurrentBasketRepository extends JpaRepository<CurrentBasketEntity, CurrentBasketEntityPK>, JpaSpecificationExecutor<CurrentBasketEntity> { CurrentBasketEntity findByPkUserIdAndPkMediaId(Integer userId, Integer mediaId); boolean existsByPkUserIdAndPkMediaId(Integer userId, Integer mediaId); void deleteByPkUserIdAndPkMediaId(Integer userId, Integer mediaId); }
af7454cba8cb3aa02033a4e1b2868c14f26515dc
2e528aeefc1723e1fef70c94bbf0242faa3ea021
/src/main/java/com/bookpot/web/config/WebMvcConfig.java
ad75b94e2cdee5c677b622359b36fb18adcc289b
[]
no_license
leezu2020/bookpot
b7e92fa33aaf62d4a51735e1cbc36ac828f7dc0c
b9e2bdc83a4afe5af7fd466af8dae730d8126bf4
refs/heads/master
2023-04-20T10:55:13.212077
2021-05-10T14:51:22
2021-05-10T14:51:22
344,498,319
0
0
null
2021-05-10T14:51:22
2021-03-04T14:15:46
Java
UTF-8
Java
false
false
730
java
package com.bookpot.web.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc public class WebMvcConfig implements WebMvcConfigurer{ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } }
b5fa54136e5f39c40ab187da23ab83d4cd3d7bc7
eb6128b90a825fa8b1f4223618cfae2fa1498366
/spec/fixtures/projs/java/testclass.java
73cd71e9a7027485adbb8206a2e53aa917374dfb
[]
no_license
KevinHeaton-Money4nothin/enterprise-analyzer
3e6c1ad71c454c4b3ffc47c0626124b979d9352b
3adafe1cba7299e8c7a28554371e40efc17744a9
refs/heads/master
2021-01-12T13:53:17.872153
2016-08-16T00:21:24
2016-08-16T00:21:24
null
0
0
null
null
null
null
UTF-8
Java
false
false
45
java
package com.fake.test; public class Test { }
3d59235581978612bbe47b2a2a17402b558ab8c1
8c085f12963e120be684f8a049175f07d0b8c4e5
/castor/tags/castor-1.3.2/cpa/src/main/java/org/castor/cache/distributed/OsCache.java
109f7bd080eadc03e405c56a444b87bce0a56a65
[]
no_license
alam93mahboob/castor
9963d4110126b8f4ef81d82adfe62bab8c5f5bce
974f853be5680427a195a6b8ae3ce63a65a309b6
refs/heads/master
2020-05-17T08:03:26.321249
2014-01-01T20:48:45
2014-01-01T20:48:45
null
0
0
null
null
null
null
UTF-8
Java
false
false
9,917
java
/* * Copyright 2005 Werner Guttmann, Ralf Joachim * * 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.castor.cache.distributed; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.castor.cache.AbstractBaseCache; import org.castor.cache.CacheAcquireException; /** * OSCache (opensymphony) implementation of Castor JDO Cache. * * For more details of OSCache, see http://www.opensymphony.com/oscache * * @see <a href="http://www.opensymphony.com/oscache">The OSCache Home page</a> * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a> * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a> * @version $Revision$ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $ * @since 1.0 */ public final class OsCache extends AbstractBaseCache { //-------------------------------------------------------------------------- /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons * Logging </a> instance used for all logging. */ private static final Log LOG = LogFactory.getLog(OsCache.class); /** The type of the cache. */ public static final String TYPE = "oscache"; /** The classname of the implementations cache class. */ public static final String IMPLEMENTATION = "com.opensymphony.oscache.general.GeneralCacheAdministrator"; /** Classname of exception thrown by getFromCache() method of oscache. */ public static final String NEEDS_REFRESH_EXCEPTION = "com.opensymphony.oscache.base.NeedsRefreshException"; /** Parameter types for calling getFromCache() method on cache instance. */ private static final Class<?>[] TYPES_GET = new Class[] {String.class}; /** Parameter types for calling cancelUpdate() method on cache instance. */ private static final Class<?>[] TYPES_CANCEL = TYPES_GET; /** Parameter types for calling putInCache() method on cache instance. */ private static final Class<?>[] TYPES_PUT = new Class[] {String.class, Object.class, String[].class}; /** Parameter types for calling flushEntry() method on cache instance. */ private static final Class<?>[] TYPES_REMOVE = TYPES_GET; /** Parameter types for calling flushGroup() method on cache instance. */ private static final Class<?>[] TYPES_CLEAR = TYPES_GET; /** The cache instance. */ private final Object _cache; /** The method to invoke on cache instead of calling getFromCache() directly. */ private Method _getMethod; /** The method to invoke on cache instead of calling cancelUpdate() directly. */ private Method _cancelMethod; /** The method to invoke on cache instead of calling putInCache() directly. */ private Method _putMethod; /** The method to invoke on cache instead of calling flushEntry() directly. */ private Method _removeMethod; /** The method to invoke on cache instead of calling flushGroup() directly. */ private Method _clearMethod; /** The string array of groups which every entry of this cache belongs to. */ private String[] _groups; //-------------------------------------------------------------------------- /** * Construct an instance of OsCache that wrapps access to given cache implementation * of class <code>com.opensymphony.oscache.general.GeneralCacheAdministrator</code>. * * @param cache The cache to be wrapped. */ public OsCache(final Object cache) { _cache = cache; } //-------------------------------------------------------------------------- // operations for life-cycle management of cache /** * {@inheritDoc} */ public void initialize(final Properties params) throws CacheAcquireException { super.initialize(params); Class<?> cls = _cache.getClass(); try { _getMethod = cls.getMethod("getFromCache", TYPES_GET); _cancelMethod = cls.getMethod("cancelUpdate", TYPES_CANCEL); _putMethod = cls.getMethod("putInCache", TYPES_PUT); _removeMethod = cls.getMethod("flushEntry", TYPES_REMOVE); _clearMethod = cls.getMethod("flushGroup", TYPES_CLEAR); } catch (Exception e) { String msg = "Failed to find method on OSCache instance: " + e.getMessage(); LOG.error(msg, e); throw new CacheAcquireException(msg, e); } _groups = new String[] {getName()}; } //-------------------------------------------------------------------------- // getters/setters for cache configuration /** * {@inheritDoc} */ public String getType() { return TYPE; } //-------------------------------------------------------------------------- // query operations of map interface /** * {@inheritDoc} */ public int size() { throw new UnsupportedOperationException("size()"); } /** * {@inheritDoc} */ public boolean isEmpty() { throw new UnsupportedOperationException("isEmpty()"); } /** * {@inheritDoc} */ public boolean containsKey(final Object key) { return (get(key) != null); } /** * {@inheritDoc} */ public boolean containsValue(final Object value) { throw new UnsupportedOperationException("containsValue(Object)"); } /** * {@inheritDoc} */ public Object get(final Object key) { try { return _getMethod.invoke(_cache, new Object[] {String.valueOf(key)}); } catch (InvocationTargetException e) { String cause = e.getTargetException().getClass().getName(); if (cause.equals(NEEDS_REFRESH_EXCEPTION)) { invokeCacheMethod(_cancelMethod, new Object[] {String.valueOf(key)}); return null; } String msg = "Failed to call method on OSCache instance: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(e.getMessage()); } catch (Exception e) { String msg = "Failed to call method on OSCache instance: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(e.getMessage()); } } //-------------------------------------------------------------------------- // modification operations of map interface /** * {@inheritDoc} */ public Object put(final Object key, final Object value) { Object oldValue = get(key); invokeCacheMethod(_putMethod, new Object[] {String.valueOf(key), value, _groups}); return oldValue; } /** * {@inheritDoc} */ public Object remove(final Object key) { Object oldValue = get(key); invokeCacheMethod(_removeMethod, new Object[] {String.valueOf(key)}); return oldValue; } //-------------------------------------------------------------------------- // bulk operations of map interface /** * {@inheritDoc} */ public void putAll(final Map<? extends Object, ? extends Object> map) { Iterator<? extends Entry<? extends Object, ? extends Object>> iter; iter = map.entrySet().iterator(); while (iter.hasNext()) { Entry<? extends Object, ? extends Object> entry = iter.next(); String key = String.valueOf(entry.getKey()); invokeCacheMethod(_putMethod, new Object[] {key, entry.getValue(), _groups}); } } /** * {@inheritDoc} */ public void clear() { invokeCacheMethod(_clearMethod, new Object[] {getName()}); } //-------------------------------------------------------------------------- // view operations of map interface /** * {@inheritDoc} */ public Set<Object> keySet() { throw new UnsupportedOperationException("keySet()"); } /** * {@inheritDoc} */ public Collection<Object> values() { throw new UnsupportedOperationException("values()"); } /** * {@inheritDoc} */ public Set<Entry<Object, Object>> entrySet() { throw new UnsupportedOperationException("entrySet()"); } //-------------------------------------------------------------------------- // helper methods /** * Invoke given method on cache with given arguments. Any possible exception will * be catched and IllegalStateException will be thrown instead. * * @param method The method to call on cache. * @param arguments The parameters. * @return The result of the method invocation. */ private Object invokeCacheMethod(final Method method, final Object[] arguments) { try { return method.invoke(_cache, arguments); } catch (Exception e) { String msg = "Failed to call method on OSCache instance: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(e.getMessage()); } } //-------------------------------------------------------------------------- }
[ "wguttmn@b24b0d9a-6811-0410-802a-946fa971d308" ]
wguttmn@b24b0d9a-6811-0410-802a-946fa971d308
5679f617f114c6a31a3fbe133e8a991df40c6790
2961e7969064e7ad20f7667088c2d3baabc6cdc3
/security-web/src/main/java/com/security/thread/singletion/SingletonEnum.java
575fa1b0157b5419ad2e8149f90437e2cac631a7
[]
no_license
Alan666156/security
dc2e20baefaa21bad00c3a2edf4479b6dbe875d7
4081903747028e7bc7e257af7b7880f17d3a3904
refs/heads/master
2023-06-23T23:28:12.102576
2023-02-21T15:46:05
2023-02-21T15:46:05
64,898,164
0
0
null
2023-06-14T22:42:12
2016-08-04T03:12:04
Java
UTF-8
Java
false
false
954
java
package com.security.thread.singletion; /** * 单例枚举(每个枚举实例都是static final类型的,也就表明只能被实例化一次。在调用构造方法时,我们的单例被实例化; * 也就是说,因为enum中的实例被保证只会被实例化一次,所以我们的INSTANCE也被保证实例化一次) * 默认枚举实例的创建是线程安全的,并且在任何情况下都是单例。实际上枚举类隐藏了私有的构造器, 枚举类的域 是相应类型的一个实例对象 * * @author fuhx */ public enum SingletonEnum { /** * */ INSTANCE; /** * 可以省略此方法,通过Singleton.INSTANCE进行操作 * * @return 单例 */ public static SingletonEnum getInstance() { return SingletonEnum.INSTANCE; } /** * 最终形态枚举访问 */ public void doSomething() { System.out.println("doSomething"); } }
44b031363339fc3d3d96dd3783ecf7f474540a53
44d665cbcb71ea22d2da842736aa8b62a7cc0e12
/src/fuzzy_logic/Rules.java
3e408699983f4eac83f87b609edb39feacc1b29a
[]
no_license
Abdullah-Hany/Fuzzy-Logic
79106d0f303970a5977040b4327bc9da2c73e322
2246b0c1d278825e5730c121157a111b8ddb2b56
refs/heads/master
2020-04-12T00:13:03.894314
2018-12-17T21:38:01
2018-12-17T21:38:01
162,192,885
0
0
null
null
null
null
UTF-8
Java
false
false
592
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package fuzzy_logic; /** * * @author Beido */ public class Rules { String name; double value; public Rules() { } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getValue() { return value; } public void setValue(double value) { this.value = value; } }
cf7bfdd4d111c99640c27e82cee23a5b03eb04ce
dd91670019955817db095b9ff26b4fcbf13107e6
/app/src/main/java/com/anuragsingh5478/notesapp/NoteViewModel.java
8c167b069b3cd0b16c080606c51e8b112db3f1ef
[]
no_license
anuragsingh5478/NotesApp
f6f67a19dd1bd2adae1564c0d02e3d7c2ec22d1d
04902ad08023f3724cd9f8e624b55853768eb603
refs/heads/master
2022-12-16T06:46:59.689919
2020-09-16T06:14:04
2020-09-16T06:14:04
295,419,634
0
0
null
null
null
null
UTF-8
Java
false
false
1,002
java
package com.anuragsingh5478.notesapp; import android.app.Application; import android.content.Context; import androidx.annotation.NonNull; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.ViewModel; import java.util.List; public class NoteViewModel extends AndroidViewModel { private NoteRepository repository; private LiveData<List<Note>> allNotes; public NoteViewModel(@NonNull Application application) { super(application); repository = new NoteRepository(application); allNotes = repository.getAllNotes(); } public void insert(Note note) { repository.insert(note); } public void update(Note note) { repository.update(note); } public void delete(Note note) { repository.delete(note); } public void deleteAllNotes() { repository.deleteAllNotes(); } public LiveData<List<Note>> getAllNotes() { return allNotes; } }