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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13a5568dd0aed1ff240304a036f19daffe693f56 | 37543ec265ffb1aa0b0196a8456dcb5ac21db0e6 | /app/src/main/java/com/example/keephealty/model/register/Register.java | 533c64acb884759d5de25a54f9607f302112443a | [] | no_license | Rajihkharissuha12/KeepHealty | 284472c600bb8863ba0a2676f12b37af33953802 | 57d4b74128345665323da8d0238893a61c8b4cdc | refs/heads/master | 2023-06-27T17:51:36.796212 | 2021-07-16T11:25:49 | 2021-07-16T11:25:49 | 381,573,918 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 680 | java | package com.example.keephealty.model.register;
import com.google.gson.annotations.SerializedName;
public class Register{
@SerializedName("data")
private RegisterData registerData;
@SerializedName("message")
private String message;
@SerializedName("status")
private boolean status;
public void setData(RegisterData registerData){
this.registerData = registerData;
}
public RegisterData getData(){
return registerData;
}
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
return message;
}
public void setStatus(boolean status){
this.status = status;
}
public boolean isStatus(){
return status;
}
} | [
"[email protected]"
] | |
eada2bb0deb5071f93a4d9fdf59106c0e5fbcf10 | aebf066e9b2420e3c7d0915eda4b735a49e8be12 | /src/main/java/com/binay/userdetails/persistence/entity/User.java | 14a8a49408a2bf7a69cdb83b68b7a6b42bed58b7 | [] | no_license | BinayTripathi/UserManager | 42fbd4eb1a538fb76e5d521636c6382e6de636ec | e5b3bed71c3c3f5c007dc8df4370c2813856f7e9 | refs/heads/main | 2022-12-27T05:24:56.679867 | 2020-10-13T02:36:30 | 2020-10-13T02:36:30 | 303,161,048 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,342 | java | package com.binay.userdetails.persistence.entity;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class User implements UserDetails {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue( strategy=GenerationType.AUTO)
Integer userId;
@Enumerated(EnumType.STRING)
Title title;
@Column(name = "first_name")
String firstn;
String lastName;
@Enumerated(EnumType.STRING)
Gender gender;
@OneToOne
Address address;
@NotEmpty
private String userName;
@NotEmpty
private String password;
@ElementCollection(fetch = FetchType.EAGER)
private List<String> roles = new ArrayList<>();
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.roles.stream()
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toList());
}
/*@Override
public String getUsername() {
return String.valueOf(this.userId);
}*/
@Override
public boolean isAccountNonExpired() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isAccountNonLocked() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isCredentialsNonExpired() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isEnabled() {
// TODO Auto-generated method stub
return true;
}
@Override
public String getUsername() {
// TODO Auto-generated method stub
return userName;
}
}
| [
"[email protected]"
] | |
2b89681f06d11d36354d45818ba20ae2c9e746c3 | 8fd1aeffcbcf438289bba5172ae35648ca8120fe | /src/main/java/com/xiwan/NettyGamer/Job/IJob.java | ec7f32d02e485bf80d659509db8f3ecfb0882ccc | [
"MIT"
] | permissive | xiwan/NettyGamer | 6398074e8d513d6c42e8a29f360a58d8c2bc9c24 | 429dcfb93caf8b13cefa915566b5cec97b71abce | refs/heads/master | 2020-05-14T16:32:44.250350 | 2019-05-22T12:08:44 | 2019-05-22T12:08:44 | 181,874,491 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 189 | java | package com.xiwan.NettyGamer.Job;
import java.util.ArrayList;
import java.util.List;
public interface IJob {
public void init();
public void job();
public void shutdown();
}
| [
"[email protected]"
] | |
e38cd0cddd496f987b09e832d40fe3be2a4540e6 | a565137c1de4669226ad057cd336618fdf2481d4 | /src/main/java/com/moon/spring/data/jpa/factory/SqlQueryLookupStrategyCreator.java | 761f6d787e2f4c40bc586f7cfb35b195b404c6c8 | [
"MIT"
] | permissive | moon-util/moon-util | ec58aefa46c526ae11b1a55a946c1763ecb9c693 | 28c5cb418861da4d0a5a035a3de919b86b939c0e | refs/heads/master | 2022-12-25T23:01:28.564115 | 2020-12-17T15:55:52 | 2020-12-17T15:55:52 | 184,226,062 | 8 | 1 | MIT | 2022-12-16T15:29:24 | 2019-04-30T08:46:31 | Java | UTF-8 | Java | false | false | 6,487 | java | package com.moon.spring.data.jpa.factory;
import com.moon.core.lang.ClassUtil;
import com.moon.core.lang.ref.FinalAccessor;
import org.springframework.data.jpa.provider.QueryExtractor;
import org.springframework.data.jpa.repository.query.EscapeCharacter;
import org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy;
import org.springframework.data.jpa.repository.query.JpaQueryMethod;
import org.springframework.data.jpa.repository.query.JpaQueryMethodFactory;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
import javax.persistence.EntityManager;
import java.lang.reflect.Method;
import java.util.Objects;
/**
* @author benshaoye
*/
public class SqlQueryLookupStrategyCreator {
private final static Method CREATOR_METHOD;
private final static CreateStrategy STRATEGY;
static {
Method resultMethod = null;
CreateStrategy resultStrategy = null;
CreateStrategy[] strategies = CreateStrategy.values();
Method[] methods = JpaQueryLookupStrategy.class.getDeclaredMethods();
methods:
for (Method method : methods) {
for (CreateStrategy strategy : strategies) {
if (strategy.isLoadSuccessful(method.getName(), method.getParameterTypes())) {
resultStrategy = strategy;
resultMethod = method;
break methods;
}
}
}
STRATEGY = Objects.requireNonNull(resultStrategy);
CREATOR_METHOD = Objects.requireNonNull(resultMethod);
}
static QueryLookupStrategy create(
EntityManager em,
QueryLookupStrategy.Key key,
QueryExtractor extractor,
QueryMethodEvaluationContextProvider provider,
EscapeCharacter escape
) {
try {
return (QueryLookupStrategy) CREATOR_METHOD.invoke(null,
STRATEGY.transform(em, key, extractor, provider, escape));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("all")
private static enum CreateStrategy {
OLD(FinalAccessor.of("create"),
"javax.persistence.EntityManager",
"org.springframework.data.repository.query.QueryLookupStrategy$Key",
"org.springframework.data.jpa.provider.QueryExtractor",
"org.springframework.data.repository.query.QueryMethodEvaluationContextProvider",
"org.springframework.data.jpa.repository.query.EscapeCharacter") {
@Override
Object[] transform(
EntityManager em,
QueryLookupStrategy.Key key,
QueryExtractor extractor,
QueryMethodEvaluationContextProvider provider,
EscapeCharacter escape
) { return toObjects(em, key, extractor, provider, escape); }
},
NEW(FinalAccessor.of("create"),
"javax.persistence.EntityManager",
"org.springframework.data.jpa.repository.query.JpaQueryMethodFactory",
"org.springframework.data.repository.query.QueryLookupStrategy$Key",
"org.springframework.data.repository.query.QueryMethodEvaluationContextProvider",
"org.springframework.data.jpa.repository.query.EscapeCharacter") {
@Override
Object[] transform(
EntityManager em,
QueryLookupStrategy.Key key,
QueryExtractor extractor,
QueryMethodEvaluationContextProvider provider,
EscapeCharacter escape
) {
return toObjects(em, new MoonJpaQueryMethodFactory(extractor), key, provider, escape);
}
},
;
final String methodName;
final Class[] classes;
final boolean loadSuccessful;
CreateStrategy(FinalAccessor<String> method, String... parametersType) {
this.methodName = method.get();
boolean successful = true;
Class[] classArr = new Class[parametersType.length];
for (int i = 0; i < parametersType.length; i++) {
Class type = ClassUtil.forNameOrNull(parametersType[i]);
if (type == null) {
successful = false;
classArr = null;
break;
} else {
classArr[i] = type;
}
}
this.classes = classArr;
this.loadSuccessful = successful;
}
abstract Object[] transform(
EntityManager em,
QueryLookupStrategy.Key key,
QueryExtractor extractor,
QueryMethodEvaluationContextProvider provider,
EscapeCharacter escape
);
static Object[] toObjects(Object... objects) { return objects; }
public boolean isLoadSuccessful(String methodName, Class... types) {
if (loadSuccessful && Objects.equals(methodName, this.methodName)) {
if (types != null && types.length == classes.length) {
for (int i = 0; i < types.length; i++) {
if (types[i] != classes[i]) {
return false;
}
}
return true;
}
}
return false;
}
}
private static final class MoonJpaQueryMethodFactory implements JpaQueryMethodFactory {
private final QueryExtractor extractor;
public MoonJpaQueryMethodFactory(QueryExtractor extractor) {
Objects.requireNonNull(extractor, "QueryExtractor must not be null");
this.extractor = extractor;
}
@Override
public JpaQueryMethod build(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
return new MoonJpaQueryMethod(method, metadata, factory, this.extractor);
}
}
private static final class MoonJpaQueryMethod extends JpaQueryMethod {
protected MoonJpaQueryMethod(
Method method, RepositoryMetadata metadata, ProjectionFactory factory, QueryExtractor extractor
) { super(method, metadata, factory, extractor); }
}
}
| [
"[email protected]"
] | |
168abf530bfb17d82af12295bae476b0e4f5d041 | b9aeca822e976296c241a90ae06c9361267d0cb6 | /test/org/nutz/mvc/testapp/classes/action/CommonTest.java | 0123f3f4a89fa9d77e972fa33bbb3bdce9a8791c | [
"Apache-2.0"
] | permissive | nutzam/nutz | 8bf0357da1a959330eac815ecf37ccd43e991268 | 17c2dbc97e705b9ea670a16bbebbaf63faf7bf2d | refs/heads/master | 2023-08-31T19:27:51.325161 | 2023-06-08T02:26:44 | 2023-06-08T02:26:44 | 1,873,881 | 2,367 | 930 | Apache-2.0 | 2023-07-07T21:38:17 | 2011-06-10T01:25:43 | Java | UTF-8 | Java | false | false | 3,171 | java | package org.nutz.mvc.testapp.classes.action;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.nutz.ioc.annotation.InjectName;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.DELETE;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.testapp.BaseWebappTest;
import org.nutz.mvc.testapp.classes.bean.UserT;
@InjectName
@IocBean
@At("/common")
@Ok("raw")
public class CommonTest extends BaseWebappTest {
//最最基本的测试
@At("/pathArgs/*")
public String test_base_pathargs(String name){
return name;
}
//基本测试1
@At("/pathArgs2/*")
public String test_base_pathargs2(String name,
int id,
long pid,
short fid,
double xid,
float yid,
boolean z,
char p){
return name + id + pid + fid + (int)xid + (int)yid + z + p;
}
//含?和*
@At("/pathArgs3/?/blog/*")
public String test_base_pathargs3(String type,long id){
return type + "&" +id;
}
//含? 与方法test_base_pathargs3比对,
@At("/pathArgs3/?")
public String test_base_pathargs3_2(String type){
return type + "&Z";
}
//与Parms混用
@At("/pathArgs4/*")
public String test_base_pathargs4(String key,@Param("..")UserT userT){
return key+"&"+userT.getName();
}
//与Parms混用
@At("/pathArgs5/*")
public String test_base_pathargs5(String key,
@Param("::user.")UserT user1,
@Param("::user2.")UserT user2){
return key+"&"+user1.getName()+"&"+user2.getName();
}
//Parms混用
@At("/param")
public String test_param(@Param("id") long id){
return ""+id;
}
//Parms混用
@At("/path")
@Ok(">>:/${key}.jsp")
public void test_req_param(){
}
//Test EL
@At("/path2")
@Ok("->:/${key.length() == 1 ? 'base' : 'false'}.jsp")
public void test_req_param2(){
}
//Test 测试获取Servlet的对象
@At("/servlet_obj")
@Ok("http:200")
public void test_servlet_obj(HttpServletRequest req,
HttpServletResponse resp,
ServletContext context,
HttpSession session) throws Throwable {
req.getInputStream();
req.getContentLength();
//resp.getOutputStream();
resp.getWriter();
session.getId();
session.isNew();
context.getAttributeNames();
}
@At
@DELETE
@Ok("raw")
public String httpmethods() {
return "DELETE";
}
}
| [
"[email protected]"
] | |
f3556385ec40610aa97743e630b9a20c2df55422 | 7bb847d4fd72e7946b676b62539d00246d35018c | /src/org/astm/ccr/EncounterType.java | b5c963146af569a13ba686237645e90f7d9c06d4 | [] | no_license | cclamb/usage.management.medical | acfadc8475a7ef01303434f7e40f111da286141f | 607a231623698a3d6c612d7f8bc75f6296fdd0b3 | refs/heads/master | 2020-12-24T17:26:39.064286 | 2010-10-11T00:01:47 | 2010-10-11T00:01:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,157 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2010.05.11 at 08:32:25 PM MDT
//
package org.astm.ccr;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for EncounterType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="EncounterType">
* <complexContent>
* <extension base="{urn:astm-org:CCR}CCRCodedDataObjectType">
* <sequence>
* <element ref="{urn:astm-org:CCR}Locations" minOccurs="0"/>
* <element ref="{urn:astm-org:CCR}Practitioners" minOccurs="0"/>
* <element name="Frequency" type="{urn:astm-org:CCR}FrequencyType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="Interval" type="{urn:astm-org:CCR}IntervalType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="Duration" type="{urn:astm-org:CCR}DurationType" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:astm-org:CCR}Indications" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:astm-org:CCR}Instructions" minOccurs="0"/>
* <element name="Consent" type="{urn:astm-org:CCR}CCRCodedDataObjectType" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EncounterType", propOrder = {
"locations",
"practitioners",
"frequency",
"interval",
"duration",
"indications",
"instructions",
"consent"
})
@XmlSeeAlso({
GoalType.class
})
public class EncounterType
extends CCRCodedDataObjectType
{
@XmlElement(name = "Locations")
protected Locations locations;
@XmlElement(name = "Practitioners")
protected Practitioners practitioners;
@XmlElement(name = "Frequency")
protected List<FrequencyType> frequency;
@XmlElement(name = "Interval")
protected List<IntervalType> interval;
@XmlElement(name = "Duration")
protected List<DurationType> duration;
@XmlElement(name = "Indications")
protected List<Indications> indications;
@XmlElement(name = "Instructions")
protected Instructions instructions;
@XmlElement(name = "Consent")
protected CCRCodedDataObjectType consent;
/**
* Gets the value of the locations property.
*
* @return
* possible object is
* {@link Locations }
*
*/
public Locations getLocations() {
return locations;
}
/**
* Sets the value of the locations property.
*
* @param value
* allowed object is
* {@link Locations }
*
*/
public void setLocations(Locations value) {
this.locations = value;
}
/**
* Gets the value of the practitioners property.
*
* @return
* possible object is
* {@link Practitioners }
*
*/
public Practitioners getPractitioners() {
return practitioners;
}
/**
* Sets the value of the practitioners property.
*
* @param value
* allowed object is
* {@link Practitioners }
*
*/
public void setPractitioners(Practitioners value) {
this.practitioners = value;
}
/**
* Gets the value of the frequency property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the frequency property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFrequency().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link FrequencyType }
*
*
*/
public List<FrequencyType> getFrequency() {
if (frequency == null) {
frequency = new ArrayList<FrequencyType>();
}
return this.frequency;
}
/**
* Gets the value of the interval property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the interval property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getInterval().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link IntervalType }
*
*
*/
public List<IntervalType> getInterval() {
if (interval == null) {
interval = new ArrayList<IntervalType>();
}
return this.interval;
}
/**
* Gets the value of the duration property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the duration property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getDuration().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link DurationType }
*
*
*/
public List<DurationType> getDuration() {
if (duration == null) {
duration = new ArrayList<DurationType>();
}
return this.duration;
}
/**
* Gets the value of the indications property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the indications property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getIndications().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Indications }
*
*
*/
public List<Indications> getIndications() {
if (indications == null) {
indications = new ArrayList<Indications>();
}
return this.indications;
}
/**
* Gets the value of the instructions property.
*
* @return
* possible object is
* {@link Instructions }
*
*/
public Instructions getInstructions() {
return instructions;
}
/**
* Sets the value of the instructions property.
*
* @param value
* allowed object is
* {@link Instructions }
*
*/
public void setInstructions(Instructions value) {
this.instructions = value;
}
/**
* Gets the value of the consent property.
*
* @return
* possible object is
* {@link CCRCodedDataObjectType }
*
*/
public CCRCodedDataObjectType getConsent() {
return consent;
}
/**
* Sets the value of the consent property.
*
* @param value
* allowed object is
* {@link CCRCodedDataObjectType }
*
*/
public void setConsent(CCRCodedDataObjectType value) {
this.consent = value;
}
}
| [
"[email protected]"
] | |
78736b5a49b1336d5ce320c20a9acf0e94d558f6 | 3ee36a59ae67f3918c1d5507938f1c9a39287a85 | /src/FormListener.java | 0bd21faae437d6a0df8b0dde5b718d01dbb237a7 | [] | no_license | RuiJu1998/MovieCollection | 3d59f4a1be7c6414c5d422c5b68f4e4024cc292e | 737d5037d9d96a7a407ffd0e67a5a78d01ae52c9 | refs/heads/master | 2020-04-16T18:39:59.252257 | 2019-01-16T01:22:14 | 2019-01-16T01:22:14 | 165,830,190 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 135 | java | import java.util.EventListener;
public interface FormListener extends EventListener {
public void formEventOccurred(FormEvent e);
}
| [
"[email protected]"
] | |
2b605e6835739ea7b9d16fecf7dbe4d1ad93c741 | 1091bfb810ad7513a23d832c4ea6d10ea51775c3 | /CH14-SQLite/1412_SQliteDBHper(Final)/src/main/java/tw/tcnr21/m1405/M1405update.java | afce1b6cd399f2889d382b1e1c1438490c3662e2 | [
"MIT"
] | permissive | sars12349/Android-work-newest | 0b0debd06b3fde6e5e6f667d99dcf82cb1ba89a1 | c5580137dd24bbe8173b8a1e6653c607c88870d6 | refs/heads/master | 2020-04-18T06:30:18.130033 | 2019-03-14T08:47:57 | 2019-03-14T08:47:57 | 167,323,689 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,379 | java | package tw.tcnr21.m1405;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class M1405update extends AppCompatActivity implements View.OnClickListener {
private TextView count_t;
private Button b001, b002, b003, b004;
private EditText e001, e002, e003, e004;
private FriendDbHelper dbHper;
private static final String DB_FILE = "friends.db";
private static final String DB_TABLE = "member";
private static final int DBversion = 1;
private TextView tvTitle;
private Button btNext, btPrev,btTop,btEnd,btEdit,btDel;
private ArrayList<String> recSet;
private int index = 0;
String msg = null;
private String TAG="tcnr21=>";
private float x1;
private float y1;
private float x2;
private float y2;
private float range=50;
private int ran=60;
private EditText b_edid;
private String tid,tname,tgrp,taddr;
private int rowsAffected;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.m1405_update);
setupViewComponent();
// initDB();
// count_t.setText("共計:" + Integer.toString(dbHper.RecCount()) + "筆");
}
private void setupViewComponent() {
tvTitle = (TextView) findViewById(R.id.tvIdTitle);
e001 = (EditText) findViewById(R.id.edtName);
e002 = (EditText) findViewById(R.id.edtGrp);
e003 = (EditText) findViewById(R.id.edtAddr);
count_t = (TextView) findViewById(R.id.count_t);
btNext = (Button) findViewById(R.id.btIdNext);
btPrev = (Button) findViewById(R.id.btIdPrev);
btTop = (Button) findViewById(R.id.btIdtop);
btEnd = (Button) findViewById(R.id.btIdend);
btEdit = (Button) findViewById(R.id.btnupdate);
btDel = (Button) findViewById(R.id.btIdDel);
b_edid = (EditText) findViewById(R.id.edid);
btNext.setOnClickListener(this);
btPrev.setOnClickListener(this);
btTop.setOnClickListener(this);
btEnd.setOnClickListener(this);
btEdit.setOnClickListener(this);
btDel.setOnClickListener(this);
initDB();
count_t.setText("共計:" + Integer.toString(dbHper.RecCount()) + "筆");
showRec(index);
}
private void showRec(int index) {
if (recSet.size() != 0) {
String stHead = "顯示資料:第 " + (index + 1) + " 筆 / 共 " + recSet.size() + " 筆";
tvTitle.setTextColor(ContextCompat.getColor(this, R.color.Blue));
tvTitle.setText(stHead);
//--------------------------
String[] fld = recSet.get(index).split("#");
b_edid.setTextColor(ContextCompat.getColor(this,R.color.Red));
b_edid.setBackgroundColor(ContextCompat.getColor(this,R.color.Yellow));
b_edid.setText(fld[0]);
e001.setTextColor(ContextCompat.getColor(this, R.color.Red));
e001.setText(fld[1]);
e002.setText(fld[2]);
e003.setText(fld[3]);
//---------------------
} else {
e001.setText("");
e002.setText("");
e003.setText("");
}
}
private void initDB() {
if (dbHper == null)
dbHper = new FriendDbHelper(this, DB_FILE, null, DBversion);
recSet=dbHper.getRecSet();
}
@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.btIdNext:
ctlNext();
break;
case R.id.btIdPrev:
ctlPrev();
break;
case R.id.btIdtop:
ctlFirst();
break;
case R.id.btIdend:
ctlLast();
break;
case R.id.btnupdate:
tid = b_edid.getText().toString().trim();
tname = e001.getText().toString().trim();
tgrp = e002.getText().toString().trim();
taddr = e003.getText().toString().trim();
rowsAffected = dbHper.updateRec(tid, tname, tgrp, taddr);//傳回修改筆數
if (rowsAffected == -1) {
msg = "資料表已空, 無法修改 !";
} else if (rowsAffected == 0) {
msg = "找不到欲修改的記錄, 無法修改 !";
} else {
msg = "第 " + (index + 1) + " 筆記錄 已修改 ! \n" + "共 " + rowsAffected + " 筆記錄 被修改 !";
recSet = dbHper.getRecSet();
showRec(index);
}
Toast.makeText(M1405update.this, msg, Toast.LENGTH_SHORT).show();
break;
case R.id.btIdDel:
// 刪除資料
tid = b_edid.getText().toString().trim();
rowsAffected = dbHper.deleteRec(tid);
if (rowsAffected == -1) {
msg = "資料表已空, 無法刪除 !";
} else if (rowsAffected == 0) {
msg = "找不到欲刪除的記錄, 無法刪除 !";
} else {
msg = "第 " + (index + 1) + " 筆記錄 已刪除 ! \n" + "共 " + rowsAffected + " 筆記錄 被刪除 !";
recSet = dbHper.getRecSet();
if(index==dbHper.RecCount()){
index --;
}
showRec(index); //重構
}
Toast.makeText(M1405update.this, msg, Toast.LENGTH_SHORT).show();
break;
}
}
//------------------------------------------------
private void ctlFirst() {
// 第一筆
index = 0;
showRec(index);
}
private void ctlPrev() {
// 上一筆
index--;
if (index < 0)
index = recSet.size() - 1;
showRec(index);
}
private void ctlNext() {
// 下一筆
index++;
if (index >= recSet.size())
index = 0;
showRec(index);
}
private void ctlLast() {
// 最後一筆
index = recSet.size() - 1;
showRec(index);
}
@Override
protected void onPause() {
super.onPause();
if (dbHper != null)
{
dbHper.close();
dbHper = null;
}
}
@Override
protected void onResume() {
super.onResume();
if (dbHper == null)
dbHper = new FriendDbHelper(this, DB_FILE, null, DBversion);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
x1 = event.getX(); // 觸控按下的 X 軸位置
y1 = event.getY(); // 觸控按下的 Y 軸位置
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
x2=event.getX();
y2=event.getY();
// 判斷左右的方法,因為屏幕的左上角是:0,0 點右下角是max,max
// 並且移動距離需大於 > range
float xbar = Math.abs(x2 - x1);
float ybar = Math.abs(y2 - y1);
double z = Math.sqrt(xbar * xbar + ybar * ybar);
int angle = Math.round((float) (Math.asin(ybar / z) / Math.PI * 180));// 角度
if (x1 != 0 && y1 != 0) {
if (x1 - x2 > range) { // 向左滑動
ctlPrev();
}
if (x2 - x1 > range) { // 向右滑動
ctlNext();
// t001.setText("向右滑動\n" + "滑動參值x1=" + x1 + " x2=" + x2 + "
// r=" + (x2 - x1)+"\n"+"ang="+angle);
}
if (y2 - y1 > range && angle > ran) { // 向下滑動
// 往下角度需大於50
// 最後一筆
ctlLast();
}
if (y1 - y2 > range && angle > ran) { // 向上滑動
// 往上角度需大於50
ctlFirst();// 第一筆
}
}
break;
}
return super.onTouchEvent(event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.m1405sub, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.m_return) finish();
return true;
}
}
| [
"[email protected]"
] | |
35302a39ff25d03f2f53db27f242063420331a21 | 8637757c7f2e49e4d67bc5295ee4e9d991382c1b | /src/main/java/zm/hashcode/mshengu/repository/ui/demographics/GenderRepository.java | 594d467a988fa897f492be68b9a4a19fc20a7302 | [] | no_license | smkumatela/mshengu | 63ee88e9bd91c961d6e453f802f76a2020b0a9e5 | 8528538b8c75b4298b467787bc0f624117e03354 | refs/heads/master | 2020-12-31T03:26:47.493050 | 2015-03-17T14:29:54 | 2015-03-17T14:29:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 451 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package zm.hashcode.mshengu.repository.ui.demographics;
import java.util.List;
import java.util.Set;
import org.springframework.data.repository.PagingAndSortingRepository;
import zm.hashcode.mshengu.domain.ui.demographics.Gender;
/**
*
* @author lucky
*/
public interface GenderRepository extends PagingAndSortingRepository<Gender, String>{
}
| [
"[email protected]"
] | |
60fa667d9cba5ef630f00489791fcf1de5da2625 | f42be70f9037f7b9d6a8c41b972e7d6af3183451 | /dynamodb-spring-boot-core/src/main/java/com/github/wonwoo/dynamodb/repository/DynamoDBRepositoryFactory.java | 29c5eaccd0d87c584be96b6c0e3953d77ba45f32 | [
"Apache-2.0"
] | permissive | PioneerlabsOrg/dynamodb-spring-boot | 0ccd4382808b4973952817acbe8cc4e936370353 | c1d4cd4a384473fdc79941c596435fca848efe70 | refs/heads/master | 2020-03-28T21:32:05.487184 | 2018-09-19T12:15:00 | 2018-09-19T12:15:00 | 149,163,718 | 0 | 0 | Apache-2.0 | 2018-09-17T17:38:13 | 2018-09-17T17:38:13 | null | UTF-8 | Java | false | false | 1,554 | java | /*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.wonwoo.dynamodb.repository;
import org.socialsignin.spring.data.dynamodb.core.DynamoDBOperations;
import org.springframework.data.repository.core.RepositoryMetadata;
import java.io.Serializable;
/**
* @author wonwoo
*/
public class DynamoDBRepositoryFactory extends org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory {
private final DynamoDBOperations dynamoDBOperations;
public DynamoDBRepositoryFactory(DynamoDBOperations dynamoDBOperations) {
super(dynamoDBOperations);
this.dynamoDBOperations = dynamoDBOperations;
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected <T, ID extends Serializable> DynamoDBRepository<?, ?> getDynamoDBRepository(
RepositoryMetadata metadata) {
return new SimpleDynamoDBRepository(getEntityInformation(metadata.getDomainType()),
dynamoDBOperations, getEnableScanPermissions(metadata));
}
} | [
"[email protected]"
] | |
1655a538d2042717add643918af1a50c80d04f12 | de58f3607b567eed507251d4060648a53d6f37e7 | /2.JavaCore/src/com/javarush/task/task15/task1516/Solution.java | 75a48b15117330176c40352d06b872a06bec087e | [] | no_license | sorrelcat/javarush | f984ec782095e7608114ea7f52c65cd6a21264c2 | 13a0c8638ec95269eb9c281843cda27e976f7d9f | refs/heads/master | 2021-07-19T18:25:14.809877 | 2017-10-25T18:03:00 | 2017-10-25T18:03:00 | 105,542,130 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 710 | java | package com.javarush.task.task15.task1516;
/*
Значения по умолчанию
*/
public class Solution {
public static void main(String[] args) {
Solution s = new Solution();
System.out.println(s.intVar);
System.out.println(s.doubleVar);
System.out.println(s.DoubleVar);
System.out.println(s.booleanVar);
System.out.println(s.ObjectVar);
System.out.println(s.ExceptionVar);
System.out.println(s.StringVar);
}
public int intVar;
public double doubleVar;
public Double DoubleVar;
public boolean booleanVar;
public Object ObjectVar;
public Exception ExceptionVar;
public String StringVar;
}
| [
"[email protected]"
] | |
9a33e18f9526d61bde4ac2c8a2983d060ac5979e | 6acc198889ba65d3900dfe7e4adeaf9b99bbd816 | /src/main/java/com/core/ssm/dao/IUserDao.java | 1f1fd6519e2574eee309ca3d13913e69977df2a7 | [] | no_license | f1ashine/SpringMVC-MybatisDemo | 33177170700fca0c617d38da4cd5926487de0087 | 8e99fdcdf7c0f4f7a3b9dbe635a2c6461d1bee83 | refs/heads/master | 2021-07-04T12:34:25.238677 | 2017-09-27T01:12:08 | 2017-09-27T01:12:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 144 | java | package com.core.ssm.dao;
import java.util.Map;
public interface IUserDao {
Map<String,Object> getUserById(Map<String,Object> map);
}
| [
"[email protected]"
] | |
1201c01ad8cf6bd69255c6e821808da6ce161bec | 9ed58ddd48f28abe752d3a6a714c33c2455c7358 | /src/main/java/br/com/felipe/exception/RssException.java | 70f1cca310610652793d8757a2fdc78df4eb0437 | [] | no_license | felipewom-zz/JavaBlogFeedBurner | 20e7a65153c1aa509ce275e69b759f84afb29db3 | ac7c7302c7a844361cf8aa58cbd4fb0d32df7d9e | refs/heads/master | 2022-03-10T20:16:45.621276 | 2015-01-15T16:06:08 | 2015-01-15T16:06:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 152 | java | package br.com.felipe.exception;
public class RssException extends Exception{
public RssException(Throwable cause) {
super(cause);
}
}
| [
"[email protected]"
] | |
6492c9aa27e1f2680e8025fc8ca758a61c523dd7 | b61a8ce87a27a325dba024f3d0fc67fb596fd291 | /0718/src/RadioButton/RadioBtn.java | f5983e7a0b083d2c1c84faf4417c54906186a400 | [] | no_license | sagek23/Java-Training | df8b7003b2d791f99c195433f61685a3ded3988a | 015e3dfffb10e3665960a71203cfcf37783048df | refs/heads/master | 2022-07-12T06:42:13.632644 | 2019-10-31T00:36:09 | 2019-10-31T00:36:09 | 218,571,922 | 0 | 0 | null | 2022-06-22T20:06:54 | 2019-10-30T16:24:33 | Java | UHC | Java | false | false | 2,809 | java | package RadioButton;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class RadioBtn extends JFrame{
JLabel jb;
ImageIcon icon1;
ImageIcon icon2;
ImageIcon icon3;
ImageIcon icon4;
ImageIcon icon5;
ButtonGroup group;
public RadioBtn() {
JRadioButton animal [] = new JRadioButton[5];
setLayout(new BorderLayout());
icon1 = new ImageIcon("cat.png");
icon2 = new ImageIcon("dog.png");
icon3 = new ImageIcon("tiger.png");
icon4 = new ImageIcon("wolf.png");
icon5 = new ImageIcon("jaguar.png");
group = new ButtonGroup();
jb = new JLabel(icon1);
setVisible(true);
setSize(800, 800);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
animal[0] = new JRadioButton("고양이");
animal[1] = new JRadioButton("강아지");
animal[2] = new JRadioButton("호랑이");
animal[3] = new JRadioButton("늑대");
animal[4] = new JRadioButton("재규어");
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
animal[0].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
jb.setIcon(icon1);
}
});
animal[1].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
jb.setIcon(icon2);
}
});
animal[2].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
jb.setIcon(icon3);
}
});
animal[3].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
jb.setIcon(icon4);
}
});
animal[4].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
jb.setIcon(icon5);
}
});
for(JRadioButton rb : animal)
{
try {
group.add(rb);
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
JPanel jp = new JPanel();
jp.add(animal[0]);
jp.add(animal[1]);
jp.add(animal[2]);
jp.add(animal[3]);
jp.add(animal[4]);
jp.setLayout(new FlowLayout());
add(jp, BorderLayout.NORTH);
add(jb, BorderLayout.CENTER);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new RadioBtn();
}
}
| [
"[email protected]"
] | |
8bce17e0cdac2887c257e82ac6d81b56871ef067 | 056324a979107168014f8e8a01e2bd6b220c4059 | /app/src/main/java/de/davidartmann/android/rosa2/util/eventbus/event/ArchiveDialogConfirmedEvent.java | 5ed6b8f2f7ebd1f312cdde932772da9301cf11c9 | [] | no_license | dartmann/Rosa-2.0 | 17a2bc9835498c0695ac8a9b8695c54e5a40d186 | 97529dc7b67f7f8a85578453c737eb11039eab5e | refs/heads/master | 2020-12-24T13:08:08.794182 | 2017-04-04T18:49:00 | 2017-04-04T18:49:00 | 66,391,161 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 270 | java | package de.davidartmann.android.rosa2.util.eventbus.event;
/**
* Event class for the confirmation of the cancel dialog of
* {@link de.davidartmann.android.rosa2.activity.EditActivity}.
* Created by david on 05.10.16.
*/
public class ArchiveDialogConfirmedEvent {
}
| [
"[email protected]"
] | |
a89cf08c31bcf5389e6dc7206684860e6f80c538 | 7e41fc008bb1ad28cc0aaf03dbaadb5b0e2e6b16 | /src/test/java/com/woloszunwojciech/spring5recipeapp/services/ImageServiceImplTest.java | 9823d16061ed68b575f57e5c8e8892f4e1e5b708 | [] | no_license | woyteq1/abcd | 0b61afcc77a443ead5925ab0ccf9c911bf6494c5 | 7caaf45fb7286415c281b7ca0747807c0dacd3c0 | refs/heads/master | 2020-03-29T05:53:15.958015 | 2018-09-20T11:41:05 | 2018-09-20T11:41:05 | 149,600,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,812 | java | package com.woloszunwojciech.spring5recipeapp.services;
import com.woloszunwojciech.spring5recipeapp.domain.Recipe;
import com.woloszunwojciech.spring5recipeapp.repositories.RecipeRepository;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.util.Optional;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class ImageServiceImplTest {
@Mock
RecipeRepository recipeRepository;
ImageService imageService;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
imageService = new ImageServiceImpl(recipeRepository);
}
@Test
public void saveImageFile() throws Exception {
//given
Long id = 1L;
MultipartFile multipartFile = new MockMultipartFile("imagefile","testing.txt","text/plain","Wojciech Woloszun App".getBytes());
Recipe recipe=new Recipe();
recipe.setId(id);
Optional<Recipe>recipeOptional =Optional.of(recipe);
when(recipeRepository.findById(anyLong())).thenReturn(recipeOptional);
ArgumentCaptor<Recipe>argumentCaptor = ArgumentCaptor.forClass(Recipe.class);
//when
imageService.saveImageFile(id,multipartFile);
//then
verify(recipeRepository,times(1)).save(argumentCaptor.capture());
Recipe savedRecipe = argumentCaptor.getValue();
assertEquals(multipartFile.getBytes().length,savedRecipe.getImage().length);
}
} | [
"[email protected]"
] | |
c963d5944786a1705a133088193bf3624b3276cf | 7587495be51cde3a96a356c3eaf967799b43a7d0 | /src/main/java/Logic/Builder/LastFloorBuilder.java | e04bcfdd8de4ca7cfb230831db5163f6dae6c465 | [] | no_license | Lemetr/Lift | 9e45a6ed972b5670760d6bad73f65f0ae632d65e | 41b7fff6ab942c38407cd6e5744218c3abdd52f9 | refs/heads/master | 2022-11-30T11:13:54.719816 | 2020-08-24T10:51:56 | 2020-08-24T10:51:56 | 289,901,526 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,043 | java | package Logic.Builder;
import Constants.Constants;
import Interfaces.IButton;
import Interfaces.IFloor;
import Interfaces.IFloorBuilder;
import Interfaces.IPassenger;
import Models.Floors.FloorImpl;
import Models.Passengers.Passenger;
import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
public class LastFloorBuilder implements IFloorBuilder {
private FloorImpl f;
@Override
public void reset(int location, IButton button) {
f = new FloorImpl(location, button);
}
@Override
public void createPassengers(int location, int floorsNumber, Random r) {
Queue<IPassenger> floorPassengers = new ArrayDeque<>();
for (int j = 0; j < r.nextInt(Constants.MaxPASSENGERS + 1); j++) {
int destination = r.nextInt(floorsNumber);
floorPassengers.add(new Passenger(location, destination));
}
f.setFloorPassengers(floorPassengers);
}
@Override
public IFloor getResult() {
return f;
}
}
| [
"[email protected]"
] | |
89c0faf3ac6783cf45443faaaf52f1146887251b | 37cd0aff4e47f55090ced97e3f34f6d146b63edb | /app/src/main/java/com/dnbitstudio/londoncycles/utils/Utils.java | 8e05a75961295cbae13c6aefbf1fbf8a5a5a5182 | [] | no_license | dnbit/LondonCycles | ff5e3eecc3595a5094413951e3cc366ca971308d | e3764d5c55421f64822b9e65184c59d394215450 | refs/heads/master | 2020-08-03T16:53:17.941630 | 2016-12-20T23:09:36 | 2016-12-20T23:09:36 | 73,541,068 | 1 | 0 | null | 2016-12-20T23:09:37 | 2016-11-12T08:28:21 | null | UTF-8 | Java | false | false | 5,157 | java | package com.dnbitstudio.londoncycles.utils;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.dnbitstudio.londoncycles.R;
import com.dnbitstudio.londoncycles.ui.BaseLocationActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatDrawableManager;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import static android.content.Context.MODE_PRIVATE;
public class Utils {
public static boolean isNetworkConnected(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnected();
}
public static void isGPSEnabled(Context context) {
final LocationManager manager =
(LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
buildAlertMessageNoGps(context);
}
}
private static void buildAlertMessageNoGps(final Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("Your GPS seems to be disabled, do you want to enable it?")
.setCancelable(false)
.setPositiveButton(R.string.button_gps_alert_yes, new DialogInterface.OnClickListener() {
public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
context.startActivity(new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
})
.setNegativeButton(R.string.button_gps_alert_no, new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
dialog.cancel();
}
});
final AlertDialog alert = builder.create();
alert.show();
}
public static String loadMockedBikePoints(Context context) {
return loadJSONFromAsset(context, "mokedBikePoints.json");
}
private static String loadJSONFromAsset(Context context, String fileName) {
String json;
try {
InputStream is = context.getAssets().open(fileName);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
Log.d("loadJSONFromAsset", ex.getMessage());
return null;
}
return json;
}
public static void saveLatLonInSharedPreferences(Context context,
double latitude, double longitude) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
BaseLocationActivity.LOCATION_SHARED_PREFERENCES, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(BaseLocationActivity.KEY_LATITUDE, String.valueOf(latitude));
editor.putString(BaseLocationActivity.KEY_LONGITUDE, String.valueOf(longitude));
editor.apply();
}
private static Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate();
}
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
public static Intent generateNavigationIntent(double lat, double lon) {
String uriString = "http://maps.google.com/maps?daddr=" + lat + "," + lon;
return new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
}
public static BitmapDescriptor loadMarkerIcon(Context context) {
Bitmap iconBitmap = Utils
.getBitmapFromVectorDrawable(context, R.drawable.ic_current_position_map_marker);
return BitmapDescriptorFactory.fromBitmap(iconBitmap);
}
} | [
"[email protected]"
] | |
923dd9b603b4f6aca9855451b2c57c603428e02c | d9359f0929e13cb92181173f850473a98defc13e | /src/filters/pmp/pipes/RemotePipeProxy.java | 7527196f721f5def7ffd21abd715ccd5c717260a | [] | no_license | elisabethgombkoto/BeanBoxIntelliJ | 9c0f0e2484307044c1334069e11d066a5a27fd59 | 77db15f34f2cd3432f9da10ab1771fe2a8b564f3 | refs/heads/master | 2021-08-18T19:57:43.509672 | 2017-11-23T18:02:43 | 2017-11-23T18:02:43 | 110,537,993 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,230 | java | package filters.pmp.pipes;
import java.io.StreamCorruptedException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import filters.pmp.interfaces.IOable;
public class RemotePipeProxy<T> implements IOable<T, T>{
RemoteIOable<T> m_RemotePipe = null;
public RemotePipeProxy(String remoteAdr, String remotePipeName) throws StreamCorruptedException {
if (!remoteAdr.endsWith("/")) remoteAdr += "/";
try {
m_RemotePipe = (RemoteIOable)Naming.lookup("rmi://" + remoteAdr + remotePipeName);
} catch (Exception e) {
// TODO Automatisch erstellter Catch-Block
e.printStackTrace();
}
}
public T read() throws StreamCorruptedException {
try {
return m_RemotePipe.read();
} catch (RemoteException e) {
throw new StreamCorruptedException(e.getMessage());
}
}
public void write(T value) throws StreamCorruptedException {
try {
m_RemotePipe.write(value);
} catch (RemoteException e) {
throw new StreamCorruptedException(e.getMessage());
}
}
}
| [
"[email protected]"
] | |
5ded132d4a5bbbb4ccfe98b5e5e3d202fb880dcb | 48dd26d7c8356eddada078c5dc01f68c546fe489 | /src/main/java/org/sid/dao/ProjectionFilmRepository.java | 98d18a396b1e8decdffb9d3bca36cfd2da708a19 | [] | no_license | RAJAA1234/App-web-Gestion-des-cinemas-JEE-PartieFrontend-Thymleaf | 9547577094b50e21585a94df1b60049952365fff | 39a1d61f1aadd046d802b105d0c4dc4e4b559d90 | refs/heads/master | 2023-04-14T14:20:51.269598 | 2020-07-09T17:25:04 | 2020-07-09T17:25:04 | 278,425,683 | 1 | 0 | null | 2021-04-26T20:28:01 | 2020-07-09T17:14:33 | Java | UTF-8 | Java | false | false | 796 | java | package org.sid.dao;
import org.sid.entite.ProjectionFilm;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.CrossOrigin;
@CrossOrigin("*")
public interface ProjectionFilmRepository extends JpaRepository<ProjectionFilm, Long> {
public Page<ProjectionFilm> findByprixContains(String mc, PageRequest of);
@Query("select p from ProjectionFilm p where p.film.id = :idf")
public Page<ProjectionFilm> Projectionparfilm(@Param ("idf")Long id, Pageable pageable);
} | [
"[email protected]"
] | |
0680c86c829d2812148c4ef70e78236488fcf2ed | 221fac1821481bab67beb76400dc4073ea83e191 | /src/main.java | 759415b823958c9c60135eda3fc15e9b7bc2afb5 | [] | no_license | pinonclement/GrapheVoyageur | f935d3cfc8f38599fbf2da9281fd6dfecbfd8412 | c80c18b8a02270c0c1505251a3962a3920ba2a4d | refs/heads/master | 2021-01-18T19:17:34.912558 | 2017-04-06T09:23:40 | 2017-04-06T09:23:40 | 86,895,832 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 256 | java |
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
TSP tsp = new TSP();
tsp.ajoutPoints(200);
tsp.circuitrandom();
tsp.circuit();
tsp.longueur();
tsp.glouton();
tsp.heuristique();
}
}
| [
"[email protected]"
] | |
c700fe2236f5c875d181a2af0a3e3554dfbed91d | 0c220a8716b7423f169eee4e9cc435e1ebfa8271 | /zheng-ucenter/zheng-ucenter-dao/src/main/java/com/zheng/ucenter/dao/mapper/UcenterUserMapper.java | 7ef7a784fd5cefb2fa6abed33af4bf6da1edea36 | [
"MIT"
] | permissive | mhearttzw/yunyi | d304f9a135642fec2611578199bfccce542591da | 931cbea0fe851bedcdba5b6fbc36a599f216ec5f | refs/heads/master | 2021-04-12T08:54:50.607583 | 2018-04-16T13:49:01 | 2018-04-16T13:49:01 | 126,781,655 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,576 | java | package com.zheng.ucenter.dao.mapper;
import com.zheng.ucenter.dao.model.CmsArticle;
import com.zheng.ucenter.dao.model.UcenterUser;
import com.zheng.ucenter.dao.model.UcenterUserExample;
import java.util.List;
import com.zheng.ucenter.dao.model.dto.CmsArticleDto;
import org.apache.ibatis.annotations.Param;
public interface UcenterUserMapper {
long countByExample(UcenterUserExample example);
int deleteByExample(UcenterUserExample example);
int deleteByPrimaryKey(Integer userId);
/**
* 添加注册用户
* @param record
* @return
*/
int insert(UcenterUser record);
/**
* 添加文章
* @param article
* @return
*/
int insertArticle(CmsArticle article);
int insertSelective(UcenterUser record);
List<UcenterUser> selectByExample(UcenterUserExample example);
UcenterUser selectByPrimaryKey(Integer userId);
/**
* 根据手机号查询用户
* @param ucenterUser
* @return
*/
List<UcenterUser> selectByPhone(UcenterUser ucenterUser);
/**
* 根据昵称查询用户
* @param nickname
* @return
*/
List<UcenterUser> selectByNickname(@Param("nickname") String nickname);
/**
* 根据手机号和密码查询用户
* @param phone
* @param password
* @return
*/
List<UcenterUser> selectByPassword(@Param("phone") String phone, @Param("password") String password);
/**
* 根据昵称和密码查询用户
* @param nickname
* @param password
* @return
*/
List<UcenterUser> selectByNickAndPwd(@Param("nickname") String nickname, @Param("password") String password);
/**
* 根据用户名(手机号)查询用户uuid
* @param userName
* @return
*/
String selectUserUuidByUserName(@Param("userName") String userName);
/**
* 分页文章查询
* @param cursor
* @param pageSize
* @return
*/
List<CmsArticleDto> selectArticleByPage(@Param("cursor") int cursor, @Param("pageSize") int pageSize);
/**
* 修改用户密码
* @param password
* @return
*/
int updatePassword(@Param("password") String password, @Param("phone") String userName);
int updateByExampleSelective(@Param("record") UcenterUser record, @Param("example") UcenterUserExample example);
int updateByExample(@Param("record") UcenterUser record, @Param("example") UcenterUserExample example);
int updateByPrimaryKeySelective(UcenterUser record);
int updateByPrimaryKey(UcenterUser record);
} | [
"[email protected]"
] | |
dbb252653454f09eccfe41b2689e5ceadcddf7dc | d946961d06cd61250004e0fcf77f8e91ecd85ca2 | /src/oop/inheritance/verifone/v240m/VerifoneV240mGPS.java | a053557ba61ddcd1d88e2ba5cac38214c905f9d8 | [] | no_license | RicardoJuarez305951/tpv-exercise | 41b5b387a9b8e280050ade2a43625a037a939df1 | 5c5ce1755ba22553574a0f558dda71adc7f9d339 | refs/heads/main | 2023-04-06T10:42:42.685046 | 2021-04-21T20:34:47 | 2021-04-21T20:34:47 | 360,016,328 | 0 | 0 | null | 2021-04-21T03:04:54 | 2021-04-21T03:04:53 | null | UTF-8 | Java | false | false | 1,166 | java | package oop.inheritance.verifone.v240m;
public class VerifoneV240mGPS{
private static VerifoneV240mGPS uniqueInstance;
private VerifoneV240mGPS(){
}
public static VerifoneV240mGPS getInstance(){
if(uniqueInstance == null){
uniqueInstance = new VerifoneV240mGPS();
}
return uniqueInstance;
}
/**
* Opens a connection using the GPS device
*
* @return true if the connection was successfully opened
*/
public boolean open(){
return true;
}
/**
* Sends a message to the server
*
* @param message message to be sent to the server
* @return true if the message was sent successfully, false otherwise
*/
public boolean send(byte[] message){
return true;
}
/**
* Method blocks until host send a response or until a timeout is reached.
*
* @return Message received from the host. In case of timeout it returns null
*/
public byte[] receive(){
return "response".getBytes();
}
/**
* Closes the channel releasing every used resources
*/
public void close(){
}
}
| [
"[email protected]"
] | |
e61bc6e1651e761a738ddb79847b8ea7f96d357c | 697b29d5aab1fc57b1b5f27338c1225bdb54e53b | /src/main/java/webdemo/WebAppInitializer.java | 86ec33fe9ddfea01baa7ba3cd1ef815c8c1725e1 | [] | no_license | Eugnat/spring-security-trial | 5b3dff4bb53c2e6de18f16a0d41aba4bbecf8524 | a2fb1e8c5b3f70d9f70446fa633273890a38dd3f | refs/heads/master | 2020-04-23T14:57:37.553400 | 2019-02-18T12:40:53 | 2019-02-18T12:40:53 | 171,249,094 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 947 | java | package webdemo;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import webdemo.config.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@Order(1)
public class WebAppInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] {MongoDbConfiguration.class, SecurityConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebMvcConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
public void onStartup(final ServletContext servletContext)
throws ServletException {
super.onStartup(servletContext);
}
}
| [
"[email protected]"
] | |
49fa0f2d184c914dc21a07b95fa335dfd479507f | 08cd8d0e18d9ae512be9771b09e94dfee66a12d9 | /src/main/java/br/com/vanglas/util/jsf/JsfExceptionHandlerFactory.java | 614a3224fc087be79f6f9f2fa84d373115338d14 | [] | no_license | paulohorizonti/vanglas | 4e41ef943f2c3834c732b02c4c36897d08d07569 | a328c5bb35a3f22d5df181945ec411888d35fb80 | refs/heads/master | 2023-01-06T06:11:14.768950 | 2020-10-30T21:34:39 | 2020-10-30T21:34:39 | 297,756,496 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 479 | java | package br.com.vanglas.util.jsf;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;
public class JsfExceptionHandlerFactory extends ExceptionHandlerFactory {
private ExceptionHandlerFactory parent;
public JsfExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler() {
return new JsfExceptionHandler(parent.getExceptionHandler());
}
} | [
"[email protected]"
] | |
274351b2d6d261ef400d60fae9fa6d0f3927a424 | 191581300643abd865d242ab2389ca794f1e871d | /v1_16_R3/src/main/java/com/minefit/xerxestireiron/tallnether/v1_16_R3/BiomeModifiers/BiomeModifier.java | 1daf6757d1ac514fa99c13352b2d6399d2566dc7 | [] | no_license | OtakuMegane/TallNether | 90e930983e637e8e7b3afefa0de2b62cc2422844 | 53e04ff10d584f78327230d9f607ad7747cc2fe5 | refs/heads/master | 2021-12-27T17:26:16.091031 | 2021-12-24T02:31:14 | 2021-12-24T02:31:14 | 55,877,016 | 12 | 4 | null | null | null | null | UTF-8 | Java | false | false | 710 | java | package com.minefit.xerxestireiron.tallnether.v1_16_R3.BiomeModifiers;
import java.lang.reflect.Field;
import com.minefit.xerxestireiron.tallnether.ReflectionHelper;
import net.minecraft.server.v1_16_R3.BiomeBase;
import net.minecraft.server.v1_16_R3.BiomeSettingsGeneration;
public class BiomeModifier {
public boolean injectSettings(BiomeBase biomeBase, BiomeSettingsGeneration biomeSettingsGeneration) {
try {
Field f = biomeBase.getClass().getDeclaredField("k");
f.setAccessible(true);
ReflectionHelper.fieldSetter(f, biomeBase, biomeSettingsGeneration);
} catch (Throwable t) {
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
4a917e42a74e3f79cde61c24e83efc6583f28210 | 5e945f3be803a70c9d860696e40231dcc4a299cc | /src/model/servlet/RoomListServlet.java | 93c330ed71fee8b452c751398ea2d50a37f65a7f | [] | no_license | NaHyeongJin/JSLTeamProject | 3d2d320f75d00f3f4bd989024bfc4383e2596c12 | de8994a4ff7af597e09e4e33a6c1570b9f9aafa6 | refs/heads/main | 2023-01-28T17:12:38.373976 | 2020-12-03T12:03:55 | 2020-12-03T12:03:55 | 316,156,546 | 0 | 0 | null | 2020-12-03T12:03:56 | 2020-11-26T07:40:35 | JavaScript | UTF-8 | Java | false | false | 3,363 | java | package model.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
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 model.dao.RoomDAO;
import model.vo.RoomVO;
import util.PageIndex;
/**
* Servlet implementation class RoomServlet
*/
@WebServlet("/room")
public class RoomListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RoomListServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
RoomDAO dao = RoomDAO.getInstance();
//List<RoomVO> list = dao.RoomList();
String url = "room";
String query = "", key = "", s_query = "";
int totcount = 0;//검색조건이 들어왔을때
if(request.getParameter("key") != null && !request.getParameter("key").equals("")) {
query = request.getParameter("search");
key = request.getParameter("key");
s_query = query + " like '%" + key + "%'";
totcount = dao.RoomCount(s_query);
}else{
//검색 없을시 총 갯수
totcount = dao.RoomCount();
}
int nowpage = 1; //편재 페이지 초기화
int maxlist = 10; //페이지당 게시글 수 초기화
int totpage = 1; //전체 페이지 초기화
//총페이지 수 계산
if(totcount % maxlist == 0) {
totpage = totcount / maxlist;
}else {
totpage = totcount / maxlist +1;
}
if(totpage == 0) {
totpage = 1;
}
if(request.getParameter("page") != null) {
nowpage = Integer.parseInt(request.getParameter("page"));
}
if(nowpage>totpage) {
nowpage=totpage;
}
int startpage = (nowpage-1)*maxlist+1;
int endpage = nowpage*maxlist;
int listcount = totcount-((nowpage-1)*maxlist);
List<RoomVO> list = null;
if(key.equals("")) {
list = dao.RoomList(startpage, endpage);
}else {
list = dao.RoomList(s_query, startpage, endpage);
}
//페이지 처리
String pageSkip = "";
if(key.equals("")) {
pageSkip = PageIndex.pageList(nowpage, totpage, url, "");
}else {
pageSkip = PageIndex.pageListHan(nowpage, totpage, url, query, key);
}
request.setAttribute("totcount", totcount);
request.setAttribute("page", nowpage);
request.setAttribute("totpage", totpage);
request.setAttribute("listcount", listcount);
request.setAttribute("list", list);
request.setAttribute("pageSkip", pageSkip);
request.setAttribute("query", query);
request.setAttribute("key", key);
request.setAttribute("list", list);
RequestDispatcher rd = request.getRequestDispatcher("Room/roomList.jsp");
rd.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
] | |
2e701158cde95ea9cec82079927541d37c7ac973 | ad0b3d49fcee74db858e72eccb7773aa982c35b6 | /uitest/src/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java | d8027f8934b31eef17ffd5ee9e2b344bf74ea733 | [
"Apache-2.0"
] | permissive | travisfw/vaadin | b88dd1f649019ceabbcfbe2049574ee81c72b84e | 6961ad54df58f09930a451bba1c5b72e1429e789 | refs/heads/master | 2021-01-24T19:51:59.571001 | 2015-07-06T00:48:35 | 2015-07-06T00:48:35 | 35,126,389 | 0 | 0 | null | 2015-05-05T22:06:00 | 2015-05-05T22:05:59 | null | UTF-8 | Java | false | false | 1,945 | java | /*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridRowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSubPixelProblemWrappingTest extends MultiBrowserTest {
@Test
public void addedRowShouldNotWrap() {
openTestURL();
GridElement grid = $(GridElement.class).first();
// Cells in first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Add a row
$(ButtonElement.class).first().click();
// Cells in the first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Cells in the second row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 1);
}
private void assertRowAndCellTops(GridElement grid, int rowIndex) {
GridRowElement row = grid.getRow(rowIndex);
int rowTop = row.getLocation().y;
int cell0Top = grid.getCell(rowIndex, 0).getLocation().y;
int cell1Top = grid.getCell(rowIndex, 1).getLocation().y;
Assert.assertEquals(rowTop, cell0Top);
Assert.assertEquals(rowTop, cell1Top);
}
}
| [
"[email protected]"
] | |
b406011b1288b721015de0b7b814241447a2b695 | fcd46f84c746f5ed1dd38ce24f9cf5b27e150d78 | /finder-web/src/main/java/com/skin/finder/util/RandomUtil.java | f5fb391430f8cdd358d70f3de088acc6a06a562e | [
"Apache-2.0"
] | permissive | lambertwe/finder-parent | f03936ac7c1a9cec3901fbd2dd4e82e92296b099 | 378a643fda255a79582a4666637875c05bfb07fd | refs/heads/master | 2022-05-01T10:38:31.872493 | 2021-07-01T02:07:44 | 2021-07-01T02:07:44 | 177,890,255 | 0 | 0 | Apache-2.0 | 2022-03-31T18:47:21 | 2019-03-27T00:37:04 | Java | UTF-8 | Java | false | false | 1,284 | java | /*
* $RCSfile: RandomUtil.java,v $
* $Revision: 1.1 $
*
* Copyright (C) 2008 Skin, Inc. All rights reserved.
*
* This software is the proprietary information of Skin, Inc.
* Use is subject to license terms.
*/
package com.skin.finder.util;
import java.util.Random;
/**
* <p>Title: RandomUtil</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* @author xuesong.net
* @version 1.0
*/
public class RandomUtil {
private static final char[] DEFAULT_CHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/**
* @param min
* @param max
* @return String
*/
public static String getRandString(int min, int max) {
return getRandString(DEFAULT_CHARS, min, max);
}
/**
* @param cbuf
* @param min
* @param max
* @return String
*/
public static String getRandString(char[] cbuf, int min, int max) {
int length = min;
Random random = new Random();
length = min + random.nextInt(max - min + 1);
length = Math.max(length, min);
char[] chars = new char[length];
for(int i = 0; i < length; i++) {
chars[i] = cbuf[random.nextInt(16)];
}
return new String(chars);
}
}
| [
"[email protected]"
] | |
9eef49ccfff4d15a4f535268de7bcb07ea73c8e9 | e5b4b05035b37097e487179d61744530b9fa9d79 | /src/test/java/rocks/byivo/passwordmeter/measure/score/requiremets/RequirementCheckerTest.java | 095d9f2ca2587528aea95328aea3796138ced499 | [] | no_license | ByIvo/password-meter | a6292c09040fd1d6bfffaa6183a7aeb5257033ab | e13841671a47f09239937c57d415188700d68fc0 | refs/heads/master | 2020-03-27T19:41:52.656935 | 2018-09-05T01:50:34 | 2018-09-05T01:50:34 | 147,005,920 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,403 | java | package rocks.byivo.passwordmeter.measure.score.requiremets;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static rocks.byivo.passwordmeter.model.Requirement.HAS_MINIMUM_LENGTH;
import static rocks.byivo.passwordmeter.model.Requirement.HAS_SYMBOLS;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.test.context.junit4.SpringRunner;
import rocks.byivo.passwordmeter.model.Requirement;
@RunWith(SpringRunner.class)
public class RequirementCheckerTest {
private static final String RAW_PASSWORD = "123";
private RequirementChecker requirementChecker;
@Mock
private PasswordRequirement sizeRequirement, numberRequirement, letterRequirement;
@Before
public void setUp() throws Exception {
List<PasswordRequirement> allRequirements = Arrays.asList(
sizeRequirement,
numberRequirement,
letterRequirement );
requirementChecker = new RequirementChecker(allRequirements);
}
@Test
public void shouldCheckAllExistingsRequirements() {
requirementChecker.checkForReachedRequirementsIn(RAW_PASSWORD);
verify(sizeRequirement).isTheMinimumRequirementReachedIn(RAW_PASSWORD);
verify(numberRequirement).isTheMinimumRequirementReachedIn(RAW_PASSWORD);
verify(letterRequirement).isTheMinimumRequirementReachedIn(RAW_PASSWORD);
}
@Test
public void shouldReturnOnlyThePasswordRequirementsThatReachesRequirements() {
String rawPassword = RAW_PASSWORD;
makeMockReturnTheRequirement(sizeRequirement, HAS_SYMBOLS);
makeMockReturnTheRequirement(letterRequirement, Requirement.HAS_MINIMUM_LENGTH);
List<Requirement> requirementsPassed = requirementChecker.checkForReachedRequirementsIn(rawPassword);
List<Requirement> expecpedRechedRequirements = Arrays.asList(HAS_SYMBOLS, HAS_MINIMUM_LENGTH);
assertThat(requirementsPassed, is(expecpedRechedRequirements));
}
private void makeMockReturnTheRequirement(PasswordRequirement passwordRequirementMock, Requirement requirementType) {
when(passwordRequirementMock.isTheMinimumRequirementReachedIn(RAW_PASSWORD)).thenReturn(true);
when(passwordRequirementMock.getRequirement()).thenReturn(requirementType);
}
}
| [
"[email protected]"
] | |
ea7237ab046edfe0f89895f8ae34ab9811a5baf6 | 29ef246e7e9030611f5d9d35122791badb9426b9 | /src/com/sopiana/yang/javaDecompiler/component/sub/frame/same_frame.java | 06c5725c3656d62c2d0f99def979098af74fca13 | [] | no_license | sopiana/javaDecompiler | c6085f36d04100dca80c9eec2062b951b7620aec | 4c09b7db1fd87f24d56dadee4fd9e6b552b93714 | refs/heads/master | 2021-05-31T15:58:37.607374 | 2016-04-27T16:13:31 | 2016-04-27T16:13:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 572 | java | package com.sopiana.yang.javaDecompiler.component.sub.frame;
import com.sopiana.yang.javaDecompiler.component.cp_info;
import com.sopiana.yang.javaDecompiler.component.sub.stack_map_frame;
public class same_frame extends stack_map_frame
{
public static same_frame getInstance(byte[] classFileData, int offset)
{
same_frame res= new same_frame();
res.tag = classFileData[offset];
return res;
}
public int getSize() { return 1; }
@Override
public String toString(int indent, cp_info[] constant_pool) {
// TODO Auto-generated method stub
return null;
}
}
| [
"[email protected]"
] | |
11f9851dd013fbdd8f3023f0298090da15226a53 | c733e6b433914a8faba256c7853f5cf2cd39c62a | /Java/priorityQueue/_347_TopKFrequentElements.java | 83e156fe46665d52ce061c8856f5eab741cac707 | [] | no_license | YaqianQi/Algorithm-and-Data-Structure | 3016bebcc1f1356b6e5f3c3e588f3d46c276a805 | 2e1751263f484709102f7f2caf18776a004c8230 | refs/heads/master | 2021-10-27T16:29:18.409235 | 2021-10-14T13:57:36 | 2021-10-14T13:57:36 | 178,946,803 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,215 | java | import java.util.*;
public class _347_TopKFrequentElements {
public List<Integer> topKFrequent(int[] nums, int k) {
HashMap<Integer, Integer> map = new HashMap<>();
for (int num : nums) {
map.put(num, map.getOrDefault(num, 0) + 1);
}
// create a min heap
PriorityQueue<Map.Entry<Integer, Integer>> queue
= new PriorityQueue<>(Comparator.comparing(e -> e.getValue()));
//maintain a heap of size k.
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
queue.offer(entry);
if (queue.size() > k) {
queue.poll();
}
}
//get all elements from the heap
List<Integer> result = new ArrayList<>();
while (queue.size() > 0) {
result.add(queue.poll().getKey());
}
//reverse the order
Collections.reverse(result);
return result;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] nums = {1,1,1,2,2,3};
int k = 2;
_347_TopKFrequentElements tfe = new _347_TopKFrequentElements();
System.out.println(tfe.topKFrequent(nums,k));
}
}
| [
"[email protected]"
] | |
649af260624edfe4e0b54ac2897b05bd4b9833ad | f203fdfd85c0705dbc05a171b8f42bd3a628917f | /algorithms/leet/java/70-climbing-stairs-b.java | ef18d44f7cb260be9a44082371314f96fb263e2b | [] | no_license | krfong916/fullcourtpressed | 6e0fb1091a93dca6270173b5d88430557c422269 | 8fdee5d3141aa215bda8043997b144fecca0fa0c | refs/heads/master | 2023-03-12T01:47:40.193373 | 2021-11-14T06:16:59 | 2021-11-14T06:16:59 | 238,838,256 | 0 | 0 | null | 2023-03-05T23:31:10 | 2020-02-07T03:46:55 | Java | UTF-8 | Java | false | false | 266 | java | class Solution {
public int climbStairs(int n) {
int[] dp = new int[n + 1];
if (n == 0 || n == 1 || n == 2) return n;
dp[0] = 0; dp[1] = 1; dp[2] = 2;
for (int i = 3; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[n];
}
} | [
"[email protected]"
] | |
db0261c6f41909552bd9ebbad0a1eb8353c0d363 | 46dcacf51903160d4bf5c66798b08947f24aaf40 | /pipe-service/pipe-rta/src/main/java/com/bs/pipe/service/impl/RtaLegendStandardImpl.java | 537c348420e944760877be2d3ee14c6e8743cec0 | [] | no_license | Moming0/pipe | 7d989cd8331e61d4bf4b7bdd4d79be4ae802bb75 | 447e17485646db80d13393cabf02a16775c7dafd | refs/heads/master | 2023-04-08T15:51:12.222933 | 2021-04-20T03:28:17 | 2021-04-20T03:28:17 | 355,085,338 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,564 | java | package com.bs.pipe.service.impl;
import java.util.*;
import com.bs.pipe.entity.po.RtaLegendStandard;
import com.bs.pipe.exception.BusinessException;
import com.bs.pipe.mapper.RtaLegendStandardMapper;
import com.bs.pipe.service.RtaLegendStandardService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@Service
@Transactional
public class RtaLegendStandardImpl implements RtaLegendStandardService {
@Resource
private RtaLegendStandardMapper rtaLegendStandardMapper;
@Override
public List<RtaLegendStandard> selectRtaLegendStandardList(RtaLegendStandard rtaLegendStandard) {
// TODO Auto-generated method stub
List<RtaLegendStandard> list = rtaLegendStandardMapper.selectRtaLegendStandardList(rtaLegendStandard);
return CollectionUtils.isEmpty(list) ? Collections.emptyList() : list;
}
@Override
public RtaLegendStandard selectRtaLegendStandard(RtaLegendStandard rtaLegendStandard) {
// TODO Auto-generated method stub
return rtaLegendStandardMapper.selectRtaLegendStandard(rtaLegendStandard);
}
@Override
public void insertRtaLegendStandard(RtaLegendStandard rtaLegendStandard) {
// TODO Auto-generated method stub
if(this.rtaLegendStandardExistWhenCreate(rtaLegendStandard)){
throw new BusinessException("该统计类型已被设置");
} else {
if(rtaLegendStandardMapper.insertRtaLegendStandard(rtaLegendStandard) != 1){
throw new BusinessException("添加失败");
}
}
}
@Override
public void updateRtaLegendStandard(RtaLegendStandard rtaLegendStandard) {
// TODO Auto-generated method stub
if(this.rtaLegendStandardExistWhenUpdate(rtaLegendStandard)){
throw new BusinessException("该统计类型已被设置");
} else {
if(rtaLegendStandardMapper.updateRtaLegendStandard(rtaLegendStandard) != 1){
throw new BusinessException("修改失败");
}
}
}
@Override
public void deleteRtaLegendStandard(Integer id) {
// TODO Auto-generated method stub
if(rtaLegendStandardMapper.deleteRtaLegendStandard(id) != 1){
throw new BusinessException("删除失败");
}
}
private boolean rtaLegendStandardExistWhenCreate(RtaLegendStandard rtaLegendStandard) {
return rtaLegendStandardMapper.rtaLegendStandardExistWhenCreate(rtaLegendStandard);
}
private boolean rtaLegendStandardExistWhenUpdate(RtaLegendStandard rtaLegendStandard) {
return rtaLegendStandardMapper.rtaLegendStandardExistWhenUpdate(rtaLegendStandard);
}
}
| [
"[email protected]"
] | |
94c535c21736d2aac5b3a9da51e3a2625a3263fe | 927569a3f9024f4d58fdf0c4b4e5d98dff227ec0 | /demo/src/com/ichliebephone/AndroidPreferenceDemoII.java | df1b0532dfbb843a7bd0ba312eb65b5f026e73fc | [] | no_license | loveFeng/android-widget | 9eab91c92ca4a569f2e2a4b6ba4a9f934eddafb0 | 5c9b5e220e51fb1f0b991061f1699045b3a7b40a | refs/heads/master | 2020-06-03T21:27:41.210208 | 2014-03-14T09:39:05 | 2014-03-14T09:39:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,844 | java | package com.ichliebephone;
import com.example.demo_highlights.R;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;
public class AndroidPreferenceDemoII extends Activity {
/** Called when the activity is first created. */
// �˵���
final private int menuSettings=Menu.FIRST;
private static final int REQ_SYSTEM_SETTINGS = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_preferences);
//add virtual menu
try {
getWindow().addFlags(WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
}catch (NoSuchFieldException e) {
// Ignore since this field won't exist in most versions of Android
}catch (IllegalAccessException e) {
Log.w("feelyou.info", "Could not access FLAG_NEEDS_MENU_KEY in addLegacyOverflowButton()", e);
}
//add end virtual menu
}
//�����˵�
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// �����˵�
menu.add(0, menuSettings, 2, "menu1");
return super.onCreateOptionsMenu(menu);
}
//�˵�ѡ���¼�����
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
switch (item.getItemId())
{
case menuSettings:
//ת��Settings���ý���
startActivityForResult(new Intent(this, Settings.class), REQ_SYSTEM_SETTINGS);
break;
default:
break;
}
return super.onMenuItemSelected(featureId, item);
}
//Settings���ý��淵�صĽ��
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQ_SYSTEM_SETTINGS)
{
//��ȡ���ý���PreferenceActivity�и���Preference��ֵ
String updateSwitchKey = getResources().getString(R.string.auto_update_switch_key);
String updateFrequencyKey = getResources().getString(R.string.auto_update_frequency_key);
//ȡ���������Ӧ�ó����SharedPreferences
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
Boolean updateSwitch = settings.getBoolean(updateSwitchKey, true);
String updateFrequency = settings.getString(updateFrequencyKey, "10");
//��ӡ���
Log.v("CheckBoxPreference_Main", updateSwitch.toString());
Log.v("ListPreference_Main", updateFrequency);
}
else
{
//����Intent���صĽ��
}
}
} | [
"[email protected]"
] | |
f5bae65ddd14b9dee0fae0d0c2c8b61df78bdfa5 | 235175e676df449e168c26180a6905ed1ee3ac30 | /SRC/Objetos/Boletos.java | 1e7102a00b1a5b95de3f23bf1708088e279a59a4 | [] | no_license | WEBEXZ/Estadio | 744746f14346335ddaa876abc347f90196e968b2 | 9310443acc41dda708ee24d8f74497fbd9fff0c5 | refs/heads/master | 2021-01-21T11:08:15.060281 | 2014-12-07T05:39:15 | 2014-12-07T05:39:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,872 | java | package Acciones;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
public class Boletos
{
Conexion conexion = new Conexion();
public void agregar_cliente(String Clave,int id_Zona, int id_Area,int id_Temporada,int id_Partido,String nom_Cliente,String tipo_Cliente,String fecha_Compra,double precio,int boletos)
{
try
{
String insertar = "INSERT INTO boletos(id_boleto,id_zona,id_area,id_temporada,id_partido,nom_cliente,tipo_cliente,fecha_compra,precio_total,n_boletos) VALUES(?,?,?,?,?,?,?,?,?,?);";
PreparedStatement p = conexion.getConexion().prepareStatement(insertar);
p.setString(1,Clave);
p.setInt(2,id_Zona);
p.setInt(3,id_Area);
p.setInt(4,id_Temporada);
p.setInt(5,id_Partido);
p.setString(6,nom_Cliente);
p.setString(7,tipo_Cliente);
p.setString(8,fecha_Compra);
p.setDouble(9,precio);
p.setInt(10,boletos);
p.execute();
p.close();
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}
public String busqueda(String clave)
{
String consulta = "NO EXISTE EL CLIENTE";
try
{
String usuario = "SELECT CLAVE FROM seguridad where CLAVE = ?;";
PreparedStatement p = conexion.getConexion().prepareStatement(usuario);
p.setString(1,clave);
ResultSet rs = p.executeQuery();
while (rs.next())
{
consulta = "CLIENTE REGISTRADO";
}
rs.close();
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
return consulta;
}
} | [
"[email protected]"
] | |
9625b9c6bb4c7f3ef7568fd42b5608c9ba8f71ec | 762a99183550fb163c5f6156f4165958cbef76ad | /src/main/java/com/exercise/nosunsetservice/controllers/ExceptionHandlerController.java | 39fdcbe119b7c749a16b6c09dcb9a1af762b641b | [] | no_license | neetubansal13/demoproject | 10d9434846f9befe79c1732b6d66a0a31746b30a | c42bcb4ec09ae86776b4b523c50d3402e68a287f | refs/heads/master | 2023-06-29T22:50:54.808024 | 2021-08-03T07:01:16 | 2021-08-03T07:01:16 | 392,222,026 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 593 | java | package com.exercise.nosunsetservice.controllers;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.exercise.nosunsetservice.exceptions.SunsetServiceException;
@ControllerAdvice
public class ExceptionHandlerController {
@ExceptionHandler(SunsetServiceException.class)
public ResponseEntity<Object> noServiceException(SunsetServiceException sunsetException) {
return ResponseEntity.internalServerError().body(sunsetException.getMessage());
}
}
| [
"[email protected]"
] | |
646f8a180e0011fd5dcf79a91288d4e6856db840 | ba3c937860fa1903741c256f52b602eb3682685c | /src/me/grax/jbytemod/ui/JAboutFrame.java | 1fca99202bb2c6d3e3bf24d20911c8c21486528f | [] | no_license | Techlord-RCE/JByteMod-Beta | 7dcaa3ee9f25da2ef3a94de317ac6fd87f4c5a1c | 7fa09842e36113e8fda2347b864f5ddfa89c3535 | refs/heads/master | 2021-09-04T02:22:53.171041 | 2018-01-14T16:11:09 | 2018-01-14T16:11:09 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 2,043 | java | package me.grax.jbytemod.ui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.UIDefaults;
import javax.swing.border.EmptyBorder;
import me.grax.jbytemod.JByteMod;
import me.grax.jbytemod.utils.TextUtils;
public class JAboutFrame extends JDialog {
public JAboutFrame(JByteMod jbm) {
this.setTitle(jbm.getRes().getResource("about") + " " + jbm.getTitle());
this.setModal(true);
setBounds(100, 100, 400, 300);
JPanel cp = new JPanel();
cp.setLayout(new BorderLayout());
cp.setBorder(new EmptyBorder(10, 10, 10, 10));
setResizable(false);
JButton close = new JButton("Close");
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JAboutFrame.this.dispose();
}
});
JPanel jp = new JPanel(new GridLayout(1, 4));
for (int i = 0; i < 3; i++)
jp.add(new JPanel());
jp.add(close);
cp.add(jp, BorderLayout.PAGE_END);
JTextPane title = new JTextPane();
title.setContentType("text/html");
title.setText(TextUtils.toHtml(jbm.getTitle()
+ "<br/>Copyright © 2016-2018 noverify<br/><font color=\"#0000EE\"><u>https://github.com/GraxCode/JByteMod-Beta</u></font><br/>Donate LTC: <font color=\"#333333\">LhwXLVASzb6t4vHSssA9FQwq2X5gAg8EKX</font>"));
Color bgColor = new Color(0xd6d9df);
UIDefaults defaults = new UIDefaults();
defaults.put("TextPane[Enabled].backgroundPainter", bgColor);
title.putClientProperty("Nimbus.Overrides", defaults);
title.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
title.setBackground(bgColor);
title.setEditable(false);
title.setBorder(null);
cp.add(title, BorderLayout.CENTER);
getContentPane().add(cp);
}
}
| [
"[email protected]"
] | |
3e4c89a7455728e87a37b4d1c705f6a03981d12c | 678adc0bade1f2594b18e844b06938c7e444b5f0 | /distributed-programming-in-java/src/main/java/edu/coursera/parallel/StudentAnalytics.java | 88a66a21f3e761ce19debcceb6689d2b6732b842 | [
"Unlicense"
] | permissive | farinazgh/parallel-concurrent-distributed-programming | 7e4596f911bc513353ae10440490950c5b531d4d | ac91aabcb4558c098f5067c640e24940052b78de | refs/heads/main | 2023-02-08T05:51:19.777598 | 2021-01-01T16:57:54 | 2021-01-01T16:57:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,940 | java | package edu.coursera.parallel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple wrapper class for various analytics methods.
*/
public final class StudentAnalytics {
/**
* Sequentially computes the average age of all actively enrolled students
* using loops.
*
* @param studentArray Student data for the class.
* @return Average age of enrolled students
*/
public double averageAgeOfEnrolledStudentsImperative(
final Student[] studentArray) {
List<Student> activeStudents = new ArrayList<Student>();
for (Student s : studentArray) {
if (s.checkIsCurrent()) {
activeStudents.add(s);
}
}
double ageSum = 0.0;
for (Student s : activeStudents) {
ageSum += s.getAge();
}
return ageSum / (double) activeStudents.size();
}
/**
* TODO compute the average age of all actively enrolled students using
* parallel streams. This should mirror the functionality of
* averageAgeOfEnrolledStudentsImperative. This method should not use any
* loops.
*
* @param studentArray Student data for the class.
* @return Average age of enrolled students
*/
public double averageAgeOfEnrolledStudentsParallelStream(
final Student[] studentArray) {
throw new UnsupportedOperationException();
}
/**
* Sequentially computes the most common first name out of all students that
* are no longer active in the class using loops.
*
* @param studentArray Student data for the class.
* @return Most common first name of inactive students
*/
public String mostCommonFirstNameOfInactiveStudentsImperative(
final Student[] studentArray) {
List<Student> inactiveStudents = new ArrayList<Student>();
for (Student s : studentArray) {
if (!s.checkIsCurrent()) {
inactiveStudents.add(s);
}
}
Map<String, Integer> nameCounts = new HashMap<String, Integer>();
for (Student s : inactiveStudents) {
if (nameCounts.containsKey(s.getFirstName())) {
nameCounts.put(s.getFirstName(),
new Integer(nameCounts.get(s.getFirstName()) + 1));
} else {
nameCounts.put(s.getFirstName(), 1);
}
}
String mostCommon = null;
int mostCommonCount = -1;
for (Map.Entry<String, Integer> entry : nameCounts.entrySet()) {
if (mostCommon == null || entry.getValue() > mostCommonCount) {
mostCommon = entry.getKey();
mostCommonCount = entry.getValue();
}
}
return mostCommon;
}
/**
* TODO compute the most common first name out of all students that are no
* longer active in the class using parallel streams. This should mirror the
* functionality of mostCommonFirstNameOfInactiveStudentsImperative. This
* method should not use any loops.
*
* @param studentArray Student data for the class.
* @return Most common first name of inactive students
*/
public String mostCommonFirstNameOfInactiveStudentsParallelStream(
final Student[] studentArray) {
throw new UnsupportedOperationException();
}
/**
* Sequentially computes the number of students who have failed the course
* who are also older than 20 years old. A failing grade is anything below a
* 65. A student has only failed the course if they have a failing grade and
* they are not currently active.
*
* @param studentArray Student data for the class.
* @return Number of failed grades from students older than 20 years old.
*/
public int countNumberOfFailedStudentsOlderThan20Imperative(
final Student[] studentArray) {
int count = 0;
for (Student s : studentArray) {
if (!s.checkIsCurrent() && s.getAge() > 20 && s.getGrade() < 65) {
count++;
}
}
return count;
}
/**
* TODO compute the number of students who have failed the course who are
* also older than 20 years old. A failing grade is anything below a 65. A
* student has only failed the course if they have a failing grade and they
* are not currently active. This should mirror the functionality of
* countNumberOfFailedStudentsOlderThan20Imperative. This method should not
* use any loops.
*
* @param studentArray Student data for the class.
* @return Number of failed grades from students older than 20 years old.
*/
public int countNumberOfFailedStudentsOlderThan20ParallelStream(
final Student[] studentArray) {
throw new UnsupportedOperationException();
}
} | [
"[email protected]"
] | |
fd090d9040bba9e3394f4c0c66433856dc02a421 | f6b9ddd6dd31284993a58138c490442cdc7b6a03 | /Ejercicio05.java | 5ca063523d93f673238f45a6a82a88149120266c | [] | no_license | Lucilaada/Ejercicios-ada-procedural | c25ae0e383f061cbaab8eb14cb801a067ae00338 | 127438f301c49a3376ef340a90e81043633e8643 | refs/heads/master | 2020-09-04T17:42:51.682541 | 2019-11-05T19:47:52 | 2019-11-05T19:47:52 | 219,836,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,489 | java | import java.util.Scanner;
/**
* Ejercicio05
*/
public class Ejercicio05 {
public static Scanner Teclado = new Scanner(System.in);
public static void main(String[] args) {
int numeroVentas;
int a=0;
int b=0;
int c=0;
int t1=0;
int t2=0;
int t3=0;
int tt=0;
int cantidadVentas;
int montoVenta;
numeroVentas=tt;
cantidadVentas=1;
System.out.println("Ingrese el monto de la venta");
montoVenta=Teclado.nextInt();
while (cantidadVentas <= numeroVentas)
{if (montoVenta > 1000)
{
a=a+1;
t1=t1+1;
}else
{
if (montoVenta > 500)
{
b=b+1;
t2=t2+1;
}else{
c=c+1;
t3=t3+1;
}
}
tt=tt+montoVenta;
cantidadVentas=cantidadVentas+1;
}
System.out.println(" Ventas mayores a 1000: " + a);
System.out.println(" Ventas mayores a 500: " + b);
System.out.println(" Ventas menores o iguales a 500: " + c);
System.out.println(" Total de ventas mayores a 1000: " + t1);
System.out.println(" Total de ventas mayores a 500: " + t2);
System.out.println(" Total de ventas menores o iguales a 500: " + t3);
System.out.println(" Total de ventas: "+ cantidadVentas);
}
} | [
"lucilasol.aguilar01"
] | lucilasol.aguilar01 |
cafa40abbec451f877033f845d2288d0fb97fe17 | ed9eaec84195d990b7f05623e152d75cac98769a | /src/main/java/io/stibits/web/rest/AuditResource.java | 7bb8392461802ef18c47200b75405654725adf67 | [] | no_license | BulkSecurityGeneratorProject/extract-from-blockchain | 4ef3a22ea6fe49fb369144d1a18edda198803ea4 | 3f728325a7a17b6fb26349a59a14cf1c05945f16 | refs/heads/master | 2022-12-10T07:41:13.695608 | 2019-04-22T11:23:45 | 2019-04-22T11:23:45 | 296,582,922 | 0 | 0 | null | 2020-09-18T09:59:14 | 2020-09-18T09:59:13 | null | UTF-8 | Java | false | false | 2,946 | java | package io.stibits.web.rest;
import io.stibits.service.AuditEventService;
import io.stibits.web.rest.util.PaginationUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
/**
* REST controller for getting the audit events.
*/
@RestController
@RequestMapping("/management/audits")
public class AuditResource {
private final AuditEventService auditEventService;
public AuditResource(AuditEventService auditEventService) {
this.auditEventService = auditEventService;
}
/**
* GET /audits : get a page of AuditEvents.
*
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
*/
@GetMapping
public ResponseEntity<List<AuditEvent>> getAll(Pageable pageable) {
Page<AuditEvent> page = auditEventService.findAll(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
/**
* GET /audits : get a page of AuditEvents between the fromDate and toDate.
*
* @param fromDate the start of the time period of AuditEvents to get
* @param toDate the end of the time period of AuditEvents to get
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
*/
@GetMapping(params = {"fromDate", "toDate"})
public ResponseEntity<List<AuditEvent>> getByDates(
@RequestParam(value = "fromDate") LocalDate fromDate,
@RequestParam(value = "toDate") LocalDate toDate,
Pageable pageable) {
Page<AuditEvent> page = auditEventService.findByDates(
fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant(),
toDate.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant(),
pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
/**
* GET /audits/:id : get an AuditEvent by id.
*
* @param id the id of the entity to get
* @return the ResponseEntity with status 200 (OK) and the AuditEvent in body, or status 404 (Not Found)
*/
@GetMapping("/{id:.+}")
public ResponseEntity<AuditEvent> get(@PathVariable Long id) {
return ResponseUtil.wrapOrNotFound(auditEventService.find(id));
}
}
| [
"[email protected]"
] | |
c9cc1507f41c7c1a35db1840177eca21ce9e0c70 | caf8d8ab00196c52b43fc3d9895d33368666a126 | /3 - Construtores e Encapsulamento/ex3/ex2/Pessoa.java | 9d4f9b29f9e18f12abcf9c70e6851d0bbe68b3fb | [] | no_license | luamz/orientacao-a-objetos | 1d75cd62872cfde68005e23b9b927bca11b5bde4 | 9170c10bd714a4a7cd52299a84d06b62708028e9 | refs/heads/master | 2023-03-05T15:36:46.435558 | 2021-02-15T11:10:44 | 2021-02-15T11:10:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 624 | java | package ex3.ex2;
/* @author Luam */
public class Pessoa {
protected String nome;
protected int idade;
public Pessoa(String nome, int idade) {
this.nome = nome;
this.idade = idade;
}
void fazAniversario(){
idade++;
}
void imprimir(){
System.out.print(nome +", "+ idade + " anos \n");
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
}
| [
"[email protected]"
] | |
248b425c9d9527122d7f39640e165abdebc3f5b1 | 70a14851cd185261c1ced3bb07f6206ea1d2f9ab | /Array insertion/Main.java | ddcc1192b5a329c3d8a9db4dfce3203286f32131 | [] | no_license | Nithy-Sree/Playground | 1a255ca4006ebb5741e3c4d4de0aa90ce1301b3c | cab353c550dc0cac39e9a7140d8132fccede042a | refs/heads/master | 2021-05-26T20:39:20.091455 | 2020-05-06T10:40:13 | 2020-05-06T10:40:13 | 254,162,125 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | #include<iostream>
using namespace std;
int main()
{
int n,i;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
int l,val;
cin>>l>>val;
n++;
for(i=n;i>=l;i--)
a[i]=a[i-1];
a[l-1]=val;
cout<<"Enter the number of elements in the array\nEnter the elements in the array\nEnter the location where you wish to insert an element\n";
if(l>n){
cout<<"Invalid Input";
}
else{
cout<<"Enter the value to insert\nArray after insertion is\n";
for(i=0;i<n;i++)
cout<<a[i]<<"\n";
}
} | [
"[email protected]"
] | |
86f6c7c84f90e98bb57d08bf0cc8291875668e7c | 0099cf9ecfb5fc5de223854ebc49e60d2a67436a | /NewsService/src/TechnologyServlet.java | 7091990e797f221b1c53cc7420d0a4d6a5a57b14 | [] | no_license | VSTR39/Programming101-Java | ccb0f5496c04914253366f5b1c812900e48e7210 | 78fd083c05bdf47ef3ccbca33508ff190f80ec0a | refs/heads/master | 2021-01-10T15:25:07.811708 | 2016-03-25T18:49:43 | 2016-03-25T18:49:43 | 47,116,203 | 0 | 3 | null | 2016-01-18T19:27:07 | 2015-11-30T12:13:00 | HTML | UTF-8 | Java | false | false | 1,116 | java |
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class TechnologyServlet
*/
@WebServlet("/TechnologyServlet")
public class TechnologyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public TechnologyServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
] | |
a51b5b98c4361f4559ba26c9062b8fd6c1d2890d | e245da2da841089900f82ddefe3636c817b1d4a9 | /src/com/sinosoft/lis/vschema/LABranchGroupBSet.java | 9c947f23cfa16925ac6f46851e844a1ff0177a8e | [] | no_license | ssdtfarm/Productoin_CMS | 46820daa441b449bd96ec699c554bb594017b63e | 753818ca1ddb1b05e5d459b8028580b7ac8250b5 | refs/heads/master | 2020-04-12T22:54:13.456687 | 2016-04-14T06:44:57 | 2016-04-14T06:44:57 | 60,250,819 | 0 | 3 | null | 2016-06-02T09:29:06 | 2016-06-02T09:29:05 | null | UTF-8 | Java | false | false | 2,372 | java | /**
* Copyright (c) 2002 sinosoft Co. Ltd.
* All right reserved.
*/
package com.sinosoft.lis.vschema;
import com.sinosoft.lis.schema.LABranchGroupBSchema;
import com.sinosoft.utility.*;
/*
* <p>ClassName: LABranchGroupBSet </p>
* <p>Description: LABranchGroupBSchemaSet类文件 </p>
* <p>Copyright: Copyright (c) 2007</p>
* <p>Company: sinosoft </p>
* @Database: SqlServerSchemaMaker
*/
public class LABranchGroupBSet extends SchemaSet
{
// @Method
public boolean add(LABranchGroupBSchema aSchema)
{
return super.add(aSchema);
}
public boolean add(LABranchGroupBSet aSet)
{
return super.add(aSet);
}
public boolean remove(LABranchGroupBSchema aSchema)
{
return super.remove(aSchema);
}
public LABranchGroupBSchema get(int index)
{
LABranchGroupBSchema tSchema = (LABranchGroupBSchema)super.getObj(index);
return tSchema;
}
public boolean set(int index, LABranchGroupBSchema aSchema)
{
return super.set(index,aSchema);
}
public boolean set(LABranchGroupBSet aSet)
{
return super.set(aSet);
}
/**
* 数据打包,按 XML 格式打包,顺序参见<A href ={@docRoot}/dataStructure/tb.html#PrpLABranchGroupB描述/A>表字段
* @return: String 返回打包后字符串
**/
public String encode()
{
StringBuffer strReturn = new StringBuffer("");
int n = this.size();
for (int i = 1; i <= n; i++)
{
LABranchGroupBSchema aSchema = this.get(i);
strReturn.append(aSchema.encode());
if( i != n ) strReturn.append(SysConst.RECORDSPLITER);
}
return strReturn.toString();
}
/**
* 数据解包
* @param: str String 打包后字符串
* @return: boolean
**/
public boolean decode( String str )
{
int nBeginPos = 0;
int nEndPos = str.indexOf('^');
this.clear();
while( nEndPos != -1 )
{
LABranchGroupBSchema aSchema = new LABranchGroupBSchema();
if(aSchema.decode(str.substring(nBeginPos, nEndPos)))
{
this.add(aSchema);
nBeginPos = nEndPos + 1;
nEndPos = str.indexOf('^', nEndPos + 1);
}
else
{
// @@错误处理
this.mErrors.copyAllErrors( aSchema.mErrors );
return false;
}
}
LABranchGroupBSchema tSchema = new LABranchGroupBSchema();
if(tSchema.decode(str.substring(nBeginPos)))
{
this.add(tSchema);
return true;
}
else
{
// @@错误处理
this.mErrors.copyAllErrors( tSchema.mErrors );
return false;
}
}
}
| [
"[email protected]"
] | |
82c03296408c7af68cee0f9810553dd8fe759b3f | e56a1201d911258bf829be71fb309387eaa06312 | /EJEntregar/app/src/main/java/com/example/ejentregar/AdaptadorListaCompleta.java | 38535a2b41b7f9c67a4ddf4fb02ae5d9d9e9a9f8 | [] | no_license | Matias-Louzao-Ataria/Android | 84f81b3cb5e47031017c004ad747b1fe26f30c8a | e2e561ea1f1e639a2500f04d2e90727014c12f6b | refs/heads/master | 2023-03-01T08:26:24.718171 | 2021-02-10T17:11:39 | 2021-02-10T17:11:39 | 302,009,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,848 | java | package com.example.ejentregar;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import java.time.LocalDate;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class AdaptadorListaCompleta extends RecyclerView.Adapter<AdaptadorListaCompleta.ViewHolder>{
private ArrayList<Pelicula> peliculas;
private ItemClickListener itemClickListener;
public AdaptadorListaCompleta(ArrayList<Pelicula> datos,ItemClickListener itemClickListener) {
this.peliculas = datos;
this.itemClickListener = itemClickListener;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View peli = LayoutInflater.from(parent.getContext()).inflate(R.layout.peliculacompleta,parent,false);
ViewHolder item = new ViewHolder(peli,itemClickListener);
return item;
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
Pelicula peli = peliculas.get(position);
holder.titulo.setText(peli.getTitulo());
holder.director.setText(peli.getDirector());
holder.pegi.setImageResource(peli.getPegi());
holder.portada.setImageResource(peli.getPortada());
Calendar cal = Calendar.getInstance();
cal.setTime(peli.getFecha());
LocalDate d = LocalDateTime.ofInstant(peli.getFecha().toInstant(), ZoneId.systemDefault()).toLocalDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
holder.fecha.setText(d.format(formatter));
holder.sala.setText(peli.getSala());
holder.duracion.setText(peli.getDuracion()+" minutos");
holder.fav.setChecked(peli.isFavorita());
holder.fav.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//hacer favorita la pelicula
Pelicula p = MainActivity.peliculas.get(position);
p.setFavorita(!p.isFavorita());
}
});
}
@Override
public int getItemCount() {
return this.peliculas.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private TextView titulo,director,sala,duracion,fecha;
private ImageView portada,pegi;
private ItemClickListener itemClickListener;
private CheckBox fav;
public ViewHolder(@NonNull View itemView,ItemClickListener itemClickListener) {
super(itemView);
this.titulo = itemView.findViewById(R.id.titulo);
this.director = itemView.findViewById(R.id.director);
this.pegi = itemView.findViewById(R.id.pegi);
this.portada = itemView.findViewById(R.id.portada3);
this.sala = itemView.findViewById(R.id.sala);
this.duracion = itemView.findViewById(R.id.duracion);
this.fecha = itemView.findViewById(R.id.fecha);
this.fav = itemView.findViewById(R.id.checkBox2);
this.itemClickListener = itemClickListener;
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
itemClickListener.OnItemClicked(getAdapterPosition());
}
}
public interface ItemClickListener{
void OnItemClicked(int pos);
}
}
| [
"[email protected]"
] | |
ea0bb0cbc078af7fa9d61ffd1c385b5d427b53bd | 634497f6be03d2fb731518592a7b8dfa919ce44c | /components/org.wso2.carbon.deployment.engine/src/test/java/org/wso2/carbon/deployment/engine/listeners/CustomLifecycleListener.java | df28a5a8d630f8bbc05f890fb71971a5c779a131 | [
"Apache-2.0"
] | permissive | Subasinghe/carbon-deployment | 84c13ff5da7edd5bc3c690f6a3dd2f895e69e689 | 11a5b5f439294c9b0ef63bd6f9ab13d24a81a7da | refs/heads/master | 2021-01-01T19:03:46.007016 | 2017-06-21T05:20:52 | 2017-06-21T05:20:52 | 98,495,694 | 0 | 0 | null | 2017-07-27T05:02:40 | 2017-07-27T05:02:40 | null | UTF-8 | Java | false | false | 1,542 | java | /*
* Copyright (c) $today.year, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.deployment.engine.listeners;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wso2.carbon.deployment.engine.Artifact;
import org.wso2.carbon.deployment.engine.LifecycleEvent;
import org.wso2.carbon.deployment.engine.LifecycleListener;
public class CustomLifecycleListener implements LifecycleListener {
private static final Logger logger = LoggerFactory.getLogger(CustomLifecycleListener.class);
@Override
public void lifecycleEvent(LifecycleEvent event) {
Artifact artifact = event.getArtifact();
String artifactName = artifact.getName();
LifecycleEvent.RESULT deploymentResult = event.getDeploymentResult();
logger.info("{} event triggered for artifact: {}, with current deployment result: {} ", event.getState(),
artifactName, deploymentResult);
}
}
| [
"[email protected]"
] | |
eee72eb2d7bcc5080d727df2b292105958bf5da5 | aa6997aba1475b414c1688c9acb482ebf06511d9 | /src/java/util/zip/Inflater.java | e488bfef411020365f8c84c39ced9e1dbb3d095a | [] | no_license | yueny/JDKSource1.8 | eefb5bc88b80ae065db4bc63ac4697bd83f1383e | b88b99265ecf7a98777dd23bccaaff8846baaa98 | refs/heads/master | 2021-06-28T00:47:52.426412 | 2020-12-17T13:34:40 | 2020-12-17T13:34:40 | 196,523,101 | 4 | 2 | null | null | null | null | UTF-8 | Java | false | false | 11,686 | java | /*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.util.zip;
/**
* This class provides support for general purpose decompression using the
* popular ZLIB compression library. The ZLIB compression library was
* initially developed as part of the PNG graphics standard and is not
* protected by patents. It is fully described in the specifications at
* the <a href="package-summary.html#package_description">java.util.zip
* package description</a>.
*
* <p>The following code fragment demonstrates a trivial compression
* and decompression of a string using <tt>Deflater</tt> and
* <tt>Inflater</tt>.
*
* <blockquote><pre>
* try {
* // Encode a String into bytes
* String inputString = "blahblahblah\u20AC\u20AC";
* byte[] input = inputString.getBytes("UTF-8");
*
* // Compress the bytes
* byte[] output = new byte[100];
* Deflater compresser = new Deflater();
* compresser.setInput(input);
* compresser.finish();
* int compressedDataLength = compresser.deflate(output);
*
* // Decompress the bytes
* Inflater decompresser = new Inflater();
* decompresser.setInput(output, 0, compressedDataLength);
* byte[] result = new byte[100];
* int resultLength = decompresser.inflate(result);
* decompresser.end();
*
* // Decode the bytes into a String
* String outputString = new String(result, 0, resultLength, "UTF-8");
* } catch(java.io.UnsupportedEncodingException ex) {
* // handle
* } catch (java.util.zip.DataFormatException ex) {
* // handle
* }
* </pre></blockquote>
*
* @author David Connelly
* @see Deflater
*/
public class Inflater {
private final ZStreamRef zsRef;
private byte[] buf = defaultBuf;
private int off, len;
private boolean finished;
private boolean needDict;
private long bytesRead;
private long bytesWritten;
private static final byte[] defaultBuf = new byte[0];
static {
/* Zip library is loaded from System.initializeSystemClass */
initIDs();
}
/**
* Creates a new decompressor. If the parameter 'nowrap' is true then
* the ZLIB header and checksum fields will not be used. This provides
* compatibility with the compression format used by both GZIP and PKZIP.
* <p>
* Note: When using the 'nowrap' option it is also necessary to provide
* an extra "dummy" byte as input. This is required by the ZLIB native
* library in order to support certain optimizations.
*
* @param nowrap if true then support GZIP compatible compression
*/
public Inflater(boolean nowrap) {
zsRef = new ZStreamRef(init(nowrap));
}
/**
* Creates a new decompressor.
*/
public Inflater() {
this(false);
}
/**
* Sets input data for decompression. Should be called whenever
* needsInput() returns true indicating that more input data is
* required.
*
* @param b the input data bytes
* @param off the start offset of the input data
* @param len the length of the input data
* @see Inflater#needsInput
*/
public void setInput(byte[] b, int off, int len) {
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
this.buf = b;
this.off = off;
this.len = len;
}
}
/**
* Sets input data for decompression. Should be called whenever
* needsInput() returns true indicating that more input data is
* required.
*
* @param b the input data bytes
* @see Inflater#needsInput
*/
public void setInput(byte[] b) {
setInput(b, 0, b.length);
}
/**
* Sets the preset dictionary to the given array of bytes. Should be
* called when inflate() returns 0 and needsDictionary() returns true
* indicating that a preset dictionary is required. The method getAdler()
* can be used to get the Adler-32 value of the dictionary needed.
*
* @param b the dictionary data bytes
* @param off the start offset of the data
* @param len the length of the data
* @see Inflater#needsDictionary
* @see Inflater#getAdler
*/
public void setDictionary(byte[] b, int off, int len) {
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
setDictionary(zsRef.address(), b, off, len);
needDict = false;
}
}
/**
* Sets the preset dictionary to the given array of bytes. Should be
* called when inflate() returns 0 and needsDictionary() returns true
* indicating that a preset dictionary is required. The method getAdler()
* can be used to get the Adler-32 value of the dictionary needed.
*
* @param b the dictionary data bytes
* @see Inflater#needsDictionary
* @see Inflater#getAdler
*/
public void setDictionary(byte[] b) {
setDictionary(b, 0, b.length);
}
/**
* Returns the total number of bytes remaining in the input buffer.
* This can be used to find out what bytes still remain in the input
* buffer after decompression has finished.
*
* @return the total number of bytes remaining in the input buffer
*/
public int getRemaining() {
synchronized (zsRef) {
return len;
}
}
/**
* Returns true if no data remains in the input buffer. This can
* be used to determine if #setInput should be called in order
* to provide more input.
*
* @return true if no data remains in the input buffer
*/
public boolean needsInput() {
synchronized (zsRef) {
return len <= 0;
}
}
/**
* Returns true if a preset dictionary is needed for decompression.
*
* @return true if a preset dictionary is needed for decompression
* @see Inflater#setDictionary
*/
public boolean needsDictionary() {
synchronized (zsRef) {
return needDict;
}
}
/**
* Returns true if the end of the compressed data stream has been
* reached.
*
* @return true if the end of the compressed data stream has been reached
*/
public boolean finished() {
synchronized (zsRef) {
return finished;
}
}
/**
* Uncompresses bytes into specified buffer. Returns actual number
* of bytes uncompressed. A return value of 0 indicates that
* needsInput() or needsDictionary() should be called in order to
* determine if more input data or a preset dictionary is required.
* In the latter case, getAdler() can be used to get the Adler-32
* value of the dictionary required.
*
* @param b the buffer for the uncompressed data
* @param off the start offset of the data
* @param len the maximum number of uncompressed bytes
* @return the actual number of uncompressed bytes
* @throws DataFormatException if the compressed data format is invalid
* @see Inflater#needsInput
* @see Inflater#needsDictionary
*/
public int inflate(byte[] b, int off, int len)
throws DataFormatException {
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
int thisLen = this.len;
int n = inflateBytes(zsRef.address(), b, off, len);
bytesWritten += n;
bytesRead += (thisLen - this.len);
return n;
}
}
/**
* Uncompresses bytes into specified buffer. Returns actual number
* of bytes uncompressed. A return value of 0 indicates that
* needsInput() or needsDictionary() should be called in order to
* determine if more input data or a preset dictionary is required.
* In the latter case, getAdler() can be used to get the Adler-32
* value of the dictionary required.
*
* @param b the buffer for the uncompressed data
* @return the actual number of uncompressed bytes
* @throws DataFormatException if the compressed data format is invalid
* @see Inflater#needsInput
* @see Inflater#needsDictionary
*/
public int inflate(byte[] b) throws DataFormatException {
return inflate(b, 0, b.length);
}
/**
* Returns the ADLER-32 value of the uncompressed data.
*
* @return the ADLER-32 value of the uncompressed data
*/
public int getAdler() {
synchronized (zsRef) {
ensureOpen();
return getAdler(zsRef.address());
}
}
/**
* Returns the total number of compressed bytes input so far.
*
* <p>Since the number of bytes may be greater than
* Integer.MAX_VALUE, the {@link #getBytesRead()} method is now
* the preferred means of obtaining this information.</p>
*
* @return the total number of compressed bytes input so far
*/
public int getTotalIn() {
return (int) getBytesRead();
}
/**
* Returns the total number of compressed bytes input so far.
*
* @return the total (non-negative) number of compressed bytes input so far
* @since 1.5
*/
public long getBytesRead() {
synchronized (zsRef) {
ensureOpen();
return bytesRead;
}
}
/**
* Returns the total number of uncompressed bytes output so far.
*
* <p>Since the number of bytes may be greater than
* Integer.MAX_VALUE, the {@link #getBytesWritten()} method is now
* the preferred means of obtaining this information.</p>
*
* @return the total number of uncompressed bytes output so far
*/
public int getTotalOut() {
return (int) getBytesWritten();
}
/**
* Returns the total number of uncompressed bytes output so far.
*
* @return the total (non-negative) number of uncompressed bytes output so far
* @since 1.5
*/
public long getBytesWritten() {
synchronized (zsRef) {
ensureOpen();
return bytesWritten;
}
}
/**
* Resets inflater so that a new set of input data can be processed.
*/
public void reset() {
synchronized (zsRef) {
ensureOpen();
reset(zsRef.address());
buf = defaultBuf;
finished = false;
needDict = false;
off = len = 0;
bytesRead = bytesWritten = 0;
}
}
/**
* Closes the decompressor and discards any unprocessed input.
* This method should be called when the decompressor is no longer
* being used, but will also be called automatically by the finalize()
* method. Once this method is called, the behavior of the Inflater
* object is undefined.
*/
public void end() {
synchronized (zsRef) {
long addr = zsRef.address();
zsRef.clear();
if (addr != 0) {
end(addr);
buf = null;
}
}
}
/**
* Closes the decompressor when garbage is collected.
*/
protected void finalize() {
end();
}
private void ensureOpen() {
assert Thread.holdsLock(zsRef);
if (zsRef.address() == 0) {
throw new NullPointerException("Inflater has been closed");
}
}
boolean ended() {
synchronized (zsRef) {
return zsRef.address() == 0;
}
}
private native static void initIDs();
private native static long init(boolean nowrap);
private native static void setDictionary(long addr, byte[] b, int off,
int len);
private native int inflateBytes(long addr, byte[] b, int off, int len)
throws DataFormatException;
private native static int getAdler(long addr);
private native static void reset(long addr);
private native static void end(long addr);
}
| [
"[email protected]"
] | |
508faed32bcb5986560cb590248cbc53fab6bba9 | 2672c126e9e05f42dc481419d7689c85cbae3d2b | /MicroserviciosSpringBoot/example-microservice-master-Person/src/main/java/com/profile/examplemicroservices/service/PersonServiceImpl.java | c78d23ba49ef946906a716de94da4a296f7a00c4 | [] | no_license | daviddp98/DIU-21 | 9cb411b34e938eaf3db766e86ff8ffb969c338ba | e9bd4f342ab60b981511d6a3991fd608cd5d079d | refs/heads/main | 2023-06-03T13:17:18.439880 | 2021-06-11T10:47:52 | 2021-06-11T10:47:52 | 329,587,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,796 | java | package com.profile.examplemicroservices.service;
import com.profile.examplemicroservices.model.PersonVO;
import com.profile.examplemicroservices.model.dto.PersonDTO;
import com.profile.examplemicroservices.repository.PersonRepository;
import com.profile.examplemicroservices.service.converter.PersonConverterToDTO;
import com.profile.examplemicroservices.service.converter.PersonConverterToVO;
import com.profile.examplemicroservices.service.impl.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class PersonServiceImpl implements PersonService {
@Autowired
private PersonRepository personRepository;
@Autowired
private PersonConverterToDTO personConverterToDTO;
@Autowired
private PersonConverterToVO personConverterToVO;
@Override
public List <PersonDTO> getAll() {
return personRepository.findAll()
.stream()
.map( personConverterToDTO::convert )
.collect( Collectors.toList());
}
@Override
public PersonDTO create(PersonDTO city ) {
PersonVO personVO = personConverterToVO.convert( city );
return personConverterToDTO.convert( personRepository.insert(personVO) );
}
@Override
public PersonDTO update(PersonDTO city ) {
PersonVO personVO = personConverterToVO.convert( city );
return personConverterToDTO.convert( personRepository.save(personVO) );
}
@Override
public boolean delete( String id ) {
try{
personRepository.deleteById( id );
return Boolean.TRUE;
} catch (Exception e){
return Boolean.FALSE;
}
}
}
| [
"[email protected]"
] | |
d9a1517bf85b1b5897f52b1dfa269ea2347fa92b | 6114e67c912a631ca80b2e5126262d241309ccc6 | /src/main/java/com/pmo/dashboard/controller/SendEmailController.java | 6f636ea52b2d2046030143d416df499f4f02e699 | [] | no_license | chaings/PMO | fe109414f9dadc02e16a560ed81a998cbc687db0 | 49860195f23109ac5e23a2be4840a7eee0d6349f | refs/heads/master | 2020-03-13T20:41:34.610435 | 2018-09-06T03:20:51 | 2018-09-06T03:20:51 | 131,280,217 | 3 | 0 | null | 2018-04-27T10:08:51 | 2018-04-27T10:08:50 | null | UTF-8 | Java | false | false | 6,685 | java | package com.pmo.dashboard.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.pmo.dashboard.entity.CandidateInterview;
import com.pmo.dashboard.entity.Employee;
import com.pmo.dashboard.entity.User;
import com.pmo.dashboard.util.SendUtil;
import com.pom.dashboard.service.EmployeeService;
import com.pom.dashboard.service.InterviewService;
import com.pom.dashboard.service.UserService;
/**
* 邮件发送
* @author Devin
* @since 2018-3-27
*
*/
@Controller
@RequestMapping(value="/sendemail")
public class SendEmailController {
@Resource
UserService userService;
@Resource
InterviewService interviewService;
@Resource
EmployeeService employeeService;
/**
* 发送邮件--添加需求时
* @param sei
* @return
*/
@RequestMapping("/send1")
@ResponseBody
public boolean send1(final HttpServletRequest request,
final HttpServletResponse response){
try{
String eHr = request.getParameter("ehr");
Map<String,Object> map = new HashMap<String,Object>();
JSONArray array= new JSONArray(eHr);
for(int i=0;i<array.length();i++){
if(array.get(i)!=null && !"".equals(array.get(i))){
map.put("ehr", array.get(i));
List<User> list = userService.getUser(map);
if(list.get(0).getEmail()!=null && !"".equals(list.get(0).getEmail())){
SendUtil.send(list.get(0).getEmail(), "Pmo系统有新的需求被添加", "你好:Pmo系统有新的需求被添加,请及时查看,谢谢!");
}
}
}
return true;
}catch(Exception e){
}
return false;
}
/**
* 发送邮件--修改需求时
* @param sei
* @return
*/
@RequestMapping("/send2")
@ResponseBody
public boolean send2(final HttpServletRequest request,
final HttpServletResponse response){
try{
String eHr = request.getParameter("ehr");
//获取需求编号
String demandid = request.getParameter("demandid");
Map<String,Object> map = new HashMap<String,Object>();
JSONArray array= new JSONArray(eHr);
for(int i=0;i<array.length();i++){
if(array.get(i)!=null && !"".equals(array.get(i))){
map.put("ehr", array.get(i));
List<User> list = userService.getUser(map);
if(list.get(0).getEmail()!=null && !"".equals(list.get(0).getEmail())){
SendUtil.send(list.get(0).getEmail(), "Pmo系统编号为["+demandid+"]的需求被修改", "你好:Pmo系统编号为["+demandid+"]的需求被修改,请及时查看,谢谢!");
}
}
}
return true;
}catch(Exception e){
}
return false;
}
/**
* 发送邮件--招聘管理-HR确认
* @param sei
* @return
*/
@RequestMapping("/send3")
@ResponseBody
public boolean send3(final HttpServletRequest request,
final HttpServletResponse response){
try{
String eHr = request.getParameter("ehr");
//获取候选人ID
String canid = request.getParameter("candidateId");
//获取是否发送到面试官标志
String issendtointerview = request.getParameter("issendtointerview");
Map<String,Object> map = new HashMap<String,Object>();
JSONArray array= new JSONArray(eHr);
//发送到RM
for(int i=0;i<array.length();i++){
if(array.get(i)!=null && !"".equals(array.get(i))){
map.put("ehr", array.get(i));
List<User> list = userService.getUser(map);
if(list.get(0).getEmail()!=null && !"".equals(list.get(0).getEmail())){
SendUtil.send(list.get(0).getEmail(), "Pmo系统,HR已确认面试安排", "你好:HR已确认面试安排,请及时查看,谢谢!");
}
}
}
//发送到面试官
if(issendtointerview.equals("1")){
Map<String,Object> param = new HashMap<String,Object>();
param.put("candidid", canid);
CandidateInterview ci = interviewService.getInteviewer(param);
if(ci.getInterviewerId()!=null && !"".equals(ci.getInterviewerId())){
Employee ep = employeeService.queryEmployeeById(ci.getInterviewerId());
if(ep.getEmail()!=null && !"".equals(ep.getEmail())){
SendUtil.send(ep.getEmail(), "Pmo系统,HR已确认面试安排", "你好:HR已确认面试安排,请及时面试,谢谢!");
}
}
}
return true;
}catch(Exception e){
}
return false;
}
/**
* 发送邮件--面试管理-面试安排
* @param sei
* @return
*/
@RequestMapping("/send4")
@ResponseBody
public boolean send4(final HttpServletRequest request,
final HttpServletResponse response){
try{
String eHr = request.getParameter("ehr");
//获取需求编号
//String demandid = request.getParameter("demandid");
Map<String,Object> map = new HashMap<String,Object>();
JSONArray array= new JSONArray(eHr);
for(int i=0;i<array.length();i++){
if(array.get(i)!=null && !"".equals(array.get(i))){
map.put("ehr", array.get(i));
List<User> list = userService.getUser(map);
if(list.get(0).getEmail()!=null && !"".equals(list.get(0).getEmail())){
SendUtil.send(list.get(0).getEmail(), "Pmo系统,RM已成功安排面试", "你好:RM已成功安排面试,请及时跟候选人确认,谢谢!");
}
}
}
return true;
}catch(Exception e){
}
return false;
}
/**
* 发送邮件--招聘管理-推送候选人
* @param sei
* @return
*/
@RequestMapping("/send5")
@ResponseBody
public boolean send5(final HttpServletRequest request,
final HttpServletResponse response){
try{
String eHr = request.getParameter("ehr");
//获取需求编号
//String demandid = request.getParameter("demandid");
Map<String,Object> map = new HashMap<String,Object>();
JSONArray array= new JSONArray(eHr);
for(int i=0;i<array.length();i++){
if(array.get(i)!=null && !"".equals(array.get(i))){
map.put("ehr", array.get(i));
List<User> list = userService.getUser(map);
if(list.get(0).getEmail()!=null && !"".equals(list.get(0).getEmail())){
SendUtil.send(list.get(0).getEmail(), "Pmo系统,HR已成功推送候选人", "你好:HR已成功推送候选人,请及时安排面试,谢谢!");
}
}
}
return true;
}catch(Exception e){
}
return false;
}
}
| [
"[email protected]"
] | |
cb1d7e3faf7f5452c9cc382680c65640d2c0140c | 028cbe18b4e5c347f664c592cbc7f56729b74060 | /external/modules/relaxngcc/src/relaxngcc/parser/IncludeParserRuntime.java | 997d582cbe0138fff2aef93622a9eefcf6541c18 | [] | no_license | dmatej/Glassfish-SVN-Patched | 8d355ff753b23a9a1bd9d7475fa4b2cfd3b40f9e | 269e29ba90db6d9c38271f7acd2affcacf2416f1 | refs/heads/master | 2021-05-28T12:55:06.267463 | 2014-11-11T04:21:44 | 2014-11-11T04:21:44 | 23,610,469 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,215 | java | package relaxngcc.parser;
import relaxngcc.parser.state.IncludedGrammarState;
/**
* Used to parse grammar included by <include> elements.
*
* @author Kohsuke Kawaguchi ([email protected])
*/
public class IncludeParserRuntime extends ParserRuntime {
/**
* @param
* The parent runtime object that created this runtime.
*/
public IncludeParserRuntime( ParserRuntime parent ) {
_start = new IncludedGrammarState(this);
setRootHandler(_start);
// inherit context from the parent
grammar = parent.grammar;
_parent = parent;
_nsStack.add(parent.getCurrentAttributes()); // inherit the ns attribute
}
/** The root state object that we use to parse the RELAX NG grammar. */
private final IncludedGrammarState _start;
/** Parent runtime object. */
private final ParserRuntime _parent;
public void appendGlobalImport( String code ) {
_parent.appendGlobalImport(code);
}
public void appendGlobalBody( String code ) {
_parent.appendGlobalBody(code);
}
protected void checkLastModifiedTime( long time ) {
_parent.checkLastModifiedTime(time);
}
}
| [
"janey@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5"
] | janey@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5 |
bd0bbfa66d2d1f1b56052b23b7c168c598304c67 | 6018c9bcf3eec8854238a8107e491a19b4c40728 | /LamdabasicsanAssignment/src/LambdaBasics/Lambdaseven.java | e4378ffd0d6d9fd49a2d23f78d7bd94c78b15e56 | [] | no_license | Ganesh-6301/Spring-Core | 1b41cbf8f37d27f89a2b48033c5a68069d3c94f3 | 4f10736d0cf35f5a769bff93da91b0f44a9828e5 | refs/heads/master | 2023-04-23T08:01:13.650843 | 2021-05-14T14:30:58 | 2021-05-14T14:30:58 | 367,392,636 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 707 | java | package LambdaBasics;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class Lambdaseven {
public static void main(String[] args) {
HashMap<String,String> h=new HashMap<String, String>();
StringBuilder p=new StringBuilder();
h.put("Navin", "Venky");
h.put("Rohan", "Narsha");
h.put("Naga", "Asha");
Set s1=h.entrySet();
System.out.println(s1);
Iterator na=s1.iterator();
while(na.hasNext())
{
Map.Entry m1 =(Map.Entry)na.next();
String n=(String) m1.getKey()+m1.getValue();
p.append(n);
}
System.out.println(p);
}
}
| [
"[email protected]"
] | |
b848f27debe3d0a334d982d0012f417c517ed58b | e61b05f444a2621567c444f83e229f3067e3dc7d | /src/main/java/codesquad/domain/AttachmentRepository.java | b3bb30dd825c73aa9bad0ce14618ab6ee8aeafbe | [] | no_license | imjinbro/java-ims | 83c60c5f4b71fa4beaacbfb0d7b93b7b240c85d6 | f200c9de950a2889fe8993b1b7489b51089e75ad | refs/heads/master | 2020-03-19T20:04:39.371250 | 2018-08-23T15:45:02 | 2018-08-23T15:45:02 | 136,887,080 | 0 | 0 | null | 2018-06-11T07:02:05 | 2018-06-11T07:02:05 | null | UTF-8 | Java | false | false | 170 | java | package codesquad.domain;
import org.springframework.data.repository.CrudRepository;
public interface AttachmentRepository extends CrudRepository<Attachment, Long> {
}
| [
"[email protected]"
] | |
d309906ffc894015c37356209f5970950d2e787b | 4de4d25d636e03d6e08bdbfb0f8e07587b7d933a | /kodilla-patterns/src/test/java/com/kodilla/patterns/singleton/prototype/library/LibraryTestSuite.java | fd860abec9a6a0e60e30e9571a269381a97557fc | [] | no_license | MarcinBilant/Marcin-Bilant-kodilla-java | 10b18784f9bd753898c562476ca16c838db08811 | 022b1f9e4ee42f4b0a78c2c71ebd861e305515d1 | refs/heads/master | 2020-05-04T23:54:28.533251 | 2019-11-20T21:51:31 | 2019-11-20T21:51:31 | 179,558,960 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,643 | java | package com.kodilla.patterns.singleton.prototype.library;
import com.kodilla.patterns.prototype.Library.Book;
import com.kodilla.patterns.prototype.Library.Library;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDate;
import java.util.stream.IntStream;
public class LibraryTestSuite {
@Test
public void testGetBooks() {
//given
Library library = new Library("Library number 1");
IntStream.iterate(1, n -> n + 1)
.limit(10)
.forEach(n -> library.getBooks().add(new Book("title" + n, "author" + n,
LocalDate.of(2005, 2, 3).plusYears(n))));
//when
Library clonedLibrary = null;
try {
clonedLibrary = library.shallowCopy();
clonedLibrary.setName("Library number 2");
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
Library deepClonedLibrary = null;
try {
deepClonedLibrary = library.deepCopy();
deepClonedLibrary.setName("Library number 3");
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
library.getBooks().remove(new Book("title1", "author1", LocalDate.of(2006,2,3)));
//then
Assert.assertEquals(9, library.getBooks().size());
Assert.assertEquals(9, clonedLibrary.getBooks().size());
Assert.assertEquals(10, deepClonedLibrary.getBooks().size());
Assert.assertEquals(clonedLibrary.getBooks(), library.getBooks());
Assert.assertNotEquals(deepClonedLibrary.getBooks(), library.getBooks());
}
}
| [
"[email protected]"
] | |
f3610fbb69e6986ef93b4cb2544fcbc41020f2bc | 6ab668843032fee25fbbdd3ca35fb1ea3a2ae2d4 | /LightHttp-Library/src/main/java/com/yuqianhao/lighthttp/reqheader/MethodType.java | 59a155b5a651712fc15539b9ed529f567a331eea | [
"Apache-2.0"
] | permissive | YuQianhao/LightHttp | 5c8cd6b03389da63d9f51fc08843733826a91782 | 0e901d440e77149aa7674a41c0b03cc67317a3d7 | refs/heads/master | 2022-01-29T08:22:36.198053 | 2022-01-07T08:49:13 | 2022-01-07T08:49:13 | 214,945,316 | 10 | 0 | null | 2020-04-24T02:07:25 | 2019-10-14T04:07:10 | Java | UTF-8 | Java | false | false | 221 | java | package com.yuqianhao.lighthttp.reqheader;
public class MethodType {
public static final int GET=0;
public static final int POST=1;
public static final int PUT=2;
public static final int DELETE=3;
}
| [
"yqh916640168****"
] | yqh916640168**** |
6ac1b9444338492e1d4a13cd1dd058aa3be31d08 | c1248eb892670ca9ea49381e812b2d4f659ff2c9 | /src/main/java/com/yunnex/ops/erp/modules/diagnosis/entity/DiagnosisIndustryAttribute.java | 52a0fea1697e4e397c76dbf8be58832680b41dc6 | [
"Apache-2.0"
] | permissive | 13802706376/HIYA_CORE_CODES_6ISA_ops-web-erp | fe62fb23211648587b5d8396a9462e0587c23e55 | 705e90e0e48ec2afaa63d54db6b74d39fad750ff | refs/heads/master | 2020-04-08T08:24:09.287005 | 2018-11-26T14:33:11 | 2018-11-26T14:33:11 | 159,177,385 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 2,069 | java | package com.yunnex.ops.erp.modules.diagnosis.entity;
import org.hibernate.validator.constraints.Length;
import com.yunnex.ops.erp.common.persistence.DataEntity;
/**
* 行业属性Entity
*
* @author yunnex
* @version 2018-04-03
*/
public class DiagnosisIndustryAttribute extends DataEntity<DiagnosisIndustryAttribute> {
private static final long serialVersionUID = 1L;
private String name; // 行业名称
private String industryAttribute; // 推荐的行业属性
private String pid; // 父类行业
private Integer level; // 当前行业分类级别,默认从1开始递增
private Integer order; // 排序
public DiagnosisIndustryAttribute() {
super();
}
public DiagnosisIndustryAttribute(String id) {
super(id);
}
@Length(min = 0, max = 255, message = "行业名称长度必须介于 0 和 255 之间")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Length(min = 0, max = 255, message = "推荐的行业属性长度必须介于 0 和 255 之间")
public String getIndustryAttribute() {
return industryAttribute;
}
public void setIndustryAttribute(String industryAttribute) {
this.industryAttribute = industryAttribute;
}
@Length(min = 0, max = 64, message = "父类行业长度必须介于 0 和 64 之间")
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
}
| [
"caozhijun@caozhijun-book"
] | caozhijun@caozhijun-book |
21dcf04efb081d647805e9d59ea1aeb4ca112ee4 | 32e2b993c25bada9d148a7d53ca6e48a5067f953 | /KruskalAndPrim/src/by/bsu/seredinski/algorithms/Kruskal.java | d96af71e28d66751f19f5a06823f883f560b9e0d | [] | no_license | TimSeredinski/Algorithms | 281126a849d07126dd905fbd484762d057a87368 | 232d03613e27979f0f378c47a451868f678ed262 | refs/heads/master | 2020-03-28T12:10:30.177606 | 2019-05-17T07:52:44 | 2019-05-17T07:52:44 | 148,275,441 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 890 | java | package by.bsu.seredinski.algorithms;
import by.bsu.seredinski.entity.DSU;
import by.bsu.seredinski.entity.Edge;
import by.bsu.seredinski.entity.EdgesOfGraph;
import by.bsu.seredinski.entity.Graph;
import java.util.Comparator;
public class Kruskal {
public static EdgesOfGraph doKruskal(Graph graph) {
EdgesOfGraph edges = new EdgesOfGraph();
edges.setEdgesOfGraph(graph.getMatrixOfIncidence());
edges.getEdges().sort(Comparator.comparing(Edge::getWeight));
DSU dsu = new DSU(graph.getNumberOfVertices());
EdgesOfGraph minimumSpanningTree = new EdgesOfGraph();
for (Edge edge : edges.getEdges()) {
if (dsu.unite(edge.getFirstVertex(), edge.getSecondVertex())) {
minimumSpanningTree.addEdge(edge);
System.out.println(edge);
}
}
return minimumSpanningTree;
}
}
| [
"[email protected]"
] | |
5dd79a4c8deeedaa9ec877c95091a6117fe38e17 | 931136d2bfda3ad0eb3608b9cd583dad5d0d977d | /multipart-redis/src/main/java/com.kagura/config/order/KinJ.java | 46b0e21cdc6ad9557c0c132a97a6a413d501e024 | [] | no_license | hongwen1993/multipart | 59cbfe5e670ee2afe3ec58b73fdcb37da06fd5a2 | 9bc8f733991e200453d396ae03aeddccd6382f85 | refs/heads/master | 2023-04-02T13:52:13.092592 | 2023-03-22T16:36:33 | 2023-03-22T16:36:33 | 191,141,376 | 6 | 2 | null | 2023-02-22T06:42:38 | 2019-06-10T09:52:01 | Java | UTF-8 | Java | false | false | 396 | java | package com.kagura.config.order;
import org.springframework.core.Ordered;
/**
* KingJ
*
* @author <a href="mailto:[email protected]">Karas</a>
* @date 2019/7/24 15:13
* @since 1.0.0
*/
public class KinJ implements Ordered {
public KinJ() {
System.err.println("KinJ -> 构造");
}
@Override
public int getOrder() {
return Integer.MAX_VALUE;
}
}
| [
"[email protected]"
] | |
db0caf615d81e12c9befa278e829aebf21273b3a | 4f042b3eced6865f6b9492d226a5035cb08d57d9 | /addressbook-web-tests/src/test/java/pl/kasieksoft/addressbook/model/GroupData.java | 0d6a2baccc6c006d51195c37b3a960b08f6ae67c | [
"Apache-2.0"
] | permissive | bike7/testingtasks | 63dcbd66a656f0d7c3c334a899c06b8cb51401bf | dd76da8be055d3a42daed86d5a9d8972ec64bb9b | refs/heads/master | 2020-04-05T12:41:23.694745 | 2019-05-28T15:26:04 | 2019-05-28T15:26:04 | 156,876,223 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,196 | java | package pl.kasieksoft.addressbook.model;
import com.google.gson.annotations.Expose;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@XStreamAlias("group")
@Entity
@Table(name = "group_list")
public class GroupData {
@XStreamOmitField
@Id
@Column(name = "group_id")
private int id;
@Expose
@Column(name = "group_name")
private String name;
@Expose
@Column(name = "group_header")
@Type(type = "text")
private String header;
@Expose
@Column(name = "group_footer")
@Type(type = "text")
private String footer;
@ManyToMany(mappedBy = "groups")
private Set<ContactData> contacts = new HashSet<ContactData>();
public GroupData(int id, String name, String header, String footer) {
this.id = id;
this.name = name;
this.header = header;
this.footer = footer;
}
private GroupData() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public String getHeader() {
return header;
}
public String getFooter() {
return footer;
}
public Contacts getContacts() {
return new Contacts(contacts);
}
@Override
public String toString() {
return "GroupData{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GroupData groupData = (GroupData) o;
return id == groupData.id &&
Objects.equals(name, groupData.name) &&
Objects.equals(header, groupData.header) &&
Objects.equals(footer, groupData.footer);
}
@Override
public int hashCode() {
return Objects.hash(id, name, header, footer);
}
}
| [
"[email protected]"
] | |
83e111ae7b1f568c196ac1733972b5a535fbb730 | dbbfcdd4db7c2f4509a2bc16ef13ff99ae164d9e | /Yi's code/6231Project/src/server/MCGServer.java | 6304ef0cad962b8bf9f7d87b93b2adbe81ceabf3 | [] | no_license | Divyansh88/Distributed-Library-Management-System-DLMS-Project | 7245eaf8bafbcaeb2e686f8298f0e7c7e81b1b3f | 1af02a8ad76eaa19205d179bf826b486aae29f88 | refs/heads/master | 2020-09-10T19:05:01.969393 | 2019-11-15T00:15:41 | 2019-11-15T00:15:41 | 221,793,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,018 | java | package server;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import Implementation.LibraryObj;
import service.logService;
public class MCGServer {
public DatagramSocket aSocket = null;
private volatile boolean exit = false;
public MCGServer(){
try {
aSocket = new DatagramSocket();
System.out.println("initialize mcg server");
}
catch(SocketException e) {
System.out.println("initialize mcg server error ..........");
}
}
public void closeSocket(){
aSocket.close();
}
public void start() {
try {
logService log = new logService("MCGserver");
LibraryObj obj = new LibraryObj();
obj = new LibraryObj("MCGserver");
System.out.println("MCG Server ready and waiting ...");
log.writeLog("Server is Started");
// Receive
try {
aSocket = new DatagramSocket(2222);
byte[] buffer = new byte[1000];
//System.out.println("Port 2222 ready............");
while (true) {
DatagramPacket request = new DatagramPacket(buffer, buffer.length);
aSocket.receive(request);
String s = new String(request.getData(),
request.getOffset(),
request.getLength(), "UTF-8");
// System.out.println("server receive message" + s);
if(s.contains("@")){
String[] messageSegment = s.split("_");
String SequenceID = messageSegment[0];
InetAddress FEUdpInetAddress = InetAddress.getByName(messageSegment[1].split(":")[0]);
int FEUdpPort = Integer.parseInt(messageSegment[1].split(":")[1]);
String requestName = messageSegment[2];
String requestParam[] = messageSegment[3].split("@");
// System.out.println("SequenceID is: " + SequenceID);
String answer = "";
switch(requestName){
case "addItem": {
String managerID = requestParam[0];
String itemID = requestParam[1];
String itemName = requestParam[2];
int quantity = Integer.parseInt(requestParam[3]);
answer = obj.adItem(managerID, itemID, itemName, quantity, true);
break;
}
case "removeItem": {
String managerID = requestParam[0];
String itemID = requestParam[1];
int quantity = Integer.parseInt(requestParam[2]);
answer = obj.removeItem(managerID, itemID, quantity);
break;
}
case "listItemAvailability": {
String managerID = requestParam[0];
answer = obj.listItemAvailability(managerID);
break;
}
case "borrowItem": {
String userID = requestParam[0];
String itemID = requestParam[1];
String days = requestParam[2];
answer = obj.borrowItem(userID, itemID, days);
break;
}
case "findItem": {
String userID = requestParam[0];
String itemName = requestParam[1];
answer = obj.findItem(userID, itemName);
break;
}
case "returnItem": {
String userID = requestParam[0];
String itemID = requestParam[1];
answer = obj.returnItem(userID, itemID);
break;
}
case "addWaitQueue": {
String userID = requestParam[0];
String itemID = requestParam[1];
answer = obj.addWaitQueue(userID, itemID);
break;
}
case "exchangeItem": {
String userID = requestParam[0];
String newItemID = requestParam[1];
String oldItemID = requestParam[2];
answer = obj.exchangeItem(userID, newItemID, oldItemID);
break;
}
}
answer = SequenceID +"_" + answer;
System.out.println("Answer is: " + answer);
byte[] message = answer.getBytes();
// System.out.println("ip is: "+FEUdpInetAddress + "port is: " + FEUdpPort);
DatagramPacket reply = new DatagramPacket(message, answer.length(), FEUdpInetAddress,
FEUdpPort);
aSocket.send(reply);
}
else{
String[] parts = s.split("_");
String action = parts[0];
String answer = "";
switch(action){
case "borrowItem": {
String userID = parts[1];
String itemID = parts[2];
String days = parts[3];
answer = obj.borrow(userID, itemID, days);
break;
}
case "findItem": {
String userID = parts[1];
String itemName = parts[2];
answer = obj.find(userID, itemName);
break;
}
case "returnItem": {
String userID = parts[1];
String itemID = parts[2];
answer = obj.returnBook(userID, itemID);
break;
}
case "reserveItem": {
String userID = parts[1];
String itemID = parts[2];
answer = obj.reserve(userID, itemID);
break;
}
case "cancelReserve": {
String userID = parts[1];
String itemID = parts[2];
answer = obj.cancelR(userID, itemID);
break;
}
case "holdItem": {
String userID = parts[1];
String itemID = parts[2];
answer = obj.holdBook(userID, itemID);
break;
}
case "RholdItem": {
String userID = parts[1];
String itemID = parts[2];
answer = obj.RholdBook(userID, itemID);
break;
}
}
byte[] message = answer.getBytes();
DatagramPacket reply = new DatagramPacket(message, answer.length(), request.getAddress(),
request.getPort());
aSocket.send(reply);
}
}
} catch (SocketException e) {
System.out.println("Socket MCG: " + e.getMessage());
} catch (IOException e) {
System.out.println("IO: " + e.getMessage());
} finally {
if (aSocket != null)
aSocket.close();
}
}
catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
public void run() {
while(!exit){ System.out.println("Server is running....."); }
System.out.println("Server is stopped....");
}
public void stop(){
exit = true;
}
}
| [
"[email protected]"
] | |
4d9a0abb2d08901a8ef965b4d384d58fdad9b48f | 582ab62311335794a9e9a4ca63d33528e607c2fd | /app/src/main/java/com/mob/sms/activity/ShareQrcodeActivity.java | e2821ee8832c60d34a052b3540f3576c55d86e11 | [] | no_license | bbbayin/phonehelper | 893f756b0600de73db4e191872f852ac9ad39598 | 90b0e000d449004b357d82e6d6037bef4cb46e2d | refs/heads/master | 2023-07-09T15:28:40.109833 | 2021-06-08T11:58:25 | 2021-06-08T11:58:25 | 344,005,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,790 | java | package com.mob.sms.activity;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.mob.sms.R;
import com.mob.sms.base.BaseActivity;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import java.util.Hashtable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class ShareQrcodeActivity extends BaseActivity {
@BindView(R.id.qrcode)
ImageView mQrcode;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share_qrcode);
ButterKnife.bind(this);
setStatusBar(getResources().getColor(R.color.green));
mQrcode.setImageBitmap(createQRCodeBitmap(getIntent().getStringExtra("url"), UIUtil.dip2px(this, 207),
UIUtil.dip2px(this, 207), "UTF-8", "H", "1", Color.BLACK, Color.WHITE));
}
/**
* 生成简单二维码
*
* @param content 字符串内容
* @param width 二维码宽度
* @param height 二维码高度
* @param character_set 编码方式(一般使用UTF-8)
* @param error_correction_level 容错率 L:7% M:15% Q:25% H:35%
* @param margin 空白边距(二维码与边框的空白区域)
* @param color_black 黑色色块
* @param color_white 白色色块
* @return BitMap
*/
private Bitmap createQRCodeBitmap(String content, int width, int height,
String character_set, String error_correction_level,
String margin, int color_black, int color_white) {
// 字符串内容判空
if (TextUtils.isEmpty(content)) {
return null;
}
// 宽和高>=0
if (width < 0 || height < 0) {
return null;
}
try {
/** 1.设置二维码相关配置 */
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
// 字符转码格式设置
if (!TextUtils.isEmpty(character_set)) {
hints.put(EncodeHintType.CHARACTER_SET, character_set);
}
// 容错率设置
if (!TextUtils.isEmpty(error_correction_level)) {
hints.put(EncodeHintType.ERROR_CORRECTION, error_correction_level);
}
// 空白边距设置
if (!TextUtils.isEmpty(margin)) {
hints.put(EncodeHintType.MARGIN, margin);
}
/** 2.将配置参数传入到QRCodeWriter的encode方法生成BitMatrix(位矩阵)对象 */
BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
/** 3.创建像素数组,并根据BitMatrix(位矩阵)对象为数组元素赋颜色值 */
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
//bitMatrix.get(x,y)方法返回true是黑色色块,false是白色色块
if (bitMatrix.get(x, y)) {
pixels[y * width + x] = color_black;//黑色色块像素设置
} else {
pixels[y * width + x] = color_white;// 白色色块像素设置
}
}
}
/** 4.创建Bitmap对象,根据像素数组设置Bitmap每个像素点的颜色值,并返回Bitmap对象 */
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
} catch (WriterException e) {
e.printStackTrace();
return null;
}
}
@OnClick({R.id.back, R.id.save, R.id.wx_ll, R.id.qq_ll})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.back:
finish();
break;
case R.id.save:
break;
case R.id.wx_ll:
break;
case R.id.qq_ll:
break;
}
}
}
| [
"[email protected]"
] | |
2b78a4d291d585cac8b42237ce510beb0db29111 | 402e4c21f0607555eaba00cf7789df7dbc05e6d5 | /src/main/java/com/pcg/search/utils/SolrQueryUtils.java | 470e7ca5bc81383118349cd9b1e38626e4b1fa0d | [] | no_license | obinna240/CouncilDemo | 9212e376c002eee27a44afb207a1e1a2009c1739 | b495b46911b8cf747ea9b30fbbdc897b464a4ef9 | refs/heads/master | 2020-03-07T22:14:08.332466 | 2018-04-02T11:43:24 | 2018-04-02T11:43:24 | 127,748,657 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,737 | java | package com.pcg.search.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
//import org.apache.commons.lang.StringUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import uk.me.jstott.jcoord.LatLng;
import com.pcg.db.mongo.dao.SAAddressDAO;
import com.pcg.db.mongo.model.SAAddress;
import com.pcg.db.mongo.model.SAAddress.Coverage;
import com.pcg.search.api.beans.CareHomeBean;
import com.pcg.search.api.beans.CareHomeBeans;
import com.pcg.search.api.beans.PaginatorBean;
import com.pcg.search.api.beans.ResultBean;
import com.pcg.util.Cleaner;
import com.pcg.util.Utils;
/**
*
* @author oonyimadu
*
*/
public class SolrQueryUtils
{
private static Log log = LogFactory.getLog(SolrQueryUtils .class);
@Autowired
private QueryParameters queryParameters;
@Autowired
private SAAddressDAO addressMasterUKDAO;
public QueryParameters getQueryParameters () {
return queryParameters;
}
public void setQueryParameters (QueryParameters queryParameters) {
this.queryParameters = queryParameters;
}
/**
*/
public ResultBean doGenericSearch(String careProvided, String admissions, String typeOfCareHome, Map<String,Object> qParamStartRow)
{
ResultBean resultBean = null;
CareHomeBeans careHomeBeans = null;
QueryResponse response = null;
ErrorManager2 errorManager = null;
String url = queryParameters.getSolrQueryUrl();
PaginatorBean originalPaginatorBean = null;
HashMap<String, List<String>> mapStr = queryParameters.getQuery();
List<String> listOfFields = mapStr.get("generalSearch");
String queryLetter = listOfFields.get(0);
String queryString = listOfFields.get(1);
String fl = listOfFields.get(2);
String careProvFields = listOfFields.get(3);
String admissionsFields = listOfFields.get(4);
String homeTypeFields = listOfFields.get(5);
SolrClient server = new HttpSolrClient(url);
SolrQuery query = new SolrQuery();
query.setQuery(queryString);
if(StringUtils.isNotBlank(careProvided)||StringUtils.isNotBlank(admissions)||StringUtils.isNotBlank(typeOfCareHome))
{
List<String> filters = new ArrayList<String>();
if(StringUtils.isNotBlank(careProvided))
{
String[] careProvided_Filters = Cleaner.splitUnderscore(careProvided);
Boolean valBool = Cleaner.checkParams(queryParameters, "careprovided", careProvided_Filters);
if(valBool==true)
{
List<String> list = Cleaner.mergeListForFiler(careProvFields, careProvided_Filters);
filters.addAll(list);
}
else
{
if(errorManager==null)
{
errorManager = new ErrorManager2();
List<String> errorList = new ArrayList<String>();
errorList.add("Invalid Care Provided (cp) Parameter provided");
errorManager.setListOfErrors(errorList);
}
}
}
if(StringUtils.isNotBlank(admissions))
{
String[] admission_Filters = Cleaner.splitUnderscore(admissions);
Boolean valBool = Cleaner.checkParams(queryParameters, "admissions", admission_Filters );
if(valBool==true)
{
List<String> list = Cleaner.mergeListForFiler(admissionsFields, admission_Filters);
filters.addAll(list);
}
else
{
if(errorManager==null)
{
errorManager = new ErrorManager2();
List<String> errorList = new ArrayList<String>();
errorList.add("Invalid admissions (ap) Parameter provided");
errorManager.setListOfErrors(errorList);
}
else
{
List<String> errorList = errorManager.getListOfErrors();
errorList.add("Invalid admissions (ap) Parameter provided");
errorManager.setListOfErrors(errorList);
}
}
}
if(StringUtils.isNotBlank(typeOfCareHome))
{
String[] typeOfCareHome_Filters = Cleaner.splitUnderscore(typeOfCareHome);
Boolean valBool = Cleaner.checkParams(queryParameters, "typeOfCareHome", typeOfCareHome_Filters);
if(valBool==true)
{
List<String> list = Cleaner.mergeListForFiler(homeTypeFields, typeOfCareHome_Filters);
//OR this here
//asa
List<String> newTcList = Cleaner.createFilterForTypeOfCare(list);
filters.addAll(newTcList);
}
else
{
if(errorManager==null)
{
errorManager = new ErrorManager2();
List<String> errorList = new ArrayList<String>();
errorList.add("Invalid type Of CareHome (tc) Parameter provided");
errorManager.setListOfErrors(errorList);
}
else
{
List<String> errorList = errorManager.getListOfErrors();
errorList.add("Invalid type Of CareHome (tc) Parameter provided");
errorManager.setListOfErrors(errorList);
}
}
}
String filteredStrings = Cleaner.createFilterParam(filters);
query.setParam("fq", filteredStrings);
}
query.setParam("fl", fl);
if(MapUtils.isNotEmpty(qParamStartRow))
{
Integer qStart = (Integer)qParamStartRow.get("queryStart");
Integer qRows = (Integer)qParamStartRow.get("queryRows");
originalPaginatorBean = (PaginatorBean)qParamStartRow.get("originalPaginatorBean");
query.setStart(qStart);
query.setRows(qRows);
}
try
{
response = server.query(query);
Long resultSize = response.getResults().getNumFound();
if(resultSize>0)
{
careHomeBeans = new CareHomeBeans();
List<CareHomeBean> careHomeBeanList = new ArrayList<CareHomeBean>();
Integer numberOfResults = (int)(long)resultSize;
resultBean = new ResultBean();
SolrDocumentList solrList = response.getResults();
if(CollectionUtils.isNotEmpty(solrList))
{
for(SolrDocument solrDoc:solrList)
{
CareHomeBean chb = Utils.doSearchResultBean(solrDoc);
careHomeBeanList.add(chb);
}
careHomeBeans.setCareHomeBean(careHomeBeanList);
PaginatorBean resultPBean = null;
if(originalPaginatorBean!=null)
{
resultPBean = PaginationUtils.doPaginationTest(numberOfResults, originalPaginatorBean);
careHomeBeans.setPaginatorBean(resultPBean);
}
resultBean.setCareHomeBeans(careHomeBeans);
resultBean.setTotalNumberOfResults(numberOfResults);
resultBean.setStart(query.getStart());
resultBean.setErrorManager(errorManager);
}
}
server.close();
}
catch(Exception ex)
{
ex.printStackTrace();
log.error(ex);
}
return resultBean;
}
public ResultBean doNameSearch(String name, String town, Map<String,Object> qParamStartRow)
{
ResultBean resultBean = null;
CareHomeBeans careHomeBeans = null;
QueryResponse response = null;
String url = queryParameters.getSolrQueryUrl();
PaginatorBean originalPaginatorBean = null;
HashMap<String, List<String>> mapStr = queryParameters.getQuery();
List<String> listOfFields = mapStr.get("nameSearch");
String queryLetter = listOfFields.get(0);
String queryStringStart = listOfFields.get(1);
String queryStringEnd = listOfFields.get(2);
String fl = listOfFields.get(3);
String filterField = listOfFields.get(4);
SolrClient server = new HttpSolrClient(url);
SolrQuery query = new SolrQuery();
if(StringUtils.isNotBlank(name))
{
name = StringUtils.normalizeSpace(name);
String qString = queryStringStart+name+queryStringEnd;
query.setQuery(qString);
query.setParam("fl", fl);
if(StringUtils.isNotBlank(town))
{
town = StringUtils.normalizeSpace(town);
query.setParam("fq", town);
}
if(MapUtils.isNotEmpty(qParamStartRow))
{
Integer qStart = (Integer)qParamStartRow.get("queryStart");
Integer qRows = (Integer)qParamStartRow.get("queryRows");
originalPaginatorBean = (PaginatorBean)qParamStartRow.get("originalPaginatorBean");
query.setStart(qStart);
query.setRows(qRows);
}
}
try
{
response = server.query(query);
Long resultSize = response.getResults().getNumFound();
if(resultSize>0)
{
careHomeBeans = new CareHomeBeans();
List<CareHomeBean> careHomeBeanList = new ArrayList<CareHomeBean>();
Integer numberOfResults = (int)(long)resultSize;
resultBean = new ResultBean();
SolrDocumentList solrList = response.getResults();
if(CollectionUtils.isNotEmpty(solrList))
{
for(SolrDocument solrDoc:solrList)
{
CareHomeBean chb = Utils.doSearchResultBean(solrDoc);
careHomeBeanList.add(chb);
}
careHomeBeans.setCareHomeBean(careHomeBeanList);
PaginatorBean resultPBean = null;
if(originalPaginatorBean!=null)
{
resultPBean = PaginationUtils.doPaginationTest(numberOfResults, originalPaginatorBean);
careHomeBeans.setPaginatorBean(resultPBean);
}
resultBean.setCareHomeBeans(careHomeBeans);
resultBean.setTotalNumberOfResults(numberOfResults);
resultBean.setStart(query.getStart());
}
}
server.close();
}
catch(Exception ex)
{
ex.printStackTrace();
log.error(ex);
}
return resultBean;
}
public ResultBean doLocationSearch(String town, String careProvided, String admissions,
String careHomeType, Map<String,Object> qParamStartRow)
{
ResultBean resultBean = null;
CareHomeBeans careHomeBeans = null;
QueryResponse response = null;
String url = queryParameters.getSolrQueryUrl();
PaginatorBean originalPaginatorBean = null;
SolrClient server = new HttpSolrClient(url);
SolrQuery query = new SolrQuery();
HashMap<String, List<String>> mapStr = queryParameters.getQuery();
List<String> listOfFields = mapStr.get("townPcSearch");
String queryLetter = listOfFields.get(0); //q
String aQuery = listOfFields.get(1); //*:*
String fq = listOfFields.get(2); //fq
String sort = listOfFields.get(9); //sort
String flist = listOfFields.get(11); //field list
String careProvFields = listOfFields.get(13); //miles
String admissionsFields = listOfFields.get(14); //miles
String homeTypeFields = listOfFields.get(15); //miles
String fl = listOfFields.get(16); //fl
String townField = listOfFields.get(17); //fl
String townFieldQuery = townField+":\""+town+"\"";
query.setParam(fl, flist);
query.setParam(queryLetter, aQuery);
if(StringUtils.isNotBlank(careProvided)||StringUtils.isNotBlank(admissions)||StringUtils.isNotBlank(careHomeType))
{
List<String> filters = new ArrayList<String>();
if(StringUtils.isNotBlank(careProvided))
{
String[] careProvided_Filters = Cleaner.splitUnderscore(careProvided);
List<String> list = Cleaner.mergeListForFiler(careProvFields, careProvided_Filters);
filters.addAll(list);
}
if(StringUtils.isNotBlank(admissions))
{
String[] admission_Filters = Cleaner.splitUnderscore(admissions);
List<String> list = Cleaner.mergeListForFiler(admissionsFields, admission_Filters);
filters.addAll(list);
}
if(StringUtils.isNotBlank(careHomeType))
{
String[] typeOfCareHome_Filters = Cleaner.splitUnderscore(careHomeType);
List<String> list = Cleaner.mergeListForFiler(homeTypeFields, typeOfCareHome_Filters);
List<String> newTcList = Cleaner.createFilterForTypeOfCare(list);
filters.addAll(newTcList);
}
filters.add(townFieldQuery);
String filteredStrings = Cleaner.createFilterParam(filters);
filteredStrings = "("+filteredStrings+")";
query.setParam(fq, filteredStrings);
}
else if(StringUtils.isBlank(careProvided)&& StringUtils.isBlank(admissions)&& StringUtils.isBlank(careHomeType))
{
query.setParam(fq, townFieldQuery);
}
if(MapUtils.isNotEmpty(qParamStartRow))
{
Integer qStart = (Integer)qParamStartRow.get("queryStart");
Integer qRows = (Integer)qParamStartRow.get("queryRows");
originalPaginatorBean = (PaginatorBean)qParamStartRow.get("originalPaginatorBean");
query.setStart(qStart);
query.setRows(qRows);
}
try
{
response = server.query(query);
Long resultSize = response.getResults().getNumFound();
if(resultSize>0)
{
careHomeBeans = new CareHomeBeans();
List<CareHomeBean> careHomeBeanList = new ArrayList<CareHomeBean>();
Integer numberOfResults = (int)(long)resultSize;
resultBean = new ResultBean();
SolrDocumentList solrList = response.getResults();
if(CollectionUtils.isNotEmpty(solrList))
{
for(SolrDocument solrDoc:solrList)
{
CareHomeBean chb = Utils.doSearchResultBean(solrDoc);
careHomeBeanList.add(chb);
}
careHomeBeans.setCareHomeBean(careHomeBeanList);
PaginatorBean resultPBean = null;
if(originalPaginatorBean!=null)
{
resultPBean = PaginationUtils.doPaginationTest(numberOfResults, originalPaginatorBean);
careHomeBeans.setPaginatorBean(resultPBean);
}
resultBean.setCareHomeBeans(careHomeBeans);
resultBean.setTotalNumberOfResults(numberOfResults);
resultBean.setStart(query.getStart());
}
}
server.close();
}
catch(Exception ex)
{
ex.printStackTrace();
log.error(ex);
}
return resultBean;
}
public ResultBean doLocationSearch(String locationType, String locationOrPostcode, String radius,
String careProvided, String admissions, String careHomeType, Map<String,Object> qParamStartRow)
{
String coordinates = "";
ResultBean resultBean = null;
CareHomeBeans careHomeBeans = null;
QueryResponse response = null;
String url = queryParameters.getSolrQueryUrl();
PaginatorBean originalPaginatorBean = null;
SolrClient server = new HttpSolrClient(url);
SolrQuery query = new SolrQuery();
HashMap<String, List<String>> mapStr = queryParameters.getQuery();
if(locationType.equalsIgnoreCase("postcode"))
{
String latitude = null;
String longitude = null;
List<SAAddress> listAddresses = addressMasterUKDAO.findByPostcode(locationOrPostcode, Coverage.UK);
if (listAddresses != null && listAddresses.size() > 0 )
{
// just use the first?
SAAddress addressmaster = listAddresses.get(0);
latitude = Double.toString(addressmaster.getLatitude());
longitude = Double.toString(addressmaster.getLongtitude());
} else {
LatLng latLng = addressMasterUKDAO.findLatLngByPostcode(locationOrPostcode, Coverage.UK);
if (latLng != null) {
Double lat = latLng.getLatitude();
Double lng = latLng.getLongitude();
latitude = Double.toString(lat);
longitude = Double.toString(lng);
latitude = StringUtils.normalizeSpace(latitude);
longitude = StringUtils.normalizeSpace(longitude);
}
}
if(StringUtils.isNotBlank(latitude)&&StringUtils.isNotBlank(longitude))
{
coordinates = latitude+","+longitude;
}
}
else if(locationType.equalsIgnoreCase("town"))
{
coordinates = queryParameters.getCoordinates().get(locationOrPostcode);
}
if(StringUtils.isNotBlank(coordinates))
{
List<String> listOfFields = mapStr.get("townPcSearch");
String queryLetter = listOfFields.get(0); //q
String aQuery = listOfFields.get(1); //*:*
String fq = listOfFields.get(2); //fq
String geofilt = listOfFields.get(3); //{!geofilt}
String sfield = listOfFields.get(4); //sfield
String sfieldValue = listOfFields.get(5); //location
String score = listOfFields.get(6); //score
String pt = listOfFields.get(7); //pt
String d = listOfFields.get(8); //d
String sort = listOfFields.get(9); //sort
String geodistSort = listOfFields.get(10); //geodist() asc
String flist = listOfFields.get(11); //field list
String miles = listOfFields.get(12); //miles
String careProvFields = listOfFields.get(13); //miles
String admissionsFields = listOfFields.get(14); //miles
String homeTypeFields = listOfFields.get(15); //miles
String fl = listOfFields.get(16); //fl
String radiusKm = Utils.milesToKm(radius);
query.setParam(d,radiusKm);
query.setParam(pt,coordinates);
query.setParam(score,miles);
query.setParam(sort, geodistSort);
query.setParam(sfield, sfieldValue);
query.setParam(fl, flist);
query.setParam(queryLetter, aQuery);
if(StringUtils.isNotBlank(careProvided)||StringUtils.isNotBlank(admissions)||StringUtils.isNotBlank(careHomeType))
{
List<String> filters = new ArrayList<String>();
if(StringUtils.isNotBlank(careProvided))
{
String[] careProvided_Filters = Cleaner.splitUnderscore(careProvided);
List<String> list = Cleaner.mergeListForFiler(careProvFields, careProvided_Filters);
filters.addAll(list);
}
if(StringUtils.isNotBlank(admissions))
{
String[] admission_Filters = Cleaner.splitUnderscore(admissions);
List<String> list = Cleaner.mergeListForFiler(admissionsFields, admission_Filters);
filters.addAll(list);
}
if(StringUtils.isNotBlank(careHomeType))
{
String[] typeOfCareHome_Filters = Cleaner.splitUnderscore(careHomeType);
List<String> list = Cleaner.mergeListForFiler(homeTypeFields, typeOfCareHome_Filters);
List<String> newTcList = Cleaner.createFilterForTypeOfCare(list);
filters.addAll(newTcList);
}
filters.add(geofilt);
String filteredStrings = Cleaner.createFilterParam(filters);
filteredStrings = "("+filteredStrings+")";
query.setParam(fq, filteredStrings);
}
else if(StringUtils.isBlank(careProvided)&& StringUtils.isBlank(admissions)&& StringUtils.isBlank(careHomeType))
{
query.setParam(fq, geofilt);
}
}
if(MapUtils.isNotEmpty(qParamStartRow))
{
Integer qStart = (Integer)qParamStartRow.get("queryStart");
Integer qRows = (Integer)qParamStartRow.get("queryRows");
originalPaginatorBean = (PaginatorBean)qParamStartRow.get("originalPaginatorBean");
query.setStart(qStart);
query.setRows(qRows);
}
try
{
response = server.query(query);
Long resultSize = response.getResults().getNumFound();
if(resultSize>0)
{
careHomeBeans = new CareHomeBeans();
List<CareHomeBean> careHomeBeanList = new ArrayList<CareHomeBean>();
Integer numberOfResults = (int)(long)resultSize;
resultBean = new ResultBean();
SolrDocumentList solrList = response.getResults();
if(CollectionUtils.isNotEmpty(solrList))
{
for(SolrDocument solrDoc:solrList)
{
CareHomeBean chb = Utils.doSearchResultBean(solrDoc);
careHomeBeanList.add(chb);
}
careHomeBeans.setCareHomeBean(careHomeBeanList);
PaginatorBean resultPBean = null;
if(originalPaginatorBean!=null)
{
resultPBean = PaginationUtils.doPaginationTest(numberOfResults, originalPaginatorBean);
careHomeBeans.setPaginatorBean(resultPBean);
}
resultBean.setCareHomeBeans(careHomeBeans);
resultBean.setTotalNumberOfResults(numberOfResults);
resultBean.setStart(query.getStart());
}
}
server.close();
}
catch(Exception ex)
{
ex.printStackTrace();
log.error(ex);
}
return resultBean;
}
}
| [
"[email protected]"
] | |
afe7155e7cbe8de7e9f6d705d45f7425bbdde8f6 | 84745d0ad0fdeb70957eacf45c84271c20ebecdc | /DynamicProgramming/MaximumProductSubArray.java | fc8af57b0ad3265cc1aa485c0d03587861f76597 | [] | no_license | AnandKshitij/Java-Codes | 1f6c39c882161c360ce9bb5e149311fd4b23696b | f5ca324efd01d214e45c3646c8e878ec7eab99b7 | refs/heads/main | 2023-01-07T04:51:07.031104 | 2020-11-05T10:05:01 | 2020-11-05T10:05:01 | 310,256,830 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,542 | java | package DynamicProgramming;
/*
Given an integer array, find the contiguous sub array within an array (containing at least one
number) which has the largest product.
Example 1:
Input: [2,3,-2,4]
Output: 6
Explanation: [2,3] has the largest product 6.
Example 2:
Input: [-2,0,-1]
Output: 0
Explanation: The result cannot be 2, because [-2,-1] is not a sub array.
*/
import java.util.Scanner;
public class MaximumProductSubArray {
public static int maxProduct(int[] nums) {
int minValue = Integer.MAX_VALUE;
int maxValue = Integer.MIN_VALUE;
if(nums.length==0) {
return maxValue;
}
if(nums.length==1) {
return nums[0];
}
int n = nums.length;
int min[] = new int [n];
int max[] = new int [n];
for(int i=0; i<nums.length; i++) {
if(i==0) {
min[i] = nums[i];
max[i] = nums[i];
}
else {
int val1 = min[i-1]*nums[i];
int val2 = max[i-1]*nums[i];
max[i] = Math.max(nums[i],Math.max(val1,val2));
min[i] = Math.min(nums[i],Math.min(val1,val2));
}
maxValue = Math.max(maxValue,max[i]);
minValue = Math.min(minValue,min[i]);
}
return maxValue;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int arr[] = new int[n];
for(int i=0; i<n; i++) {
arr[i] = s.nextInt();
}
System.out.println(maxProduct(arr));
s.close();
}
}
| [
"[email protected]"
] | |
6775a7396ef5394f5ffbf1d3dccc6c933237d360 | b7cba4fbb8a5673156a0ce2ec948bd8156a28760 | /lib-smpp/src/com/adenon/api/smpp/message/OptionalParameter.java | cc1816e1abc7d6a514a5be3d98745b25ca16cdc6 | [] | no_license | eaorak/service_platform | f723d64c8dac745d4182a112ee6f3882658c9dc7 | 03690bc3f5c9bec48166304ae19c61e76b3e7552 | refs/heads/master | 2020-11-24T16:44:02.458358 | 2019-12-30T10:40:10 | 2019-12-30T13:39:44 | 228,252,238 | 0 | 2 | null | 2019-12-30T13:39:45 | 2019-12-15T21:03:59 | Java | UTF-8 | Java | false | false | 672 | java | package com.adenon.api.smpp.message;
public class OptionalParameter {
private int optionalParameterTag;
private byte[] optionalParameterData;
public OptionalParameter() {
}
public int getOptionalParameterTag() {
return this.optionalParameterTag;
}
public void setOptionalParameterTag(final int optionalParameterTag) {
this.optionalParameterTag = optionalParameterTag;
}
public byte[] getOptionalParameterData() {
return this.optionalParameterData;
}
public void setOptionalParameterData(final byte[] optionalParameterData) {
this.optionalParameterData = optionalParameterData;
}
}
| [
"[email protected]"
] | |
2c76eba4d2f79b7fec4af6565c9007678c68f5c7 | 4055e5e3da26ba9955d91a381938a70bc5aafa4b | /Stationery/src/com/wabacus/system/datatype/CDateType.java | 8ab31a332cd916474f66f2f24b00b5aa01f68f8a | [] | no_license | xiciliu/Stationery | b2eb55bc5246e774e242db465c7a10b8b64aa349 | 738159fffb30a84c82a25975d3acd6c66225d5b3 | refs/heads/master | 2021-12-13T01:22:07.531961 | 2017-03-09T13:18:07 | 2017-03-09T13:18:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,712 | java | /*
* Copyright (C) 2010---2014 星星(wuweixing)<[email protected]>
*
* This file is part of Wabacus
*
* Wabacus 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wabacus.system.datatype;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.wabacus.config.database.type.AbsDatabaseType;
public class CDateType extends AbsDateTimeType
{
private final static Log log=LogFactory.getLog(CDateType.class);
private final static Map<String,AbsDateTimeType> mDatetimeTypeObjects=new HashMap<String,AbsDateTimeType>();
public Object label2value(String label)
{
if(label==null||label.trim().equals("")) return null;
SimpleDateFormat sdf=new SimpleDateFormat(dateformat);
try
{
Date date=sdf.parse(label.trim());
return new java.sql.Date(date.getTime());
}catch(ParseException e)
{
log.error(label+"非法的日期格式,不能格式化为"+dateformat+"形式的日期类型",e);
return null;
}
}
public String value2label(Object value)
{
if(value==null) return "";
if(!(value instanceof Calendar))
{
return String.valueOf(value);
}
return new SimpleDateFormat(dateformat).format(((Calendar)value).getTime());
}
public Object getColumnValue(ResultSet rs,String column,AbsDatabaseType dbtype)
throws SQLException
{
java.sql.Date cdd=rs.getDate(column);
if(cdd==null) return null;
Calendar cd=Calendar.getInstance();
cd.setTimeInMillis(cdd.getTime());
return cd;
}
public Object getColumnValue(ResultSet rs,int iindex,AbsDatabaseType dbtype)
throws SQLException
{
java.sql.Date cdd=rs.getDate(iindex);
if(cdd==null) return null;
Calendar cd=Calendar.getInstance();
cd.setTimeInMillis(cdd.getTime());
return cd;
}
public void setPreparedStatementValue(int iindex,String value,PreparedStatement pstmt,
AbsDatabaseType dbtype) throws SQLException
{
log.debug("setDate("+iindex+","+value+")");
pstmt.setDate(iindex,(java.sql.Date)label2value(value));
}
public void setPreparedStatementValue(int index,Date dateValue,PreparedStatement pstmt)
throws SQLException
{
log.debug("setDate("+index+","+dateValue+")");
if(dateValue==null)
{
pstmt.setDate(index,null);
}else
{
pstmt.setDate(index,new java.sql.Date(dateValue.getTime()));
}
}
public Class getJavaTypeClass()
{
return Calendar.class;
}
protected Map<String,AbsDateTimeType> getMDatetimeTypeObjects()
{
return mDatetimeTypeObjects;
}
}
| [
"[email protected]"
] | |
aea93705566bfa69b3ac6a165b42d52fef35cf80 | 6f8505d60d88c0235db908132414754c213908e6 | /src/main/java/optional/lab1/GenerateRandomGraph.java | ca674609f445a6a877c0b19410ebea145d3365c8 | [] | no_license | DmitriCojocari/APLabs | 04e839b98e6b07733d05645f271142d4f9def796 | 5183e5d5badaae84891c0dc3488a0cabdabc3511 | refs/heads/master | 2023-04-24T17:17:35.965076 | 2021-04-25T14:29:16 | 2021-04-25T14:29:16 | 342,677,517 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,082 | java | package optional.lab1;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class GenerateRandomGraph {
public int vertices;
public int edges;
Random random = new Random();
public List<List<Integer>> adjacencyList;
int maxEdges(int nrOfVertices) {
return nrOfVertices * ((nrOfVertices - 1) / 2);
}
public GenerateRandomGraph(int vertices) {
this.vertices = vertices;
//the number of edges will be the max number of edges possible
this.edges = maxEdges(vertices);
//representation of graph by adjacency list for vertices
adjacencyList = new ArrayList<>(vertices);
for (int i = 0; i < vertices; i++) {
adjacencyList.add(new ArrayList<>());
}
for (int i = 0; i < edges; i++) {
//randomly select 2 vertices
int u = random.nextInt(vertices);
int v = random.nextInt(vertices);
//if we have already an edge between and u and v
if ((u == v) || adjacencyList.get(u).contains(v)) {
//decrease i so u and v can be selected for next
i = i - 1;
continue;
}
addEdge(u, v);
}
}
void addEdge(int u, int v) {
//we find u in the list, and add v to its adjacency list
adjacencyList.get(u).add(v);
//same for v
adjacencyList.get(v).add(u);
}
public static void main(String[] args) {
int n = 0;
if (args.length < 1) {
System.out.println("Not enough arguments!");
System.exit(-1);
}
if (args.length > 0) {
try {
n = Math.abs(Integer.parseInt(args[0]));
} catch (NumberFormatException e) {
System.err.println("Argument " + args[0] + " must be an integer.");
System.exit(1);
}
}
if (n > 100) {
long startTime = System.nanoTime();
GenerateRandomGraph graph = new GenerateRandomGraph(n);
long endTime = System.nanoTime();
long timeElapsed = endTime - startTime;
System.out.println("Execution time in nanoseconds : " + timeElapsed);
} else {
GenerateRandomGraph graph = new GenerateRandomGraph(n);
System.out.println("The generated random graph :");
for (int i = 0; i < graph.adjacencyList.size(); i++) {
System.out.print(i + " -> { ");
List<Integer> list = graph.adjacencyList.get(i);
if (list.isEmpty())
System.out.print(" No adjacent vertices ");
else {
int size = list.size();
for (int j = 0; j < size; j++) {
System.out.print(list.get(j));
if (j < size - 1)
System.out.print(" , ");
}
}
System.out.println("}");
}
}
}
}
| [
"[email protected]"
] | |
9fa8f3921dd762971a17fa8599d5149276c54860 | 08dbc59960b71cb9deabdaf96962d67cd045ead1 | /app/src/main/java/app/meantime/MyApplication.java | 8d54c340e988923ec41cd8d3d263033188e1fbc8 | [] | no_license | hasaansworld/meantime2 | 29558728334329ee6ef0a4b3ec084881b8fba14a | ad4c2502ca227cb46339ff5dfe152f4ec63e42c9 | refs/heads/master | 2022-09-24T10:02:52.557526 | 2020-06-01T16:25:10 | 2020-06-01T16:25:10 | 226,483,683 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 416 | java | package app.meantime;
import android.app.Application;
import androidx.multidex.MultiDexApplication;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.ios.IosEmojiProvider;
public class MyApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
RealmUtils.init(this);
EmojiManager.install(new IosEmojiProvider());
}
}
| [
"[email protected]"
] | |
16b2a277d55ed3e5da9e4f80e8ae3fc63bb203fc | 21aea0b4a8f9482b6e279e72f742fe8b6bdd56a3 | /Day_17/Counter.java | 7505532596fbcadd46e2d2cd48775705e1689ca3 | [] | no_license | BBK-PiJ-2014-17/exercises | 03d81b3251fb69960a88aa39821a74567507e0cf | 29a1e24f46bb1dc8d1c31f459e6eec14c6af7be6 | refs/heads/master | 2020-04-01T01:03:20.432785 | 2015-06-02T15:05:09 | 2015-06-02T15:05:09 | 24,856,311 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 164 | java | public class Counter {
private int n = 0;
public synchronized void increase() {
n++;
}
public int getCount() {
return n;
}
} | [
"[email protected]"
] | |
b782f9d5b227008f9a395e579065dd0acdf8015e | c2ae43874a4e39f48af3e62fc6d20625fe0d1906 | /src/main/java/moa/streams/FilteredStream.java | 319a7b7cfc2e3bfff2686ff7b74c7edd5f9bd6bd | [] | no_license | DraXus/draxus-moa | 119c9b7e9996c786abe696c10302c79e3c274c70 | 0c6bca70f053f4a1ffa3ea53ed26e8fffd64aa6b | refs/heads/master | 2021-01-01T18:12:33.101901 | 2012-01-25T16:34:57 | 2012-01-25T16:34:57 | 32,275,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,121 | java | /*
* FilteredStream.java
* Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
* @author Richard Kirkby ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package moa.streams;
import moa.core.InstancesHeader;
import moa.core.ObjectRepository;
import moa.options.AbstractOptionHandler;
import moa.options.ClassOption;
import moa.options.ListOption;
import moa.options.Option;
import moa.options.OptionHandler;
import moa.streams.filters.StreamFilter;
import moa.tasks.TaskMonitor;
import weka.core.Instance;
/**
* Class for representing a stream that is filtered.
*
* @author Richard Kirkby ([email protected])
* @version $Revision: 7 $
*/
public class FilteredStream extends AbstractOptionHandler implements
InstanceStream {
@Override
public String getPurposeString() {
return "A stream that is filtered.";
}
private static final long serialVersionUID = 1L;
public ClassOption streamOption = new ClassOption("stream", 's',
"Stream to filter.", InstanceStream.class,
"generators.RandomTreeGenerator");
public ListOption filtersOption = new ListOption("filters", 'f',
"Filters to apply.", new ClassOption("filter", ' ',
"Stream filter.", StreamFilter.class, "AddNoiseFilter"),
new Option[0], ',');
protected InstanceStream filterChain;
@Override
public void prepareForUseImpl(TaskMonitor monitor,
ObjectRepository repository) {
Option[] filterOptions = this.filtersOption.getList();
StreamFilter[] filters = new StreamFilter[filterOptions.length];
for (int i = 0; i < filters.length; i++) {
monitor.setCurrentActivity("Materializing filter " + (i + 1)
+ "...", -1.0);
filters[i] = (StreamFilter) ((ClassOption) filterOptions[i]).materializeObject(monitor, repository);
if (monitor.taskShouldAbort()) {
return;
}
if (filters[i] instanceof OptionHandler) {
monitor.setCurrentActivity("Preparing filter " + (i + 1)
+ "...", -1.0);
((OptionHandler) filters[i]).prepareForUse(monitor, repository);
if (monitor.taskShouldAbort()) {
return;
}
}
}
InstanceStream chain = (InstanceStream) getPreparedClassOption(this.streamOption);
for (int i = filters.length - 1; i >= 0; i--) {
filters[i].setInputStream(chain);
chain = filters[i];
}
this.filterChain = chain;
}
@Override
public long estimatedRemainingInstances() {
return this.filterChain.estimatedRemainingInstances();
}
@Override
public InstancesHeader getHeader() {
return this.filterChain.getHeader();
}
@Override
public boolean hasMoreInstances() {
return this.filterChain.hasMoreInstances();
}
@Override
public boolean isRestartable() {
return this.filterChain.isRestartable();
}
@Override
public Instance nextInstance() {
return this.filterChain.nextInstance();
}
@Override
public void restart() {
this.filterChain.restart();
}
@Override
public void getDescription(StringBuilder sb, int indent) {
// TODO Auto-generated method stub
}
}
| [
"abifet@localhost"
] | abifet@localhost |
6538fac242bff3e6825d32361a67bb465b53ae5e | 3ab94477da38658a8cd9c6cea32679e28b3184e3 | /src/main/java/me/zambie/asc/click/actions/ToggleSlotHelmetAction.java | 0e26c97b4a9436ab79b27fb1e59996053ba711bc | [] | no_license | ZombieGhostMC/ArmorStandController | 8e3c5878fe554560a081d1e1d2e0e023274c01d9 | 33bad6d77efcbbaa98e9348f22d6e26ad163581d | refs/heads/master | 2021-01-16T19:07:10.205449 | 2017-08-12T21:42:33 | 2017-08-12T21:42:33 | 100,138,140 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 258 | java | package me.zambie.asc.click.actions;
import me.zambie.asc.color.ColorSession;
public final class ToggleSlotHelmetAction extends ToggleArmorSlotAction {
public ToggleSlotHelmetAction() {
super(0, ColorSession.Slot.HELMET, "setHelmet");
}
}
| [
"[email protected]"
] | |
cb440bc58e315558a0e644007bfd785df8af9bd5 | 2585982cacc02b99818c8923b015634367b53c70 | /Clase3/AprendiendoMyBatis/src/pe/egcc/app/service/EmpleadoService.java | bc691ed4419b6b97c4c013b5cd709f2574fd8318 | [] | no_license | gcoronelc/CEPSUNI_JDBC_001 | cf55cb91423ee6228662e665bd321be764338944 | b7229dd4e97958b0a48f93e8311ef2b656d56677 | refs/heads/master | 2021-01-18T00:16:19.427899 | 2016-01-10T02:50:46 | 2016-01-10T02:50:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 977 | java | package pe.egcc.app.service;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import pe.egcc.app.model.EmpleadoBean;
import pe.egcc.mybatis.db.AccesoDB;
import pe.egcc.mybatis.espec.EmpleadoMapper;
/**
*
* @author Eric Gustavo Coronel Castillo
* @email [email protected]
* @blog www.desarrollasoftware.com
* @date 19/12/2015
*
*/
public class EmpleadoService {
public List<EmpleadoBean> traerEmpleados(EmpleadoBean empleadoBean){
List<EmpleadoBean> lista = null;
SqlSession sqlSession = null;
try {
sqlSession = AccesoDB.getSqlSession();
EmpleadoMapper empleadoMapper;
empleadoMapper = sqlSession.getMapper(EmpleadoMapper.class);
lista = empleadoMapper.getTraerEmpleados(empleadoBean);
} catch (Exception e) {
lista = new ArrayList<>();
} finally {
try {
sqlSession.close();
} catch (Exception e) {
}
}
return lista;
}
}
| [
"[email protected]"
] | |
61ef1db06ab20c8abf82eabef578e7e52b7ad38c | 4e4d079f1e60835e9ea0142b130aa075be24cebf | /server/src/main/java/drawing/GuiController.java | 06abb816fd8dfc11315acf2f74dac4293ea8f243 | [] | no_license | haimofer/CooperativeDrawing | 01a69f174d29984bddb5e1054b0912a5ffd599fd | 54c1e0c9adef9a57be0ea2a0929b29c10ac987dd | refs/heads/master | 2020-05-18T13:39:33.546649 | 2019-05-01T16:48:52 | 2019-05-01T16:48:52 | 184,447,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 907 | java | package drawing;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
/**
* Created by Ofer on 6/22/2017.
*/
@Controller
public class GuiController {
private static final Logger logger = LogManager.getLogger(GuiController.class);
@CrossOrigin
@RequestMapping(path = "/getDrawings", method = RequestMethod.GET)
@ResponseBody
public ArrayList<CanvasData> getDrawings() throws Exception {
return ManageDrawings.getAllResults();
}
@CrossOrigin
@RequestMapping(value = "/saveData", method = RequestMethod.POST)
@ResponseBody
public void saveData(@RequestBody CanvasData data) throws Exception {
logger.info("entered details: {}",data);
ManageDrawings.addNewDrawing(data);
}
} | [
"[email protected]"
] | |
0984097cb0d311d14aeb0dce56e837bf81341892 | 3b39a2b4ca3cf48739bedaef615f2b4e0b1a8ff2 | /AfectacioBosc_www/src/cat/creaf/afectaciobosc/www/controllers/LlistarSequeresController.java | 854a26b1f5f2b032c3178bdae01bd21c31ec6aae | [] | no_license | aescobarr/Afectacio | 8303922ca3eb0c91943afe663408ac573864f05f | 6963f47e7d7541c4fc5e92a0401a97a6882025de | refs/heads/master | 2016-09-11T05:55:42.304724 | 2014-07-25T09:40:54 | 2014-07-25T09:40:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,147 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cat.creaf.afectaciobosc.www.controllers;
import MSeguretatObj.Usuari;
import cat.creaf.afectaciobosc.service.IAfectacioService;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.acegisecurity.context.SecurityContextHolder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
/**
*
* @author a_escobar
*/
public class LlistarSequeresController extends AbstractController {
private IAfectacioService afectacioService;
public LlistarSequeresController(){
super();
}
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
HashMap hm = new HashMap();
String primerElement = "0";
if (request.getParameter("primerelement") != null) {
primerElement = request.getParameter("primerelement");
}
hm.put("primerelement", primerElement);
hm.put("numtotalelements", request.getParameter("numtotalelements"));
int primer = Integer.parseInt(primerElement);
String numElemsString = request.getParameter("numelements");
if (numElemsString == null || "".equals(numElemsString)) {
numElemsString = "30";
}
int numElements = Integer.parseInt(numElemsString);
hm.put("numelements", request.getParameter("numelements"));
int numTotal = afectacioService.getNevadesCount();
hm.put("numtotalelements", numTotal);
String operacio = request.getParameter("operacio");
if (numElements == -1) {
primer = 0;
numElements = numTotal;
} else if ("0".equals(operacio)) {
primer = 0;
} else if ("1".equals(operacio)) {
primer = primer - numElements;
} else if ("2".equals(operacio)) {
primer = primer + numElements;
} else if ("3".equals(operacio)) {
if (numTotal % numElements > 0) {
primer = numTotal - (numTotal % numElements);
numElements = numTotal % numElements;
} else {
primer = numTotal - numElements;
}
}
hm.put("primerelement", primer + "");
hm.put("ip", getIP());
boolean editable = false;
boolean esborrable = false;
boolean llistableShape = false;
String nomUsuari = "";
if (SecurityContextHolder.getContext().getAuthentication() != null) {
nomUsuari = SecurityContextHolder.getContext().getAuthentication().getName();
}
Usuari usuari = afectacioService.getUsuariPerNom(nomUsuari);
for(int i=0;i<usuari.getAuthorities().size();i++){
editable = editable || "ROLE_EDITAR_SEQUERA".equals(usuari.getAuthorities().get(i).getAuthority());
esborrable = esborrable || "ROLE_ESBORRAR_SEQUERA".equals(usuari.getAuthorities().get(i).getAuthority());
llistableShape = llistableShape || "ROLE_CONSULTA_SHAPE_PROC".equals(usuari.getAuthorities().get(i).getAuthority());
}
hm.put("editable", editable);
hm.put("esborrable", esborrable);
hm.put("llistableShape", llistableShape);
return new ModelAndView("Sequeres/llistarSequeres", "dades", hm);
}
private String getIP() {
String ip = null;
try {
java.net.InetAddress i = java.net.InetAddress.getLocalHost();
ip =i.getCanonicalHostName();
} catch (Exception e) {
e.printStackTrace();
}
return ip;
}
/**
* @return the afectacioService
*/
public IAfectacioService getAfectacioService() {
return afectacioService;
}
/**
* @param afectacioService the afectacioService to set
*/
public void setAfectacioService(IAfectacioService afectacioService) {
this.afectacioService = afectacioService;
}
}
| [
"[email protected]"
] | |
aefb4a2a8ccf6ee2278da02bc015efc2f9707f0d | e2b806c9a2af64308bdd00e55cd04546da0667f5 | /app/src/main/java/com/nagstud/adnan/mobileapp_1/LoginActivity.java | ca6beb9c49546a3a918d1f3d39bddff131d6d909 | [] | no_license | Shubham-Shendre/NagpurStudentsoneOone | 62d37a34eb4e513db535371cd1ede59343674d96 | 7f7aa3ab4d139fc0a6e5e9bcad49d092f2d85640 | refs/heads/master | 2021-09-06T14:42:56.416072 | 2018-02-07T17:51:19 | 2018-02-07T17:51:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,121 | java | package com.nagstud.adnan.mobileapp_1;
/**
* Created by Shubham Dilip Shendre aka SdS
* Adnan Kazi aka Addy
* Furqan
* Sadat Hussain
*
* for NagStud LLP Project nagpurstudents
*/
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import org.json.JSONException;
import org.json.JSONObject;
import com.nagstud.adnan.mobileapp_1.SharedPrefManager.*;
import java.util.HashMap;
import java.util.Map;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.L;
import static com.nagstud.adnan.mobileapp_1.URLs.URL_LOGIN;
public class LoginActivity extends AppCompatActivity {
private ProgressDialog progressDialog;
EditText editTextUsername, editTextPassword;
ProgressBar progressBar;
public String TAG ="LoginAct" ;
public StringRequest stringRequest;
public String u_name,u_password,u_email;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
SharedPrefManager.getInstance(this).getUser();
progressBar = (ProgressBar) findViewById(R.id.progressBar);
editTextUsername = (EditText) findViewById(R.id.editTextUsername);
editTextPassword = (EditText) findViewById(R.id.editTextPassword);
//if user presses on login
//calling the method login
findViewById(R.id.buttonLogin).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
userLogin();
}
});
//if user presses on not registered
findViewById(R.id.textViewRegister).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//open register screen
finish();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
});
}
private void userLogin() {
//first getting the values
final String username = editTextUsername.getText().toString();
final String password = editTextPassword.getText().toString();
System.out.println("Userlogin in login activity");
//validating inputs
if (TextUtils.isEmpty(username)) {
editTextUsername.setError("Please enter your username");
editTextUsername.requestFocus();
return;
}
if (TextUtils.isEmpty(password)) {
editTextPassword.setError("Please enter your password");
editTextPassword.requestFocus();
return;
}
showProgressDialog();
//progressBar.setVisibility(View.VISIBLE);
//if everything is fine
stringRequest = new StringRequest(Request.Method.POST, URL_LOGIN,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
dismissProgressDialog();
try {
System.out.println("on response in login ACt");
//converting response to json object
JSONObject obj = new JSONObject(response);
//if no error in response
if (!obj.getBoolean("error")) {
System.out.println("if part of on response in loginact");
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
// Toast.makeText(getApplicationContext(), obj.getString("user"), Toast.LENGTH_SHORT).show();
Log.e(TAG,"inside response");
//getting the user from the response
JSONObject userJson = obj.getJSONObject("user");
//creating a new user object
u_name= userJson.getString("username");
u_email= userJson.getString("email");
u_password= userJson.getString("password");
User user = new User(u_name,u_email,u_password,"true");
//storing the user in shared preferences
SharedPrefManager.getInstance(getApplicationContext()).userLogin(user);
//starting the fullscreen activity
progressBar.setVisibility(View.GONE);
finish();
startActivity(new Intent(getApplicationContext(), FullscreenActivity.class));
} else {
System.out.println("if part of on response in loginact");
Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "No internet Connection", Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("email", username);
params.put("password", password);
return params;
}
};
VolleySingleton.getInstance(this).addToRequestQueue(stringRequest);
}
public void showProgressDialog() {
if (progressDialog == null) {
progressDialog = new ProgressDialog(this);
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
}
progressDialog.setMessage("Loading...");
progressDialog.show();
}
public void dismissProgressDialog() {
if (progressDialog != null) {
progressDialog.dismiss();
}
}
}
| [
"[email protected]"
] | |
7b9bb591b340d0e8c30e13cd9bc951d8bb3918d6 | d60cf290ef068925de38e494f4d622a10e28b6a9 | /src/test/java/simplesmc/TestSMC.java | cef8660b6c3121ac673b8826b980973a4a05b478 | [] | no_license | junseonghwan/spf-experiments | 78a031aecac7124ca0ce58c6bbba57ce79240903 | d20df62cdbdcce9950c8e6549435a51f3e262978 | refs/heads/master | 2021-01-21T20:25:45.288401 | 2017-10-26T06:45:43 | 2017-10-26T06:45:43 | 92,233,851 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,917 | java | package simplesmc;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
import org.junit.Test;
import simplesmc.hmm.HMMProblemSpecification;
import simplesmc.hmm.HMMUtils;
import simplesmc.hmm.ToyHMMParams;
import tutorialj.Tutorial;
public class TestSMC
{
/**
* We show here a simple example where the target distribution is a finite HMM. This is
* only for test purpose, to ensure that the estimate of the log normalization is close to
* the true value.
*
* Note the only step required to customize the SMC algorithm to more complex and interesting problem
* is to create a class that implements ``simplesmc.ProblemSpecification``.
*/
@Tutorial(showLink = true, linkPrefix = "src/test/java/")
@Test
public void testSMC()
{
// Create a synthetic dataset
Random random = new Random(1);
ToyHMMParams hmmParams = new ToyHMMParams(5);
Pair<List<Integer>, List<Integer>> generated = HMMUtils.generate(random, hmmParams, 10);
List<Integer> observations = generated.getRight();
// Here we can compute the exact log Z using sum product since we have a discrete HMM
double exactLogZ = HMMUtils.exactDataLogProbability(hmmParams, observations);
System.out.println("exact = " + exactLogZ);
// Run SMC to ensure correctness of our implementation
HMMProblemSpecification proposal = new HMMProblemSpecification(hmmParams, observations);
SMCOptions options = new SMCOptions();
options.nParticles = 1_000;
SMCAlgorithm<Integer> smc = new SMCAlgorithm<>(proposal, options);
// Check they agree within 1%
double approxLogZ = smc.sample().logNormEstimate();
System.out.println("estimate = " + approxLogZ);
double tol = Math.abs(exactLogZ / 100.0);
System.out.println("tol = " + tol);
Assert.assertEquals(exactLogZ, approxLogZ, tol);
}
}
| [
"[email protected]"
] | |
79dfd0c355691048c798548c35b26ca2b872357a | c79ee439c43597b1ba7c21650b216a63f2691386 | /src/ConteudoProgramatico.java | e26e0a456b334338f805932fd96eab576f4b0297 | [] | no_license | adammedeiros/Projeto2013.2 | 85db10c3e3d4306dc06ad56eb70205f40dbaf0f2 | 5f9d4f48f08570e002f19b8f8fd630c34acbf0db | refs/heads/master | 2021-01-25T04:58:12.352494 | 2014-08-04T23:50:09 | 2014-08-04T23:50:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,591 | java |
public class ConteudoProgramatico {
private int unidade;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((assunto == null) ? 0 : assunto.hashCode());
result = prime * result
+ ((horaAula == null) ? 0 : horaAula.hashCode());
result = prime * result + unidade;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConteudoProgramatico other = (ConteudoProgramatico) obj;
if (assunto == null) {
if (other.assunto != null)
return false;
} else if (!assunto.equals(other.assunto))
return false;
if (horaAula == null) {
if (other.horaAula != null)
return false;
} else if (!horaAula.equals(other.horaAula))
return false;
if (unidade != other.unidade)
return false;
return true;
}
private String assunto;
private String horaAula;
public ConteudoProgramatico(int unidade, String assunto, String horaAula){
this.unidade = unidade;
this.assunto = assunto;
this.horaAula = horaAula;
}
public ConteudoProgramatico() {
// TODO Auto-generated constructor stub
}
public int getUnidade() {
return unidade;
}
public void setUnidade(int unidade) {
this.unidade = unidade;
}
public String getAssunto() {
return assunto;
}
public void setAssunto(String assunto) {
this.assunto = assunto;
}
public String getHoraAula() {
return horaAula;
}
public void setHoraAula(String horaAula) {
this.horaAula = horaAula;
}
}
| [
"[email protected]"
] | |
aca1ac3054293780034e80a840aba09297e4fc11 | dbdc779fd2243a090f031cca40c197e9235666f8 | /implementations/java/vanilla/src/main/java/org/cwi/waebric/parser/ast/NullVisitor.java | ad591b10fb9d7db0db592d4a0eee89fb4459665d | [] | no_license | tvdstorm/waebric | 8452a49f3416d7e00494dc8a69bdef017127fa1d | 7091d8c731fa2189d460d99965f8431070406fdb | refs/heads/master | 2021-01-16T18:19:29.632277 | 2010-09-13T07:52:48 | 2010-09-13T07:52:48 | 33,249,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,647 | java | package org.cwi.waebric.parser.ast;
import org.cwi.waebric.parser.ast.basic.*;
import org.cwi.waebric.parser.ast.expression.KeyValuePair;
import org.cwi.waebric.parser.ast.expression.Expression.*;
import org.cwi.waebric.parser.ast.markup.*;
import org.cwi.waebric.parser.ast.markup.Markup.Call;
import org.cwi.waebric.parser.ast.markup.Markup.Tag;
import org.cwi.waebric.parser.ast.module.*;
import org.cwi.waebric.parser.ast.module.function.FunctionDef;
import org.cwi.waebric.parser.ast.module.function.Formals.EmptyFormal;
import org.cwi.waebric.parser.ast.module.function.Formals.RegularFormal;
import org.cwi.waebric.parser.ast.module.site.*;
import org.cwi.waebric.parser.ast.statement.Assignment.FuncBind;
import org.cwi.waebric.parser.ast.statement.Assignment.VarBind;
import org.cwi.waebric.parser.ast.statement.Statement.*;
import org.cwi.waebric.parser.ast.statement.embedding.*;
import org.cwi.waebric.parser.ast.statement.embedding.TextTail.MidTail;
import org.cwi.waebric.parser.ast.statement.embedding.TextTail.PostTail;
import org.cwi.waebric.parser.ast.statement.predicate.Type;
import org.cwi.waebric.parser.ast.statement.predicate.Predicate.*;
/**
* Default implementation for node visiting, all visit functions delegate the
* visit request to children nodes. Only extend visits that are relevant for
* your implementations.
*
* @author Jeroen van Schagen
* @date 11-06-2009
*/
public abstract class NullVisitor<T> implements INodeVisitor<T> {
public T visit(Module module) {
visitChildren(module);
return null;
}
public T visit(ModuleId id) {
visitChildren(id);
return null;
}
public T visit(Import imprt) {
visitChildren(imprt);
return null;
}
public T visit(Site site) {
visitChildren(site);
return null;
}
public T visit(Mappings mappings) {
visitChildren(mappings);
return null;
}
public T visit(Mapping mapping) {
visitChildren(mapping);
return null;
}
public T visit(Path path) {
visitChildren(path);
return null;
}
public T visit(FunctionDef function) {
visitChildren(function);
return null;
}
public T visit(RegularFormal formals) {
visitChildren(formals);
return null;
}
public T visit(EmptyFormal formals) {
visitChildren(formals);
return null;
}
public T visit(If statement) {
visitChildren(statement);
return null;
}
public T visit(IfElse statement) {
visitChildren(statement);
return null;
}
public T visit(Block statement) {
visitChildren(statement);
return null;
}
public T visit(CData statement) {
visitChildren(statement);
return null;
}
public T visit(Comment statement) {
visitChildren(statement);
return null;
}
public T visit(Each statement) {
visitChildren(statement);
return null;
}
public T visit(Echo statement) {
visitChildren(statement);
return null;
}
public T visit(EchoEmbedding statement) {
visitChildren(statement);
return null;
}
public T visit(Let statement) {
visitChildren(statement);
return null;
}
public T visit(Yield statement) {
visitChildren(statement);
return null;
}
public T visit(MarkupStatement statement) {
visitChildren(statement);
return null;
}
public T visit(MarkupsMarkup statement) {
visitChildren(statement);
return null;
}
public T visit(MarkupsExpression statement) {
visitChildren(statement);
return null;
}
public T visit(MarkupsStatement statement) {
visitChildren(statement);
return null;
}
public T visit(MarkupsEmbedding statement) {
visitChildren(statement);
return null;
}
public T visit(FuncBind bind) {
visitChildren(bind);
return null;
}
public T visit(VarBind bind) {
visitChildren(bind);
return null;
}
public T visit(RegularPredicate predicate) {
visitChildren(predicate);
return null;
}
public T visit(And predicate) {
visitChildren(predicate);
return null;
}
public T visit(Is predicate) {
visitChildren(predicate);
return null;
}
public T visit(Not predicate) {
visitChildren(predicate);
return null;
}
public T visit(Or predicate) {
visitChildren(predicate);
return null;
}
public T visit(Type.ListType type) {
visitChildren(type);
return null;
}
public T visit(Type.RecordType type) {
visitChildren(type);
return null;
}
public T visit(Type.StringType type) {
visitChildren(type);
return null;
}
public T visit(Embedding embedding) {
visitChildren(embedding);
return null;
}
public T visit(Embed.ExpressionEmbed embed) {
visitChildren(embed);
return null;
}
public T visit(Embed.MarkupEmbed embed) {
visitChildren(embed);
return null;
}
public T visit(PreText text) {
visitChildren(text);
return null;
}
public T visit(MidText text) {
visitChildren(text);
return null;
}
public T visit(PostText text) {
visitChildren(text);
return null;
}
public T visit(MidTail tail) {
visitChildren(tail);
return null;
}
public T visit(PostTail tail) {
visitChildren(tail);
return null;
}
public T visit(Call markup) {
visitChildren(markup);
return null;
}
public T visit(Tag markup) {
visitChildren(markup);
return null;
}
public T visit(Designator designator) {
visitChildren(designator);
return null;
}
public T visit(Attributes attributes) {
visitChildren(attributes);
return null;
}
public T visit(Attribute.IdAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Attribute.NameAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Attribute.TypeAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Attribute.WidthAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Attribute.WidthHeightAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Attribute.ClassAttribute attribute) {
visitChildren(attribute);
return null;
}
public T visit(Arguments arguments) {
visitChildren(arguments);
return null;
}
public T visit(Argument argument) {
visitChildren(argument);
return null;
}
public T visit(CatExpression expression) {
visitChildren(expression);
return null;
}
public T visit(Field expression) {
visitChildren(expression);
return null;
}
public T visit(ListExpression expression) {
visitChildren(expression);
return null;
}
public T visit(NatExpression expression) {
visitChildren(expression);
return null;
}
public T visit(RecordExpression expression) {
visitChildren(expression);
return null;
}
public T visit(SymbolExpression expression) {
visitChildren(expression);
return null;
}
public T visit(TextExpression expression) {
visitChildren(expression);
return null;
}
public T visit(VarExpression expression) {
visitChildren(expression);
return null;
}
public T visit(KeyValuePair pair) {
visitChildren(pair);
return null;
}
public T visit(Text text) {
visitChildren(text);
return null;
}
public T visit(IdCon id) {
visitChildren(id);
return null;
}
public T visit(NatCon nat) {
visitChildren(nat);
return null;
}
public T visit(StrCon str) {
visitChildren(str);
return null;
}
public T visit(SymbolCon symbol) {
visitChildren(symbol);
return null;
}
public T visit(SyntaxNodeList<?> list) {
visitChildren(list);
return null;
}
public T visit(TokenNode node) {
visitChildren(node);
return null;
}
/**
* Delegate visit request to children of node.
*
* @param node
* Node
*/
private void visitChildren(SyntaxNode node) {
for (SyntaxNode child : node.getChildren()) {
child.accept(this);
}
}
} | [
"jeroen.v.schagen@370d2b24-1e00-11de-8120-8d224146dbbc"
] | jeroen.v.schagen@370d2b24-1e00-11de-8120-8d224146dbbc |
54d3d31e9df1aab20c150305f2b447a47f1125dc | e2537b67a3cff26c8e4603678b5955fe8e6a81f3 | /commons-scan/src/test/java/com/xiongyingqi/util/PackageScannerTest.java | d551b63297606d51dd8f768f9017d6d5c3cc64d5 | [
"Apache-2.0"
] | permissive | hzw1310/common_utils | 7adc8a25ffa7aac4e0b075c64ff272fbca7ad82b | ef6baf0367c16de95a28caab67a7d5842a6d13db | refs/heads/master | 2023-03-17T15:47:59.886069 | 2016-05-18T15:03:03 | 2016-05-18T15:03:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,454 | java | package com.xiongyingqi.util;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Collection;
@PackageScannerTest.PackageScannerTestAnnotation
public class PackageScannerTest implements Serializable, CharSequence {
@Override
public int length() {
return 0;
}
@Override
public char charAt(int index) {
return 0;
}
@Override
public CharSequence subSequence(int start, int end) {
return null;
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@interface PackageScannerTestAnnotation {
}
@org.junit.Test
public void testScan() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.scan();
org.junit.Assert.assertTrue(scan.size() > 0);
}
@org.junit.Test
public void testWithAnnotation() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.orAnnotation(PackageScannerTestAnnotation.class)
.scan();
org.junit.Assert.assertEquals(scan.iterator().next(), getClass());
}
@org.junit.Test
public void testStartWithString() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.orStartWithString("PackageScannerTest")
.scan();
org.junit.Assert.assertTrue(scan.contains(getClass()));
System.out.println(scan);
}
@org.junit.Test
public void testEndWithString() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.orEndWithString("ScannerTest")
.scan();
org.junit.Assert.assertTrue(scan.contains(getClass()));
System.out.println(scan);
}
@org.junit.Test
public void testAndImplementsInterface() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.andInterface(Serializable.class)
.andInterface(CharSequence.class)
.scan();
System.out.println(scan);
org.junit.Assert.assertTrue(scan.contains(getClass()));
}
@org.junit.Test
public void testOrImplementsInterface() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(PackageScanner.class.getPackage())
.orInterface(Serializable.class)
.orInterface(CharSequence.class)
.scan();
System.out.println(scan);
org.junit.Assert.assertTrue(scan.contains(getClass()));
}
@org.junit.Test
public void testImplementsInterface() throws Exception {
Collection<Class<?>> scan = PackageScanner.newScanner()
.addPackage(getClass().getPackage())
.orInterface(TestInterface.class)
.scan();
System.out.println(scan);
Assert.notNull(scan);
// org.junit.Assert.assertTrue(scan.contains(getClass()));
}
} | [
"[email protected]"
] | |
808b9c203f8820fe6c92582bf1c35bf7be609da1 | 1d371d512c0c0071058b6b03400c2c75f0d8766a | /src/main/java/com/trsvax/tapestry/facebook/components/LikeBox.java | 94d4c3fec7d37c95233af1d91887ef97f4738aa8 | [
"Apache-2.0"
] | permissive | trsvax/tapestry-facebook | 6dcbea70d468143d1714b083e40de46425e55ce4 | 4848a5343b52883416a2ec368439dfb34bd29e48 | refs/heads/master | 2021-06-03T08:19:35.783634 | 2019-01-10T12:52:12 | 2019-01-10T12:52:12 | 1,421,269 | 8 | 7 | null | null | null | null | UTF-8 | Java | false | false | 1,921 | java |
//Copyright [2011] [Barry Books]
// 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.trsvax.tapestry.facebook.components;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;
/**
* @author bfb
* Facebook XFBML Like Box component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/like-box/">Like Box</a>
*
*/
@SupportsInformalParameters
public class LikeBox {
@Parameter(value = "literal:edge.create,edge.remove")
private String events;
@Environmental
private FBAsyncSupport fbAsync;
@Inject
private ComponentResources resources;
@BeginRender
void beginRender(MarkupWriter writer) {
fbAsync.render();
writer.element("fb:like-box");
resources.renderInformalParameters(writer);
writer.end();
if ( events == null || events.length() == 0 ) {
return;
}
for ( String e : events.split(",")) {
fbAsync.subscribe(e,resources);
}
}
}
| [
"[email protected]"
] | |
3d237d7f82710d7cd4b73f94565e5ab6cd0d4307 | cb0503762fd4cab31e84a846ab760792e6a7b352 | /src/main/java/org/jetlinks/supports/cluster/ClusterLocalCache.java | d1bcdc8929d4bd1623b561bcbf083f5ab3660cb0 | [] | no_license | ybinpvt/jetlinks-supports | b0756883d5edc31b3b75a58701775d7728bc5e21 | b6cf9774133fb22146bf67be6ae25c42d8d036ed | refs/heads/master | 2023-01-23T00:44:32.422784 | 2020-11-30T05:27:58 | 2020-11-30T05:27:58 | 317,117,640 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,702 | java | package org.jetlinks.supports.cluster;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.jetlinks.core.cluster.ClusterCache;
import org.jetlinks.core.cluster.ClusterManager;
import org.jetlinks.core.cluster.ClusterTopic;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Collection;
public class ClusterLocalCache<K, V> extends AbstractLocalCache<K, V> {
private final ClusterTopic<K> clearTopic;
public ClusterLocalCache(String name, ClusterManager clusterManager) {
this(name, clusterManager, clusterManager.getCache(name), CacheBuilder.newBuilder().build());
}
public ClusterLocalCache(String name,
ClusterManager clusterManager,
ClusterCache<K, V> clusterCache,
Cache<K, Object> localCache) {
super(clusterCache, localCache);
this.clearTopic = clusterManager.getTopic("_local_cache_modify:".concat(name));
}
@Override
protected Mono<Void> onUpdate(K key, V value) {
return clearTopic
.publish(Mono.just(key))
.then();
}
@Override
protected Mono<Void> onRemove(K key) {
return clearTopic
.publish(Mono.just(key))
.then();
}
@Override
protected Mono<Void> onRemove(Collection<? extends K> key) {
return clearTopic
.publish(Flux.fromIterable(key))
.then();
}
@Override
protected Mono<Void> onClear() {
return clearTopic
.publish(Mono.just((K) "___all"))
.then();
}
}
| [
"[email protected]"
] | |
1312cae5948a1b12684421d568bb96f03e251049 | b7d6cb7cf5ded8a55da0f2a7bd5158c2514f8738 | /src/main/java/com/example/insumos/services/dao/ITratamentoCRUDService.java | 10478959ca80102ce052f920970d930be360f0e8 | [
"MIT"
] | permissive | netrometro/upe_20202_verdinhas | 8735f3584e2c4c63b2af637be8c3f7f17465b692 | e8d856cf929e42baf50a28192e8c14105a5bc3c8 | refs/heads/main | 2023-07-29T12:07:55.651856 | 2021-09-10T21:58:08 | 2021-09-10T21:58:08 | 379,738,387 | 0 | 0 | MIT | 2021-07-29T17:26:16 | 2021-06-23T21:58:04 | Java | UTF-8 | Java | false | false | 208 | java | package com.example.insumos.services.dao;
import com.example.base.CrudService;
import com.example.insumos.model.Tratamento;
public interface ITratamentoCRUDService extends CrudService<Tratamento, Long>{
}
| [
"[email protected]"
] | |
027ee27598da3bb14ccae48606aca4c8bb381e7e | abb61caa81f0d8acc0a4b95c687593d9620f2efc | /src/main/java/com/radhesh/studentportal/service/impl/TimesheetServiceImpl.java | def18e28ca869835d8a61e91cae2ac8df2b4eb4e | [] | no_license | lingamaneniradhesh/studentportal | 56dae88acffeb968bd5613e91f10f1aa928ace95 | 29583dac70cfd795ae69bdd15466f5987cdcac53 | refs/heads/master | 2021-01-16T23:51:16.783642 | 2016-07-14T15:31:01 | 2016-07-14T15:31:01 | 61,243,549 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,368 | java | package com.radhesh.studentportal.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.radhesh.studentportal.dao.TimesheetDAO;
import com.radhesh.studentportal.model.Timesheet;
import com.radhesh.studentportal.service.TimesheetService;
@Service
@Transactional
public class TimesheetServiceImpl implements TimesheetService {
@Autowired
private TimesheetDAO timesheetDAO;
public Timesheet findById(Integer id) {
return timesheetDAO.findById(id);
}
public void save(Timesheet timesheet) {
timesheetDAO.save(timesheet);
}
public void update(Timesheet timesheet) {
Timesheet entity = timesheetDAO.findById(timesheet.getStudent().getId());
if (entity != null) {
entity.setHrs(timesheet.getHrs());
entity.setMins(timesheet.getMins());
entity.setStudent(timesheet.getStudent());
entity.setTask(timesheet.getTask());
entity.setTsDate(timesheet.getTsDate());
}
}
public void delete(Timesheet timesheet) {
timesheetDAO.delete(timesheet);
}
public List<Timesheet> findAll() {
return timesheetDAO.findAll();
}
public Timesheet findByEmpId(Integer empId) {
return timesheetDAO.findByEmpId(empId);
}
}
| [
"[email protected]"
] | |
fb2cc95f856a687ff93470e68e43bee7d0161eda | 3e251eb8d48e57d3ced9bb97d256d889256f5efe | /BenchmarkTest00020.java | d71caece71bd75de1baeaf18274359baa0bbc220 | [] | no_license | nancyag11/testSCAN | 7eefe5ecb523b922269652b2cda64e75319cf927 | ef04d7a7f4a6188aaf55620a04de2c4bcab41fe4 | refs/heads/master | 2021-01-25T09:26:42.608663 | 2017-06-12T10:32:49 | 2017-06-12T10:32:49 | 93,837,352 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,783 | java | /**
* OWASP Benchmark v1.3alpha
*
* This file is part of the Open Web Application Security Project (OWASP)
* Benchmark Project. For details, please see
* <a href="https://www.owasp.org/index.php/Benchmark">https://www.owasp.org/index.php/Benchmark</a>.
*
* The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation, version 2.
*
* The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @author Dave Wichers <a href="https://www.aspectsecurity.com">Aspect Security</a>
* @created 2015
*/
package org.owasp.benchmark.testcode;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(value="/crypto-00/BenchmarkTest00020")
public class BenchmarkTest00020 extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// some code
response.setContentType("text/html;charset=UTF-8");
String param = request.getParameter("BenchmarkTest00020");
if (param == null) param = "";
// Code based on example from:
// http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
// 8-byte initialization vector
// byte[] iv = {
// (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
// (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
// };
java.security.SecureRandom random = new java.security.SecureRandom();
byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
try {
javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
// Prepare the cipher to encrypt
javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
java.security.spec.AlgorithmParameterSpec paramSpec = new javax.crypto.spec.IvParameterSpec(iv);
c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
// encrypt and store the results
byte[] input = { (byte)'?' };
Object inputParam = param;
if (inputParam instanceof String) input = ((String) inputParam).getBytes();
if (inputParam instanceof java.io.InputStream) {
byte[] strInput = new byte[1000];
int i = ((java.io.InputStream) inputParam).read(strInput);
if (i == -1) {
response.getWriter().println(
"This input source requires a POST, not a GET. Incompatible UI for the InputStream source."
);
return;
}
input = java.util.Arrays.copyOf(strInput, i);
}
byte[] result = c.doFinal(input);
java.io.File fileTarget = new java.io.File(
new java.io.File(org.owasp.benchmark.helpers.Utils.testfileDir),"passwordFile.txt");
java.io.FileWriter fw = new java.io.FileWriter(fileTarget,true); //the true will append the new data
fw.write("secret_value=" + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true) + "\n");
fw.close();
response.getWriter().println(
"Sensitive value: '" + org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(input)) + "' encrypted and stored<br/>"
);
} catch (java.security.NoSuchAlgorithmException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (java.security.NoSuchProviderException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (javax.crypto.NoSuchPaddingException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (javax.crypto.IllegalBlockSizeException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (javax.crypto.BadPaddingException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (java.security.InvalidKeyException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
} catch (java.security.InvalidAlgorithmParameterException e) {
response.getWriter().println(
"Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case"
);
e.printStackTrace(response.getWriter());
throw new ServletException(e);
}
response.getWriter().println(
"Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed"
);
}
}
| [
"[email protected]"
] | |
ee03d82425f3d509e6bd8497aad2136586c742a1 | 1c6fe1c9ad917dc9dacaf03eade82d773ccf3c8a | /acm-common/src/main/java/com/wisdom/base/common/form/ExtendedColumnForm.java | 8f129164a4d89ef44c73470d8625908e7cb2464e | [
"Apache-2.0"
] | permissive | daiqingsong2021/ord_project | 332056532ee0d3f7232a79a22e051744e777dc47 | a8167cee2fbdc79ea8457d706ec1ccd008f2ceca | refs/heads/master | 2023-09-04T12:11:51.519578 | 2021-10-28T01:58:43 | 2021-10-28T01:58:43 | 406,659,566 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | package com.wisdom.base.common.form;
import lombok.Data;
/**
* 扩展列
*/
@Data
public class ExtendedColumnForm extends BaseForm{
private String extendedColumn1;
private String extendedColumn2;
private String extendedColumn3;
private String extendedColumn4;
private String extendedColumn5;
}
| [
"[email protected]"
] | |
e87202e3f643df64e56e3fac10fe7e28fb7265d9 | 12563229bd1c69d26900d4a2ea34fe4c64c33b7e | /nan21.dnet.module.md/nan21.dnet.module.md.domain/src/main/java/net/nan21/dnet/module/md/org/domain/entity/StockLocatorType.java | 8db8d21e786e963c65f8109d1da94ac348568141 | [] | no_license | nan21/nan21.dnet.modules | 90b002c6847aa491c54bd38f163ba40a745a5060 | 83e5f02498db49e3d28f92bd8216fba5d186dd27 | refs/heads/master | 2023-03-15T16:22:57.059953 | 2012-08-01T07:36:57 | 2012-08-01T07:36:57 | 1,918,395 | 0 | 1 | null | 2012-07-24T03:23:00 | 2011-06-19T05:56:03 | Java | UTF-8 | Java | false | false | 3,192 | java | /*
* DNet eBusiness Suite
* Copyright: 2008-2012 Nan21 Electronics SRL. All rights reserved.
* Use is subject to license terms.
*/
package net.nan21.dnet.module.md.org.domain.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.QueryHint;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import net.nan21.dnet.core.domain.eventhandler.DefaultEventHandler;
import net.nan21.dnet.core.domain.model.AbstractType;
import org.eclipse.persistence.annotations.Customizer;
import org.eclipse.persistence.config.HintValues;
import org.eclipse.persistence.config.QueryHints;
import org.eclipse.persistence.descriptors.DescriptorEvent;
/** StockLocatorType. */
@Entity
@Table(name = StockLocatorType.TABLE_NAME, uniqueConstraints = { @UniqueConstraint(name = StockLocatorType.TABLE_NAME
+ "_UK1", columnNames = { "CLIENTID", "NAME" }) })
@Customizer(DefaultEventHandler.class)
@NamedQueries({
@NamedQuery(name = StockLocatorType.NQ_FIND_BY_ID, query = "SELECT e FROM StockLocatorType e WHERE e.clientId = :pClientId and e.id = :pId ", hints = @QueryHint(name = QueryHints.BIND_PARAMETERS, value = HintValues.TRUE)),
@NamedQuery(name = StockLocatorType.NQ_FIND_BY_IDS, query = "SELECT e FROM StockLocatorType e WHERE e.clientId = :pClientId and e.id in :pIds", hints = @QueryHint(name = QueryHints.BIND_PARAMETERS, value = HintValues.TRUE)),
@NamedQuery(name = StockLocatorType.NQ_FIND_BY_NAME, query = "SELECT e FROM StockLocatorType e WHERE e.clientId = :pClientId and e.name = :pName ", hints = @QueryHint(name = QueryHints.BIND_PARAMETERS, value = HintValues.TRUE)) })
public class StockLocatorType extends AbstractType {
public static final String TABLE_NAME = "MD_STOCKLOC_TYPE";
public static final String SEQUENCE_NAME = "MD_STOCKLOC_TYPE_SEQ";
private static final long serialVersionUID = -8865917134914502125L;
/**
* Named query find by ID.
*/
public static final String NQ_FIND_BY_ID = "StockLocatorType.findById";
/**
* Named query find by IDs.
*/
public static final String NQ_FIND_BY_IDS = "StockLocatorType.findByIds";
/**
* Named query find by unique key: Name.
*/
public static final String NQ_FIND_BY_NAME = "StockLocatorType.findByName";
/**
* System generated unique identifier.
*/
@Column(name = "ID", nullable = false)
@NotNull
@Id
@GeneratedValue(generator = SEQUENCE_NAME)
private Long id;
/* ============== getters - setters ================== */
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public void aboutToInsert(DescriptorEvent event) {
super.aboutToInsert(event);
if (this.getActive() == null) {
event.updateAttributeWithObject("active", false);
}
}
}
| [
"[email protected]"
] | |
c58f3b01f38f79889a0644a86b72cf982ddae3ad | 8896e628288f94b4efc4fefa33ed3e298702abae | /Android Testing Ground/UFAS-Rev1/Tesing/src/main/java/com/okstate/ufas/tesing/communication/BT.java | fb281a51ec5ba2299ebf7175c6fb604b986351cd | [] | no_license | nathanlea/UFRO | 686adbb556e0fce1469dcaa89117c2d3c7041722 | 744483e2ba297947db1c4590e71b8443e5317253 | refs/heads/master | 2021-01-17T21:08:39.141166 | 2014-03-31T15:55:33 | 2014-03-31T15:55:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,941 | java | package com.okstate.ufas.tesing.communication;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import com.okstate.ufas.tesing.R;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
public class BT extends Communication {
private static final boolean D = true;
private BluetoothAdapter mBluetoothAdapter = null;
private BluetoothSocket btSocket = null;
private OutputStream outStream = null;
private InputStream inStream = null;
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public BT(Context context) {
super(context);
Enable();
}
@Override
public void Enable() {
Toast.makeText(context, "Starting Bluetooth", Toast.LENGTH_SHORT).show();
if (D)
Log.d(TAG, "+++ Enable BT +++");
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
Toast.makeText(context, context.getString(R.string.Bluetoothisnotavailable), Toast.LENGTH_LONG).show();
// finish();
return;
}
if (!mBluetoothAdapter.isEnabled()) {
Toast.makeText(context, "Starting Bluetooth...", Toast.LENGTH_SHORT).show();
mBluetoothAdapter.enable();
return;
}
if (D)
Log.d(TAG, "+++ DONE IN ON CREATE, GOT LOCAL BT ADAPTER +++");
}
@Override
public void Connect(String address, int speed) {
Toast.makeText(context, context.getString(R.string.Connecting), Toast.LENGTH_LONG).show();
if (mBluetoothAdapter.isEnabled()) {
try {
GetRemoteDevice(address);
btSocket.connect();
Connected = true;
Log.d(TAG, "BT connection established, data transfer link open.");
Toast.makeText(context, context.getString(R.string.Connected), Toast.LENGTH_LONG).show();
} catch (IOException e) {
try {
btSocket.close();
Connected = false;
Toast.makeText(context, context.getString(R.string.Unabletoconnect), Toast.LENGTH_LONG).show();
} catch (IOException e2) {
Log.e(TAG, "ON RESUME: Unable to close socket during connection failure", e2);
Toast.makeText(context, "Connection failure", Toast.LENGTH_LONG).show();
}
}
// Create a data stream so we can talk to server.
if (D)
Log.d(TAG, "+ getOutputStream getInputStream +");
try {
outStream = btSocket.getOutputStream();
inStream = btSocket.getInputStream();
} catch (IOException e) {
Log.e(TAG, "ON RESUME: Output stream creation failed.", e);
Toast.makeText(context, "Stream creation failed", Toast.LENGTH_LONG).show();
}
}
}
@Override
public boolean dataAvailable() {
boolean a = false;
try {
if (Connected)
a = inStream.available() > 0;
} catch (IOException e) {
e.printStackTrace();
}
return a;
}
@Override
public byte Read() {
BytesRecieved += 1;
byte a = 0;
try {
a = (byte) inStream.read();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(context, "Read error", Toast.LENGTH_LONG).show();
}
return (byte) (a);
}
@Override
public void Write(byte[] arr) {
super.Write(arr);
try {
if (Connected)
outStream.write(arr);
} catch (IOException e) {
Log.e(TAG, "SEND : Exception during write.", e);
CloseSocket();
Toast.makeText(context, "Write error", Toast.LENGTH_LONG).show();
}
}
@Override
public void Close() {
CloseSocket();
}
@Override
public void Disable() {
try {
mBluetoothAdapter.disable();
} catch (Exception e) {
Toast.makeText(context, "Can't dissable BT", Toast.LENGTH_LONG).show();
}
}
@SuppressLint("NewApi")
private void GetRemoteDevice(String address) {
if (D) {
Log.d(TAG, "+ ON RESUME +");
Log.d(TAG, "+ ABOUT TO ATTEMPT CLIENT CONNECT +");
}
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, "ON RESUME: Socket creation failed.", e);
Toast.makeText(context, context.getString(R.string.Unabletoconnect), Toast.LENGTH_LONG).show();
}
if (mBluetoothAdapter.isDiscovering())
mBluetoothAdapter.cancelDiscovery();
}
public void CloseSocket() {
if (outStream != null) {
try {
outStream.flush();
} catch (IOException e) {
Log.e(TAG, "ON PAUSE: Couldn't flush output stream.", e);
Toast.makeText(context, "Unable to close socket", Toast.LENGTH_LONG).show();
}
}
try {
if (btSocket != null)
btSocket.close();
Connected = false;
Toast.makeText(context, context.getString(R.string.Disconnected), Toast.LENGTH_LONG).show();
} catch (Exception e2) {
Log.e(TAG, "ON PAUSE: Unable to close socket.", e2);
Toast.makeText(context, "Unable to close socket", Toast.LENGTH_LONG).show();
}
}
}
| [
"[email protected]"
] | |
a789512af9fa47fd1844855dce6ef7dcdb0d2c43 | b52234e5b62cfbc1eea7651335db35db7895f5d3 | /app/src/main/java/com/example/lucas/fitnet20/Item_ClienteAdapter.java | bfd13766940cfdc27f1f4299191ee193cbff6e0e | [] | no_license | lucasgroba/Fitnet2.0 | 713be73b1e34dcb83bd534fa92342f7b67f8298d | 92f3dba8ea93ccbca94a8bfc30de494d6b5fbf59 | refs/heads/master | 2021-01-23T10:54:58.499724 | 2017-07-14T19:34:03 | 2017-07-14T19:34:03 | 93,103,198 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,524 | java | package com.example.lucas.fitnet20;
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;
/**
* Created by santiago on 13/07/17.
*/
public class Item_ClienteAdapter extends BaseAdapter{
private ArrayList<Item_Cliente> arrayListItem;
private Context context;
private LayoutInflater layoutInflater;
public Item_ClienteAdapter(ArrayList<Item_Cliente> arrayListItem, Context context) {
this.arrayListItem = arrayListItem;
this.context = context;
}
@Override
public int getCount() {
return arrayListItem.size();
}
@Override
public Object getItem(int position) {
return arrayListItem.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if(view!=null){
//layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//view = layoutInflater.inflate(R.layout.item,viewGroup,false);
}
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.item_cliente,viewGroup,false);
TextView nombre = (TextView) view.findViewById(R.id.NomCli);
ImageView imagen = (ImageView) view.findViewById(R.id.ImagenCli);
TextView cedula = (TextView) view.findViewById(R.id.Cedula);
TextView correo = (TextView) view.findViewById(R.id.Correo);
TextView celular = (TextView) view.findViewById(R.id.Celular);
TextView mutualista = (TextView) view.findViewById(R.id.Mutualista);
TextView fecha_nac = (TextView) view.findViewById(R.id.FechaNac);
TextView sexo = (TextView) view.findViewById(R.id.Sexo);
nombre.setText(arrayListItem.get(i).getNombre());
cedula.setText(arrayListItem.get(i).getCedula());
correo.setText(arrayListItem.get(i).getCorreo());
celular.setText(arrayListItem.get(i).getCelular());
fecha_nac.setText(arrayListItem.get(i).getFecha_nac());
mutualista.setText(arrayListItem.get(i).getMutualista());
sexo.setText(arrayListItem.get(i).getSexo());
imagen.setImageBitmap(arrayListItem.get(i).getImagen());
return view;
}
}
| [
"[email protected]"
] | |
f35a9469211798a7b7c8603ffd2a2aef1b271874 | 284e2abafe1adc6eb494aa9910a61bf66b8ac857 | /src/jdivers/PlayState.java | 145ab1a2889e059e32fc8c2e79fdc525695fb32d | [] | no_license | MJKAEM/Salvage-Quest-Java | ec299b604b2a5df452ffcd0e23d656911ef9585e | 16148d1497ad490be86ce263d7d45af0b57b379b | refs/heads/master | 2021-01-25T13:23:25.214754 | 2015-08-12T07:53:47 | 2015-08-12T07:53:47 | 123,560,377 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,666 | java | package jdivers;
import jdivers.items.ItemEnum;
import jdivers.items.RandomGenerator;
import jdivers.output.OutputTextBox;
import jdivers.playmenu.DiveMenu;
import jdivers.playmenu.MainHubMenu;
import jdivers.playmenu.ShopMenu;
import jdivers.playmenu.StashMenu;
import jdivers.playmenu.SwimMenu;
import jdivers.textbox.ClickHandler;
import org.newdawn.slick.AngelCodeFont;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class PlayState extends BasicGameState
{
private AngelCodeFont textboxFont, outputTextFont;
public static OutputTextBox outputTextbox = new OutputTextBox();
private PlayerData playerData;
private MainHubMenu mainHubMenu;
private ShopMenu shopMenu;
private StashMenu stashMenu;
private SwimMenu swimMenu;
private DiveMenu diveMenu;
private AbstractMenu currentMenu;
private ClickHandler switchMainHub, switchShop, switchStash, switchSwim,
switchDive, switchFishing;
private ClickHandler searchItem;
public PlayState(int state)
{
}
@Override
public void init(GameContainer gc, StateBasedGame sbg)
throws SlickException
{
playerData = new PlayerData("Anonymous");
mainHubMenu = new MainHubMenu();
shopMenu = new ShopMenu();
stashMenu = new StashMenu();
swimMenu = new SwimMenu();
diveMenu = new DiveMenu();
currentMenu = mainHubMenu;
textboxFont = ContentLoader.fonts[0];
outputTextFont = ContentLoader.fonts[3];
outputTextbox = new OutputTextBox(outputTextFont);
initMenuHandlerClickActions();
initMenuHandlers();
}
@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
throws SlickException
{
g.setFont(textboxFont);
currentMenu.show(g);
g.setFont(outputTextFont);
outputTextbox.show(g);
drawHud(g);
}
@Override
public void update(GameContainer gc, StateBasedGame sbg, int delta)
throws SlickException
{
MouseFix.updateMouseY();
currentMenu.update();
}
@Override
public void mouseReleased(int button, int x, int y)
{
switch (button)
{
case 0:
currentMenu.mouseReleased();
break;
}
}
@Override
public int getID()
{
return Global.PLAY_STATE_ID;
}
private void drawHud(final Graphics g)
{
g.setFont(outputTextFont);
g.setColor(Color.black);
g.drawString(playerData.getCurHealth() + " HP", 20,
Global.threeFourthHeight - 40);
g.drawString(playerData.getCurArmor() + " AP", 20,
Global.threeFourthHeight - 20);
g.drawString("$" + playerData.getCurMoney(), Global.threeFourthWidth,
Global.threeFourthHeight - 20);
// Draw player items.
//
playerData.showInventory(g);
}
private void initMenuHandlerClickActions()
{
switchMainHub = new ClickHandler()
{
@Override
public void onClick()
{
currentMenu = mainHubMenu;
}
};
switchShop = new ClickHandler()
{
@Override
public void onClick()
{
currentMenu = shopMenu;
}
};
switchStash = new ClickHandler()
{
@Override
public void onClick()
{
currentMenu = stashMenu;
}
};
switchSwim = new ClickHandler()
{
@Override
public void onClick()
{
currentMenu = swimMenu;
}
};
switchDive = new ClickHandler()
{
@Override
public void onClick()
{
currentMenu = diveMenu;
}
};
searchItem = new ClickHandler()
{
@Override
public void onClick()
{
int itemID = RandomGenerator.generateGem();
switch (itemID)
{
case 0:
outputTextbox.println("It seems you found nothing.");
break;
default:
ItemEnum itemEnum = ItemEnum.translateId(itemID);
boolean added = playerData.putIntoHand(itemEnum);
if (added)
{
outputTextbox.println("You found a " +
itemEnum.toString()
+ ". It is now in your hands.");
}
else
{
outputTextbox.println("Your hands are full!");
}
break;
}
}
};
}
private void initMenuHandlers()
{
mainHubMenu.setClickHandler(switchShop, 0);
mainHubMenu.setClickHandler(switchStash, 1);
mainHubMenu.setClickHandler(switchSwim, 2);
// mainHubMenu.setClickHandler(switchFishing, 4);
shopMenu.setClickHandler(switchMainHub, AbstractMenu.GO_BACK);
stashMenu.setClickHandler(switchMainHub, AbstractMenu.GO_BACK);
swimMenu.setClickHandler(switchMainHub, AbstractMenu.GO_BACK);
swimMenu.setClickHandler(switchDive, SwimMenu.GO_DIVE);
diveMenu.setClickHandler(switchSwim, AbstractMenu.GO_BACK);
diveMenu.setClickHandler(searchItem, DiveMenu.SEARCH);
}
};
| [
"[email protected]"
] | |
a7570c273ce9d8b275e99fefc1aced76acf8d936 | a55e52fb28d0aacadd250eb52719d093cf154642 | /HelloWorld/HelloWorld.java | f224ad162354e401d347b7ae247ffe17afced418 | [
"MIT"
] | permissive | terry2012/jni_practice | 4dfb608800ca0fba86eda399382e47a24595b59e | 8c71776090e806056d753f79a574f4a38c85b6a2 | refs/heads/master | 2020-12-25T04:28:17.358397 | 2014-08-12T07:05:24 | 2014-08-12T07:05:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 210 | java | public class HelloWorld {
static {
System.loadLibrary("hello");
}
private native void sayHello();
public static void main (String [] args) {
new HelloWorld().sayHello();
}
}
| [
"[email protected]"
] | |
4827ebc03e19a1b164b9459a4848c212b7710f8b | 930693182862a0fa42195282e3d6b59167de8ba7 | /com/jse/member/MemberController.java | f733143b765dc181a37748dfd9c6c84f947d1d46 | [] | no_license | DeokCho/Bitcamp | 792476c86768e537c6e1ba902fe6677845e9c7f6 | 3af6884b07b213598442c8b2422912e089899c85 | refs/heads/master | 2021-05-24T19:00:21.211309 | 2020-04-20T11:58:03 | 2020-04-20T11:58:03 | 253,708,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 130 | java | package com.jse.member;
public class MemberController {
public static void main(String[] args) {
new MemberView().open();
}
} | [
"[email protected]"
] | |
6f32fcb9b897abc2da74f9a249f1e304b92f0f5a | a1050bdd29edf32635d3d693afb6e3841fddb5d0 | /examples/java/RestaurantSchedule.java | 05d128501b6de31742fb93838647a739b3b1f788 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | google/differential-privacy | fd2eafae20f2b5b5f9ea814193d4b9e0c12652ca | 5e09d51dee26c4c6a5a805a288e19285f3983e6d | refs/heads/main | 2023-09-03T09:07:58.451237 | 2023-08-28T14:03:33 | 2023-08-28T15:14:39 | 206,320,938 | 2,969 | 397 | Apache-2.0 | 2023-08-14T07:55:30 | 2019-09-04T13:04:15 | Go | UTF-8 | Java | false | false | 1,258 | java | //
// Copyright 2020 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
//
// 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.privacy.differentialprivacy.example;
import com.google.common.collect.Range;
public class RestaurantSchedule {
/** An hour when visitors start entering the restaurant. */
static final int OPENING_HOUR = 9;
/** An hour when visitors stop entering the restaurant. */
static final int CLOSING_HOUR = 20;
/**For how many hours visitors can enter the restaurant. */
static final int NUM_OF_WORK_HOURS = CLOSING_HOUR - OPENING_HOUR + 1;
/** Range of valid work hours when a visitor can enter the restaurant. */
static final Range<Integer> VALID_HOURS = Range.closed(OPENING_HOUR, CLOSING_HOUR);
private RestaurantSchedule() {}
}
| [
"[email protected]"
] | |
97f2767871e5f384454675ea5a290cd56ea87b8a | fedf0751c9727534c547e40fff5515051acaa27c | /src/Domain/output/technicalindicators/MINUS_DI.java | 70be814c6a51f6b8d8e8143653cf1a8293f4dea5 | [] | no_license | SpoonDS-LuisAS/fxclass | 78bd967274ad2ba40f2d2600d50173e3d051dab4 | f4cf64a049dbdde3e0908a0706d8743e45a90af1 | refs/heads/master | 2020-08-07T08:11:02.564034 | 2020-03-06T09:22:29 | 2020-03-06T09:22:29 | 213,361,209 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,927 | java | package Domain.output.technicalindicators;
import Domain.input.technicalindicators.Interval;
import Domain.output.JsonParser;
import Domain.output.technicalindicators.data.IndicatorData;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Representation of the minus directional indicator (MINUS_DI) response from api.
*
* @see TechnicalIndicatorResponse
*/
public class MINUS_DI extends TechnicalIndicatorResponse<IndicatorData> {
private MINUS_DI(final Map<String, String> metaData,
final List<IndicatorData> indicators) {
super(metaData, indicators);
}
/**
* Creates {@code MINUS_DI} instance from json.
*
* @param interval specifies how to interpret the date key to the data json object
* @param json string to parse
* @return MINUS_DI instance
*/
public static MINUS_DI from(Interval interval, String json) {
Parser parser = new Parser(interval);
return parser.parseJson(json);
}
/**
* Helper class for parsing json to {@code MINUS_DI}.
*
* @see TechnicalIndicatorParser
* @see JsonParser
*/
private static class Parser extends TechnicalIndicatorParser<MINUS_DI> {
public Parser(Interval interval) {
super(interval);
}
@Override
String getIndicatorKey() {
return "Technical Analysis: MINUS_DI";
}
@Override
MINUS_DI resolve(Map<String, String> metaData,
Map<String, Map<String, String>> indicatorData) {
List<IndicatorData> indicators = new ArrayList<>();
indicatorData.forEach((key, values) -> indicators.add(new IndicatorData(
resolveDate(key),
Double.parseDouble(values.get("MINUS_DI"))
)));
return new MINUS_DI(metaData, indicators);
}
}
}
| [
"[email protected]"
] | |
4f9ae60d3ca6b27309af8e0d9393f1799c6b57e6 | c73635d59900677047d662e39df9fdd784d68724 | /Split/src/Split.java | 3501cdcb2b1f7c28e410a6f42e8856bd46319e4a | [] | no_license | qiany1230/y_qian-Aug2017 | 3c34ffcd5165d02f34092875f4faa3101bafe181 | d096b6352fd7c9d533dc2bf6b1e65827a2eecdec | refs/heads/master | 2021-09-15T00:11:58.519452 | 2018-05-22T15:43:38 | 2018-05-22T15:43:38 | 100,618,964 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 927 | java | /* Ying Qian
* October 26 2017
* Split String Practice
*/
//SplitString Starter Code
import java.util.*;
public class Split {
public static void main(String[] args) {
System.out.println(Arrays.toString("I like apples!".split(" ")));
System.out.println(Arrays.toString("I really like really red apples".split("really")));
System.out.println(Arrays.toString("I reallyreally likesapples".split("really")));
System.out.println(Arrays.toString("applespineapplesbreadlettustomatobaconmayohambreadcheese".split("bread")));
System.out.println(Arrays.toString("applesbreadpineapplesbreadlettustomatobreadbaconmayohambreadcheese".split("bread")));
System.out.println(Arrays.toString("apples pineapples bread lettus tomato bacon mayo ham bread cheese".split(" ")));
System.out.println(Arrays.toString("apples pineapples bread lettus tomato bacon mayo ham bread cheese".split(" bread ")));
}
} | [
"[email protected]"
] | |
06525a53523a5af115d1ab85b3fb1ef6367155e5 | b31fbbe62464b321c25d8efb8ee5c916ab75a97c | /src/IARCExample.java | 8b7c46f0180265586121ccd9596581552ea8013e | [] | no_license | yume190/RS | 6f5eb81d7a829718726157d7979861b3dce576ce | 6b6fff5b4f0207732ecd5dbc171a1cbfa577b1e2 | refs/heads/master | 2021-01-01T16:34:21.178728 | 2013-04-29T09:12:15 | 2013-04-29T09:12:15 | null | 0 | 0 | null | null | null | null | BIG5 | Java | false | false | 1,628 | java | import java.util.Arrays;
public class IARCExample {
public static void main(String[] args) throws Exception{
double Rc1 = 20.0;
double Rc2 = 60.0;
double Rs = 5.0;
double P = 5.0;
double C0 = 0.9;
double l = 100.0;
int bit = 32;
int turn = 1;
//建立SINK 和 ARC NODE
Sink sink = new Sink(Rc1,Rc2);
RS nodes[] = new RS[1000];
//原始版本
for(int i=0;i<nodes.length;i++){
nodes[i] = new RS(l*Math.random(),l*Math.random(),Rs,Rc1,Rc2,P,C0,i,l,l,nodes.length,bit);
nodes[i].self = nodes[i];
nodes[i].power.owner = nodes[i];
}
//建立鄰近關係
sink.ALLNodes = nodes;
sink.searchNeighborNode();
for(int i=0;i<nodes.length;i++){
nodes[i].searchNeighborNode(nodes);
}
//PHASE 1
sink.CHNSelection();
Arrays.sort(nodes);
for(int i=0;i<nodes.length;i++){
nodes[i].CHN();
}
for(int i=0;i<nodes.length;i++)
((RS)nodes[i]).JOIN();
//PHASE 2
sink.routeSetup();
sink.HOP();
{
int i=0,CHNAmount=0;
for(int j=0;j<nodes.length;j++){
if(nodes[j].nodeState == ARCNode.CHN)
CHNAmount++;
}
while(true){
Arrays.sort(nodes);
for(;i<CHNAmount;i++){
if(nodes[i].deliverHOPTime == 100.0)
break;
nodes[i].HOP();
}
if(i == CHNAmount)
break;
}
}
/*
//PHASE 3
sink.NCHNActivation();
for(int i=0;i<nodes.length;i++){
nodes[i].Threshold();
}
*/
//PAHSE 4
sink.steadyPhase();
for(int i=0;i<nodes.length;i++){
if(nodes[i].nodeState == ARCNode.CHN || nodes[i].nodeState == ARCNode.ACTIVE){
for(int j=0;j<turn;j++){
nodes[i].reportData();
}
}
}
}
}
| [
"[email protected]"
] | |
c040b4323ab69da9b0c4f312b2b39a2ea62bf2cf | e75ea956710f74949ac7177ca1098c1194f72de2 | /src/serverlet/Logout.java | ffb6814203682efeff878c69a7d07c13ba71d490 | [] | no_license | T-O-N-G/PDD | b1efc2cf2aff5f90ddfc1fa6c520cef6dd377f59 | 4cdb60507e14d04b2eed91d99cf54be70a3a3773 | refs/heads/master | 2021-06-16T12:11:35.052503 | 2017-05-20T17:07:10 | 2017-05-20T17:07:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,636 | java | package serverlet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
/**
* Created by wzf on 2017/4/20.
*/
@WebServlet(name = "Logout")
public class Logout extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.print("get");
Cookie[] cookies=request.getCookies();
for(Cookie cookie: cookies){
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
}
HttpSession session=request.getSession();//返回与当前request相关联的session,如果没有则在服务器端创建一个;
session.removeAttribute("user");
response.sendRedirect("login.jsp");
return;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.print("post");
Cookie[] cookies=request.getCookies();
for(Cookie cookie: cookies){
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
}
HttpSession session=request.getSession();//返回与当前request相关联的session,如果没有则在服务器端创建一个;
session.removeAttribute("user");
response.sendRedirect("login.jsp");
return;
}
}
| [
"[email protected]"
] | |
6e4beb254e49d8ad31ed33432f7a6ac6ee4efdf6 | 27d395d22408e2d7f4a5d655ceb8ecb3e87bddaf | /app/src/main/java/com/huacheng/huiservers/center/NamenickVerfityActivity.java | 6267b988cff6de98afc71107cc6de825207d3329 | [] | no_license | wangxiaotao520/Huiservers_Branches | 4305d6be4188d094ab88c49116274d2f6fae1809 | 81ba4ddcac85aa0b92bae45b3c05b0bd975862c4 | refs/heads/master | 2020-04-04T13:31:26.307596 | 2018-11-03T08:48:02 | 2018-11-03T08:48:38 | 155,964,697 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 7,436 | java | package com.huacheng.huiservers.center;
import android.content.Context;
import android.text.InputFilter;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import com.huacheng.huiservers.BaseUI;
import com.huacheng.huiservers.R;
import com.huacheng.huiservers.center.bean.PersoninfoBean;
import com.huacheng.huiservers.protocol.ShopProtocol;
import com.huacheng.huiservers.utils.MyCookieStore;
import com.huacheng.huiservers.utils.UIUtils;
import com.huacheng.huiservers.utils.Url_info;
import com.huacheng.huiservers.utils.XToast;
import com.huacheng.libraryservice.http.ApiHttpClient;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import org.greenrobot.eventbus.EventBus;
import java.util.Timer;
import java.util.TimerTask;
public class NamenickVerfityActivity extends BaseUI implements OnClickListener {
TextView title_name,tv_description, tv_flag, right;
EditText et_content;
@Override
protected void init() {
super.init();
// SetTransStatus.GetStatus(this);
setContentView(R.layout.verify_editxt_new);
// title
title_name = (TextView) findViewById(R.id.title_name);
right = (TextView) findViewById(R.id.right);
tv_description = (TextView) findViewById(R.id.tv_description);
tv_flag = (TextView) findViewById(R.id.tv_flag);
et_content = (EditText) findViewById(R.id.et_content);
// set
title_name.setText("昵称");
right.setTextColor(getResources().getColor(R.color.rednew));
right.setText("提交");
// get
String nickname = getIntent().getExtras().getString("nickname");
if (!nickname.equals("")) {
et_content.setText(nickname);
} else {
et_content.setHint("请输入");
}
String sex = getIntent().getExtras().getString("tv_sex");
if (sex.equals("男")) {
tv_description.setText("先生");
} else if (sex.equals("女")) {
tv_description.setText("女士");
} else {
tv_description.setText("先生/女士");
}
tv_flag.setText("将用于社区慧生活社区交流,昵称不能超过8位,包含汉字、字母或数字,且不能与别人重复");
// 限定edittext能输入内容
et_content.setFilters(new InputFilter[]{new InputFilter.LengthFilter(8)});
// 强制隐藏Android输入法窗口
et_content.setFocusableInTouchMode(true);
et_content.setFocusable(true);
et_content.requestFocus();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
InputMethodManager inputManager = (InputMethodManager) et_content.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(et_content, 0);
}
}, 100);
// listener
findViewById(R.id.lin_left).setOnClickListener(this);
right.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.right:
String nickname = et_content.getText().toString();
if (!nickname.equals("")) {
getMyinfo(nickname);
/*closeInputMethod();
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("nickname", nickname);
intent.putExtras(bundle);
setResult(22, intent);
finish();*/
} else {
XToast.makeText(this, "昵称不能为空", XToast.LENGTH_SHORT).show();
}
break;
case R.id.lin_left:
closeInputMethod();
finish();
break;
default:
break;
}
}
/**
* 修改个人信息
*
* @param param
*/
private void getMyinfo(final String param) {
showDialog(smallDialog);
Url_info info=new Url_info(this);
HttpUtils http = new HttpUtils();
RequestParams params = new RequestParams();
params.addBodyParameter("nickname", param);
/* if (file.exists()) {
params.addBodyParameter("avatars", file);
}
System.out.println("currentSelected-----" + currentSelected);
params.addBodyParameter("sex", currentSelected);
params.addBodyParameter("birthday", txt_time.getText().toString());
*/
if (ApiHttpClient.TOKEN!=null&&ApiHttpClient.TOKEN_SECRET!=null){
params.addBodyParameter("token",ApiHttpClient.TOKEN+"");
params.addBodyParameter("tokenSecret",ApiHttpClient.TOKEN_SECRET+"");
}
http.configCookieStore(MyCookieStore.cookieStore);
http.send(HttpRequest.HttpMethod.POST,info.edit_center, params,new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
hideDialog(smallDialog);
UIUtils.showToastSafe("网络异常,请检查网络设置");
}
@Override
public void onSuccess(ResponseInfo<String> arg0) {
hideDialog(smallDialog);
ShopProtocol protocol = new ShopProtocol();
String str = protocol.setShop(arg0.result);
if (str.equals("1")) {
closeInputMethod();
EventBus.getDefault().post(new PersoninfoBean());
// MyCookieStore.My_info = 1;
// Intent intent = new Intent(NamenickVerfityActivity.this, MyInfoActivity2.class);
/*Bundle bundle = new Bundle();
bundle.putString("name", param);
intent.putExtras(bundle);
setResult(11, intent);*/
/*MyCookieStore.My_info = 1;
*/
finish();
XToast.makeText(NamenickVerfityActivity.this, "修改成功", XToast.LENGTH_SHORT)
.show();
} else {
XToast.makeText(NamenickVerfityActivity.this, str, XToast.LENGTH_SHORT).show();
}
}
});
}
/**
* 关闭软键盘
*/
private void closeInputMethod() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isOpen = imm.isActive();
if (isOpen) {
// imm.toggleSoftInput(0,
// InputMethodManager.HIDE_NOT_ALWAYS);//没有显示则显示
imm.hideSoftInputFromWindow(et_content.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
| [
"[email protected]"
] | |
35f2d9740aa7f6ddb5f9c58c1a4ad9e5994290fc | a1d7a626dce72d1f3e01d5a3d41b9337e29bac20 | /src/test/java/pages/ProductsMakmal/EditButtonPage.java | 09e57a1786689c2eae62a952235e3cc298fda013 | [] | no_license | sergheib5/CucumberManufactModule | 70825921d1acad2baf836ab86d5f29f22576a416 | ee6dac97638388e3ac676ed0c3fd8fe6f7434f67 | refs/heads/developer | 2021-01-26T06:49:45.368452 | 2020-03-03T03:15:54 | 2020-03-03T03:15:54 | 243,353,330 | 0 | 0 | null | 2020-03-03T03:15:55 | 2020-02-26T19:57:59 | Java | UTF-8 | Java | false | false | 543 | java | package pages.ProductsMakmal;
import utilities.Driver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import utilities.Driver;
public class EditButtonPage {
public EditButtonPage(){
PageFactory.initElements(Driver.getDriver(),this);
}
@FindBy(xpath = "//button[@accesskey='c']")
public WebElement createButton;
@FindBy(xpath = "//button[@accesskey='a']")
public WebElement clickEdit;
}
| [
"[email protected]"
] | |
8a0b845746f1bccc09630406fed9dfe83e541144 | 4a98ec846e81dcc31ae55e18f27f56445af84312 | /Lambda/Lambda_basics_block/src/Func.java | 1b9a56f5aebf6fe8b48f6d480267138fc68b3682 | [] | no_license | VladimirGarnovsky/Java-Reference-Examples | 434b4d29dae2847ef11be792a28c6eece47defe8 | 03964b93247febbdac3a72f6e5b3295ed89892cd | refs/heads/master | 2020-04-10T05:12:30.330879 | 2018-12-11T08:22:05 | 2018-12-11T08:22:05 | 160,820,270 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 47 | java |
public interface Func {
int getNum(int n);
}
| [
"[email protected]"
] | |
0a882b13e7e06d18531e4fe7e20f2aca4d8e4320 | 902cbae1f871f128a64e1b140fff23f72465ca0c | /spring-creed-pom/spring-creed-pro/spring-creed-module-system/spring-creed-module-system-biz/src/main/java/com/ethan/system/controller/admin/sms/vo/log/SmsLogPageReqVO.java | 55c5ddceb9073fe6cfd5ea2e630cc5b09d7c29ac | [
"Apache-2.0"
] | permissive | PhotonAlpha/spring-creed | 5f085e612fccd767baa68de7359f1ca53fcb111d | 64a08bc59ef1e21e47893ace707307bb7c529866 | refs/heads/master | 2023-06-23T02:03:34.214592 | 2023-05-13T12:05:29 | 2023-05-13T12:05:29 | 225,605,374 | 2 | 0 | Apache-2.0 | 2023-08-07T16:18:15 | 2019-12-03T11:38:37 | JavaScript | UTF-8 | Java | false | false | 1,394 | java | package com.ethan.system.controller.admin.sms.vo.log;
import com.ethan.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static com.ethan.common.utils.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(name="管理后台 - 短信日志分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SmsLogPageReqVO extends PageParam {
@Schema(name = "短信渠道编号", example = "10")
private Long channelId;
@Schema(name = "模板编号", example = "20")
private Long templateId;
@Schema(name = "手机号", example = "15601691300")
private String mobile;
@Schema(name = "发送状态", example = "1", description = "参见 SmsSendStatusEnum 枚举类")
private Integer sendStatus;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(name = "发送时间")
private Date[] sendTime;
@Schema(name = "接收状态", example = "0", description = "参见 SmsReceiveStatusEnum 枚举类")
private Integer receiveStatus;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(name = "接收时间")
private Date[] receiveTime;
}
| [
"[email protected]"
] | |
8c620e7e0e6b7b0fe6325220d84b484d03623fcf | 381b8e14b9065be336f65d0623985e4ef8e3e8ba | /ScheduleManagement/src/main/java/jp/co/jrqss/admin/schedule/domain/repository/WorkDao.java | 669f08faf7511bc8e7ec414dc45196c525b9fd68 | [] | no_license | takunoumi1998/ScheduleManagementSystem | ff762cd2c72790ff5e45dc3e93e9d4c448af9297 | ac185b91c19c9fe0796972eff06180a87298613d | refs/heads/master | 2023-02-14T19:30:55.756257 | 2021-01-12T06:14:51 | 2021-01-12T06:14:51 | 272,308,711 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package jp.co.jrqss.admin.schedule.domain.repository;
import java.util.List;
import jp.co.jrqss.admin.schedule.domain.model.Work;
public interface WorkDao {
public List<Work> selectAll();
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.