blob_id stringlengths 40 40 | __id__ int64 225 39,780B | directory_id stringlengths 40 40 | path stringlengths 6 313 | content_id stringlengths 40 40 | detected_licenses list | license_type stringclasses 2
values | repo_name stringlengths 6 132 | repo_url stringlengths 25 151 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 70 | visit_date timestamp[ns] | revision_date timestamp[ns] | committer_date timestamp[ns] | github_id int64 7.28k 689M ⌀ | star_events_count int64 0 131k | fork_events_count int64 0 48k | gha_license_id stringclasses 23
values | gha_fork bool 2
classes | gha_event_created_at timestamp[ns] | gha_created_at timestamp[ns] | gha_updated_at timestamp[ns] | gha_pushed_at timestamp[ns] | gha_size int64 0 40.4M ⌀ | gha_stargazers_count int32 0 112k ⌀ | gha_forks_count int32 0 39.4k ⌀ | gha_open_issues_count int32 0 11k ⌀ | gha_language stringlengths 1 21 ⌀ | gha_archived bool 2
classes | gha_disabled bool 1
class | content stringlengths 7 4.37M | src_encoding stringlengths 3 16 | language stringclasses 1
value | length_bytes int64 7 4.37M | extension stringclasses 24
values | filename stringlengths 4 174 | language_id stringclasses 1
value | entities list | contaminating_dataset stringclasses 0
values | malware_signatures list | redacted_content stringlengths 7 4.37M | redacted_length_bytes int64 7 4.37M | alphanum_fraction float32 0.25 0.94 | alpha_fraction float32 0.25 0.94 | num_lines int32 1 84k | avg_line_length float32 0.76 99.9 | std_line_length float32 0 220 | max_line_length int32 5 998 | is_vendor bool 2
classes | is_generated bool 1
class | max_hex_length int32 0 319 | hex_fraction float32 0 0.38 | max_unicode_length int32 0 408 | unicode_fraction float32 0 0.36 | max_base64_length int32 0 506 | base64_fraction float32 0 0.5 | avg_csv_sep_count float32 0 4 | is_autogen_header bool 1
class | is_empty_html bool 1
class | shard stringclasses 16
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d6f92e2ff1748ab896d12057758859b290ed9d59 | 5,738,076,335,869 | c318c30be66f4c71b1ef22816143b6423eba6dab | /TabletopTool/src/main/java/com/t3/client/ui/tokenpanel/InitiativeTransferable.java | 4bf85e1004bd1927159c4ced36d1e14ecf6ed972 | [] | no_license | mbbhudgins/tabletoptool | https://github.com/mbbhudgins/tabletoptool | 89000ab1c39b321154259b36d80cbd3a178ac668 | 48643ef5bb7161b63a92fb16392fbac57c349229 | refs/heads/master | 2021-01-16T22:10:41.130000 | 2015-01-27T04:12:40 | 2015-01-27T04:12:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2014 tabletoptool.com team.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* rptools.com team - initial implementation
* tabletoptool.com team - further development
*/
package com.t3.client.ui.tokenpanel;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.t3.guid.GUID;
/**
* Transferable for token identifiers.
*
* @author Jay
*/
public class InitiativeTransferable implements Transferable {
/*---------------------------------------------------------------------------------------------
* Instance Variables
*-------------------------------------------------------------------------------------------*/
/**
* Transferred id.
*/
private GUID id;
/**
* The initiative order of the transferred token. Needed for moving duplicate tokens
*/
private int inititiave;
/*---------------------------------------------------------------------------------------------
* Class Variables
*-------------------------------------------------------------------------------------------*/
/**
* Pass GUIDs around when dragging.
*/
public static final DataFlavor INIT_TOKEN_FLAVOR;
/**
* Logger instance for this class.
*/
private static final Logger LOGGER = Logger.getLogger(InitiativeTransferable.class.getName());
/*---------------------------------------------------------------------------------------------
* Constructors
*-------------------------------------------------------------------------------------------*/
/**
* Build the transferable.
*
* @param anId The id of the token being transferred.
* @param init The index of the token being transferred.
*/
public InitiativeTransferable(GUID anId, int init) {
id = anId;
inititiave = init;
}
/**
* Build the flavors and handle exceptions.
*/
static {
DataFlavor guid = null;
try {
guid = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=com.t3.client.ui.tokenpanel.InitiativeTransferable");
} catch (ClassNotFoundException e) {
LOGGER.log(Level.WARNING, "Should never happen since the GUID is a valid class when the classpath is correct.");
} // endtry
INIT_TOKEN_FLAVOR = guid;
}
/*---------------------------------------------------------------------------------------------
* Transferable Method Implementations
*-------------------------------------------------------------------------------------------*/
/**
* @see java.awt.datatransfer.Transferable#getTransferData(java.awt.datatransfer.DataFlavor)
*/
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (INIT_TOKEN_FLAVOR.equals(flavor)) {
return this;
}
InitiativeTransferHandler.LOGGER.warning("Can't support flavor: " + flavor.getHumanPresentableName());
throw new UnsupportedFlavorException(flavor);
}
/**
* @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
*/
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {INIT_TOKEN_FLAVOR};
}
/**
* @see java.awt.datatransfer.Transferable#isDataFlavorSupported(java.awt.datatransfer.DataFlavor)
*/
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return INIT_TOKEN_FLAVOR.equals(flavor);
}
/*---------------------------------------------------------------------------------------------
* Instance Methods
*-------------------------------------------------------------------------------------------*/
/** @return Getter for id */
public GUID getId() {
return id;
}
/** @return Getter for initiative */
public int getInititiave() {
return inititiave;
}
}
| UTF-8 | Java | 4,385 | java | InitiativeTransferable.java | Java | [
{
"context": "Transferable for token identifiers.\n * \n * @author Jay\n */\npublic class InitiativeTransferable implement",
"end": 770,
"score": 0.9976148009300232,
"start": 767,
"tag": "NAME",
"value": "Jay"
}
] | null | [] | /*
* Copyright (c) 2014 tabletoptool.com team.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* rptools.com team - initial implementation
* tabletoptool.com team - further development
*/
package com.t3.client.ui.tokenpanel;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.t3.guid.GUID;
/**
* Transferable for token identifiers.
*
* @author Jay
*/
public class InitiativeTransferable implements Transferable {
/*---------------------------------------------------------------------------------------------
* Instance Variables
*-------------------------------------------------------------------------------------------*/
/**
* Transferred id.
*/
private GUID id;
/**
* The initiative order of the transferred token. Needed for moving duplicate tokens
*/
private int inititiave;
/*---------------------------------------------------------------------------------------------
* Class Variables
*-------------------------------------------------------------------------------------------*/
/**
* Pass GUIDs around when dragging.
*/
public static final DataFlavor INIT_TOKEN_FLAVOR;
/**
* Logger instance for this class.
*/
private static final Logger LOGGER = Logger.getLogger(InitiativeTransferable.class.getName());
/*---------------------------------------------------------------------------------------------
* Constructors
*-------------------------------------------------------------------------------------------*/
/**
* Build the transferable.
*
* @param anId The id of the token being transferred.
* @param init The index of the token being transferred.
*/
public InitiativeTransferable(GUID anId, int init) {
id = anId;
inititiave = init;
}
/**
* Build the flavors and handle exceptions.
*/
static {
DataFlavor guid = null;
try {
guid = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=com.t3.client.ui.tokenpanel.InitiativeTransferable");
} catch (ClassNotFoundException e) {
LOGGER.log(Level.WARNING, "Should never happen since the GUID is a valid class when the classpath is correct.");
} // endtry
INIT_TOKEN_FLAVOR = guid;
}
/*---------------------------------------------------------------------------------------------
* Transferable Method Implementations
*-------------------------------------------------------------------------------------------*/
/**
* @see java.awt.datatransfer.Transferable#getTransferData(java.awt.datatransfer.DataFlavor)
*/
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (INIT_TOKEN_FLAVOR.equals(flavor)) {
return this;
}
InitiativeTransferHandler.LOGGER.warning("Can't support flavor: " + flavor.getHumanPresentableName());
throw new UnsupportedFlavorException(flavor);
}
/**
* @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
*/
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {INIT_TOKEN_FLAVOR};
}
/**
* @see java.awt.datatransfer.Transferable#isDataFlavorSupported(java.awt.datatransfer.DataFlavor)
*/
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return INIT_TOKEN_FLAVOR.equals(flavor);
}
/*---------------------------------------------------------------------------------------------
* Instance Methods
*-------------------------------------------------------------------------------------------*/
/** @return Getter for id */
public GUID getId() {
return id;
}
/** @return Getter for initiative */
public int getInititiave() {
return inititiave;
}
}
| 4,385 | 0.511745 | 0.509692 | 131 | 32.473282 | 33.624401 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.251908 | false | false | 9 |
ab11fc6dc3027beddd39629a033d61bf9645312d | 4,286,377,394,960 | 60c795882b679d0475b8a21ded206a391780202d | /plugins/index/legacy/CSVRecordEntity.java | 6e07f51e2ea6ed5a9d2bd6aac42359edf7146f6d | [
"BSD-3-Clause"
] | permissive | walterjwhite/csv | https://github.com/walterjwhite/csv | da3e017f4739354499fe082030d2973757dfdde2 | 694d9adc85df6f51437e687bb0bec3e8ab0cb32b | refs/heads/master | 2021-04-29T14:48:52.396000 | 2019-11-19T03:31:22 | 2019-11-19T03:31:22 | 112,989,742 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // package com.walterjwhite.csv.plugins.index;
//
// import com.walterjwhite.datastore.api.model.entity.AbstractEntity;
// import org.apache.commons.csv.CSVRecord;
//
// public class CSVRecordEntity extends AbstractEntity{
// // used to specify the index name in the index service
// protected final String csvFile;
// protected final CSVRecord csvRecord;
//
// public CSVRecordEntity(String csvFile, int row, CSVRecord csvRecord) {
// super();
// this.csvFile = csvFile;
// this.id = Integer.toString(row);
// this.csvRecord = csvRecord;
// }
//
// @Override
// public String toString() {
// return "CSVRecordEntity{" +
// "csvRecord=" + csvRecord +
// '}';
// }
// }
| UTF-8 | Java | 758 | java | CSVRecordEntity.java | Java | [] | null | [] | // package com.walterjwhite.csv.plugins.index;
//
// import com.walterjwhite.datastore.api.model.entity.AbstractEntity;
// import org.apache.commons.csv.CSVRecord;
//
// public class CSVRecordEntity extends AbstractEntity{
// // used to specify the index name in the index service
// protected final String csvFile;
// protected final CSVRecord csvRecord;
//
// public CSVRecordEntity(String csvFile, int row, CSVRecord csvRecord) {
// super();
// this.csvFile = csvFile;
// this.id = Integer.toString(row);
// this.csvRecord = csvRecord;
// }
//
// @Override
// public String toString() {
// return "CSVRecordEntity{" +
// "csvRecord=" + csvRecord +
// '}';
// }
// }
| 758 | 0.621372 | 0.621372 | 24 | 30.583334 | 21.914448 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 9 |
c2f06ee3c5a6c903781801713755a49f8c859b77 | 6,717,328,888,568 | cc1b12ed17beb23d554900a2248015c46bc7f12c | /rest/src/main/java/com/clinovo/rest/odm/RestOdmContainer.java | d1119ba137e24023c7c646a84433d68a315aa651 | [] | no_license | colima/ClinCaptureSvn | https://github.com/colima/ClinCaptureSvn | 363659b87a9aff36180b0f326a8ec5ac9157d5d7 | c63a01a98dba420d5e6ee9696d7d1dca7b359bb2 | refs/heads/master | 2020-05-19T03:49:48.819000 | 2016-07-07T13:03:00 | 2016-07-07T13:03:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*******************************************************************************
* CLINOVO RESERVES ALL RIGHTS TO THIS SOFTWARE, INCLUDING SOURCE AND DERIVED BINARY CODE. BY DOWNLOADING THIS SOFTWARE YOU AGREE TO THE FOLLOWING LICENSE:
*
* Subject to the terms and conditions of this Agreement including, Clinovo grants you a non-exclusive, non-transferable, non-sublicenseable limited license without license fees to reproduce and use internally the software complete and unmodified for the sole purpose of running Programs on one computer.
* This license does not allow for the commercial use of this software except by IRS approved non-profit organizations; educational entities not working in joint effort with for profit business.
* To use the license for other purposes, including for profit clinical trials, an additional paid license is required. Please contact our licensing department at http://www.clincapture.com/contact for pricing information.
*
* You may not modify, decompile, or reverse engineer the software.
* Clinovo disclaims any express or implied warranty of fitness for use.
* No right, title or interest in or to any trademark, service mark, logo or trade name of Clinovo or its licensors is granted under this Agreement.
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. CLINOVO FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* LIMITATION OF LIABILITY. IN NO EVENT SHALL CLINOVO BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF ORACLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. CLINOVO'S ENTIRE LIABILITY FOR DAMAGES HEREUNDER SHALL IN NO EVENT EXCEED TWO HUNDRED DOLLARS (U.S. $200).
*******************************************************************************/
package com.clinovo.rest.odm;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.cdisc.ns.odm.v130.FileType;
import org.cdisc.ns.odm.v130.ODM;
import com.clinovo.rest.model.RestData;
import com.clinovo.rest.model.Server;
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
/**
* RestOdmContainer.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "ODM", namespace = "http://www.cdisc.org/ns/odm/v1.3")
public class RestOdmContainer extends ODM {
public static final int MILLISEC_IN_HOUR = 3600000;
public static final int MILLISEC_IN_MINUTES = 60000;
@XmlElement(name = "Server", namespace = "http://www.cdisc.org/ns/odm/v1.3")
private Server server;
public Server getServer() {
return server;
}
public void setServer(Server server) {
this.server = server;
}
@XmlElement(name = "RestData", namespace = "http://www.cdisc.org/ns/odm/v1.3")
private RestData restData;
public RestData getRestData() {
return restData;
}
public void setRestData(RestData restData) {
this.restData = restData;
}
/**
* Collects odm root data.
*/
public void collectOdmRoot() {
Date creationDatetime = new Date();
SimpleDateFormat localTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
TimeZone timeZone = TimeZone.getDefault();
localTime.setTimeZone(timeZone);
int offset = localTime.getTimeZone().getOffset(creationDatetime.getTime());
String sign = "+";
if (offset < 0) {
offset = -offset;
sign = "-";
}
int hours = offset / MILLISEC_IN_HOUR;
int minutes = (offset - hours * MILLISEC_IN_HOUR) / MILLISEC_IN_MINUTES;
DecimalFormat twoDigits = new DecimalFormat("00");
setFileOID("REST-Data".concat(new SimpleDateFormat("yyyyMMddHHmmssZ").format(creationDatetime)));
setDescription("REST Data");
setCreationDateTime(XMLGregorianCalendarImpl
.parse(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss".concat(sign).concat(twoDigits.format(hours))
.concat(":").concat(twoDigits.format(minutes))).format(creationDatetime)));
setODMVersion("1.3");
setFileType(FileType.SNAPSHOT);
}
}
| UTF-8 | Java | 4,493 | java | RestOdmContainer.java | Java | [] | null | [] | /*******************************************************************************
* CLINOVO RESERVES ALL RIGHTS TO THIS SOFTWARE, INCLUDING SOURCE AND DERIVED BINARY CODE. BY DOWNLOADING THIS SOFTWARE YOU AGREE TO THE FOLLOWING LICENSE:
*
* Subject to the terms and conditions of this Agreement including, Clinovo grants you a non-exclusive, non-transferable, non-sublicenseable limited license without license fees to reproduce and use internally the software complete and unmodified for the sole purpose of running Programs on one computer.
* This license does not allow for the commercial use of this software except by IRS approved non-profit organizations; educational entities not working in joint effort with for profit business.
* To use the license for other purposes, including for profit clinical trials, an additional paid license is required. Please contact our licensing department at http://www.clincapture.com/contact for pricing information.
*
* You may not modify, decompile, or reverse engineer the software.
* Clinovo disclaims any express or implied warranty of fitness for use.
* No right, title or interest in or to any trademark, service mark, logo or trade name of Clinovo or its licensors is granted under this Agreement.
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. CLINOVO FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* LIMITATION OF LIABILITY. IN NO EVENT SHALL CLINOVO BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF ORACLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. CLINOVO'S ENTIRE LIABILITY FOR DAMAGES HEREUNDER SHALL IN NO EVENT EXCEED TWO HUNDRED DOLLARS (U.S. $200).
*******************************************************************************/
package com.clinovo.rest.odm;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.cdisc.ns.odm.v130.FileType;
import org.cdisc.ns.odm.v130.ODM;
import com.clinovo.rest.model.RestData;
import com.clinovo.rest.model.Server;
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
/**
* RestOdmContainer.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "ODM", namespace = "http://www.cdisc.org/ns/odm/v1.3")
public class RestOdmContainer extends ODM {
public static final int MILLISEC_IN_HOUR = 3600000;
public static final int MILLISEC_IN_MINUTES = 60000;
@XmlElement(name = "Server", namespace = "http://www.cdisc.org/ns/odm/v1.3")
private Server server;
public Server getServer() {
return server;
}
public void setServer(Server server) {
this.server = server;
}
@XmlElement(name = "RestData", namespace = "http://www.cdisc.org/ns/odm/v1.3")
private RestData restData;
public RestData getRestData() {
return restData;
}
public void setRestData(RestData restData) {
this.restData = restData;
}
/**
* Collects odm root data.
*/
public void collectOdmRoot() {
Date creationDatetime = new Date();
SimpleDateFormat localTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
TimeZone timeZone = TimeZone.getDefault();
localTime.setTimeZone(timeZone);
int offset = localTime.getTimeZone().getOffset(creationDatetime.getTime());
String sign = "+";
if (offset < 0) {
offset = -offset;
sign = "-";
}
int hours = offset / MILLISEC_IN_HOUR;
int minutes = (offset - hours * MILLISEC_IN_HOUR) / MILLISEC_IN_MINUTES;
DecimalFormat twoDigits = new DecimalFormat("00");
setFileOID("REST-Data".concat(new SimpleDateFormat("yyyyMMddHHmmssZ").format(creationDatetime)));
setDescription("REST Data");
setCreationDateTime(XMLGregorianCalendarImpl
.parse(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss".concat(sign).concat(twoDigits.format(hours))
.concat(":").concat(twoDigits.format(minutes))).format(creationDatetime)));
setODMVersion("1.3");
setFileType(FileType.SNAPSHOT);
}
}
| 4,493 | 0.726241 | 0.719119 | 91 | 47.373627 | 68.833237 | 449 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.549451 | false | false | 9 |
19e9a1a9d8b3af2211a0146304286971b342143e | 22,720,377,029,291 | 8e25bb3bf08a06e33bd06533531edb3624be8064 | /WidYouClient/src/kr/or/ddit/vo/AlarmVO.java | df76aae861879bb53579b2c741a8d7be5b7c221e | [] | no_license | qouque/MiddleProject | https://github.com/qouque/MiddleProject | ca33ca10526d8db20ec500cdd6b2cc484c9fe0c2 | e9af405f993aaa214bbb14e2054c0cb1115c8887 | refs/heads/master | 2022-11-26T14:21:34.310000 | 2020-08-05T02:37:52 | 2020-08-05T02:37:52 | 285,145,600 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kr.or.ddit.vo;
public class AlarmVO {
private int alarm_id;
private String mem_id;
private String alarm_comment;
public AlarmVO() {}
@Override
public String toString() {
return "AlarmVO [alarm_id=" + alarm_id + ", mem_id=" + mem_id + ", alarm_comment=" + alarm_comment + "]";
}
public AlarmVO(int alarm_id, String mem_id, String alarm_comment) {
super();
this.alarm_id = alarm_id;
this.mem_id = mem_id;
this.alarm_comment = alarm_comment;
}
public int getAlarm_id() {
return alarm_id;
}
public void setAlarm_id(int alarm_id) {
this.alarm_id = alarm_id;
}
public String getMem_id() {
return mem_id;
}
public void setMem_id(String mem_id) {
this.mem_id = mem_id;
}
public String getAlarm_comment() {
return alarm_comment;
}
public void setAlarm_comment(String alarm_comment) {
this.alarm_comment = alarm_comment;
}
}
| UTF-8 | Java | 936 | java | AlarmVO.java | Java | [] | null | [] | package kr.or.ddit.vo;
public class AlarmVO {
private int alarm_id;
private String mem_id;
private String alarm_comment;
public AlarmVO() {}
@Override
public String toString() {
return "AlarmVO [alarm_id=" + alarm_id + ", mem_id=" + mem_id + ", alarm_comment=" + alarm_comment + "]";
}
public AlarmVO(int alarm_id, String mem_id, String alarm_comment) {
super();
this.alarm_id = alarm_id;
this.mem_id = mem_id;
this.alarm_comment = alarm_comment;
}
public int getAlarm_id() {
return alarm_id;
}
public void setAlarm_id(int alarm_id) {
this.alarm_id = alarm_id;
}
public String getMem_id() {
return mem_id;
}
public void setMem_id(String mem_id) {
this.mem_id = mem_id;
}
public String getAlarm_comment() {
return alarm_comment;
}
public void setAlarm_comment(String alarm_comment) {
this.alarm_comment = alarm_comment;
}
}
| 936 | 0.623932 | 0.623932 | 49 | 17.102041 | 20.713049 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.408163 | false | false | 9 |
1bb87d91db4df877149d3e3281b77002396e5e31 | 5,832,565,650,277 | fb9e80a24d4bd6e2d93f5e68153e2f2b4193fccc | /main/java/org/testdwr/springservlet/SpringServletTest.java | 0fe1fdfceac8095d1458d0a31932ffe3f25b2a5d | [
"Apache-2.0"
] | permissive | directwebremoting/testdwr | https://github.com/directwebremoting/testdwr | 90f09adc0c3effb3c0174caf9e59f0fc341b1e18 | e34f3de6ad27b0158287b81b2d3c3cc19b5cede8 | refs/heads/master | 2023-04-03T07:25:06.199000 | 2019-03-13T17:56:41 | 2019-03-13T18:21:55 | 76,248,781 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2005 Joe Walker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.testdwr.springservlet;
import java.util.List;
import org.directwebremoting.Container;
import org.directwebremoting.ServerContext;
import org.directwebremoting.ServerContextFactory;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.dwrunit.Verify;
import org.directwebremoting.extend.InboundContext;
import org.directwebremoting.spring.SpringContainer;
import org.directwebremoting.util.VersionUtil;
/**
* Methods to help unit test DWR that are configured by the SpringServlet.
* @author Joe Walker [joe at getahead dot ltd dot uk]
*/
public class SpringServletTest
{
public Verify checkContext(String contextPath)
{
ServerContext serverContext = ServerContextFactory.get();
Container container = serverContext.getContainer();
Verify verify = new Verify();
verify.equals("ContextPath", contextPath, serverContext.getContextPath());
verify.equals("Version", VersionUtil.getLabel(), serverContext.getVersion());
verify.equals("Container.class", SpringContainer.class.getName(), container.getClass().getName());
verify.equals("Container.getBean", "DwrSpringServlet", container.getBean("ContainerType"));
return verify;
}
public String getPath()
{
return WebContextFactory.get().getContextPath();
}
public boolean areIdentical(List<?> a, List<?> b)
{
return a == b;
}
public SpringServletBean springServletBeanParam(SpringServletBean test)
{
return test;
}
public boolean booleanParam(boolean test)
{
return test;
}
public byte byteParam(byte test)
{
return test;
}
public char charParam(char test)
{
return test;
}
public short shortParam(short test)
{
return test;
}
public int intParam(int test)
{
return test;
}
public long longParam(long test)
{
return test;
}
public float floatParam(float test)
{
return test;
}
public double doubleParam(double test)
{
return test;
}
public String stringParam(String test)
{
return test;
}
public String delete()
{
return "You can't touch me";
}
protected String protectedMethod()
{
privateMethod();
return "You can't touch me";
}
private String privateMethod()
{
return "You can't touch me";
}
public static String staticMethod()
{
return "static SpringServletTest.staticMethod() says hello.";
}
public String dangerOverload(String param1)
{
return "SpringServletTest.dangerOverload(" + param1 + ") says hello.";
}
public String dangerOverload()
{
return "SpringServletTest.dangerOverload() says hello.";
}
public String error(InboundContext cx)
{
return "You should not see this: " + cx;
}
}
| UTF-8 | Java | 3,554 | java | SpringServletTest.java | Java | [
{
"context": "/*\n * Copyright 2005 Joe Walker\n *\n * Licensed under the Apache License, Version ",
"end": 31,
"score": 0.9998438358306885,
"start": 21,
"tag": "NAME",
"value": "Joe Walker"
},
{
"context": "at are configured by the SpringServlet.\n * @author Joe Walker [joe at getah... | null | [] | /*
* Copyright 2005 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.testdwr.springservlet;
import java.util.List;
import org.directwebremoting.Container;
import org.directwebremoting.ServerContext;
import org.directwebremoting.ServerContextFactory;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.dwrunit.Verify;
import org.directwebremoting.extend.InboundContext;
import org.directwebremoting.spring.SpringContainer;
import org.directwebremoting.util.VersionUtil;
/**
* Methods to help unit test DWR that are configured by the SpringServlet.
* @author <NAME> [joe at getahead dot ltd dot uk]
*/
public class SpringServletTest
{
public Verify checkContext(String contextPath)
{
ServerContext serverContext = ServerContextFactory.get();
Container container = serverContext.getContainer();
Verify verify = new Verify();
verify.equals("ContextPath", contextPath, serverContext.getContextPath());
verify.equals("Version", VersionUtil.getLabel(), serverContext.getVersion());
verify.equals("Container.class", SpringContainer.class.getName(), container.getClass().getName());
verify.equals("Container.getBean", "DwrSpringServlet", container.getBean("ContainerType"));
return verify;
}
public String getPath()
{
return WebContextFactory.get().getContextPath();
}
public boolean areIdentical(List<?> a, List<?> b)
{
return a == b;
}
public SpringServletBean springServletBeanParam(SpringServletBean test)
{
return test;
}
public boolean booleanParam(boolean test)
{
return test;
}
public byte byteParam(byte test)
{
return test;
}
public char charParam(char test)
{
return test;
}
public short shortParam(short test)
{
return test;
}
public int intParam(int test)
{
return test;
}
public long longParam(long test)
{
return test;
}
public float floatParam(float test)
{
return test;
}
public double doubleParam(double test)
{
return test;
}
public String stringParam(String test)
{
return test;
}
public String delete()
{
return "You can't touch me";
}
protected String protectedMethod()
{
privateMethod();
return "You can't touch me";
}
private String privateMethod()
{
return "You can't touch me";
}
public static String staticMethod()
{
return "static SpringServletTest.staticMethod() says hello.";
}
public String dangerOverload(String param1)
{
return "SpringServletTest.dangerOverload(" + param1 + ") says hello.";
}
public String dangerOverload()
{
return "SpringServletTest.dangerOverload() says hello.";
}
public String error(InboundContext cx)
{
return "You should not see this: " + cx;
}
}
| 3,546 | 0.666854 | 0.664041 | 144 | 23.680555 | 25.362553 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.361111 | false | false | 9 |
d58d4078c696a09793f365214a541324b36a4b01 | 37,245,956,430,518 | 43d07af1742e01001c17eba4196f30156b08fbcc | /com/sun/codemodel/internal/JArrayClass.java | d147c21625aa592ff58cf182c7fa2e97685d55f7 | [] | no_license | kSuroweczka/jdk | https://github.com/kSuroweczka/jdk | b408369b4b87ab09a828aa3dbf9132aaf8bb1b71 | 7ec3e8e31fcfb616d4a625191bcba0191ca7c2d4 | refs/heads/master | 2021-12-30T00:58:24.029000 | 2018-02-01T10:07:14 | 2018-02-01T10:07:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* */ package com.sun.codemodel.internal;
/* */
/* */ import java.util.Collections;
/* */ import java.util.Iterator;
/* */ import java.util.List;
/* */
/* */ final class JArrayClass extends JClass
/* */ {
/* */ private final JType componentType;
/* */
/* */ JArrayClass(JCodeModel owner, JType component)
/* */ {
/* 45 */ super(owner);
/* 46 */ this.componentType = component;
/* */ }
/* */
/* */ public String name()
/* */ {
/* 51 */ return this.componentType.name() + "[]";
/* */ }
/* */
/* */ public String fullName() {
/* 55 */ return this.componentType.fullName() + "[]";
/* */ }
/* */
/* */ public String binaryName() {
/* 59 */ return this.componentType.binaryName() + "[]";
/* */ }
/* */
/* */ public void generate(JFormatter f) {
/* 63 */ f.g(this.componentType).p("[]");
/* */ }
/* */
/* */ public JPackage _package() {
/* 67 */ return owner().rootPackage();
/* */ }
/* */
/* */ public JClass _extends() {
/* 71 */ return owner().ref(Object.class);
/* */ }
/* */
/* */ public Iterator<JClass> _implements() {
/* 75 */ return Collections.emptyList().iterator();
/* */ }
/* */
/* */ public boolean isInterface() {
/* 79 */ return false;
/* */ }
/* */
/* */ public boolean isAbstract() {
/* 83 */ return false;
/* */ }
/* */
/* */ public JType elementType() {
/* 87 */ return this.componentType;
/* */ }
/* */
/* */ public boolean isArray() {
/* 91 */ return true;
/* */ }
/* */
/* */ public boolean equals(Object obj)
/* */ {
/* 100 */ if (!(obj instanceof JArrayClass)) return false;
/* */
/* 102 */ if (this.componentType.equals(((JArrayClass)obj).componentType)) {
/* 103 */ return true;
/* */ }
/* 105 */ return false;
/* */ }
/* */
/* */ public int hashCode() {
/* 109 */ return this.componentType.hashCode();
/* */ }
/* */
/* */ protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
/* 113 */ if (this.componentType.isPrimitive()) {
/* 114 */ return this;
/* */ }
/* 116 */ JClass c = ((JClass)this.componentType).substituteParams(variables, bindings);
/* 117 */ if (c == this.componentType) {
/* 118 */ return this;
/* */ }
/* 120 */ return new JArrayClass(owner(), c);
/* */ }
/* */ }
/* Location: D:\dt\jdk\tools.jar
* Qualified Name: com.sun.codemodel.internal.JArrayClass
* JD-Core Version: 0.6.2
*/ | UTF-8 | Java | 2,727 | java | JArrayClass.java | Java | [] | null | [] | /* */ package com.sun.codemodel.internal;
/* */
/* */ import java.util.Collections;
/* */ import java.util.Iterator;
/* */ import java.util.List;
/* */
/* */ final class JArrayClass extends JClass
/* */ {
/* */ private final JType componentType;
/* */
/* */ JArrayClass(JCodeModel owner, JType component)
/* */ {
/* 45 */ super(owner);
/* 46 */ this.componentType = component;
/* */ }
/* */
/* */ public String name()
/* */ {
/* 51 */ return this.componentType.name() + "[]";
/* */ }
/* */
/* */ public String fullName() {
/* 55 */ return this.componentType.fullName() + "[]";
/* */ }
/* */
/* */ public String binaryName() {
/* 59 */ return this.componentType.binaryName() + "[]";
/* */ }
/* */
/* */ public void generate(JFormatter f) {
/* 63 */ f.g(this.componentType).p("[]");
/* */ }
/* */
/* */ public JPackage _package() {
/* 67 */ return owner().rootPackage();
/* */ }
/* */
/* */ public JClass _extends() {
/* 71 */ return owner().ref(Object.class);
/* */ }
/* */
/* */ public Iterator<JClass> _implements() {
/* 75 */ return Collections.emptyList().iterator();
/* */ }
/* */
/* */ public boolean isInterface() {
/* 79 */ return false;
/* */ }
/* */
/* */ public boolean isAbstract() {
/* 83 */ return false;
/* */ }
/* */
/* */ public JType elementType() {
/* 87 */ return this.componentType;
/* */ }
/* */
/* */ public boolean isArray() {
/* 91 */ return true;
/* */ }
/* */
/* */ public boolean equals(Object obj)
/* */ {
/* 100 */ if (!(obj instanceof JArrayClass)) return false;
/* */
/* 102 */ if (this.componentType.equals(((JArrayClass)obj).componentType)) {
/* 103 */ return true;
/* */ }
/* 105 */ return false;
/* */ }
/* */
/* */ public int hashCode() {
/* 109 */ return this.componentType.hashCode();
/* */ }
/* */
/* */ protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
/* 113 */ if (this.componentType.isPrimitive()) {
/* 114 */ return this;
/* */ }
/* 116 */ JClass c = ((JClass)this.componentType).substituteParams(variables, bindings);
/* 117 */ if (c == this.componentType) {
/* 118 */ return this;
/* */ }
/* 120 */ return new JArrayClass(owner(), c);
/* */ }
/* */ }
/* Location: D:\dt\jdk\tools.jar
* Qualified Name: com.sun.codemodel.internal.JArrayClass
* JD-Core Version: 0.6.2
*/ | 2,727 | 0.47048 | 0.447745 | 91 | 28.978022 | 20.083878 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.32967 | false | false | 9 |
25cd66cd6e7d8f579045cede2be48fd1c5048552 | 36,833,639,568,522 | 376cc3f7524eb61a8bee0cb958fc4147d6d0ccb6 | /Java/src/uk/ac/manchester/cs/wireit/RunWireit.java | c35621cb3a59b0b21d11aeea77ae70005c850aeb | [
"MIT"
] | permissive | Christian-B/wireit | https://github.com/Christian-B/wireit | 36f68cc84aa9ef207713b938a6b72aa2b144cfc9 | f923bdda4f1708317fcebf0582264bfa1667eb1b | refs/heads/master | 2021-04-18T19:36:24.707000 | 2011-11-30T16:42:11 | 2011-11-30T16:42:11 | 2,567,921 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package uk.ac.manchester.cs.wireit;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import org.json.JSONObject;
import uk.ac.manchester.cs.wireit.exception.WireItRunException;
import uk.ac.manchester.cs.wireit.taverna.TavernaException;
import uk.ac.manchester.cs.wireit.utils.Resolver;
/**
* This is the servlet that receives the run call.
*
* @author Christian
*/
public class RunWireit extends WireitSQLBase {
public final String TAVERNA_CMD_HOME_PARAMETER = "TAVERNA_CMD_HOME";
private static String tavernaHome;
/**
* Constructor is called first time servlet is called.
* @throws ServletException
*/
public RunWireit() throws ServletException{
super();
}
/**
* This is called by Tomcat.
* Gets Taverna Home parameter is available.
*/
public void init(){
tavernaHome = getServletContext().getInitParameter(TAVERNA_CMD_HOME_PARAMETER);
}
/**
*
* <p>
* <ul>
* <li>Logs the start of the run.
* <li>Sets up a Resolver for converting between absolute and relative uris
* <li>Extracts the Json from the request body,s "working" parameter.
* <li>Sets up the reply
* <li>Runs the Pipe See doRun
* <li>Logs that the run is finished.
* <li>Adds the result (json with new values) to the output
* </ul>
* @param request
* @param response .
* @throws ServletException Error generating the Json
* @throws IOException Error reading request body
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println();
System.out.println((new Date()) + "in runWireit.doPost");
StringBuilder outputBuilder = new StringBuilder();
outputBuilder.append("Run posted at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
Resolver resolver = new Resolver(request, getServletContext());
String input = readRequestBody(request);
HashMap<String, String> parameters = convertBody(input);
JSONObject jsonInput = getInputJson(parameters);
// Set the MIME type for the response message
response.setContentType("text/x-json;charset=UTF-8");
// Get a output writer to write the response message into the network socket
PrintWriter out = response.getWriter();
JSONObject jsonReply;
try {
jsonReply = doRun(jsonInput, outputBuilder, resolver);
addRunResult(jsonReply, outputBuilder);
String output = getOutput(parameters.get("name"), jsonReply, parameters.get("language"));
out.println(output);
} catch (Exception ex) {
addRunFailed(jsonInput, ex, outputBuilder);
String output = getOutput(parameters.get("name"), jsonInput, parameters.get("language"));
out.println(output);
}
}
/**
* @return TavernaHome retreived from the paramters. May be null;
*/
public static String getTavernaHome(){
return tavernaHome;
}
/**
* Extracts the "working" paramter and converts it to a Json object
* @param parameters The paramters in the bidy of the message
* @return Pipe in json format
* @throws ServletException Any exception extracting the json.
*/
private JSONObject getInputJson(HashMap<String, String> parameters) throws ServletException{
String workingString = parameters.get("working");
JSONObject jsonInput;
try {
jsonInput = new JSONObject(workingString);
System.out.println(jsonInput.toString(4));
} catch (Exception ex) {
System.err.println("Error reading input json");
ex.printStackTrace();
throw new ServletException(ex);
}
return jsonInput;
}
/**
* Logs the finsihed pipe and adds run log to the Json output.
* @param jsonReply Pipe in Json format after the run.
* @param outputBuilder Log from the run to be added to the json.
* @throws JSONException
*/
private void addRunResult(JSONObject jsonReply, StringBuilder outputBuilder) throws JSONException {
JSONObject properties = jsonReply.getJSONObject("properties");
System.out.println(jsonReply.toString(4));
properties.put("status", "Pipe run");
outputBuilder.append("Run finished at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
properties.put("details", outputBuilder.toString());
properties.remove("error");
}
/**
* Oops something has gone wrong. Lets pass something useful back to the client.
* <p>
* This current prototype pass a lot of information back to the client.
* Future version may want to pass less back.
* @param main
* @param ex
* @param outputBuilder
* @throws ServletException
*/
private void addRunFailed(JSONObject main, Exception ex, StringBuilder outputBuilder) throws ServletException{
System.err.println("Error running pipe");
ex.printStackTrace();
String message;
if (ex.getMessage() != null && !ex.getMessage().isEmpty()){
message = ex.getMessage();
} else {
message = ex.getClass().getName();
}
outputBuilder.append(message);
try {
JSONObject properties = main.getJSONObject("properties");
properties.put("status", "Pipe Failed");
properties.put("details",outputBuilder.toString());
properties.put("error", message);
} catch (JSONException newEx) {
System.err.println("Error writing error to json");
newEx.printStackTrace();
throw new ServletException(newEx);
}
}
/**
* Converts the Json object back into string to pass to the client.
* @param name Name of the pipe
* @param working The Pipe as json (after it was run)
* @param language The WireIt language the working belongs to.
* @return String represention (encoded) or the pipe.
*/
private String getOutput(String name, JSONObject working, String language){
StringBuilder builder = new StringBuilder();
builder.append("{\"id\":\"0\",\n");
builder.append("\"name\":\"");
builder.append(name);
builder.append("\",\n");
String workingSt = URLEncoder.encode(working.toString());
workingSt = workingSt.replace("\"","\\\"");
builder.append("\"working\":\"");
builder.append(workingSt);
builder.append("\",\n");
builder.append("\"language\":\"");
builder.append(language);
builder.append("\"}");
return builder.toString();
}
/**
* Splits the request body into a map of paramters.
* @param input Body as a Single String
* @return Body as a map of Names to values.
*/
private HashMap<String, String> convertBody(String input) {
StringTokenizer tokens = new StringTokenizer(input, "&");
HashMap<String, String> parameters = new HashMap<String, String>();
while (tokens.hasMoreElements()){
String token = tokens.nextToken();
String key = token.substring(0,token.indexOf("="));
String encoded = token.substring(token.indexOf("=")+1,token.length());
String decoded = URLDecoder.decode(encoded);
parameters.put(key, decoded);
}
return parameters;
}
/**
* Workhorse method that does most of the actual work running a Pipe.
* <p>
* See Wiring which does (and explains) the construction and running of the modules.
*
* @param jsonInput The json as received from the request.
* @param outputBuilder Logger for any information modules may add.
* @param resolver Util to convert between files, absolute uri and relative uris
* @return The json after execution.
* @throws JSONException Thrown it the json is not in the expected format.
* @throws TavernaException Thrown by the TavernaModule if the information is inconsistant.
* @throws IOException Thrown by the TavernaModule if the workflow is unreadable.
* @throws WireItRunException Any Exception while running will be caught and wrapped in a single Exception type.
*/
private JSONObject doRun(JSONObject jsonInput, StringBuilder outputBuilder, Resolver resolver)
throws WireItRunException, JSONException, TavernaException, IOException{
Wiring wiring = new Wiring(jsonInput, resolver);
outputBuilder.append("Pipe loaded at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
wiring.run(outputBuilder);
return wiring.getJsonObject();
}
}
| UTF-8 | Java | 9,264 | java | RunWireit.java | Java | [
{
"context": "servlet that receives the run call.\n * \n * @author Christian\n */\npublic class RunWireit extends WireitSQLBase ",
"end": 649,
"score": 0.9991032481193542,
"start": 640,
"tag": "NAME",
"value": "Christian"
}
] | null | [] | package uk.ac.manchester.cs.wireit;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import org.json.JSONObject;
import uk.ac.manchester.cs.wireit.exception.WireItRunException;
import uk.ac.manchester.cs.wireit.taverna.TavernaException;
import uk.ac.manchester.cs.wireit.utils.Resolver;
/**
* This is the servlet that receives the run call.
*
* @author Christian
*/
public class RunWireit extends WireitSQLBase {
public final String TAVERNA_CMD_HOME_PARAMETER = "TAVERNA_CMD_HOME";
private static String tavernaHome;
/**
* Constructor is called first time servlet is called.
* @throws ServletException
*/
public RunWireit() throws ServletException{
super();
}
/**
* This is called by Tomcat.
* Gets Taverna Home parameter is available.
*/
public void init(){
tavernaHome = getServletContext().getInitParameter(TAVERNA_CMD_HOME_PARAMETER);
}
/**
*
* <p>
* <ul>
* <li>Logs the start of the run.
* <li>Sets up a Resolver for converting between absolute and relative uris
* <li>Extracts the Json from the request body,s "working" parameter.
* <li>Sets up the reply
* <li>Runs the Pipe See doRun
* <li>Logs that the run is finished.
* <li>Adds the result (json with new values) to the output
* </ul>
* @param request
* @param response .
* @throws ServletException Error generating the Json
* @throws IOException Error reading request body
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println();
System.out.println((new Date()) + "in runWireit.doPost");
StringBuilder outputBuilder = new StringBuilder();
outputBuilder.append("Run posted at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
Resolver resolver = new Resolver(request, getServletContext());
String input = readRequestBody(request);
HashMap<String, String> parameters = convertBody(input);
JSONObject jsonInput = getInputJson(parameters);
// Set the MIME type for the response message
response.setContentType("text/x-json;charset=UTF-8");
// Get a output writer to write the response message into the network socket
PrintWriter out = response.getWriter();
JSONObject jsonReply;
try {
jsonReply = doRun(jsonInput, outputBuilder, resolver);
addRunResult(jsonReply, outputBuilder);
String output = getOutput(parameters.get("name"), jsonReply, parameters.get("language"));
out.println(output);
} catch (Exception ex) {
addRunFailed(jsonInput, ex, outputBuilder);
String output = getOutput(parameters.get("name"), jsonInput, parameters.get("language"));
out.println(output);
}
}
/**
* @return TavernaHome retreived from the paramters. May be null;
*/
public static String getTavernaHome(){
return tavernaHome;
}
/**
* Extracts the "working" paramter and converts it to a Json object
* @param parameters The paramters in the bidy of the message
* @return Pipe in json format
* @throws ServletException Any exception extracting the json.
*/
private JSONObject getInputJson(HashMap<String, String> parameters) throws ServletException{
String workingString = parameters.get("working");
JSONObject jsonInput;
try {
jsonInput = new JSONObject(workingString);
System.out.println(jsonInput.toString(4));
} catch (Exception ex) {
System.err.println("Error reading input json");
ex.printStackTrace();
throw new ServletException(ex);
}
return jsonInput;
}
/**
* Logs the finsihed pipe and adds run log to the Json output.
* @param jsonReply Pipe in Json format after the run.
* @param outputBuilder Log from the run to be added to the json.
* @throws JSONException
*/
private void addRunResult(JSONObject jsonReply, StringBuilder outputBuilder) throws JSONException {
JSONObject properties = jsonReply.getJSONObject("properties");
System.out.println(jsonReply.toString(4));
properties.put("status", "Pipe run");
outputBuilder.append("Run finished at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
properties.put("details", outputBuilder.toString());
properties.remove("error");
}
/**
* Oops something has gone wrong. Lets pass something useful back to the client.
* <p>
* This current prototype pass a lot of information back to the client.
* Future version may want to pass less back.
* @param main
* @param ex
* @param outputBuilder
* @throws ServletException
*/
private void addRunFailed(JSONObject main, Exception ex, StringBuilder outputBuilder) throws ServletException{
System.err.println("Error running pipe");
ex.printStackTrace();
String message;
if (ex.getMessage() != null && !ex.getMessage().isEmpty()){
message = ex.getMessage();
} else {
message = ex.getClass().getName();
}
outputBuilder.append(message);
try {
JSONObject properties = main.getJSONObject("properties");
properties.put("status", "Pipe Failed");
properties.put("details",outputBuilder.toString());
properties.put("error", message);
} catch (JSONException newEx) {
System.err.println("Error writing error to json");
newEx.printStackTrace();
throw new ServletException(newEx);
}
}
/**
* Converts the Json object back into string to pass to the client.
* @param name Name of the pipe
* @param working The Pipe as json (after it was run)
* @param language The WireIt language the working belongs to.
* @return String represention (encoded) or the pipe.
*/
private String getOutput(String name, JSONObject working, String language){
StringBuilder builder = new StringBuilder();
builder.append("{\"id\":\"0\",\n");
builder.append("\"name\":\"");
builder.append(name);
builder.append("\",\n");
String workingSt = URLEncoder.encode(working.toString());
workingSt = workingSt.replace("\"","\\\"");
builder.append("\"working\":\"");
builder.append(workingSt);
builder.append("\",\n");
builder.append("\"language\":\"");
builder.append(language);
builder.append("\"}");
return builder.toString();
}
/**
* Splits the request body into a map of paramters.
* @param input Body as a Single String
* @return Body as a map of Names to values.
*/
private HashMap<String, String> convertBody(String input) {
StringTokenizer tokens = new StringTokenizer(input, "&");
HashMap<String, String> parameters = new HashMap<String, String>();
while (tokens.hasMoreElements()){
String token = tokens.nextToken();
String key = token.substring(0,token.indexOf("="));
String encoded = token.substring(token.indexOf("=")+1,token.length());
String decoded = URLDecoder.decode(encoded);
parameters.put(key, decoded);
}
return parameters;
}
/**
* Workhorse method that does most of the actual work running a Pipe.
* <p>
* See Wiring which does (and explains) the construction and running of the modules.
*
* @param jsonInput The json as received from the request.
* @param outputBuilder Logger for any information modules may add.
* @param resolver Util to convert between files, absolute uri and relative uris
* @return The json after execution.
* @throws JSONException Thrown it the json is not in the expected format.
* @throws TavernaException Thrown by the TavernaModule if the information is inconsistant.
* @throws IOException Thrown by the TavernaModule if the workflow is unreadable.
* @throws WireItRunException Any Exception while running will be caught and wrapped in a single Exception type.
*/
private JSONObject doRun(JSONObject jsonInput, StringBuilder outputBuilder, Resolver resolver)
throws WireItRunException, JSONException, TavernaException, IOException{
Wiring wiring = new Wiring(jsonInput, resolver);
outputBuilder.append("Pipe loaded at ");
outputBuilder.append(new Date());
outputBuilder.append("\n");
wiring.run(outputBuilder);
return wiring.getJsonObject();
}
}
| 9,264 | 0.641947 | 0.6413 | 237 | 38.088608 | 26.976871 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.599156 | false | false | 9 |
ee7993626be53d09404a5fbf55b1e1281fb27497 | 38,525,856,675,694 | 6a867b72b0af9e55799af267627a3727d0eb27d0 | /BallMayCry/src/com/mobezer/bmc/screens/GameScreen.java | 444624623c14621b78dafeb8a50f3d656b32fdf3 | [] | no_license | Shidil/ball-slingshot-game | https://github.com/Shidil/ball-slingshot-game | 74667ade68ef25e2df7492b76c8a69b9f39445e2 | 5f7b200f9cf28ca0c1ec3a73d00e08ca51df350c | refs/heads/master | 2023-02-01T22:48:47.921000 | 2020-12-19T05:13:27 | 2020-12-19T05:13:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mobezer.bmc.screens;
import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Timeline;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.equations.Quart;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.FPSLogger;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.mobezer.bmc.Assets;
import com.mobezer.bmc.Game;
import com.mobezer.bmc.GameWorld;
import com.mobezer.bmc.GlobalSettings;
import com.mobezer.bmc.TextWrapper;
import com.mobezer.bmc.TextureDimensions;
import com.mobezer.bmc.TextureWrapper;
import com.mobezer.bmc.WorldListner;
import com.mobezer.bmc.objects.BoxObjectManager;
import com.mobezer.tween.TextureAccessor;
public class GameScreen extends BaseScreen implements InputProcessor,
GestureListener {
// constants
public static final int GAME_INITIALIZE = 0;
public static final int GAME_READY = 1;
public static final int GAME_RUNNING = 2;
public static final int GAME_PAUSED = 3;
public static final int GAME_OVER = 4;
static int state;
public static int level = 1;
public static boolean levelUp = false;
Vector3 touchPoint = new Vector3(0, 0, 0);
private static Vector2 heroOld = new Vector2(-100, -100);
// Variables
// Variables used for ball shooting
float X1, Y1, X2, Y2;
float shotPower, pullArmBack, rotNeeded, rotNeeded1;
Vector2 vectorMade = new Vector2();
// ////////////////////////////////////////
private OrthographicCamera cam;
GameWorld world;
TextureWrapper backTexture, originTexture, heroOldTextuer, whiteMask;
Box2DDebugRenderer debugRenderer = new Box2DDebugRenderer();
Matrix4 debugMatrix;
private boolean ballReady = false;
private static ShapeRenderer shapeRenderer = new ShapeRenderer();
FPSLogger fps=new FPSLogger();
public GameScreen(int screenId, OrthographicCamera cam) {
// Assets.loadGame();
this.cam = cam;
this.BackScreenID = screenId;
batch.setProjectionMatrix(cam.combined);
IsDone = false;
state = GAME_INITIALIZE;
TouchPoint = new Vector3(0, 0, 0);
TouchHandler = new com.mobezer.bmc.TouchHandler();
// Gdx.input.setInputProcessor(this);
Gdx.input.setCatchBackKey(true);
debugMatrix = new Matrix4(cam.combined.cpy());
debugMatrix.scale(BoxObjectManager.BOX_TO_WORLD,
BoxObjectManager.BOX_TO_WORLD, 1f);
world = new GameWorld(cam);
levelUp = false;
Init();
}
private void Init() {
backTexture = new TextureWrapper(Assets.backgroundRegion, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
backTexture.SetDimension(cam.viewportWidth, cam.viewportHeight);
originTexture = new TextureWrapper(Assets.origin, new Vector2(
world.heroOrigin.x, world.heroOrigin.y));
originTexture.SetDimension(TextureDimensions.ORIGIN_WIDTH,
TextureDimensions.ORIGIN_HEIGHT);
heroOldTextuer = new TextureWrapper(Assets.ballTrace, new Vector2(
heroOld.x, heroOld.y));
heroOldTextuer.SetDimension(TextureDimensions.BALL_WIDTH,
TextureDimensions.BALL_WIDTH);
fadeIn();
Gdx.app.log(Game.LOG, "Level : " + level);
state = GAME_RUNNING;
cam.update();
InputMultiplexer mux = new InputMultiplexer();
mux.addProcessor(this);
mux.addProcessor(new GestureDetector(0, 0, 0, 0.5f, this));
Gdx.input.setInputProcessor(mux);
/*if(Gdx.graphics.getWidth()>=1000)
cam.zoom=1.1f;*/
}
@Override
public void update(float delta) {
if (delta > 0.1f)
delta = 0.1f;
switch (state) {
case GAME_INITIALIZE:
updateInit();
break;
case GAME_READY:
updateReady();
break;
case GAME_RUNNING:
updateRunning(delta);
break;
case GAME_PAUSED:
updatePaused();
break;
case GAME_OVER:
updateGameOver();
break;
}
}
private void updateInit() {
// TODO Auto-generated method stub
}
private void updateGameOver() {
// TODO Auto-generated method stub
}
private void updatePaused() {
// TODO Auto-generated method stub
}
private void updateRunning(float delta) {
world.update(delta);
heroOldTextuer.setPosition(heroOld);
// Check game over // Restart if yes
if (levelUp) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getX() > GlobalSettings.VIRTUAL_WIDTH) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getX() < 0) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getY() > GlobalSettings.VIRTUAL_HEIGHT) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getY() < 0) {
state = GAME_OVER;
restart();
return;
}
}
private void fadeIn() {
whiteMask = new TextureWrapper(Assets.test, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
whiteMask.SetDimension(cam.viewportWidth, cam.viewportHeight);
TweenCallback callback = new TweenCallback() {
@SuppressWarnings("rawtypes")
@Override
public void onEvent(int type, BaseTween source) {
switch (type) {
case COMPLETE:
whiteMask = null;
break;
}
}
};
Timeline.createSequence()
.push(Tween.to(whiteMask, TextureAccessor.OPACITY, 0.5f)
.target(0).ease(Quart.INOUT)).setCallback(callback)
.setCallbackTriggers(TweenCallback.COMPLETE)
.start(Game.tweenManager);
}
private void exit() {
BackScreenID = Game.MENUSCREEN;
IsDone = true;
level = 1;
levelUp = false;
}
private void restart() {
whiteMask = new TextureWrapper(Assets.test, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
whiteMask.SetDimension(cam.viewportWidth, cam.viewportHeight);
TweenCallback callback = new TweenCallback() {
@SuppressWarnings("rawtypes")
@Override
public void onEvent(int type, BaseTween source) {
switch (type) {
case COMPLETE:
BackScreenID = Game.GAMESCREEN;
IsDone = true;
break;
}
}
};
Timeline.createSequence()
// .push(Tween.set(whiteMask,
// TextureAccessor.OPACITY).target(0))
// .push(Tween.to(whiteMask, TextureAccessor.OPACITY,
// 0.4f).target(1).ease(Quart.INOUT))
.setCallback(callback)
.setCallbackTriggers(TweenCallback.COMPLETE)
.start(Game.tweenManager);
if (!levelUp)
WorldListner.restart();
}
public static void LevelUp() {
if (!levelUp) {
if (level == 6)
level = 0;
Gdx.app.log(Game.LOG, "Level ++");
level++;
levelUp = true;
heroOld.set(-150, -150);
}
}
private void updateReady() {
// TODO Auto-generated method stub
}
@Override
public void render() {
cam.update();
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(cam.combined);
batch.begin();
batch.disableBlending();
backTexture.Draw(batch);
batch.enableBlending();
drawLine(X1, Y1, X2, Y2);
drawBallOrigin();
world.render(batch);
batch.disableBlending();
// debugRenderer.render(BoxObjectManager.GetWorld(), debugMatrix);
batch.enableBlending();
if (whiteMask != null)
whiteMask.Draw(batch);
TextWrapper fp = new TextWrapper("fps "+Gdx.graphics.getFramesPerSecond(), Assets.Shemlock, new Vector2(200,80));
fp.Draw(batch);
batch.draw(originTexture.region, TouchPoint.x, TouchPoint.y,6,6);
batch.end();
}
private void drawBallOrigin() {
// Draws the Initial Ball Position
originTexture.Draw(batch);
heroOldTextuer.Draw(batch);
}
private void drawLine(float X1, float Y1, float X2, float Y2) {
batch.end();
shapeRenderer.setProjectionMatrix(GameWorld.camera.combined);
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(Color.GRAY);
shapeRenderer.line(X1, Y1, X2, Y2);
shapeRenderer.end();
batch.begin();
}
@Override
public boolean isDone() {
// TODO Auto-generated method stub
return IsDone;
}
@Override
public void dispose() {
world.dospose();
}
@Override
public void OnPause() {
// TODO Auto-generated method stub
}
@Override
public void OnResume() {
// TODO Auto-generated method stub
}
@Override
public boolean keyDown(int keycode) {
if (keycode == Keys.BACK || keycode == Keys.ESCAPE) {
exit();
return true;
}
if (keycode == Keys.R || keycode == Keys.MENU) {
restart();
return true;
}
return false;
}
@Override
public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
UnProjectCamera(x, y, cam, Game.CAMSTARTX, Game.CAMSTARTY,
Game.CAMWIDTH, Game.CAMHEIGHT);
x = (int) TouchPoint.x;
y = (int) TouchPoint.y;
Gdx.app.log("", "" + TouchPoint);
if (x < world.heroBall.getX() + TextureDimensions.BALL_WIDTH * 2
&& x > world.heroBall.getX() - TextureDimensions.BALL_WIDTH * 2
&& y < world.heroBall.getY() + TextureDimensions.BALL_WIDTH * 2
&& y > world.heroBall.getY() - TextureDimensions.BALL_WIDTH * 2) {
if (!world.heroBall.isFlying) {
X1 = world.heroBall.getX();
Y1 = world.heroBall.getY();
X2 = X1;
Y2 = Y1;
ballReady = true;
Gdx.app.log(Game.LOG, "Ball Touched ");
return true;
}
}
return false;
};
@Override
public boolean touchDragged(int x, int y, int pointer) {
// Update the end point and redraw the line
if (ballReady) {
// Gdx.app.log(Game.LOG, "Ball Dragged ");
x = (int) TouchPoint.x;
y = (int) TouchPoint.y;
X2 = x;
Y2 = y;
double angle;
float dist_x = X2 - world.circle.x;
float dist_y = Y2 - world.circle.y;
double distance = Math.sqrt(dist_x * dist_x + dist_y * dist_y);
if (distance > 100) {
angle = Math.atan2(dist_y, dist_x);
X2 = (float) (world.circle.x + 100 * Math.cos(angle));
Y2 = (float) (world.circle.y + 100 * Math.sin(angle));
}
// Update VectorMade
vectorMade.set(X2 - X1, Y2 - Y1);
shotPower = vectorMade.len();
// Store value to reduce number of calculations
pullArmBack = shotPower / 50;
// Normalise vector to yield only directional info
vectorMade.nor();
{
rotNeeded = (float) (245 + Math.toDegrees(Math.atan2(
vectorMade.y, vectorMade.x)
- Math.atan2(world.heroBall.getY(),
world.heroBall.getX())));
if (shotPower > 10)
world.heroBall.SetPosition(X2, Y2);
// Gdx.app.log(Woody.LOG, "Rotation calculated " + rotNeeded);
}
}
return false;
};
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
if (shotPower < 10 || !ballReady) {
ballReady = false;
} else if (ballReady) {
Gdx.app.log(Game.LOG, "Fire!! " + shotPower);
world.heroBall.shoot(shotPower, vectorMade);
shotPower = 0;
heroOld.set(X2, Y2);
X1 = 0;
X2 = 0;
Y1 = 0;
Y2 = 0;
ballReady = false;
return true;
}
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean scrolled(int amount) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(float x, float y, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean tap(float x, float y, int count, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean longPress(float x, float y) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean pan(float x, float y, float deltaX, float deltaY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean panStop(float x, float y, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean zoom(float initialDistance, float distance) {
// cam.zoom +=(distance-initialDistance)*0.005f;
return false;
}
@Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
Vector2 pointer1, Vector2 pointer2) {
// cam.zoom=1f;
return false;
}
}
| UTF-8 | Java | 12,788 | java | GameScreen.java | Java | [] | null | [] | package com.mobezer.bmc.screens;
import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Timeline;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.equations.Quart;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.FPSLogger;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.mobezer.bmc.Assets;
import com.mobezer.bmc.Game;
import com.mobezer.bmc.GameWorld;
import com.mobezer.bmc.GlobalSettings;
import com.mobezer.bmc.TextWrapper;
import com.mobezer.bmc.TextureDimensions;
import com.mobezer.bmc.TextureWrapper;
import com.mobezer.bmc.WorldListner;
import com.mobezer.bmc.objects.BoxObjectManager;
import com.mobezer.tween.TextureAccessor;
public class GameScreen extends BaseScreen implements InputProcessor,
GestureListener {
// constants
public static final int GAME_INITIALIZE = 0;
public static final int GAME_READY = 1;
public static final int GAME_RUNNING = 2;
public static final int GAME_PAUSED = 3;
public static final int GAME_OVER = 4;
static int state;
public static int level = 1;
public static boolean levelUp = false;
Vector3 touchPoint = new Vector3(0, 0, 0);
private static Vector2 heroOld = new Vector2(-100, -100);
// Variables
// Variables used for ball shooting
float X1, Y1, X2, Y2;
float shotPower, pullArmBack, rotNeeded, rotNeeded1;
Vector2 vectorMade = new Vector2();
// ////////////////////////////////////////
private OrthographicCamera cam;
GameWorld world;
TextureWrapper backTexture, originTexture, heroOldTextuer, whiteMask;
Box2DDebugRenderer debugRenderer = new Box2DDebugRenderer();
Matrix4 debugMatrix;
private boolean ballReady = false;
private static ShapeRenderer shapeRenderer = new ShapeRenderer();
FPSLogger fps=new FPSLogger();
public GameScreen(int screenId, OrthographicCamera cam) {
// Assets.loadGame();
this.cam = cam;
this.BackScreenID = screenId;
batch.setProjectionMatrix(cam.combined);
IsDone = false;
state = GAME_INITIALIZE;
TouchPoint = new Vector3(0, 0, 0);
TouchHandler = new com.mobezer.bmc.TouchHandler();
// Gdx.input.setInputProcessor(this);
Gdx.input.setCatchBackKey(true);
debugMatrix = new Matrix4(cam.combined.cpy());
debugMatrix.scale(BoxObjectManager.BOX_TO_WORLD,
BoxObjectManager.BOX_TO_WORLD, 1f);
world = new GameWorld(cam);
levelUp = false;
Init();
}
private void Init() {
backTexture = new TextureWrapper(Assets.backgroundRegion, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
backTexture.SetDimension(cam.viewportWidth, cam.viewportHeight);
originTexture = new TextureWrapper(Assets.origin, new Vector2(
world.heroOrigin.x, world.heroOrigin.y));
originTexture.SetDimension(TextureDimensions.ORIGIN_WIDTH,
TextureDimensions.ORIGIN_HEIGHT);
heroOldTextuer = new TextureWrapper(Assets.ballTrace, new Vector2(
heroOld.x, heroOld.y));
heroOldTextuer.SetDimension(TextureDimensions.BALL_WIDTH,
TextureDimensions.BALL_WIDTH);
fadeIn();
Gdx.app.log(Game.LOG, "Level : " + level);
state = GAME_RUNNING;
cam.update();
InputMultiplexer mux = new InputMultiplexer();
mux.addProcessor(this);
mux.addProcessor(new GestureDetector(0, 0, 0, 0.5f, this));
Gdx.input.setInputProcessor(mux);
/*if(Gdx.graphics.getWidth()>=1000)
cam.zoom=1.1f;*/
}
@Override
public void update(float delta) {
if (delta > 0.1f)
delta = 0.1f;
switch (state) {
case GAME_INITIALIZE:
updateInit();
break;
case GAME_READY:
updateReady();
break;
case GAME_RUNNING:
updateRunning(delta);
break;
case GAME_PAUSED:
updatePaused();
break;
case GAME_OVER:
updateGameOver();
break;
}
}
private void updateInit() {
// TODO Auto-generated method stub
}
private void updateGameOver() {
// TODO Auto-generated method stub
}
private void updatePaused() {
// TODO Auto-generated method stub
}
private void updateRunning(float delta) {
world.update(delta);
heroOldTextuer.setPosition(heroOld);
// Check game over // Restart if yes
if (levelUp) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getX() > GlobalSettings.VIRTUAL_WIDTH) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getX() < 0) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getY() > GlobalSettings.VIRTUAL_HEIGHT) {
state = GAME_OVER;
restart();
return;
} else if (world.heroBall.getY() < 0) {
state = GAME_OVER;
restart();
return;
}
}
private void fadeIn() {
whiteMask = new TextureWrapper(Assets.test, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
whiteMask.SetDimension(cam.viewportWidth, cam.viewportHeight);
TweenCallback callback = new TweenCallback() {
@SuppressWarnings("rawtypes")
@Override
public void onEvent(int type, BaseTween source) {
switch (type) {
case COMPLETE:
whiteMask = null;
break;
}
}
};
Timeline.createSequence()
.push(Tween.to(whiteMask, TextureAccessor.OPACITY, 0.5f)
.target(0).ease(Quart.INOUT)).setCallback(callback)
.setCallbackTriggers(TweenCallback.COMPLETE)
.start(Game.tweenManager);
}
private void exit() {
BackScreenID = Game.MENUSCREEN;
IsDone = true;
level = 1;
levelUp = false;
}
private void restart() {
whiteMask = new TextureWrapper(Assets.test, new Vector2(
GlobalSettings.VIRTUAL_WIDTH / 2,
GlobalSettings.VIRTUAL_HEIGHT / 2));
whiteMask.SetDimension(cam.viewportWidth, cam.viewportHeight);
TweenCallback callback = new TweenCallback() {
@SuppressWarnings("rawtypes")
@Override
public void onEvent(int type, BaseTween source) {
switch (type) {
case COMPLETE:
BackScreenID = Game.GAMESCREEN;
IsDone = true;
break;
}
}
};
Timeline.createSequence()
// .push(Tween.set(whiteMask,
// TextureAccessor.OPACITY).target(0))
// .push(Tween.to(whiteMask, TextureAccessor.OPACITY,
// 0.4f).target(1).ease(Quart.INOUT))
.setCallback(callback)
.setCallbackTriggers(TweenCallback.COMPLETE)
.start(Game.tweenManager);
if (!levelUp)
WorldListner.restart();
}
public static void LevelUp() {
if (!levelUp) {
if (level == 6)
level = 0;
Gdx.app.log(Game.LOG, "Level ++");
level++;
levelUp = true;
heroOld.set(-150, -150);
}
}
private void updateReady() {
// TODO Auto-generated method stub
}
@Override
public void render() {
cam.update();
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(cam.combined);
batch.begin();
batch.disableBlending();
backTexture.Draw(batch);
batch.enableBlending();
drawLine(X1, Y1, X2, Y2);
drawBallOrigin();
world.render(batch);
batch.disableBlending();
// debugRenderer.render(BoxObjectManager.GetWorld(), debugMatrix);
batch.enableBlending();
if (whiteMask != null)
whiteMask.Draw(batch);
TextWrapper fp = new TextWrapper("fps "+Gdx.graphics.getFramesPerSecond(), Assets.Shemlock, new Vector2(200,80));
fp.Draw(batch);
batch.draw(originTexture.region, TouchPoint.x, TouchPoint.y,6,6);
batch.end();
}
private void drawBallOrigin() {
// Draws the Initial Ball Position
originTexture.Draw(batch);
heroOldTextuer.Draw(batch);
}
private void drawLine(float X1, float Y1, float X2, float Y2) {
batch.end();
shapeRenderer.setProjectionMatrix(GameWorld.camera.combined);
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(Color.GRAY);
shapeRenderer.line(X1, Y1, X2, Y2);
shapeRenderer.end();
batch.begin();
}
@Override
public boolean isDone() {
// TODO Auto-generated method stub
return IsDone;
}
@Override
public void dispose() {
world.dospose();
}
@Override
public void OnPause() {
// TODO Auto-generated method stub
}
@Override
public void OnResume() {
// TODO Auto-generated method stub
}
@Override
public boolean keyDown(int keycode) {
if (keycode == Keys.BACK || keycode == Keys.ESCAPE) {
exit();
return true;
}
if (keycode == Keys.R || keycode == Keys.MENU) {
restart();
return true;
}
return false;
}
@Override
public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
UnProjectCamera(x, y, cam, Game.CAMSTARTX, Game.CAMSTARTY,
Game.CAMWIDTH, Game.CAMHEIGHT);
x = (int) TouchPoint.x;
y = (int) TouchPoint.y;
Gdx.app.log("", "" + TouchPoint);
if (x < world.heroBall.getX() + TextureDimensions.BALL_WIDTH * 2
&& x > world.heroBall.getX() - TextureDimensions.BALL_WIDTH * 2
&& y < world.heroBall.getY() + TextureDimensions.BALL_WIDTH * 2
&& y > world.heroBall.getY() - TextureDimensions.BALL_WIDTH * 2) {
if (!world.heroBall.isFlying) {
X1 = world.heroBall.getX();
Y1 = world.heroBall.getY();
X2 = X1;
Y2 = Y1;
ballReady = true;
Gdx.app.log(Game.LOG, "Ball Touched ");
return true;
}
}
return false;
};
@Override
public boolean touchDragged(int x, int y, int pointer) {
// Update the end point and redraw the line
if (ballReady) {
// Gdx.app.log(Game.LOG, "Ball Dragged ");
x = (int) TouchPoint.x;
y = (int) TouchPoint.y;
X2 = x;
Y2 = y;
double angle;
float dist_x = X2 - world.circle.x;
float dist_y = Y2 - world.circle.y;
double distance = Math.sqrt(dist_x * dist_x + dist_y * dist_y);
if (distance > 100) {
angle = Math.atan2(dist_y, dist_x);
X2 = (float) (world.circle.x + 100 * Math.cos(angle));
Y2 = (float) (world.circle.y + 100 * Math.sin(angle));
}
// Update VectorMade
vectorMade.set(X2 - X1, Y2 - Y1);
shotPower = vectorMade.len();
// Store value to reduce number of calculations
pullArmBack = shotPower / 50;
// Normalise vector to yield only directional info
vectorMade.nor();
{
rotNeeded = (float) (245 + Math.toDegrees(Math.atan2(
vectorMade.y, vectorMade.x)
- Math.atan2(world.heroBall.getY(),
world.heroBall.getX())));
if (shotPower > 10)
world.heroBall.SetPosition(X2, Y2);
// Gdx.app.log(Woody.LOG, "Rotation calculated " + rotNeeded);
}
}
return false;
};
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
if (shotPower < 10 || !ballReady) {
ballReady = false;
} else if (ballReady) {
Gdx.app.log(Game.LOG, "Fire!! " + shotPower);
world.heroBall.shoot(shotPower, vectorMade);
shotPower = 0;
heroOld.set(X2, Y2);
X1 = 0;
X2 = 0;
Y1 = 0;
Y2 = 0;
ballReady = false;
return true;
}
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean scrolled(int amount) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(float x, float y, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean tap(float x, float y, int count, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean longPress(float x, float y) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean pan(float x, float y, float deltaX, float deltaY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean panStop(float x, float y, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean zoom(float initialDistance, float distance) {
// cam.zoom +=(distance-initialDistance)*0.005f;
return false;
}
@Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
Vector2 pointer1, Vector2 pointer2) {
// cam.zoom=1f;
return false;
}
}
| 12,788 | 0.697216 | 0.683219 | 484 | 25.421488 | 20.044167 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.551653 | false | false | 9 |
353c3aa40d4d9aaecb5664b677c76e2a2c45cba4 | 36,704,790,551,613 | bbaed163d5f724f9e3315a96dfc7779d03524552 | /Utilities.java | 0399a2c3438b8c1a283e9325872ddb9335bef9fb | [] | no_license | billwu971018/ZeroSum | https://github.com/billwu971018/ZeroSum | 068f00f08706bbdc86cd54faa494594b8530d444 | aad818b5b43068031c4f9064419f8ef5ad627deb | refs/heads/master | 2021-05-08T03:06:41.110000 | 2017-10-31T03:30:42 | 2017-10-31T03:30:42 | 108,232,454 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
class Utilities{
}
| UTF-8 | Java | 41 | java | Utilities.java | Java | [] | null | [] | import java.util.*;
class Utilities{
}
| 41 | 0.682927 | 0.682927 | 5 | 7.2 | 8.471128 | 19 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 9 |
d639a4326dbf630d61484e42134ba05a6c1c1c69 | 36,129,264,939,122 | 8f594f479c4345af719338db956be292c30824a4 | /projects/hadoop-project/src/system/CommandPrompt.java | 938b9694fc4cc7bb08d73803a542892f687facd6 | [] | no_license | tborenst/Hadoop-440 | https://github.com/tborenst/Hadoop-440 | af948bb3d71d5ca1991d9bd7111d687965dfe941 | 22473799175d8d4ddcd39642141f9bae6774ec12 | refs/heads/master | 2021-01-23T20:50:09.102000 | 2015-01-11T16:53:28 | 2015-01-11T16:53:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* CommandPrompt object to interface with a human.
*/
package system;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import networking.SIOCommand;
public class CommandPrompt {
private HashMap<String, SIOCommand> bindings;
private Object printLock;
private Boolean promptGiven;
/**
* Constructor for CommandPrompt.
*/
public CommandPrompt() {
this.bindings = new HashMap<String, SIOCommand>();
this.printLock = new Object();
this.promptGiven = false;
//givePrompt();
//System.out.print("> ");
}
/**
* Bind a certain SIOCommand to be run when a certain message is "received".
* @param message
* @param command
*/
public void on(String message, SIOCommand command) {
synchronized(bindings) {
bindings.put(message, command);
}
}
/**
* Print a certain message to the user, then give them back the prompt.
* @param message
*/
public void emit(String message) {
synchronized(printLock) {
System.out.print("\n");
System.out.println(message);
givePrompt();
System.out.print("> ");
}
}
/**
* Give the user a prompt. Wait for them to type something, then take the prompt away and analyze it.
*/
private void givePrompt() {
synchronized(promptGiven) {
if(promptGiven == true) {
//someone else has the prompt
return;
} else {
//we are giving the prompt away
promptGiven = true;
}
Runnable prompt = new Runnable() {
@Override
public void run(){
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
promptGiven = false;
analayzeInput(input);
}
};
new Thread(prompt).start();
}
}
/**
* Analyzes given input and tries to verifies that the class actually exists. If the class doesn't exit, print an error message.
* Note that for processes to be executed, they must be present in the migratableProcesses package.
* @param input
*/
private void analayzeInput(String input) {
String[] inputArray = input.split(" ");
String arg1 = inputArray[0];
synchronized(bindings) {
SIOCommand cmd = bindings.get(arg1);
if(cmd != null) {
String[] argsArray = Arrays.copyOfRange(inputArray, 1, inputArray.length);
cmd.passObject(argsArray);
try {
cmd.run();
} catch (Exception e) {
emit("Failed to execute '" + input + "'.\n"
+ "Due to excetion:" + e + "\nStack Trace:\n");
e.printStackTrace();
}
} else if(arg1.equals("")) {
emit("");
} else {
emit("Command '" + arg1 + "' Not Found.");
}
}
}
}
| UTF-8 | Java | 2,576 | java | CommandPrompt.java | Java | [] | null | [] | /**
* CommandPrompt object to interface with a human.
*/
package system;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import networking.SIOCommand;
public class CommandPrompt {
private HashMap<String, SIOCommand> bindings;
private Object printLock;
private Boolean promptGiven;
/**
* Constructor for CommandPrompt.
*/
public CommandPrompt() {
this.bindings = new HashMap<String, SIOCommand>();
this.printLock = new Object();
this.promptGiven = false;
//givePrompt();
//System.out.print("> ");
}
/**
* Bind a certain SIOCommand to be run when a certain message is "received".
* @param message
* @param command
*/
public void on(String message, SIOCommand command) {
synchronized(bindings) {
bindings.put(message, command);
}
}
/**
* Print a certain message to the user, then give them back the prompt.
* @param message
*/
public void emit(String message) {
synchronized(printLock) {
System.out.print("\n");
System.out.println(message);
givePrompt();
System.out.print("> ");
}
}
/**
* Give the user a prompt. Wait for them to type something, then take the prompt away and analyze it.
*/
private void givePrompt() {
synchronized(promptGiven) {
if(promptGiven == true) {
//someone else has the prompt
return;
} else {
//we are giving the prompt away
promptGiven = true;
}
Runnable prompt = new Runnable() {
@Override
public void run(){
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
promptGiven = false;
analayzeInput(input);
}
};
new Thread(prompt).start();
}
}
/**
* Analyzes given input and tries to verifies that the class actually exists. If the class doesn't exit, print an error message.
* Note that for processes to be executed, they must be present in the migratableProcesses package.
* @param input
*/
private void analayzeInput(String input) {
String[] inputArray = input.split(" ");
String arg1 = inputArray[0];
synchronized(bindings) {
SIOCommand cmd = bindings.get(arg1);
if(cmd != null) {
String[] argsArray = Arrays.copyOfRange(inputArray, 1, inputArray.length);
cmd.passObject(argsArray);
try {
cmd.run();
} catch (Exception e) {
emit("Failed to execute '" + input + "'.\n"
+ "Due to excetion:" + e + "\nStack Trace:\n");
e.printStackTrace();
}
} else if(arg1.equals("")) {
emit("");
} else {
emit("Command '" + arg1 + "' Not Found.");
}
}
}
}
| 2,576 | 0.645186 | 0.642857 | 109 | 22.633028 | 23.024782 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.504587 | false | false | 9 |
999bfeda22e935d6a7e441baff0beab3ab668c29 | 35,742,717,888,070 | 043951f04ddb6c8df3f397fac4e0f940d8e919d8 | /source/boy-learning-designpattern/src/main/java/bugmakers/club/dp/structural/seq4/decorator/practice/ModEncryptDecorator.java | 776de68e92da2cf7de053f7487626c53352c31d0 | [] | no_license | shamexln/boy-design-pattern | https://github.com/shamexln/boy-design-pattern | 05b3c4e133b3207527a25fac134ccf8d93fb8f5d | 2a4835442d477021f555272fd3033cad987dc94f | refs/heads/master | 2021-09-12T13:06:50.423000 | 2018-04-17T02:42:24 | 2018-04-17T02:42:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bugmakers.club.dp.structural.seq4.decorator.practice;
/**
* @Description:
* @Author: Bruce
* @Datetime: 2018/3/14 14:24
*/
public class ModEncryptDecorator extends EncryptDecorator {
public ModEncryptDecorator(Encryptor encryptor) {
super(encryptor);
}
@Override
public String encrypt(String param) {
return mod(super.encrypt(param));
}
public String mod(String param){
System.out.println("求模加密:" + param + " --------------------> " + "[求模加密]" + param);
return "[求模加密]" + param;
}
}
| UTF-8 | Java | 585 | java | ModEncryptDecorator.java | Java | [
{
"context": "orator.practice;\n\n/**\n * @Description:\n * @Author: Bruce\n * @Datetime: 2018/3/14 14:24\n */\npublic class Mo",
"end": 101,
"score": 0.9860424399375916,
"start": 96,
"tag": "NAME",
"value": "Bruce"
}
] | null | [] | package bugmakers.club.dp.structural.seq4.decorator.practice;
/**
* @Description:
* @Author: Bruce
* @Datetime: 2018/3/14 14:24
*/
public class ModEncryptDecorator extends EncryptDecorator {
public ModEncryptDecorator(Encryptor encryptor) {
super(encryptor);
}
@Override
public String encrypt(String param) {
return mod(super.encrypt(param));
}
public String mod(String param){
System.out.println("求模加密:" + param + " --------------------> " + "[求模加密]" + param);
return "[求模加密]" + param;
}
}
| 585 | 0.613596 | 0.592129 | 23 | 23.304348 | 24.456589 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.217391 | false | false | 9 |
9e73810c0643f9b8f32a68ba24211f6cc7384005 | 35,648,228,606,180 | d25b9e36e78463eebcb787307a88a53a41414350 | /src/main/java/org/ucema/sgsp/persistence/CountryDAO.java | 5f3392f85bb3f97a7b2ba20188e6ece1aa4b6a35 | [] | no_license | aelingold/sgsp-core | https://github.com/aelingold/sgsp-core | bf414985383ec3ea21670f0aa698e88d75a90a7c | 4627c3654b55e528cb6967aa8e53b423c8892467 | refs/heads/master | 2020-06-02T09:45:32.134000 | 2014-12-12T03:57:46 | 2014-12-12T03:57:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.ucema.sgsp.persistence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.ucema.sgsp.persistence.model.Country;
public interface CountryDAO extends JpaRepository<Country, Long> {
Country findByCode(String code);
}
| UTF-8 | Java | 253 | java | CountryDAO.java | Java | [] | null | [] | package org.ucema.sgsp.persistence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.ucema.sgsp.persistence.model.Country;
public interface CountryDAO extends JpaRepository<Country, Long> {
Country findByCode(String code);
}
| 253 | 0.822134 | 0.822134 | 9 | 27.111111 | 25.993351 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 9 |
fd991c410765907b1474e03717f3bdf2fdd5894c | 27,633,819,586,841 | 8da0d828a695e7bab952479cb144af0c7c4fb6c2 | /app/src/main/java/abbie/example/com/yorkshirerestaurants/CuisineActivity.java | 21abaa9311814b3f8c5a67f6460f659bfb720e3e | [] | no_license | AbbieTurner95/YorkshireRestaurants | https://github.com/AbbieTurner95/YorkshireRestaurants | 6860f42a2c75b8ceeda6f1a4b2329fb488632bbd | 74784f430f4e300a1649282858bdf7105f6976c6 | refs/heads/master | 2018-09-29T20:04:21.469000 | 2018-08-31T09:44:17 | 2018-08-31T09:44:17 | 133,018,651 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package abbie.example.com.yorkshirerestaurants;
import android.app.ActivityOptions;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.transition.Fade;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.firebase.ui.auth.AuthUI;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import abbie.example.com.yorkshirerestaurants.Adapters.CuisineAdapter;
import abbie.example.com.yorkshirerestaurants.Data.Cuisine;
import abbie.example.com.yorkshirerestaurants.Data.Cuisines;
import butterknife.BindView;
import butterknife.ButterKnife;
public class CuisineActivity extends AppCompatActivity implements CuisineAdapter.CuisineItemClick {
@BindView(R.id.adView)
AdView mAdView;
@BindView(R.id.cuisine_RV)
RecyclerView recyclerView;
@BindView(R.id.toolbar)
Toolbar toolbar;
private CuisineAdapter cuisineAdapter;
private String TAG = "CUISINE_ID";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cuisine);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(getString(R.string.app_name));
toolbar.setTitleTextColor(Color.WHITE);
}
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
recyclerView.setLayoutManager(layoutManager);
cuisineAdapter = new CuisineAdapter(this, this);
recyclerView.setAdapter(cuisineAdapter);
fetchCuisines();
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
}
public void fetchCuisines() {
CuisineViewModel cuisineViewModel = ViewModelProviders.of(this).get(CuisineViewModel.class);
cuisineViewModel.getLiveData().observe(this, new Observer<Cuisines>() {
@Override
public void onChanged(@Nullable Cuisines cuisines) {
cuisineAdapter.setCuisineList(cuisines.getCuisinesList());
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.favorites_menu:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setEnterExitTransition(new Intent(CuisineActivity.this, FavoritesActivity.class));
}
startActivity(new Intent(this, FavoritesActivity.class));
return true;
case R.id.logout:
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Intent intent = new Intent(CuisineActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
});
default:
return super.onOptionsItemSelected(item);
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setEnterExitTransition(Intent intent) {
getWindow().setExitTransition(new Fade().setDuration(1000));
getWindow().setReenterTransition(new Fade().setDuration(1000));
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(CuisineActivity.this).toBundle());
}
@Override
public void onCuisineItemClick(Cuisine cuisines) {
int id = cuisines.getCuisine_id();
Intent intent = new Intent(CuisineActivity.this, RestaurantsListActivity.class);
intent.putExtra(TAG, id);
startActivity(intent);
}
} | UTF-8 | Java | 4,749 | java | CuisineActivity.java | Java | [] | null | [] | package abbie.example.com.yorkshirerestaurants;
import android.app.ActivityOptions;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.transition.Fade;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.firebase.ui.auth.AuthUI;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import abbie.example.com.yorkshirerestaurants.Adapters.CuisineAdapter;
import abbie.example.com.yorkshirerestaurants.Data.Cuisine;
import abbie.example.com.yorkshirerestaurants.Data.Cuisines;
import butterknife.BindView;
import butterknife.ButterKnife;
public class CuisineActivity extends AppCompatActivity implements CuisineAdapter.CuisineItemClick {
@BindView(R.id.adView)
AdView mAdView;
@BindView(R.id.cuisine_RV)
RecyclerView recyclerView;
@BindView(R.id.toolbar)
Toolbar toolbar;
private CuisineAdapter cuisineAdapter;
private String TAG = "CUISINE_ID";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cuisine);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(getString(R.string.app_name));
toolbar.setTitleTextColor(Color.WHITE);
}
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
recyclerView.setLayoutManager(layoutManager);
cuisineAdapter = new CuisineAdapter(this, this);
recyclerView.setAdapter(cuisineAdapter);
fetchCuisines();
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
}
public void fetchCuisines() {
CuisineViewModel cuisineViewModel = ViewModelProviders.of(this).get(CuisineViewModel.class);
cuisineViewModel.getLiveData().observe(this, new Observer<Cuisines>() {
@Override
public void onChanged(@Nullable Cuisines cuisines) {
cuisineAdapter.setCuisineList(cuisines.getCuisinesList());
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.favorites_menu:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setEnterExitTransition(new Intent(CuisineActivity.this, FavoritesActivity.class));
}
startActivity(new Intent(this, FavoritesActivity.class));
return true;
case R.id.logout:
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Intent intent = new Intent(CuisineActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
});
default:
return super.onOptionsItemSelected(item);
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setEnterExitTransition(Intent intent) {
getWindow().setExitTransition(new Fade().setDuration(1000));
getWindow().setReenterTransition(new Fade().setDuration(1000));
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(CuisineActivity.this).toBundle());
}
@Override
public void onCuisineItemClick(Cuisine cuisines) {
int id = cuisines.getCuisine_id();
Intent intent = new Intent(CuisineActivity.this, RestaurantsListActivity.class);
intent.putExtra(TAG, id);
startActivity(intent);
}
} | 4,749 | 0.673616 | 0.670878 | 128 | 36.109375 | 26.083769 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.609375 | false | false | 9 |
00e443b28ac18505864878aa1db52f6542f34146 | 29,317,446,802,327 | 0fe1f9be40127be88cfcc2ed63adb898f6fbb80b | /basic-information-8084/src/main/java/com/neusoft/basicinformation8084/product/service/ProductCategoryService.java | 41256295fb414b332891f1cfdfe553808846f983 | [] | no_license | happyma23333/bsp-backend-springcloud | https://github.com/happyma23333/bsp-backend-springcloud | c59cd5ccf1426e4d39a91d5dcc0d50b33d3ccfe6 | 61f3864eac7e0d54cc083ec0bf6cc389dae7b891 | refs/heads/master | 2023-04-06T17:55:04.368000 | 2020-07-23T07:35:16 | 2020-07-23T07:35:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.neusoft.basicinformation8084.product.service;
import com.github.pagehelper.PageInfo;
import com.neusoft.basicinformation8084.product.entity.ProductCategory;
import java.util.List;
import java.util.Map;
public interface ProductCategoryService {
int insert(ProductCategory productCategory);
int update(ProductCategory productCategory);
int delete(int pk);
ProductCategory getById(int pk);
List<ProductCategory> getAllByFilter(Map<String, Object> map);
List<ProductCategory> getAll();
PageInfo<ProductCategory> getAllByFilter(Integer pageNum, Integer pageSize, Map<String, Object> map);
int getProNum(int prc_id);
}
| UTF-8 | Java | 669 | java | ProductCategoryService.java | Java | [] | null | [] | package com.neusoft.basicinformation8084.product.service;
import com.github.pagehelper.PageInfo;
import com.neusoft.basicinformation8084.product.entity.ProductCategory;
import java.util.List;
import java.util.Map;
public interface ProductCategoryService {
int insert(ProductCategory productCategory);
int update(ProductCategory productCategory);
int delete(int pk);
ProductCategory getById(int pk);
List<ProductCategory> getAllByFilter(Map<String, Object> map);
List<ProductCategory> getAll();
PageInfo<ProductCategory> getAllByFilter(Integer pageNum, Integer pageSize, Map<String, Object> map);
int getProNum(int prc_id);
}
| 669 | 0.775785 | 0.763827 | 27 | 23.777779 | 27.898405 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62963 | false | false | 9 |
86997599525dab86b3f198c12712e9c490ee78d3 | 30,717,606,117,911 | 339ecf78a2266e3aa4eaf09ef8ea5654faad021b | /Mobile_Phone/src/myjava/exercises/Contact.java | 4b5d7116f6dc80791a1df64c4549dfc9eda9b1fd | [] | no_license | Eldraea/Exercises_in_Java | https://github.com/Eldraea/Exercises_in_Java | 4935de0f6e88d0b99f175df90a546dd4ed03f3ee | 089feba7bafea86eecec8eeecc25684adb9dca60 | refs/heads/main | 2023-05-31T15:13:32.184000 | 2021-07-08T17:38:36 | 2021-07-08T17:38:36 | 369,454,014 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
Contact.java
------------------------------------------------------------------------------------------------------------------------
Created by Eldr@e@
------------------------------------------------------------------------------------------------------------------------
The Contact class
------------------------------------------------------------------------------------------------------------------------
Created on : 27/05/2021
------------------------------------------------------------------------------------------------------------------------
Last Update on: 27/05/2021
------------------------------------------------------------------------------------------------------------------------
*/
package myjava.exercises;
public class Contact {
private String name;
private String phoneNumber;
public Contact(String name, String phoneNumber) {
this.name = name;
this.phoneNumber = phoneNumber;
}
public String getName() {
return name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public static Contact createContact(String name, String phoneNumber)
{
return new Contact(name, phoneNumber);
}
}
| UTF-8 | Java | 1,214 | java | Contact.java | Java | [
{
"context": "---------------------------------------\nCreated by Eldr@e@\n-------------------------------------------------",
"end": 154,
"score": 0.7249969840049744,
"start": 148,
"tag": "EMAIL",
"value": "Eldr@e"
}
] | null | [] | /*
Contact.java
------------------------------------------------------------------------------------------------------------------------
Created by <EMAIL>@
------------------------------------------------------------------------------------------------------------------------
The Contact class
------------------------------------------------------------------------------------------------------------------------
Created on : 27/05/2021
------------------------------------------------------------------------------------------------------------------------
Last Update on: 27/05/2021
------------------------------------------------------------------------------------------------------------------------
*/
package myjava.exercises;
public class Contact {
private String name;
private String phoneNumber;
public Contact(String name, String phoneNumber) {
this.name = name;
this.phoneNumber = phoneNumber;
}
public String getName() {
return name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public static Contact createContact(String name, String phoneNumber)
{
return new Contact(name, phoneNumber);
}
}
| 1,215 | 0.327842 | 0.314662 | 38 | 30.947369 | 38.345348 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.289474 | false | false | 9 |
68c00bb69ed99195be4e8d0d6760c2b09d633160 | 27,693,949,164,693 | ca9371238f2f8fbec5f277b86c28472f0238b2fe | /src/mx/com/kubo/repositories/investor/DAOMovimientosLogDMO.java | ecdebe1dff5ad83707a30044041d59b9174cd418 | [] | no_license | ocg1/kubo.portal | https://github.com/ocg1/kubo.portal | 64cb245c8736a1f8ec4010613e14a458a0d94881 | ab022457d55a72df73455124d65b625b002c8ac2 | refs/heads/master | 2021-05-15T17:23:48.952000 | 2017-05-08T17:18:09 | 2017-05-08T17:18:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mx.com.kubo.repositories.investor;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import mx.com.kubo.model.investor.MovimientosLog;
public abstract class DAOMovimientosLogDMO
{
protected EntityManager em = null;
protected List<MovimientosLog> lista_movimientos;
protected TypedQuery<MovimientosLog> typed_lista_movimientos;
protected final String query_MAX_log_id;
protected final String query_lista_movimientos;
protected Integer MAX_log_id;
protected boolean registrar_OK;
protected DAOMovimientosLogDMO()
{
query_MAX_log_id = "select MAX(m.pk.log_id) from MovimientosLog m";
query_lista_movimientos = "from MovimientosLog m where m.pk.prospectus_id = ? and m.pk.company_id = ?" ;
}
@PersistenceContext
public void setEntityManager(EntityManager em)
{
this.em = em;
}
public final Integer getLog_id()
{
MAX_log_id = (Integer) em.createQuery(query_MAX_log_id).getSingleResult();
if(MAX_log_id != null)
{
MAX_log_id++;
} else {
MAX_log_id = 1;
}
return MAX_log_id;
}
public List<MovimientosLog> getLista_movimientos(int prospectus_id, int company_id)
{
try
{
lista_movimientos = null;
typed_lista_movimientos = em.createQuery(query_lista_movimientos, MovimientosLog.class);
typed_lista_movimientos.setParameter(1, prospectus_id);
typed_lista_movimientos.setParameter(2, company_id);
lista_movimientos = typed_lista_movimientos.getResultList();
} catch(Exception e) {
e.printStackTrace();
}
return lista_movimientos;
}
}
| UTF-8 | Java | 1,683 | java | DAOMovimientosLogDMO.java | Java | [] | null | [] | package mx.com.kubo.repositories.investor;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import mx.com.kubo.model.investor.MovimientosLog;
public abstract class DAOMovimientosLogDMO
{
protected EntityManager em = null;
protected List<MovimientosLog> lista_movimientos;
protected TypedQuery<MovimientosLog> typed_lista_movimientos;
protected final String query_MAX_log_id;
protected final String query_lista_movimientos;
protected Integer MAX_log_id;
protected boolean registrar_OK;
protected DAOMovimientosLogDMO()
{
query_MAX_log_id = "select MAX(m.pk.log_id) from MovimientosLog m";
query_lista_movimientos = "from MovimientosLog m where m.pk.prospectus_id = ? and m.pk.company_id = ?" ;
}
@PersistenceContext
public void setEntityManager(EntityManager em)
{
this.em = em;
}
public final Integer getLog_id()
{
MAX_log_id = (Integer) em.createQuery(query_MAX_log_id).getSingleResult();
if(MAX_log_id != null)
{
MAX_log_id++;
} else {
MAX_log_id = 1;
}
return MAX_log_id;
}
public List<MovimientosLog> getLista_movimientos(int prospectus_id, int company_id)
{
try
{
lista_movimientos = null;
typed_lista_movimientos = em.createQuery(query_lista_movimientos, MovimientosLog.class);
typed_lista_movimientos.setParameter(1, prospectus_id);
typed_lista_movimientos.setParameter(2, company_id);
lista_movimientos = typed_lista_movimientos.getResultList();
} catch(Exception e) {
e.printStackTrace();
}
return lista_movimientos;
}
}
| 1,683 | 0.714201 | 0.712418 | 72 | 22.375 | 25.448442 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.125 | false | false | 9 |
da02019b308fa0e66988f72c0985bd4c71d670f0 | 30,923,764,576,144 | 631793bcc3b495c47bd76780426010014ddfb2dc | /IdeaProjects/publicapi/src/main/java/net/okdi/apiV3/controller/PhoneRecordController.java | 13e2beff24bb06a265ac91a12ecd0fd00f8a38e9 | [] | no_license | moutainhigh/communityapi | https://github.com/moutainhigh/communityapi | 15cb8f23aec0e95b380df2958f963a505ba55dde | 614ffb1329618987b89b8e4bbcb2a650f8bcfe22 | refs/heads/master | 2021-06-14T00:03:42.445000 | 2017-04-01T06:10:10 | 2017-04-01T06:10:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.okdi.apiV3.controller;
import java.util.Map;
import net.okdi.apiV3.service.PhoneRecordService;
import net.okdi.core.base.BaseController;
import net.okdi.core.util.PubMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/phoneRecord")
public class PhoneRecordController extends BaseController {
@Autowired
PhoneRecordService phoneRecordService;
/**
* @api {post} /phoneRecord/savePhoneRecord 保存电话记录
* @apiVersion 0.3.0
* @apiDescription 保存电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} sendPhone 发送者电话
* @apiParam {String} receivePhone 接收者电话
* @apiParam {String} flag 标识 1:本机电话 2:两端呼
* @apiSampleRequest /phoneRecord/savePhoneRecord
* @apiSuccessExample Success-Response:
HTTP/1.1 200 OK
* {"success":"true"}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/savePhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String savePhoneRecord(String sendPhone,String receivePhone,String flag) {
System.out.println("进入public");
if(PubMethod.isEmpty(sendPhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","sendPhone不能为空!");
}
if(PubMethod.isEmpty(receivePhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","receivePhone不能为空!");
}
if(PubMethod.isEmpty(receivePhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","flag不能为空!");
}
try{
return phoneRecordService.savePhoneRecord(sendPhone,receivePhone,flag);
}catch(RuntimeException re){
re.printStackTrace();
return this.jsonFailure(re);
}
}
/**
* @api {post} /phoneRecord/queryPhoneRecord 查询电话记录
* @apiVersion 0.3.0
* @apiDescription 查询电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} receivePhone 接收者电话
* @apiParam {String} sendPhone 发送者手机号
* @apiParam {Integer} currentPage
* @apiParam {Integer} pageSize
* @apiSampleRequest /phoneRecord/queryPhoneRecord
* @apiSuccess {Long} totalCount
* @apiSuccess {String} id
* @apiSuccess {String} sendPhone 发送者手机号
* @apiSuccess {String} receivePhone 接收者电话
* @apiSuccess {String} startTime
* @apiSuccess {String} flag 标识 1:本机电话 2:两端呼
* @apiSuccess {String} duration 时长
* @apiSuccess {String} fee 费用
* @apiSuccessExample Success-Response:
{"data":
* {"totalCount":1,
* "list":[{
* "id":"5705d31b47050604c721c21d",
* "startTime":"1460027688122",
* "receivePhone":"13521283934"
* "flag":"1",
* "duration":"",
* "fee":""
* }]},"success":true}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/queryPhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String queryPhoneRecord(String sendPhone,String receivePhone, Integer currentPage, Integer pageSize) {
if(PubMethod.isEmpty(currentPage)){
currentPage = 1;
}
if(PubMethod.isEmpty(pageSize)){
pageSize = 10;
}
try{
return phoneRecordService.queryPhoneRecord(sendPhone,receivePhone,currentPage,pageSize);
}catch(RuntimeException re){
return this.jsonFailure(re);
}
}
/**
* @api {post} /phoneRecord/deletePhoneRecord 删除电话记录
* @apiVersion 0.3.0
* @apiDescription 删除电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} id
* @apiSampleRequest /phoneRecord/deletePhoneRecord
* @apiSuccessExample Success-Response:
HTTP/1.1 200 OK
* {"success":"true"}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/deletePhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String deletePhoneRecord(String id) {
if(PubMethod.isEmpty(id)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.deletePhoneRecord","id不能为空!");
}
try{
return phoneRecordService.deletePhoneRecord(id);
}catch(RuntimeException re){
re.printStackTrace();
return this.jsonFailure(re);
}
}
} | UTF-8 | Java | 5,037 | java | PhoneRecordController.java | Java | [] | null | [] | package net.okdi.apiV3.controller;
import java.util.Map;
import net.okdi.apiV3.service.PhoneRecordService;
import net.okdi.core.base.BaseController;
import net.okdi.core.util.PubMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/phoneRecord")
public class PhoneRecordController extends BaseController {
@Autowired
PhoneRecordService phoneRecordService;
/**
* @api {post} /phoneRecord/savePhoneRecord 保存电话记录
* @apiVersion 0.3.0
* @apiDescription 保存电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} sendPhone 发送者电话
* @apiParam {String} receivePhone 接收者电话
* @apiParam {String} flag 标识 1:本机电话 2:两端呼
* @apiSampleRequest /phoneRecord/savePhoneRecord
* @apiSuccessExample Success-Response:
HTTP/1.1 200 OK
* {"success":"true"}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/savePhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String savePhoneRecord(String sendPhone,String receivePhone,String flag) {
System.out.println("进入public");
if(PubMethod.isEmpty(sendPhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","sendPhone不能为空!");
}
if(PubMethod.isEmpty(receivePhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","receivePhone不能为空!");
}
if(PubMethod.isEmpty(receivePhone)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.queryPhoneRecord","flag不能为空!");
}
try{
return phoneRecordService.savePhoneRecord(sendPhone,receivePhone,flag);
}catch(RuntimeException re){
re.printStackTrace();
return this.jsonFailure(re);
}
}
/**
* @api {post} /phoneRecord/queryPhoneRecord 查询电话记录
* @apiVersion 0.3.0
* @apiDescription 查询电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} receivePhone 接收者电话
* @apiParam {String} sendPhone 发送者手机号
* @apiParam {Integer} currentPage
* @apiParam {Integer} pageSize
* @apiSampleRequest /phoneRecord/queryPhoneRecord
* @apiSuccess {Long} totalCount
* @apiSuccess {String} id
* @apiSuccess {String} sendPhone 发送者手机号
* @apiSuccess {String} receivePhone 接收者电话
* @apiSuccess {String} startTime
* @apiSuccess {String} flag 标识 1:本机电话 2:两端呼
* @apiSuccess {String} duration 时长
* @apiSuccess {String} fee 费用
* @apiSuccessExample Success-Response:
{"data":
* {"totalCount":1,
* "list":[{
* "id":"5705d31b47050604c721c21d",
* "startTime":"1460027688122",
* "receivePhone":"13521283934"
* "flag":"1",
* "duration":"",
* "fee":""
* }]},"success":true}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/queryPhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String queryPhoneRecord(String sendPhone,String receivePhone, Integer currentPage, Integer pageSize) {
if(PubMethod.isEmpty(currentPage)){
currentPage = 1;
}
if(PubMethod.isEmpty(pageSize)){
pageSize = 10;
}
try{
return phoneRecordService.queryPhoneRecord(sendPhone,receivePhone,currentPage,pageSize);
}catch(RuntimeException re){
return this.jsonFailure(re);
}
}
/**
* @api {post} /phoneRecord/deletePhoneRecord 删除电话记录
* @apiVersion 0.3.0
* @apiDescription 删除电话记录
* @apiGroup ACCOUNT 拨打电话
* @apiParam {String} id
* @apiSampleRequest /phoneRecord/deletePhoneRecord
* @apiSuccessExample Success-Response:
HTTP/1.1 200 OK
* {"success":"true"}
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "success": false,
* "errCode": "err.001",
* "message":"XXX"
* }
*/
@ResponseBody
@RequestMapping(value = "/deletePhoneRecord", method = {RequestMethod.GET , RequestMethod.POST })
public String deletePhoneRecord(String id) {
if(PubMethod.isEmpty(id)){
return PubMethod.paramError("net.okdi.apiV3.controller.PhoneRecordController.deletePhoneRecord","id不能为空!");
}
try{
return phoneRecordService.deletePhoneRecord(id);
}catch(RuntimeException re){
re.printStackTrace();
return this.jsonFailure(re);
}
}
} | 5,037 | 0.686365 | 0.665275 | 153 | 30.30719 | 25.939417 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.777778 | false | false | 9 |
7ac8ed0705becbf625ef27e443efe1452aeb8729 | 2,388,001,865,635 | 73f814d3f7ec59573d02df534c1c4769b087c6a4 | /src/main/java/com/scalar/cassy/db/BackupHistoryRecord.java | b0df049619d1dd27163c834b08c937ce5e061b40 | [
"Apache-2.0"
] | permissive | scalar-labs/cassy | https://github.com/scalar-labs/cassy | a7ffc2eeae0c2205175836e59a90e7400478764c | 6ab1212d6ca1b2e2b531f1d758dcac34a6a57404 | refs/heads/master | 2023-01-24T05:58:08.995000 | 2021-06-11T00:45:38 | 2021-06-11T00:45:38 | 188,148,541 | 45 | 4 | Apache-2.0 | false | 2023-01-05T18:38:39 | 2019-05-23T02:39:57 | 2023-01-04T00:58:52 | 2023-01-05T18:38:37 | 9,977 | 40 | 3 | 19 | Java | false | false | package com.scalar.cassy.db;
import static com.google.common.base.Preconditions.checkArgument;
import com.scalar.cassy.config.BackupType;
import com.scalar.cassy.rpc.OperationStatus;
import javax.annotation.concurrent.Immutable;
@Immutable
public final class BackupHistoryRecord {
private final String snapshotId;
private final String clusterId;
private final String targetIp;
private final BackupType backupType;
private final long createdAt;
private final long updatedAt;
private final OperationStatus status;
private BackupHistoryRecord(Builder builder) {
this.snapshotId = builder.snapshotId;
this.clusterId = builder.clusterId;
this.targetIp = builder.targetIp;
this.backupType = builder.backupType;
this.createdAt = builder.createdAt;
this.updatedAt = builder.updatedAt;
this.status = builder.status;
}
public String getSnapshotId() {
return snapshotId;
}
public String getClusterId() {
return clusterId;
}
public String getTargetIp() {
return targetIp;
}
public BackupType getBackupType() {
return backupType;
}
public long getCreatedAt() {
return createdAt;
}
public long getUpdatedAt() {
return updatedAt;
}
public OperationStatus getStatus() {
return status;
}
public static Builder newBuilder() {
return new Builder();
}
public static final class Builder {
private String snapshotId;
private String clusterId;
private String targetIp;
private BackupType backupType;
private long createdAt;
private long updatedAt;
private OperationStatus status;
public Builder snapshotId(String snapshotId) {
checkArgument(snapshotId != null);
this.snapshotId = snapshotId;
return this;
}
public Builder clusterId(String clusterId) {
checkArgument(clusterId != null);
this.clusterId = clusterId;
return this;
}
public Builder targetIp(String targetIp) {
checkArgument(targetIp != null);
this.targetIp = targetIp;
return this;
}
public Builder backupType(BackupType backupType) {
checkArgument(backupType != null);
this.backupType = backupType;
return this;
}
public Builder createdAt(long createdAt) {
checkArgument(createdAt != 0L);
this.createdAt = createdAt;
return this;
}
public Builder updatedAt(long updatedAt) {
checkArgument(updatedAt != 0L);
this.updatedAt = updatedAt;
return this;
}
public Builder status(OperationStatus status) {
checkArgument(status != null);
this.status = status;
return this;
}
public BackupHistoryRecord build() {
if (snapshotId == null
|| clusterId == null
|| targetIp == null
|| backupType == null
|| createdAt == 0L
|| updatedAt == 0L
|| status == null) {
throw new IllegalArgumentException("Required fields are not given.");
}
return new BackupHistoryRecord(this);
}
}
}
| UTF-8 | Java | 3,043 | java | BackupHistoryRecord.java | Java | [] | null | [] | package com.scalar.cassy.db;
import static com.google.common.base.Preconditions.checkArgument;
import com.scalar.cassy.config.BackupType;
import com.scalar.cassy.rpc.OperationStatus;
import javax.annotation.concurrent.Immutable;
@Immutable
public final class BackupHistoryRecord {
private final String snapshotId;
private final String clusterId;
private final String targetIp;
private final BackupType backupType;
private final long createdAt;
private final long updatedAt;
private final OperationStatus status;
private BackupHistoryRecord(Builder builder) {
this.snapshotId = builder.snapshotId;
this.clusterId = builder.clusterId;
this.targetIp = builder.targetIp;
this.backupType = builder.backupType;
this.createdAt = builder.createdAt;
this.updatedAt = builder.updatedAt;
this.status = builder.status;
}
public String getSnapshotId() {
return snapshotId;
}
public String getClusterId() {
return clusterId;
}
public String getTargetIp() {
return targetIp;
}
public BackupType getBackupType() {
return backupType;
}
public long getCreatedAt() {
return createdAt;
}
public long getUpdatedAt() {
return updatedAt;
}
public OperationStatus getStatus() {
return status;
}
public static Builder newBuilder() {
return new Builder();
}
public static final class Builder {
private String snapshotId;
private String clusterId;
private String targetIp;
private BackupType backupType;
private long createdAt;
private long updatedAt;
private OperationStatus status;
public Builder snapshotId(String snapshotId) {
checkArgument(snapshotId != null);
this.snapshotId = snapshotId;
return this;
}
public Builder clusterId(String clusterId) {
checkArgument(clusterId != null);
this.clusterId = clusterId;
return this;
}
public Builder targetIp(String targetIp) {
checkArgument(targetIp != null);
this.targetIp = targetIp;
return this;
}
public Builder backupType(BackupType backupType) {
checkArgument(backupType != null);
this.backupType = backupType;
return this;
}
public Builder createdAt(long createdAt) {
checkArgument(createdAt != 0L);
this.createdAt = createdAt;
return this;
}
public Builder updatedAt(long updatedAt) {
checkArgument(updatedAt != 0L);
this.updatedAt = updatedAt;
return this;
}
public Builder status(OperationStatus status) {
checkArgument(status != null);
this.status = status;
return this;
}
public BackupHistoryRecord build() {
if (snapshotId == null
|| clusterId == null
|| targetIp == null
|| backupType == null
|| createdAt == 0L
|| updatedAt == 0L
|| status == null) {
throw new IllegalArgumentException("Required fields are not given.");
}
return new BackupHistoryRecord(this);
}
}
}
| 3,043 | 0.674335 | 0.67302 | 125 | 23.344 | 17.407633 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.552 | false | false | 9 |
9cdf2d90ad4ee8c3b31192c438961ec257593875 | 13,400,297,999,613 | f1103e383f37e9e2f3695cbe6475d8a4cc8416ea | /DoctorAlpes/app/models/EmergenciaEntity.java | 4e4ff932dc5b45a877f8ac5b5add681b55c2fa1d | [
"Apache-2.0"
] | permissive | ajparedes10/arquisoft | https://github.com/ajparedes10/arquisoft | 140cfaec7d6b7b22097fb73c11be1c6a8c118cae | 19a3a53163a41315c9103981960ace2b89e6b717 | refs/heads/master | 2021-01-22T10:07:22.657000 | 2017-05-01T20:16:19 | 2017-05-01T20:16:19 | 81,987,093 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package models;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.avaje.ebean.Model;
import javax.persistence.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by aj.paredes10 on 14/02/2017.
*/
@Entity
@Table(name="emergenciaEntity")
public class EmergenciaEntity extends Model {
public static Finder<Long, EmergenciaEntity> FINDER = new Finder<>(EmergenciaEntity.class);
@Id
@GeneratedValue(strategy= GenerationType.SEQUENCE,generator = "Emergencia")
private Long id;
private String descripcion;
private Date fecha;
private String ubicacion;
@ManyToOne
@JsonBackReference(value="r8")
private PacienteEntity paciente;
@ManyToOne
@JsonBackReference(value="r10")
private HistorialClinicoEntity historialClinico;
public EmergenciaEntity()
{
id=null;
descripcion="NO NAME";
fecha=null;
ubicacion="NO NAME";
}
public EmergenciaEntity(Long id)
{
this();
setId(id);
}
public EmergenciaEntity(Long id, String descripcion, String ubicacion)
{
this();
setId(id);
setDescripcion(descripcion);
setFecha(new Date());
setUbicacion(ubicacion);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public String getUbicacion() {
return ubicacion;
}
public void setUbicacion(String ubicacion) {
this.ubicacion = ubicacion;
}
public PacienteEntity getPaciente() {
return paciente;
}
public void setPaciente(PacienteEntity paciente) {
this.paciente = paciente;
}
public HistorialClinicoEntity getHistorialClinico() {
return historialClinico;
}
public void setHistorialClinico(HistorialClinicoEntity historialClinico) {
this.historialClinico = historialClinico;
}
}
| UTF-8 | Java | 2,248 | java | EmergenciaEntity.java | Java | [
{
"context": "eFormat;\nimport java.util.Date;\n\n/**\n * Created by aj.paredes10 on 14/02/2017.\n */\n\n@Entity\n@Table(name=\"emergenc",
"end": 224,
"score": 0.9993617534637451,
"start": 212,
"tag": "USERNAME",
"value": "aj.paredes10"
}
] | null | [] | package models;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.avaje.ebean.Model;
import javax.persistence.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by aj.paredes10 on 14/02/2017.
*/
@Entity
@Table(name="emergenciaEntity")
public class EmergenciaEntity extends Model {
public static Finder<Long, EmergenciaEntity> FINDER = new Finder<>(EmergenciaEntity.class);
@Id
@GeneratedValue(strategy= GenerationType.SEQUENCE,generator = "Emergencia")
private Long id;
private String descripcion;
private Date fecha;
private String ubicacion;
@ManyToOne
@JsonBackReference(value="r8")
private PacienteEntity paciente;
@ManyToOne
@JsonBackReference(value="r10")
private HistorialClinicoEntity historialClinico;
public EmergenciaEntity()
{
id=null;
descripcion="NO NAME";
fecha=null;
ubicacion="NO NAME";
}
public EmergenciaEntity(Long id)
{
this();
setId(id);
}
public EmergenciaEntity(Long id, String descripcion, String ubicacion)
{
this();
setId(id);
setDescripcion(descripcion);
setFecha(new Date());
setUbicacion(ubicacion);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public String getUbicacion() {
return ubicacion;
}
public void setUbicacion(String ubicacion) {
this.ubicacion = ubicacion;
}
public PacienteEntity getPaciente() {
return paciente;
}
public void setPaciente(PacienteEntity paciente) {
this.paciente = paciente;
}
public HistorialClinicoEntity getHistorialClinico() {
return historialClinico;
}
public void setHistorialClinico(HistorialClinicoEntity historialClinico) {
this.historialClinico = historialClinico;
}
}
| 2,248 | 0.651246 | 0.645463 | 104 | 20.615385 | 20.373583 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 9 |
081ad7d099337d7027967fa952efcc2e0dc8dc61 | 26,920,855,049,184 | e28f5dc0c764ee34598d3d8e754746ab93ea6a40 | /paper/src/main/java/com/denizenscript/denizen/paper/events/ExperienceOrbMergeScriptEvent.java | 4444187ab91611e6de362fdd432b63ff9de59ac9 | [
"MIT"
] | permissive | unizenscript/Denizen-For-Bukkit | https://github.com/unizenscript/Denizen-For-Bukkit | 3caa35f3428cc9127750e57dc140c8026c6386cb | 2fda0d65d253924d3b4491de62739e4159afd3fd | refs/heads/dev | 2021-06-25T09:49:08.553000 | 2020-06-15T18:09:13 | 2020-06-15T18:09:13 | 190,183,661 | 3 | 6 | NOASSERTION | true | 2020-06-15T18:09:14 | 2019-06-04T10:56:05 | 2020-04-16T17:48:40 | 2020-06-15T18:09:14 | 37,942 | 3 | 4 | 26 | Java | false | false | package com.denizenscript.denizen.paper.events;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.destroystokyo.paper.event.entity.ExperienceOrbMergeEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ExperienceOrbMergeScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// experience orbs merge
//
// @Regex ^on experience orbs merge$
//
// @Switch in:<area> to only process the event if it occurred within a specified area.
//
// @Plugin Paper
//
// @Cancellable true
//
// @Triggers when two experience orbs are about to merge.
//
// @Context
// <context.target> returns the EntityTag of the orb that will absorb the other experience orb.
// <context.source> returns the EntityTag of the orb that will be removed and merged into the target.
//
// -->
public ExperienceOrbMergeScriptEvent() {
instance = this;
}
public static ExperienceOrbMergeScriptEvent instance;
public ExperienceOrbMergeEvent event;
@Override
public boolean couldMatch(ScriptPath path) {
return path.eventLower.startsWith("experience orbs merge");
}
@Override
public boolean matches(ScriptPath path) {
if (!runInCheck(path, event.getMergeTarget().getLocation())) {
return false;
}
return super.matches(path);
}
@Override
public String getName() {
return "ExperienceOrbsMerge";
}
@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(null, null);
}
@Override
public ObjectTag getContext(String name) {
if (name.equals("target")) {
return new EntityTag(event.getMergeTarget());
}
else if (name.equals("source")) {
return new EntityTag(event.getMergeSource());
}
return super.getContext(name);
}
@EventHandler
public void experienceOrbsMerge(ExperienceOrbMergeEvent event) {
this.event = event;
Entity target = event.getMergeTarget();
EntityTag.rememberEntity(target);
fire(event);
EntityTag.forgetEntity(target);
}
}
| UTF-8 | Java | 2,631 | java | ExperienceOrbMergeScriptEvent.java | Java | [] | null | [] | package com.denizenscript.denizen.paper.events;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.destroystokyo.paper.event.entity.ExperienceOrbMergeEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ExperienceOrbMergeScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// experience orbs merge
//
// @Regex ^on experience orbs merge$
//
// @Switch in:<area> to only process the event if it occurred within a specified area.
//
// @Plugin Paper
//
// @Cancellable true
//
// @Triggers when two experience orbs are about to merge.
//
// @Context
// <context.target> returns the EntityTag of the orb that will absorb the other experience orb.
// <context.source> returns the EntityTag of the orb that will be removed and merged into the target.
//
// -->
public ExperienceOrbMergeScriptEvent() {
instance = this;
}
public static ExperienceOrbMergeScriptEvent instance;
public ExperienceOrbMergeEvent event;
@Override
public boolean couldMatch(ScriptPath path) {
return path.eventLower.startsWith("experience orbs merge");
}
@Override
public boolean matches(ScriptPath path) {
if (!runInCheck(path, event.getMergeTarget().getLocation())) {
return false;
}
return super.matches(path);
}
@Override
public String getName() {
return "ExperienceOrbsMerge";
}
@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(null, null);
}
@Override
public ObjectTag getContext(String name) {
if (name.equals("target")) {
return new EntityTag(event.getMergeTarget());
}
else if (name.equals("source")) {
return new EntityTag(event.getMergeSource());
}
return super.getContext(name);
}
@EventHandler
public void experienceOrbsMerge(ExperienceOrbMergeEvent event) {
this.event = event;
Entity target = event.getMergeTarget();
EntityTag.rememberEntity(target);
fire(event);
EntityTag.forgetEntity(target);
}
}
| 2,631 | 0.661345 | 0.661345 | 84 | 29.321428 | 26.403084 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
8adb8fe314dce91d75082e225b1fe540e87721ea | 23,476,291,303,784 | 40e706b1aa65dd4e0824b7175419deab5404730d | /PL08/Ex1.java | ff908549cdcb5f90ac6bb1a13635c615fb9a6a42 | [
"MIT"
] | permissive | cortereal00/ISEP-APROG | https://github.com/cortereal00/ISEP-APROG | 3fac5366f472e2352cf85da8c167a19f195d47c9 | d791fd393bd1343c8f0383637740bf4d9abf7795 | refs/heads/master | 2022-02-23T11:26:29.470000 | 2019-09-14T18:41:02 | 2019-09-14T18:41:02 | 208,485,281 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package xxsd.aprog.pl08;
import java.util.Formatter;
/**
* @author Gonçalo Corte Real <1180793@isep.ipp.pt>
*/
public class Ex1 {
public static Formatter formatter = new Formatter(System.out);
public static void main(String[] args) {
int m[][] = {{1, 4, 2, 1}, {9, 7, 2, 2}, {1, 7, 3, 5}, {2, 5, 0, 3}, {4, 7, 2, 5}};
formatter.format("%n%nMatriz:%n");
printMatriz(m);
enigma(m);
calcularMediaColuna(m);
int[][] tmatrix = getMatrizTransposta(m);
formatter.format("%n%nMatriz Transposta:%n");
printMatriz(tmatrix);
}
/*
* Este método mostra o maior valor de cada linha da matriz.
*/
public static void enigma(int[][] m) {
int x;
for (int i = 0; i < m.length; i++) {
x = m[i][0];
for (int j = 1; j < m[i].length; j++) {
if (m[i][j] > x) {
x = m[i][j];
}
}
formatter.format("%d%n", x);
}
}
public static void printMatriz(int[][] m) {
for (int i = 0; i < m.length; i++) {
String line = "";
for (int j = 0; j < m[i].length; j++) {
line += m[i][j] + ((j < m[i].length - 1) ? " " : "");
}
formatter.format("%s%n", line);
}
}
public static void calcularMediaColuna(int[][] m) {
for (int i = 0; i < m.length; i++) {
int soma = 0;
for (int j = 0; j < m[i].length; j++) {
soma += m[i][j];
}
double media = (double) soma / m[i].length;
formatter.format("%nMédia da %dª coluna: %.2f", i + 1, media);
}
}
public static int[][] getMatrizTransposta(int[][] m) {
int[][] matrizTransposta = new int[m[0].length][m.length];
for (int i = 0; i < m[i].length; i++) {
for (int j = 0; j < m.length; j++) {
matrizTransposta[i][j] = m[j][i];
}
}
return matrizTransposta;
}
}
| UTF-8 | Java | 2,541 | java | Ex1.java | Java | [
{
"context": "pl08;\n\nimport java.util.Formatter;\n\n/**\n * @author Gonçalo Corte Real <1180793@isep.ipp.pt>\n */\npublic class Ex1 {\n\n ",
"end": 88,
"score": 0.9998639225959778,
"start": 70,
"tag": "NAME",
"value": "Gonçalo Corte Real"
},
{
"context": "il.Formatter;\n\n/**\n *... | null | [] | package xxsd.aprog.pl08;
import java.util.Formatter;
/**
* @author <NAME> <<EMAIL>>
*/
public class Ex1 {
public static Formatter formatter = new Formatter(System.out);
public static void main(String[] args) {
int m[][] = {{1, 4, 2, 1}, {9, 7, 2, 2}, {1, 7, 3, 5}, {2, 5, 0, 3}, {4, 7, 2, 5}};
formatter.format("%n%nMatriz:%n");
printMatriz(m);
enigma(m);
calcularMediaColuna(m);
int[][] tmatrix = getMatrizTransposta(m);
formatter.format("%n%nMatriz Transposta:%n");
printMatriz(tmatrix);
}
/*
* Este método mostra o maior valor de cada linha da matriz.
*/
public static void enigma(int[][] m) {
int x;
for (int i = 0; i < m.length; i++) {
x = m[i][0];
for (int j = 1; j < m[i].length; j++) {
if (m[i][j] > x) {
x = m[i][j];
}
}
formatter.format("%d%n", x);
}
}
public static void printMatriz(int[][] m) {
for (int i = 0; i < m.length; i++) {
String line = "";
for (int j = 0; j < m[i].length; j++) {
line += m[i][j] + ((j < m[i].length - 1) ? " " : "");
}
formatter.format("%s%n", line);
}
}
public static void calcularMediaColuna(int[][] m) {
for (int i = 0; i < m.length; i++) {
int soma = 0;
for (int j = 0; j < m[i].length; j++) {
soma += m[i][j];
}
double media = (double) soma / m[i].length;
formatter.format("%nMédia da %dª coluna: %.2f", i + 1, media);
}
}
public static int[][] getMatrizTransposta(int[][] m) {
int[][] matrizTransposta = new int[m[0].length][m.length];
for (int i = 0; i < m[i].length; i++) {
for (int j = 0; j < m.length; j++) {
matrizTransposta[i][j] = m[j][i];
}
}
return matrizTransposta;
}
}
| 2,516 | 0.361056 | 0.343713 | 69 | 35.768116 | 25.290855 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.927536 | false | false | 9 |
6dc8be32102ba93c641aabc203f7562c5d6428f3 | 16,844,861,736,915 | 371b6c6e7074122e3fa694c4f2d68dace995c4d8 | /paparazzi-simulator/src/main/java/juav/autopilot/gps/IGpsNps.java | 472726f17ea7b0ad09c9abca7748d82ab07ccd79 | [] | no_license | adamczer/pappa | https://github.com/adamczer/pappa | fdea798fe368af36656ec075ed1372255b32510a | fad31887d47da77d3ce46f8b4c2bc0bb9145407f | refs/heads/master | 2021-01-16T22:30:56.636000 | 2016-07-02T01:20:43 | 2016-07-02T01:20:43 | 38,985,015 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package juav.autopilot.gps;
import juav.simulator.tasks.sensors.readings.GpsReading;
/**
* Created by adamczer on 6/1/16.
*/
public interface IGpsNps {
void gpsFeedValue(GpsReading reading);
}
| UTF-8 | Java | 201 | java | IGpsNps.java | Java | [
{
"context": "ks.sensors.readings.GpsReading;\n\n/**\n * Created by adamczer on 6/1/16.\n */\npublic interface IGpsNps {\n voi",
"end": 113,
"score": 0.999643862247467,
"start": 105,
"tag": "USERNAME",
"value": "adamczer"
}
] | null | [] | package juav.autopilot.gps;
import juav.simulator.tasks.sensors.readings.GpsReading;
/**
* Created by adamczer on 6/1/16.
*/
public interface IGpsNps {
void gpsFeedValue(GpsReading reading);
}
| 201 | 0.746269 | 0.726368 | 10 | 19.1 | 19.403351 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 9 |
ed446b078025ac595bb1c091e366375fd1bf9418 | 16,595,753,681,998 | cbcc0d2e44e3f613b8a87fad46800014f8a05f4f | /config/src/main/java/com/vijayrc/supportguy/domain/Scm.java | 6954154ada23b363c83cfcfa3e7316492c8b6355 | [] | no_license | reachkrishnaraj/logline | https://github.com/reachkrishnaraj/logline | a063554d76fb94c5636fa3a6007574d03d9c113b | addc9ff9f5aa3bbe650229207abc5c443148f9ea | refs/heads/master | 2020-12-31T04:06:28.866000 | 2015-03-15T12:58:44 | 2015-03-15T12:58:44 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vijayrc.supportguy.domain;
import lombok.Data;
import static com.vijayrc.supportguy.util.Util.fileSeparator;
import static com.vijayrc.supportguy.util.Util.userDir;
@Data
public class Scm {
private String name;
private String location;
private String type;
public String getFileFor(String peerFile) {
return location + peerFile.replace(userDir() + "config" + fileSeparator(), "");
}
}
| UTF-8 | Java | 452 | java | Scm.java | Java | [] | null | [] | package com.vijayrc.supportguy.domain;
import lombok.Data;
import static com.vijayrc.supportguy.util.Util.fileSeparator;
import static com.vijayrc.supportguy.util.Util.userDir;
@Data
public class Scm {
private String name;
private String location;
private String type;
public String getFileFor(String peerFile) {
return location + peerFile.replace(userDir() + "config" + fileSeparator(), "");
}
}
| 452 | 0.692478 | 0.692478 | 20 | 20.6 | 24.650354 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45 | false | false | 9 |
31201e91714fe53d241efb23c174ed5582cb9778 | 24,575,802,867,733 | 045815d70ebfa6365f54ca4d0ed743036d632196 | /process-services/src/com/process/services/rest/aop/InterceptorAuthorizationMule.java | 9b45c7e35a9ce159fb616f93e70c662d2e7ae103 | [] | no_license | processsuite/JavaRestProcess | https://github.com/processsuite/JavaRestProcess | 81e92d96ec3fb39511b84b9e268b9cce37df3e26 | 2a12d621470c892622e39654af368c0facd92f0e | refs/heads/master | 2023-05-26T16:24:27.829000 | 2023-05-17T12:22:55 | 2023-05-17T12:22:55 | 253,565,081 | 0 | 0 | null | false | 2020-06-25T21:06:56 | 2020-04-06T17:11:07 | 2020-06-23T19:06:08 | 2020-06-25T21:06:55 | 628 | 0 | 0 | 2 | Java | false | false | /**
* InterceptorAuthorizationMule.java
*
*/
package com.process.services.rest.aop;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.core.Response;
import org.apache.log4j.Logger;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.interceptor.AbstractEnvelopeInterceptor;
import org.mule.management.stats.ProcessingTime;
import com.process.business.helper.BasicAuth;
import com.process.business.helper.ClassFactory;
import com.process.business.helper.ProcessEngine;
import com.process.business.helper.c_Process;
/**
* Interceptor Authorization MULE ESB
* @author Oswel Sanchez
*
*/
public class InterceptorAuthorizationMule extends AbstractEnvelopeInterceptor {
private static final Logger logger = Logger.getLogger(InterceptorAuthorizationMule.class);
@Override
public MuleEvent after(MuleEvent arg0) throws MuleException {
try{
cerrarSession(arg0);
}catch(Exception e){
logger.error("after", e);
}
return arg0;
}
@Override
public MuleEvent before(MuleEvent arg0) throws MuleException {
String varTicket = "";
if (arg0.getMessage().getInboundProperty("http.method")!="OPTIONS"){//verifica si el servicio es un metodo option para que no ingrese en la validacion del token
if (arg0.getMessage().getInboundProperty("authorization")==null){ //verifica si tiene cabecera de autorizacion
throw new NotAuthorizedException("Missing Credentials", Response.Status.UNAUTHORIZED);
}else if (arg0.getMessage().getInboundProperty("authorization").toString()==""){//verifica si tiene cabecera de autorizacion
throw new NotAuthorizedException("Missing Credentials", Response.Status.UNAUTHORIZED);
}else if (!arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ") && !arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Basic ")){//verifica que la cabecera de autorizacion tenga berear o basic
throw new NotAuthorizedException("Wrong Sheme.", Response.Status.UNAUTHORIZED);
}else if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ")){//validacion si es para validar ticket o para iniciar sesion
Integer result = 0;
try{
varTicket = BasicAuth.decodeParameter(arg0.getMessage().getInboundProperty("authorization").toString());
result = obtenerSession(varTicket);
}catch(Exception e){
logger.error("decodificar parametros", e);
}
if (result == 0) {
throw new NotAuthorizedException("Ticket Credentials Invalid.", Response.Status.UNAUTHORIZED);
}else{
arg0.getMessage().setOutboundProperty("engineId", result);
}
//logger.info("servicio llamado: "+arg0.getMessage().getInboundProperty("http.relative.path").toString()+" "+arg0.getMessage().getInboundProperty("authorization").toString() );
//logger.info("Ticket de entrada para el servicio:( " + arg0.getMessage().getInboundProperty("authorization").toString() + ")");
}else{
if(arg0.getMessage().getInboundProperty("authorization").toString().length() < 125) {
ProcessEngine process = new ProcessEngine();
c_Process motor = ClassFactory.createProcess();
process.setEngine(motor);
varTicket = BasicAuth.decodeParameter(arg0.getMessage().getInboundProperty("authorization").toString());
process.setTicket(varTicket);
ClassFactory.getListProcess().add(process);//add engine to list
//logger.info("Inicio de sesion "+BasicAuth.decode(varTicket)[0] +" hash "+motor.hashCode() );
arg0.getMessage().setOutboundProperty("engineId", motor.hashCode());
}else {
ClassFactory.setErrorCode(406);
//logger.info("Autorizacion excede cantidad de caracteres permitida");
}
}
}
return arg0;
}
@Override
public MuleEvent last(MuleEvent arg0, ProcessingTime arg1, long arg2, boolean arg3) throws MuleException {
return arg0;
}
private synchronized Integer obtenerSession(String ticket) throws InterruptedException{
Integer result = 0;
ProcessEngine process = new ProcessEngine(); //Objeto que relaciona motor con token
c_Process motor = ClassFactory.createProcess(); //Objeto para inicar motor
process.setEngine(motor);//Guarda el objeto inicializado del motor
process.setTicket(ticket);//Guarda la relacion del token con el motor iniciado
if (ClassFactory.isTicketList(ticket)){//Verifica que el ticket Exista en el arreglo de ticket abiertos
result = motor.p4bObtenerSesionUnica(ticket,0);
}else{
result = motor.p4bObtenerSesion(ticket,0);
//result = motor.p4bObtenerSesionUnica(ticket,0);
//logger.info("No existe token "+ticket+" hash "+motor.hashCode());
}
if (result!=0){
ClassFactory.getListProcess().add(process);//add engine to list
result = motor.hashCode();
//logger.info("Get session engine to list:(" + result + ")");
}
//logger.info("Get session engineId to list:(" + result + ")");
return result;
}
private synchronized void cerrarSession(MuleEvent arg0) throws InterruptedException{//usado para guardar session y cerrar session segun sea el caso
Integer errorCode = ClassFactory.getErrorCode();
if (arg0.getMessage().getInboundProperty("authorization")!=null){
if(arg0.getMessage().getOutboundProperty("engineId") != null) {
c_Process motor = ClassFactory.getProcess(Integer.valueOf(arg0.getMessage().getOutboundProperty("engineId").toString()));
//validar si hay Error Process se informa
Integer result = motor.p4bStatus();
if (result!=0){
logger.info("result "+result+" "+arg0.getMessage().getInboundProperty("authorization").toString());
//arg0.getMessage().setOutboundProperty("http.status", result);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", result);
}else if (errorCode!=0){
//arg0.getMessage().setOutboundProperty("http.status", errorCode);
logger.info("errorCode "+errorCode+" "+arg0.getMessage().getInboundProperty("authorization").toString());
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", errorCode);
}
/*if(arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("abrir1")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("crearDocumento")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("destinos")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("document")>0) {
try {
logger.info("respuesta de servicio: "+arg0.getMessage().getInboundProperty("http.relative.path").toString()+" Parametros de servicio "+arg0.getMessage().getInboundProperty("http.query.params").toString()+" Respúesta "+arg0.getMessage().getPayloadAsString()+" hash: "+motor.hashCode() +" Token "+arg0.getMessage().getInboundProperty("authorization").toString()+" status "+ arg0.getMessage().getOutboundProperty("http.status").toString());
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Error path ",e);
}
}*/
//validar que estamos cerrando session para no llamar al guardar session.
if ((arg0.getMessage().getInboundProperty("http.method")=="DELETE") && (arg0.getMessage().getInboundProperty("http.relative.path").toString().equals("/process/api/sessions"))){
//logger.info("End session:"+arg0.getMessage().getOutboundProperty("engineId").toString());
}else{
if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ")){
//String ticket = motor.p4bGuardarSesion(0);
String ticket = motor.p4bGuardarSesionUnica(0);
arg0.getMessage().setOutboundProperty("Ticket", ticket);
}else if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Basic ")){
//String ticket = motor.p4bGuardarSesion(0);
String ticket = motor.p4bGuardarSesionUnica(0);
arg0.getMessage().setOutboundProperty("Ticket", ticket);
}
}
//delete from list engine
ClassFactory.deleteProcesList(Integer.valueOf(arg0.getMessage().getOutboundProperty("engineId").toString()));
//logger.info("Motor a eliminar "+motor.hashCode() );
motor.dispose();//elimina la instancia del motor creada
}else if(errorCode!=0){
//arg0.getMessage().setOutboundProperty("http.status", errorCode);
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", errorCode);
}
}
}
} | UTF-8 | Java | 8,744 | java | InterceptorAuthorizationMule.java | Java | [
{
"context": "\n * Interceptor Authorization MULE ESB \n * @author Oswel Sanchez\n * \n */\n\npublic class InterceptorAuthorizationMul",
"end": 630,
"score": 0.9998760223388672,
"start": 617,
"tag": "NAME",
"value": "Oswel Sanchez"
}
] | null | [] | /**
* InterceptorAuthorizationMule.java
*
*/
package com.process.services.rest.aop;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.core.Response;
import org.apache.log4j.Logger;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.interceptor.AbstractEnvelopeInterceptor;
import org.mule.management.stats.ProcessingTime;
import com.process.business.helper.BasicAuth;
import com.process.business.helper.ClassFactory;
import com.process.business.helper.ProcessEngine;
import com.process.business.helper.c_Process;
/**
* Interceptor Authorization MULE ESB
* @author <NAME>
*
*/
public class InterceptorAuthorizationMule extends AbstractEnvelopeInterceptor {
private static final Logger logger = Logger.getLogger(InterceptorAuthorizationMule.class);
@Override
public MuleEvent after(MuleEvent arg0) throws MuleException {
try{
cerrarSession(arg0);
}catch(Exception e){
logger.error("after", e);
}
return arg0;
}
@Override
public MuleEvent before(MuleEvent arg0) throws MuleException {
String varTicket = "";
if (arg0.getMessage().getInboundProperty("http.method")!="OPTIONS"){//verifica si el servicio es un metodo option para que no ingrese en la validacion del token
if (arg0.getMessage().getInboundProperty("authorization")==null){ //verifica si tiene cabecera de autorizacion
throw new NotAuthorizedException("Missing Credentials", Response.Status.UNAUTHORIZED);
}else if (arg0.getMessage().getInboundProperty("authorization").toString()==""){//verifica si tiene cabecera de autorizacion
throw new NotAuthorizedException("Missing Credentials", Response.Status.UNAUTHORIZED);
}else if (!arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ") && !arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Basic ")){//verifica que la cabecera de autorizacion tenga berear o basic
throw new NotAuthorizedException("Wrong Sheme.", Response.Status.UNAUTHORIZED);
}else if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ")){//validacion si es para validar ticket o para iniciar sesion
Integer result = 0;
try{
varTicket = BasicAuth.decodeParameter(arg0.getMessage().getInboundProperty("authorization").toString());
result = obtenerSession(varTicket);
}catch(Exception e){
logger.error("decodificar parametros", e);
}
if (result == 0) {
throw new NotAuthorizedException("Ticket Credentials Invalid.", Response.Status.UNAUTHORIZED);
}else{
arg0.getMessage().setOutboundProperty("engineId", result);
}
//logger.info("servicio llamado: "+arg0.getMessage().getInboundProperty("http.relative.path").toString()+" "+arg0.getMessage().getInboundProperty("authorization").toString() );
//logger.info("Ticket de entrada para el servicio:( " + arg0.getMessage().getInboundProperty("authorization").toString() + ")");
}else{
if(arg0.getMessage().getInboundProperty("authorization").toString().length() < 125) {
ProcessEngine process = new ProcessEngine();
c_Process motor = ClassFactory.createProcess();
process.setEngine(motor);
varTicket = BasicAuth.decodeParameter(arg0.getMessage().getInboundProperty("authorization").toString());
process.setTicket(varTicket);
ClassFactory.getListProcess().add(process);//add engine to list
//logger.info("Inicio de sesion "+BasicAuth.decode(varTicket)[0] +" hash "+motor.hashCode() );
arg0.getMessage().setOutboundProperty("engineId", motor.hashCode());
}else {
ClassFactory.setErrorCode(406);
//logger.info("Autorizacion excede cantidad de caracteres permitida");
}
}
}
return arg0;
}
@Override
public MuleEvent last(MuleEvent arg0, ProcessingTime arg1, long arg2, boolean arg3) throws MuleException {
return arg0;
}
private synchronized Integer obtenerSession(String ticket) throws InterruptedException{
Integer result = 0;
ProcessEngine process = new ProcessEngine(); //Objeto que relaciona motor con token
c_Process motor = ClassFactory.createProcess(); //Objeto para inicar motor
process.setEngine(motor);//Guarda el objeto inicializado del motor
process.setTicket(ticket);//Guarda la relacion del token con el motor iniciado
if (ClassFactory.isTicketList(ticket)){//Verifica que el ticket Exista en el arreglo de ticket abiertos
result = motor.p4bObtenerSesionUnica(ticket,0);
}else{
result = motor.p4bObtenerSesion(ticket,0);
//result = motor.p4bObtenerSesionUnica(ticket,0);
//logger.info("No existe token "+ticket+" hash "+motor.hashCode());
}
if (result!=0){
ClassFactory.getListProcess().add(process);//add engine to list
result = motor.hashCode();
//logger.info("Get session engine to list:(" + result + ")");
}
//logger.info("Get session engineId to list:(" + result + ")");
return result;
}
private synchronized void cerrarSession(MuleEvent arg0) throws InterruptedException{//usado para guardar session y cerrar session segun sea el caso
Integer errorCode = ClassFactory.getErrorCode();
if (arg0.getMessage().getInboundProperty("authorization")!=null){
if(arg0.getMessage().getOutboundProperty("engineId") != null) {
c_Process motor = ClassFactory.getProcess(Integer.valueOf(arg0.getMessage().getOutboundProperty("engineId").toString()));
//validar si hay Error Process se informa
Integer result = motor.p4bStatus();
if (result!=0){
logger.info("result "+result+" "+arg0.getMessage().getInboundProperty("authorization").toString());
//arg0.getMessage().setOutboundProperty("http.status", result);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", result);
}else if (errorCode!=0){
//arg0.getMessage().setOutboundProperty("http.status", errorCode);
logger.info("errorCode "+errorCode+" "+arg0.getMessage().getInboundProperty("authorization").toString());
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", errorCode);
}
/*if(arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("abrir1")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("crearDocumento")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("destinos")>0 || arg0.getMessage().getInboundProperty("http.relative.path").toString().indexOf("document")>0) {
try {
logger.info("respuesta de servicio: "+arg0.getMessage().getInboundProperty("http.relative.path").toString()+" Parametros de servicio "+arg0.getMessage().getInboundProperty("http.query.params").toString()+" Respúesta "+arg0.getMessage().getPayloadAsString()+" hash: "+motor.hashCode() +" Token "+arg0.getMessage().getInboundProperty("authorization").toString()+" status "+ arg0.getMessage().getOutboundProperty("http.status").toString());
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Error path ",e);
}
}*/
//validar que estamos cerrando session para no llamar al guardar session.
if ((arg0.getMessage().getInboundProperty("http.method")=="DELETE") && (arg0.getMessage().getInboundProperty("http.relative.path").toString().equals("/process/api/sessions"))){
//logger.info("End session:"+arg0.getMessage().getOutboundProperty("engineId").toString());
}else{
if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Bearer ")){
//String ticket = motor.p4bGuardarSesion(0);
String ticket = motor.p4bGuardarSesionUnica(0);
arg0.getMessage().setOutboundProperty("Ticket", ticket);
}else if (arg0.getMessage().getInboundProperty("authorization").toString().startsWith("Basic ")){
//String ticket = motor.p4bGuardarSesion(0);
String ticket = motor.p4bGuardarSesionUnica(0);
arg0.getMessage().setOutboundProperty("Ticket", ticket);
}
}
//delete from list engine
ClassFactory.deleteProcesList(Integer.valueOf(arg0.getMessage().getOutboundProperty("engineId").toString()));
//logger.info("Motor a eliminar "+motor.hashCode() );
motor.dispose();//elimina la instancia del motor creada
}else if(errorCode!=0){
//arg0.getMessage().setOutboundProperty("http.status", errorCode);
arg0.getMessage().setOutboundProperty("http.status", 400);//se informa el codigo de error
arg0.getMessage().setOutboundProperty("codError", errorCode);
}
}
}
} | 8,737 | 0.724237 | 0.712799 | 174 | 49.252872 | 59.361782 | 443 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.62069 | false | false | 9 |
eac9d1ade3d5657302eeff459df12d823734abb6 | 3,015,067,062,140 | 092a0368183a3cc9a0b13434c4b80a854cbd2dad | /epivot/src/main/java/com/pivot/framework/model/SessionUser.java | 50ee25b2deb4b6ee8ad7ca88ad1472ebf4582b32 | [] | no_license | taoxiangtao/pivot | https://github.com/taoxiangtao/pivot | 670da05143f1514d185883306d6c161a4e68c6d5 | b4320c4d36589d3d96cb6acf686e1745444e2fc7 | refs/heads/master | 2018-09-08T02:43:34.603000 | 2018-09-06T23:00:12 | 2018-09-06T23:00:12 | 64,029,570 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* @(#)SessionUser.java v${project.version} 2016年8月4日 下午3:58:01
*
* ${project.copyright.info}
* ${project.copyright}
* ==============================================================================================================*/
package com.pivot.framework.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import org.springframework.util.Assert;
import com.pivot.entity.po.StaffPrincipal;
/**
* 在Session中保存用户信息的类.
*
* @author taoxiangtao@gmail.com
*/
@SuppressWarnings("serial")
public class SessionUser implements HttpSessionBindingListener,Serializable{
//~Constructor
public SessionUser(StaffPrincipal po,String remark,List<String> roleIds){
Assert.notNull(po, "用户凭证不能为空!");
this.principalId = po.getId();
this.visitorId = po.getStaffId();
this.visitorName = po.getStaffName();
this.activated = po.isActivated();
this.remark = remark;//登录信息如IP等
this.roleIds = (roleIds==null)?new ArrayList<String>():roleIds;
//机构信息
this.parentId = po.getParentId();
this.realId = po.getRealId();
this.organId = po.getOrganId();
this.ownId = po.getOwnId();
}
//~InterfaceMethod
/*
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueBound(HttpSessionBindingEvent arg0) {
this.sessionId = (arg0.getSession()==null)?null:arg0.getSession().getId();
VisitHolder.doSessionBound(this);
}
/*
* @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueUnbound(HttpSessionBindingEvent arg0) {
VisitHolder.doSessionUnbound(this);
}
//~PublicMethod
/*
* 激活用户
*/
public void active(){
this.activated = true;
}
//~Properties
private String id;//唯一识别ID
private Long createTime=System.currentTimeMillis();
private String principalId;//凭证ID
private String visitorId;//用户ID
private String visitorName;//用户名称
private boolean activated;//是否需要修改密码
private String remark;//用户IP等登录备注信息
private String sessionId;//会话ID
private List<String> roleIds;//拥有的角色ID
private String parentId;//~机构信息
private String realId;
private String organId;
private String ownId;
//private String organPath;
//private String ownPath;
//private String parentName;
//private String parentPath;
//private String realPath;
//~Getter/Setter
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getCreateTime() {
return createTime;
}
public String getPrincipalId() {
return principalId;
}
public String getVisitorId() {
return visitorId;
}
public String getVisitorName() {
return visitorName;
}
public boolean isActivated() {
return activated;
}
public String getRemark() {
return remark;
}
public List<String> getRoleIds() {
return roleIds;
}
public String getSessionId() {
return sessionId;
}
public String getParentId() {
return parentId;
}
public String getRealId() {
return realId;
}
public String getOrganId() {
return organId;
}
public String getOwnId() {
return ownId;
}
}
//import java.io.Serializable;
//import java.text.SimpleDateFormat;
//import java.util.HashSet;
//import java.util.Set;
//import javax.servlet.http.HttpSessionBindingEvent;
//import javax.servlet.http.HttpSessionBindingListener;
//import org.apache.commons.lang.builder.EqualsBuilder;
//import org.apache.commons.lang.builder.HashCodeBuilder;
///**
// * 在Session中保存用户信息的类.
// *
// * @author taoxiangtao@gmail.com
// */
//@SuppressWarnings("serial")
//public class SessionUser implements HttpSessionBindingListener,Serializable{
// /*
// * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
// */
// @Override
// public void valueBound(HttpSessionBindingEvent arg0) {
// VisitHolder.addSessionuUser(this);
// }
// /*
// * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
// */
// @Override
// public void valueUnbound(HttpSessionBindingEvent arg0) {
// VisitHolder.removeSessionUser(this);
// }
//
//// /**
//// * 激活如果必要
//// */
//// public void activateIfNecessary(){
//// if(isNeedReset())
//// this.needReset = false;
//// }
////
//// //~ Constructor
//// public SessionUser(Staff staff){
//// this.id = staff.getId();
//// this.no = staff.getNo();
//// //this.name = (staff.getFirstName()==null?"":staff.getFirstName()) + (staff.getLastName()==null?"":staff.getLastName());
//// this.name = staff.getName();
//// this.needReset = staff.isNeedReset();
//// this.onTime = System.currentTimeMillis();
//// this.lastOnTime = staff.getLastOnTime();
//// //10.2 add
//// this.ownOrganId = staff.getOwnerId();
////
//// //11.19 modify
//// //this.useOrganId = staff.getUserId();
//// //this.useOrganId = (staff.getUseOrgan()==null?null:staff.getUseOrgan().getId());
//// this.useOrganId = staff.getRealOrganId();
////
//// this.version = staff.getVersion();
//// this.parentOrganId = staff.getOrganId();
//// //this.parentOrganId = (staff.getOrgan()==null?null:staff.getOrgan().getId());
//// //10.25 add
//// this.roleIds = staff.getRoleIds();
////// for(Role role:staff.getRoles()){
////// this.roleIds.add(role.getId());
////// }
//// //12。27 add
//// this.positionId = staff.getPositionId();
//// this.levelId = staff.getLevelId();
//// }
////
//// //~ PublicMethod
//// /*
//// * 登录时间串
//// */
//// public String getOnTimeStr(){
//// return sf.format(onTime);
//// }
////
//// //~ Properties
//// private String id;//用户ID
//// private String no;//用户代码
//// private String name;//用户名称
//// private boolean needReset;//是否需要重置
//// private Long onTime;//登录时间
//// private Long lastOnTime;//最后登录时间
////
//// //~ 10.2 add
//// private String ownOrganId;//所属机构ID
//// private String useOrganId;//工作机构ID
//// private String parentOrganId;//上级组织机构ID
//// private Integer version;//用户实体的版本(ps:系统保存与用户并联的实体时不用再查询用户信息)
////
//// //~ 10.25 add
//// private Set<String> roleIds=new HashSet<String>();//用户拥有的角色ID集合
//// private static SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
////
//// //~ 12.27 add
//// private String positionId;//岗位ID
//// private String levelId;//行员等级ID
////
//// //~ 0629 add
//// private Set<OrganRole> organRoles;//机构角色
////
//// //~ Getter/Setter
//// public String getId() {
//// return id;
//// }
//// public Long getOnTime() {
//// return onTime;
//// }
//// public Long getLastOnTime() {
//// return lastOnTime;
//// }
//// public boolean isNeedReset(){
//// return needReset;
//// }
//// public String getNo() {
//// return no;
//// }
//// public String getName() {
//// return name;
//// }
//// public String getOwnOrganId() {
//// return ownOrganId;
//// }
//// public String getUseOrganId() {
//// return useOrganId;
//// }
//// public String getParentOrganId() {
//// return parentOrganId;
//// }
//// public Integer getVersion() {
//// return version;
//// }
//// public void setVersion(Integer version) {
//// this.version = version;
//// }
//// public Set<String> getRoleIds() {
//// return roleIds;
//// }
//// public void setRoleIds(Set<String> roleIds) {
//// this.roleIds = roleIds;
//// }
//// public String getPositionId() {
//// return positionId;
//// }
//// public String getLevelId() {
//// return levelId;
//// }
//// //~ JavaBeanMethod
//// @Override
//// public boolean equals(Object o) {
//// if (this == o)
//// return true;
//// if (o == null || !SessionUser.class.isAssignableFrom(o.getClass()))
//// return false;
////
//// SessionUser user = (SessionUser) o;
//// return new EqualsBuilder().append(getId(), user.getId()).isEquals();
//// }
//// @Override
//// public int hashCode() {
//// return new HashCodeBuilder().append(getId()).toHashCode();
//// }
//}
| UTF-8 | Java | 8,921 | java | SessionUser.java | Java | [
{
"context": "cipal;\r\n/**\r\n * 在Session中保存用户信息的类.\r\n *\r\n * @author taoxiangtao@gmail.com\r\n */\r\n@SuppressWarnings(\"serial\")\r\npublic class S",
"end": 617,
"score": 0.9998584389686584,
"start": 596,
"tag": "EMAIL",
"value": "taoxiangtao@gmail.com"
},
{
"context": "///**\r\... | null | [] | /* @(#)SessionUser.java v${project.version} 2016年8月4日 下午3:58:01
*
* ${project.copyright.info}
* ${project.copyright}
* ==============================================================================================================*/
package com.pivot.framework.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import org.springframework.util.Assert;
import com.pivot.entity.po.StaffPrincipal;
/**
* 在Session中保存用户信息的类.
*
* @author <EMAIL>
*/
@SuppressWarnings("serial")
public class SessionUser implements HttpSessionBindingListener,Serializable{
//~Constructor
public SessionUser(StaffPrincipal po,String remark,List<String> roleIds){
Assert.notNull(po, "用户凭证不能为空!");
this.principalId = po.getId();
this.visitorId = po.getStaffId();
this.visitorName = po.getStaffName();
this.activated = po.isActivated();
this.remark = remark;//登录信息如IP等
this.roleIds = (roleIds==null)?new ArrayList<String>():roleIds;
//机构信息
this.parentId = po.getParentId();
this.realId = po.getRealId();
this.organId = po.getOrganId();
this.ownId = po.getOwnId();
}
//~InterfaceMethod
/*
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueBound(HttpSessionBindingEvent arg0) {
this.sessionId = (arg0.getSession()==null)?null:arg0.getSession().getId();
VisitHolder.doSessionBound(this);
}
/*
* @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueUnbound(HttpSessionBindingEvent arg0) {
VisitHolder.doSessionUnbound(this);
}
//~PublicMethod
/*
* 激活用户
*/
public void active(){
this.activated = true;
}
//~Properties
private String id;//唯一识别ID
private Long createTime=System.currentTimeMillis();
private String principalId;//凭证ID
private String visitorId;//用户ID
private String visitorName;//用户名称
private boolean activated;//是否需要修改密码
private String remark;//用户IP等登录备注信息
private String sessionId;//会话ID
private List<String> roleIds;//拥有的角色ID
private String parentId;//~机构信息
private String realId;
private String organId;
private String ownId;
//private String organPath;
//private String ownPath;
//private String parentName;
//private String parentPath;
//private String realPath;
//~Getter/Setter
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getCreateTime() {
return createTime;
}
public String getPrincipalId() {
return principalId;
}
public String getVisitorId() {
return visitorId;
}
public String getVisitorName() {
return visitorName;
}
public boolean isActivated() {
return activated;
}
public String getRemark() {
return remark;
}
public List<String> getRoleIds() {
return roleIds;
}
public String getSessionId() {
return sessionId;
}
public String getParentId() {
return parentId;
}
public String getRealId() {
return realId;
}
public String getOrganId() {
return organId;
}
public String getOwnId() {
return ownId;
}
}
//import java.io.Serializable;
//import java.text.SimpleDateFormat;
//import java.util.HashSet;
//import java.util.Set;
//import javax.servlet.http.HttpSessionBindingEvent;
//import javax.servlet.http.HttpSessionBindingListener;
//import org.apache.commons.lang.builder.EqualsBuilder;
//import org.apache.commons.lang.builder.HashCodeBuilder;
///**
// * 在Session中保存用户信息的类.
// *
// * @author <EMAIL>
// */
//@SuppressWarnings("serial")
//public class SessionUser implements HttpSessionBindingListener,Serializable{
// /*
// * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
// */
// @Override
// public void valueBound(HttpSessionBindingEvent arg0) {
// VisitHolder.addSessionuUser(this);
// }
// /*
// * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
// */
// @Override
// public void valueUnbound(HttpSessionBindingEvent arg0) {
// VisitHolder.removeSessionUser(this);
// }
//
//// /**
//// * 激活如果必要
//// */
//// public void activateIfNecessary(){
//// if(isNeedReset())
//// this.needReset = false;
//// }
////
//// //~ Constructor
//// public SessionUser(Staff staff){
//// this.id = staff.getId();
//// this.no = staff.getNo();
//// //this.name = (staff.getFirstName()==null?"":staff.getFirstName()) + (staff.getLastName()==null?"":staff.getLastName());
//// this.name = staff.getName();
//// this.needReset = staff.isNeedReset();
//// this.onTime = System.currentTimeMillis();
//// this.lastOnTime = staff.getLastOnTime();
//// //10.2 add
//// this.ownOrganId = staff.getOwnerId();
////
//// //11.19 modify
//// //this.useOrganId = staff.getUserId();
//// //this.useOrganId = (staff.getUseOrgan()==null?null:staff.getUseOrgan().getId());
//// this.useOrganId = staff.getRealOrganId();
////
//// this.version = staff.getVersion();
//// this.parentOrganId = staff.getOrganId();
//// //this.parentOrganId = (staff.getOrgan()==null?null:staff.getOrgan().getId());
//// //10.25 add
//// this.roleIds = staff.getRoleIds();
////// for(Role role:staff.getRoles()){
////// this.roleIds.add(role.getId());
////// }
//// //12。27 add
//// this.positionId = staff.getPositionId();
//// this.levelId = staff.getLevelId();
//// }
////
//// //~ PublicMethod
//// /*
//// * 登录时间串
//// */
//// public String getOnTimeStr(){
//// return sf.format(onTime);
//// }
////
//// //~ Properties
//// private String id;//用户ID
//// private String no;//用户代码
//// private String name;//用户名称
//// private boolean needReset;//是否需要重置
//// private Long onTime;//登录时间
//// private Long lastOnTime;//最后登录时间
////
//// //~ 10.2 add
//// private String ownOrganId;//所属机构ID
//// private String useOrganId;//工作机构ID
//// private String parentOrganId;//上级组织机构ID
//// private Integer version;//用户实体的版本(ps:系统保存与用户并联的实体时不用再查询用户信息)
////
//// //~ 10.25 add
//// private Set<String> roleIds=new HashSet<String>();//用户拥有的角色ID集合
//// private static SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
////
//// //~ 12.27 add
//// private String positionId;//岗位ID
//// private String levelId;//行员等级ID
////
//// //~ 0629 add
//// private Set<OrganRole> organRoles;//机构角色
////
//// //~ Getter/Setter
//// public String getId() {
//// return id;
//// }
//// public Long getOnTime() {
//// return onTime;
//// }
//// public Long getLastOnTime() {
//// return lastOnTime;
//// }
//// public boolean isNeedReset(){
//// return needReset;
//// }
//// public String getNo() {
//// return no;
//// }
//// public String getName() {
//// return name;
//// }
//// public String getOwnOrganId() {
//// return ownOrganId;
//// }
//// public String getUseOrganId() {
//// return useOrganId;
//// }
//// public String getParentOrganId() {
//// return parentOrganId;
//// }
//// public Integer getVersion() {
//// return version;
//// }
//// public void setVersion(Integer version) {
//// this.version = version;
//// }
//// public Set<String> getRoleIds() {
//// return roleIds;
//// }
//// public void setRoleIds(Set<String> roleIds) {
//// this.roleIds = roleIds;
//// }
//// public String getPositionId() {
//// return positionId;
//// }
//// public String getLevelId() {
//// return levelId;
//// }
//// //~ JavaBeanMethod
//// @Override
//// public boolean equals(Object o) {
//// if (this == o)
//// return true;
//// if (o == null || !SessionUser.class.isAssignableFrom(o.getClass()))
//// return false;
////
//// SessionUser user = (SessionUser) o;
//// return new EqualsBuilder().append(getId(), user.getId()).isEquals();
//// }
//// @Override
//// public int hashCode() {
//// return new HashCodeBuilder().append(getId()).toHashCode();
//// }
//}
| 8,893 | 0.614134 | 0.608635 | 314 | 25.219746 | 23.178608 | 126 | false | false | 0 | 0 | 0 | 0 | 110 | 0.01287 | 1.480892 | false | false | 9 |
84e8a9d6798031678dcb4e1c8e95e68a3cc6772d | 30,176,440,222,245 | 71b70f86a536317841ae0f8a8df35551f4118418 | /scd/src/main/java/com/bcpv/model/Provincia.java | 037b308ed118ec570b2ca75bd51fe2ae180e5b85 | [] | no_license | LeoBur/ProyectoSCD | https://github.com/LeoBur/ProyectoSCD | 4ea3c0f78b653722591c6eae3a3a407f4a2b944d | 31d20d7835d954eb171c6c2ddb8e33e4b103afa0 | refs/heads/master | 2016-09-08T01:56:31.924000 | 2015-04-01T23:58:11 | 2015-04-01T23:58:11 | 18,351,187 | 0 | 0 | null | false | 2015-04-01T21:05:33 | 2014-04-02T01:43:42 | 2015-04-01T00:25:18 | 2015-04-01T21:05:33 | 100,939 | 0 | 1 | 1 | Java | null | null | package com.bcpv.model;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.search.annotations.Indexed;
@Entity
@Table(name = "provincias")
@Indexed
@XmlRootElement
public class Provincia implements Serializable {
private static final long serialVersionUID = 197685765342342L;
private int id;
private String nombre;
private Set<Departamento> departamentos = new HashSet<Departamento>();
private Set<Localidad> localidades = new HashSet<Localidad>();
public Provincia() {
}
@Id
@Column(name = "id_provincia", unique = true, nullable = false)
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "nombre", nullable = false, length = 50)
public String getNombre() {
return this.nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre.toUpperCase();
}
@OneToMany(fetch = FetchType.LAZY)
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public Set<Departamento> getDepartamentos() {
return this.departamentos;
}
public void setDepartamentos(Set<Departamento> departamentos) {
this.departamentos = departamentos;
}
@OneToMany(fetch = FetchType.EAGER)
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public Set<Localidad> getLocalidades() {
return this.localidades;
}
public void setLocalidades(Set<Localidad> localidades) {
this.localidades = localidades;
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Provincia)) {
return false;
}
final Provincia provincia = (Provincia) o;
return !(nombre != null ? !nombre.equals(provincia.nombre) : provincia.nombre != null);
}
/**
* {@inheritDoc}
*/
public int hashCode() {
return (nombre != null ? nombre.hashCode() : 0);
}
/**
* {@inheritDoc}
*/
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
.append(this.nombre)
.toString();
}
}
| UTF-8 | Java | 2,552 | java | Provincia.java | Java | [] | null | [] | package com.bcpv.model;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.search.annotations.Indexed;
@Entity
@Table(name = "provincias")
@Indexed
@XmlRootElement
public class Provincia implements Serializable {
private static final long serialVersionUID = 197685765342342L;
private int id;
private String nombre;
private Set<Departamento> departamentos = new HashSet<Departamento>();
private Set<Localidad> localidades = new HashSet<Localidad>();
public Provincia() {
}
@Id
@Column(name = "id_provincia", unique = true, nullable = false)
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "nombre", nullable = false, length = 50)
public String getNombre() {
return this.nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre.toUpperCase();
}
@OneToMany(fetch = FetchType.LAZY)
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public Set<Departamento> getDepartamentos() {
return this.departamentos;
}
public void setDepartamentos(Set<Departamento> departamentos) {
this.departamentos = departamentos;
}
@OneToMany(fetch = FetchType.EAGER)
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public Set<Localidad> getLocalidades() {
return this.localidades;
}
public void setLocalidades(Set<Localidad> localidades) {
this.localidades = localidades;
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Provincia)) {
return false;
}
final Provincia provincia = (Provincia) o;
return !(nombre != null ? !nombre.equals(provincia.nombre) : provincia.nombre != null);
}
/**
* {@inheritDoc}
*/
public int hashCode() {
return (nombre != null ? nombre.hashCode() : 0);
}
/**
* {@inheritDoc}
*/
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
.append(this.nombre)
.toString();
}
}
| 2,552 | 0.697492 | 0.690439 | 106 | 23.075472 | 21.644075 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.858491 | false | false | 9 |
653e704638e182987f3d2341acc09893c7822fd6 | 23,124,103,980,313 | 504651e52edbc41056255b9f7bcdf97d739ee5e0 | /app/src/main/java/com/i9930/croptrails/RoomDatabase/Farmer/FarmerCacheManager.java | 84ff07b301601983877c093501fb55c930ca6402 | [] | no_license | Yash-Gupta-21/ct_lite_android-master | https://github.com/Yash-Gupta-21/ct_lite_android-master | 55edc2ba8040b0648edb6c70e93ab3575df298d1 | f09a8d307fc0b532934d1a420aa54a95caad4756 | refs/heads/master | 2023-08-04T17:43:48.147000 | 2021-10-04T06:53:38 | 2021-10-04T06:53:38 | 413,306,223 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.i9930.croptrails.RoomDatabase.Farmer;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.CompletableObserver;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import com.i9930.croptrails.RoomDatabase.AppDatabase;
import com.i9930.croptrails.RoomDatabase.DoneActivities.AllActivityFetchListener;
import com.i9930.croptrails.RoomDatabase.DoneActivities.DoneActivity;
import com.i9930.croptrails.RoomDatabase.DropDownData2.DropDownCacheManager2;
import com.i9930.croptrails.RoomDatabase.DropDownData2.DropDownT2;
import com.i9930.croptrails.RoomDatabase.FarmTable.Farm;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmCacheManager;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmLoadListener;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmNotifyInterface;
public class FarmerCacheManager {
public interface FarmerInsertListener{
public void onFarmerInserted(long farmerId);
}
public interface GetFarmerListener{
public void onFarmerLoaded(FarmerT farmerT);
}
public interface GetAllFarmerListener{
public void onFarmerLoaded(List<FarmerT> farmerT);
}
private Context context;
private static FarmerCacheManager _instance;
private AppDatabase db;
public static FarmerCacheManager getInstance(Context context) {
if (_instance == null) {
_instance = new FarmerCacheManager(context);
}
return _instance;
}
public FarmerCacheManager(Context context) {
this.context = context;
db = AppDatabase.getAppDatabase(context);
}
public void addFarmer(final FarmerInsertListener listener, final FarmerT farmerT) {
final long[] id = new long[1];
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
id[0] =db.farmerDaoInterface().insert(farmerT);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
try {
listener.onFarmerInserted(id[0]);
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onError(Throwable e) {
}
});
}
public void deleteAllFarmers(/*final FarmNotifyInterface notifyInterface*/){
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().deleteAllFarmers();
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
/*notifyInterface.farmDeleted();*/
}
@Override
public void onError(Throwable e) {
/* notifyInterface.farmDeletionFaild();*/
}
});
}
public void getFarmer(final GetFarmerListener getFarmerListener, String farmerId) {
db.farmerDaoInterface().getFarmerByFarmerId(farmerId).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<FarmerT>() {
@Override
public void onSubscribe(Disposable d) {
// add it to a CompositeDisposable
}
@Override
public void onSuccess(FarmerT farmerT) {
// update the UI
getFarmerListener.onFarmerLoaded(farmerT);
} @Override
public void onError(Throwable e) {
// show an error message
getFarmerListener.onFarmerLoaded(null);
}
});
}
public void getAllFarmers(final GetAllFarmerListener listener,String isOfflineAdded) {
db.farmerDaoInterface().getAllFarmerOffline(isOfflineAdded,"N").subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<FarmerT>>() {
@Override
public void accept(List<FarmerT> doneActivityList) throws Exception {
listener.onFarmerLoaded(doneActivityList);
}
});
}
public void getAllFarmers(final GetAllFarmerListener listener,String isOfflineAdded,String isUpdated) {
db.farmerDaoInterface().getAllFarmer(isOfflineAdded,isUpdated).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<FarmerT>>() {
@Override
public void accept(List<FarmerT> doneActivityList) throws Exception {
listener.onFarmerLoaded(doneActivityList);
}
});
}
public void updateFarm( String farmerIdOffline,String farmerId,String isUploaded) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().update(farmerIdOffline,farmerId,isUploaded);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
});
}
public void updateFarmData( String farmerId,String data) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().updateData(farmerId,data);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
});
}
public interface OnUpdateSuccessListener{
public void onFarmerUpdated(boolean isUpdated);
}
public void updateFarm( OnUpdateSuccessListener listener,FarmerT farmerT) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().update(farmerT);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
if (listener!=null)
listener.onFarmerUpdated(true);
}
@Override
public void onError(Throwable e) {
if (listener!=null)
listener.onFarmerUpdated(false);
}
});
}
}
| UTF-8 | Java | 7,845 | java | FarmerCacheManager.java | Java | [] | null | [] | package com.i9930.croptrails.RoomDatabase.Farmer;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.CompletableObserver;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import com.i9930.croptrails.RoomDatabase.AppDatabase;
import com.i9930.croptrails.RoomDatabase.DoneActivities.AllActivityFetchListener;
import com.i9930.croptrails.RoomDatabase.DoneActivities.DoneActivity;
import com.i9930.croptrails.RoomDatabase.DropDownData2.DropDownCacheManager2;
import com.i9930.croptrails.RoomDatabase.DropDownData2.DropDownT2;
import com.i9930.croptrails.RoomDatabase.FarmTable.Farm;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmCacheManager;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmLoadListener;
import com.i9930.croptrails.RoomDatabase.FarmTable.FarmNotifyInterface;
public class FarmerCacheManager {
public interface FarmerInsertListener{
public void onFarmerInserted(long farmerId);
}
public interface GetFarmerListener{
public void onFarmerLoaded(FarmerT farmerT);
}
public interface GetAllFarmerListener{
public void onFarmerLoaded(List<FarmerT> farmerT);
}
private Context context;
private static FarmerCacheManager _instance;
private AppDatabase db;
public static FarmerCacheManager getInstance(Context context) {
if (_instance == null) {
_instance = new FarmerCacheManager(context);
}
return _instance;
}
public FarmerCacheManager(Context context) {
this.context = context;
db = AppDatabase.getAppDatabase(context);
}
public void addFarmer(final FarmerInsertListener listener, final FarmerT farmerT) {
final long[] id = new long[1];
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
id[0] =db.farmerDaoInterface().insert(farmerT);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
try {
listener.onFarmerInserted(id[0]);
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onError(Throwable e) {
}
});
}
public void deleteAllFarmers(/*final FarmNotifyInterface notifyInterface*/){
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().deleteAllFarmers();
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
/*notifyInterface.farmDeleted();*/
}
@Override
public void onError(Throwable e) {
/* notifyInterface.farmDeletionFaild();*/
}
});
}
public void getFarmer(final GetFarmerListener getFarmerListener, String farmerId) {
db.farmerDaoInterface().getFarmerByFarmerId(farmerId).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<FarmerT>() {
@Override
public void onSubscribe(Disposable d) {
// add it to a CompositeDisposable
}
@Override
public void onSuccess(FarmerT farmerT) {
// update the UI
getFarmerListener.onFarmerLoaded(farmerT);
} @Override
public void onError(Throwable e) {
// show an error message
getFarmerListener.onFarmerLoaded(null);
}
});
}
public void getAllFarmers(final GetAllFarmerListener listener,String isOfflineAdded) {
db.farmerDaoInterface().getAllFarmerOffline(isOfflineAdded,"N").subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<FarmerT>>() {
@Override
public void accept(List<FarmerT> doneActivityList) throws Exception {
listener.onFarmerLoaded(doneActivityList);
}
});
}
public void getAllFarmers(final GetAllFarmerListener listener,String isOfflineAdded,String isUpdated) {
db.farmerDaoInterface().getAllFarmer(isOfflineAdded,isUpdated).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<FarmerT>>() {
@Override
public void accept(List<FarmerT> doneActivityList) throws Exception {
listener.onFarmerLoaded(doneActivityList);
}
});
}
public void updateFarm( String farmerIdOffline,String farmerId,String isUploaded) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().update(farmerIdOffline,farmerId,isUploaded);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
});
}
public void updateFarmData( String farmerId,String data) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().updateData(farmerId,data);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
});
}
public interface OnUpdateSuccessListener{
public void onFarmerUpdated(boolean isUpdated);
}
public void updateFarm( OnUpdateSuccessListener listener,FarmerT farmerT) {
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
db.farmerDaoInterface().update(farmerT);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()).subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
if (listener!=null)
listener.onFarmerUpdated(true);
}
@Override
public void onError(Throwable e) {
if (listener!=null)
listener.onFarmerUpdated(false);
}
});
}
}
| 7,845 | 0.604716 | 0.598725 | 244 | 31.15164 | 29.562201 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.290984 | false | false | 9 |
a2bab8e707bf36ae839b41bce8a8d93f7a3f4702 | 10,591,389,387,803 | 4a2a66c814ffc4ac04043d8fc3d0780c14d6c86b | /gdb-web-control/src/main/java/org/lcmanager/gdb/web/control/status/DefaultStatusGenerator.java | b67fa82e5d1a0747a18d4b1600189014a6595e91 | [
"Apache-2.0"
] | permissive | fdamken/gdb | https://github.com/fdamken/gdb | c24aab690f1c029b36920c4f026a5a38d55c0080 | 1bd244f4b551958454d74fdd7a5d602b73ad4c60 | refs/heads/master | 2021-06-01T00:40:33.915000 | 2016-05-30T01:42:34 | 2016-05-30T01:42:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* #%L
* Game Database
* %%
* Copyright (C) 2016 - 2016 LCManager Group
* %%
* 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.
* #L%
*/
package org.lcmanager.gdb.web.control.status;
import java.lang.reflect.Method;
import org.springframework.hateoas.Resource;
import org.springframework.http.HttpStatus;
/**
* The default {@link StatusGenerator} is the default value for
* {@link GenerateStatus#value()} and generates a status based on the result of
* the controller method.
*
* <p>
* This generator may be configured by using {@link StatusConfig @StatusConfig}
* to set some properties. The configuration can either be applied on the class
* level which represents the default for the class or on the method level which
* overrides both the default settings and the class settings. <br>
* That is, starting from the method to the default value, a configuration
* hierarchy defined by <code>method > class > default</code>.
* <p>
* <br>
* NOTE: If any non-default value is present in the hierarchy, the it is used as
* the setting. It is not possible to force the default setting. </b>
* </p>
* </p>
*
*/
public class DefaultStatusGenerator implements StatusGenerator<Object> {
/**
* The default {@link StatusConfig} annotation. This contains the default
* value only.
*
*/
private static final StatusConfig STATUS_CONFIG_DEFAULT;
static {
@StatusConfig
class Foo {
// Nothing to do.
}
STATUS_CONFIG_DEFAULT = Foo.class.getAnnotation(StatusConfig.class);
}
/**
* {@inheritDoc}
*
* @see org.lcmanager.gdb.web.control.status.StatusGenerator#generateStatus(java.lang.reflect.Method,
* java.lang.Object)
*/
@Override
public HttpStatus generateStatus(final Method method, final Object pBody) {
final StatusConfig classConfig = this.extractClassConfig(method);
final StatusConfig methodConfig = this.extractMethodConfig(method);
final HttpStatus nullStatus;
if (methodConfig.nullStatus() == DefaultStatusGenerator.STATUS_CONFIG_DEFAULT.nullStatus()) {
nullStatus = classConfig.nullStatus();
} else {
nullStatus = methodConfig.nullStatus();
}
final HttpStatus defaultStatus;
if (methodConfig.defaultStatus() == DefaultStatusGenerator.STATUS_CONFIG_DEFAULT.defaultStatus()) {
defaultStatus = classConfig.defaultStatus();
} else {
defaultStatus = methodConfig.nullStatus();
}
final Object body;
if (pBody instanceof Resource) {
body = ((Resource<?>) pBody).getContent();
} else {
body = pBody;
}
return body == null ? nullStatus : defaultStatus == HttpStatus.I_AM_A_TEAPOT ? null : defaultStatus;
}
/**
* Extracts the status configuration on the method level of the given
* method. If no status configuration annotation is present this falls back
* to {@link #STATUS_CONFIG_DEFAULT}.
*
* @param method
* The method to extract the status configuration annotation on
* method level from.
* @return The status configuration annotation.
*/
private StatusConfig extractMethodConfig(final Method method) {
return method.isAnnotationPresent(StatusConfig.class) ? method.getAnnotation(StatusConfig.class)
: DefaultStatusGenerator.STATUS_CONFIG_DEFAULT;
}
/**
* Extracts the status configuration on the class level of the given method.
* If no status configuration annotation is present this falls back to
* {@link #STATUS_CONFIG_DEFAULT}.
*
* @param method
* The method to extract the status configuration annotation on
* class level from.
* @return The status configuration annotation.
*/
private StatusConfig extractClassConfig(final Method method) {
return method.getDeclaringClass().isAnnotationPresent(StatusConfig.class) ? method.getDeclaringClass().getAnnotation(
StatusConfig.class) : DefaultStatusGenerator.STATUS_CONFIG_DEFAULT;
}
}
| UTF-8 | Java | 4,706 | java | DefaultStatusGenerator.java | Java | [] | null | [] | /*
* #%L
* Game Database
* %%
* Copyright (C) 2016 - 2016 LCManager Group
* %%
* 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.
* #L%
*/
package org.lcmanager.gdb.web.control.status;
import java.lang.reflect.Method;
import org.springframework.hateoas.Resource;
import org.springframework.http.HttpStatus;
/**
* The default {@link StatusGenerator} is the default value for
* {@link GenerateStatus#value()} and generates a status based on the result of
* the controller method.
*
* <p>
* This generator may be configured by using {@link StatusConfig @StatusConfig}
* to set some properties. The configuration can either be applied on the class
* level which represents the default for the class or on the method level which
* overrides both the default settings and the class settings. <br>
* That is, starting from the method to the default value, a configuration
* hierarchy defined by <code>method > class > default</code>.
* <p>
* <br>
* NOTE: If any non-default value is present in the hierarchy, the it is used as
* the setting. It is not possible to force the default setting. </b>
* </p>
* </p>
*
*/
public class DefaultStatusGenerator implements StatusGenerator<Object> {
/**
* The default {@link StatusConfig} annotation. This contains the default
* value only.
*
*/
private static final StatusConfig STATUS_CONFIG_DEFAULT;
static {
@StatusConfig
class Foo {
// Nothing to do.
}
STATUS_CONFIG_DEFAULT = Foo.class.getAnnotation(StatusConfig.class);
}
/**
* {@inheritDoc}
*
* @see org.lcmanager.gdb.web.control.status.StatusGenerator#generateStatus(java.lang.reflect.Method,
* java.lang.Object)
*/
@Override
public HttpStatus generateStatus(final Method method, final Object pBody) {
final StatusConfig classConfig = this.extractClassConfig(method);
final StatusConfig methodConfig = this.extractMethodConfig(method);
final HttpStatus nullStatus;
if (methodConfig.nullStatus() == DefaultStatusGenerator.STATUS_CONFIG_DEFAULT.nullStatus()) {
nullStatus = classConfig.nullStatus();
} else {
nullStatus = methodConfig.nullStatus();
}
final HttpStatus defaultStatus;
if (methodConfig.defaultStatus() == DefaultStatusGenerator.STATUS_CONFIG_DEFAULT.defaultStatus()) {
defaultStatus = classConfig.defaultStatus();
} else {
defaultStatus = methodConfig.nullStatus();
}
final Object body;
if (pBody instanceof Resource) {
body = ((Resource<?>) pBody).getContent();
} else {
body = pBody;
}
return body == null ? nullStatus : defaultStatus == HttpStatus.I_AM_A_TEAPOT ? null : defaultStatus;
}
/**
* Extracts the status configuration on the method level of the given
* method. If no status configuration annotation is present this falls back
* to {@link #STATUS_CONFIG_DEFAULT}.
*
* @param method
* The method to extract the status configuration annotation on
* method level from.
* @return The status configuration annotation.
*/
private StatusConfig extractMethodConfig(final Method method) {
return method.isAnnotationPresent(StatusConfig.class) ? method.getAnnotation(StatusConfig.class)
: DefaultStatusGenerator.STATUS_CONFIG_DEFAULT;
}
/**
* Extracts the status configuration on the class level of the given method.
* If no status configuration annotation is present this falls back to
* {@link #STATUS_CONFIG_DEFAULT}.
*
* @param method
* The method to extract the status configuration annotation on
* class level from.
* @return The status configuration annotation.
*/
private StatusConfig extractClassConfig(final Method method) {
return method.getDeclaringClass().isAnnotationPresent(StatusConfig.class) ? method.getDeclaringClass().getAnnotation(
StatusConfig.class) : DefaultStatusGenerator.STATUS_CONFIG_DEFAULT;
}
}
| 4,706 | 0.674883 | 0.672333 | 128 | 35.765625 | 32.582462 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 9 |
dd2050c2b6dac835d3d8d7eda8ec0c2d1fbd4403 | 31,911,607,040,836 | 5de25cd2d804a3a0192a9eef0c286a5cd6435d40 | /src/daily2019/D20190314.java | b71299b497a5c40ab4b75740d0fbbeca877a1e5c | [
"Apache-2.0"
] | permissive | patrickzhe/codeTest | https://github.com/patrickzhe/codeTest | f46cb8d22194f791915fc5d2407114e785425c63 | 8c435f24c88bbc78247f5993c5a612423dd52830 | refs/heads/master | 2020-03-31T03:01:19.896000 | 2020-03-29T09:16:17 | 2020-03-29T09:16:17 | 151,848,617 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package daily2019;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;
/*
Given a 32-bit integer, return the number with its bits reversed.
For example, given the binary number 1111 0000 1111 0000 1111 0000 1111 0000, return 0000 1111 0000 1111 0000 1111 0000 1111.
@Facebook
@solved
@review
@bitop
bit 操作
https://www.geeksforgeeks.org/reverse-actual-bits-given-number/
https://www.geeksforgeeks.org/reverse-bits-using-lookup-table-in-o1-time/
https://www.geeksforgeeks.org/invert-actual-bits-number/
https://www.geeksforgeeks.org/check-actual-binary-representation-number-palindrome/
https://www.geeksforgeeks.org/set-all-even-bits-of-a-number/
https://www.geeksforgeeks.org/set-odd-bits-number/
https://www.geeksforgeeks.org/number-set-bits-n/
*/
public class D20190314 {
public static void main(String[] args) {
String s = "11110000111100001111000011110000";
System.out.println(bitReverse(s));
System.out.println(reverseBits(11));
System.out.println(Integer.toBinaryString(11));
System.out.println(bitReverse(Integer.toBinaryString(11)));
System.out.println(reverseBits(10));
System.out.println(Integer.toBinaryString(10));
System.out.println(bitReverse(Integer.toBinaryString(5)));
}
public static String bitReverse(String s) {
String t = String.join("", Collections.nCopies(s.length(), "1"));
int[] ts = new int[s.length()];
for (int i = 0; i < t.length(); i++) {
ts[i] = t.charAt(i) ^ s.charAt(i);
}
return Arrays.stream(ts).mapToObj(String::valueOf).collect(Collectors.joining(""));
}
// 直接int 不是字符串怎么办?, 可以Integer.toBinaryString(), 也可以直接
// 通过一个res, 一位位的^, 同时原始n >> 右移
// O(num), where num is the number of bits in the binary representation of n
public static int reverseBits(int n)
{
int rev = 0;
// traversing bits of 'n'
// from the right
while (n > 0)
{
// bitwise left shift
// 'rev' by 1
rev <<= 1;
// if current bit is '1' , '0' 不用处理
if ((int)(n & 1) == 1)
rev ^= 1;
// bitwise right shift
//'n' by 1
n >>= 1;
}
// required number
return rev;
}
}
| UTF-8 | Java | 2,427 | java | D20190314.java | Java | [
{
"context": "return 0000 1111 0000 1111 0000 1111 0000 1111.\n\n@Facebook\n@solved\n@review\n@bitop\nbit 操作\nhttps://www.geeksfo",
"end": 318,
"score": 0.9682294726371765,
"start": 310,
"tag": "USERNAME",
"value": "Facebook"
},
{
"context": "00 1111 0000 1111.\n\n@Facebook\n@solved\... | null | [] | package daily2019;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;
/*
Given a 32-bit integer, return the number with its bits reversed.
For example, given the binary number 1111 0000 1111 0000 1111 0000 1111 0000, return 0000 1111 0000 1111 0000 1111 0000 1111.
@Facebook
@solved
@review
@bitop
bit 操作
https://www.geeksforgeeks.org/reverse-actual-bits-given-number/
https://www.geeksforgeeks.org/reverse-bits-using-lookup-table-in-o1-time/
https://www.geeksforgeeks.org/invert-actual-bits-number/
https://www.geeksforgeeks.org/check-actual-binary-representation-number-palindrome/
https://www.geeksforgeeks.org/set-all-even-bits-of-a-number/
https://www.geeksforgeeks.org/set-odd-bits-number/
https://www.geeksforgeeks.org/number-set-bits-n/
*/
public class D20190314 {
public static void main(String[] args) {
String s = "11110000111100001111000011110000";
System.out.println(bitReverse(s));
System.out.println(reverseBits(11));
System.out.println(Integer.toBinaryString(11));
System.out.println(bitReverse(Integer.toBinaryString(11)));
System.out.println(reverseBits(10));
System.out.println(Integer.toBinaryString(10));
System.out.println(bitReverse(Integer.toBinaryString(5)));
}
public static String bitReverse(String s) {
String t = String.join("", Collections.nCopies(s.length(), "1"));
int[] ts = new int[s.length()];
for (int i = 0; i < t.length(); i++) {
ts[i] = t.charAt(i) ^ s.charAt(i);
}
return Arrays.stream(ts).mapToObj(String::valueOf).collect(Collectors.joining(""));
}
// 直接int 不是字符串怎么办?, 可以Integer.toBinaryString(), 也可以直接
// 通过一个res, 一位位的^, 同时原始n >> 右移
// O(num), where num is the number of bits in the binary representation of n
public static int reverseBits(int n)
{
int rev = 0;
// traversing bits of 'n'
// from the right
while (n > 0)
{
// bitwise left shift
// 'rev' by 1
rev <<= 1;
// if current bit is '1' , '0' 不用处理
if ((int)(n & 1) == 1)
rev ^= 1;
// bitwise right shift
//'n' by 1
n >>= 1;
}
// required number
return rev;
}
}
| 2,427 | 0.624201 | 0.566681 | 75 | 30.293333 | 26.892761 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.426667 | false | false | 9 |
eaf09bcf38ec8c93ad15ed75fc39e5c4b664d56d | 29,618,094,522,593 | 1ce520272ff3a4da79573b9a7fbb629ef38aa714 | /BillerWeb/src/com/dtac/billerweb/data/BillerCollectionFeeAbsorbDTO.java | ad29f73571e2d52146159cb1d12c0f053895039d | [] | no_license | pannisai/Menh | https://github.com/pannisai/Menh | c8db84313a0d049e66ca232cfe66b925c518940c | 14d63aeead0c2aba3bea0b10674a47d09a1ee324 | refs/heads/master | 2021-01-21T13:33:59.530000 | 2016-05-25T08:44:53 | 2016-05-25T08:44:53 | 53,564,056 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dtac.billerweb.data;
import java.util.List;
import com.dtac.billerweb.common.BaseDO;
public class BillerCollectionFeeAbsorbDTO extends BaseDO {
private static final long serialVersionUID = 1L;
private String errorCode;
private String errorMssg;
private List<BillerCollectionFeeAbsorbData> dataList;
public List<BillerCollectionFeeAbsorbData> getDataList() {
return dataList;
}
public void setDataList(List<BillerCollectionFeeAbsorbData> dataList) {
this.dataList = dataList;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMssg() {
return errorMssg;
}
public void setErrorMssg(String errorMssg) {
this.errorMssg = errorMssg;
}
}
| UTF-8 | Java | 784 | java | BillerCollectionFeeAbsorbDTO.java | Java | [] | null | [] | package com.dtac.billerweb.data;
import java.util.List;
import com.dtac.billerweb.common.BaseDO;
public class BillerCollectionFeeAbsorbDTO extends BaseDO {
private static final long serialVersionUID = 1L;
private String errorCode;
private String errorMssg;
private List<BillerCollectionFeeAbsorbData> dataList;
public List<BillerCollectionFeeAbsorbData> getDataList() {
return dataList;
}
public void setDataList(List<BillerCollectionFeeAbsorbData> dataList) {
this.dataList = dataList;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMssg() {
return errorMssg;
}
public void setErrorMssg(String errorMssg) {
this.errorMssg = errorMssg;
}
}
| 784 | 0.771684 | 0.770408 | 37 | 20.18919 | 20.98756 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.189189 | false | false | 9 |
1339131b3ea8e38e4efa49042487f0481384d743 | 29,618,094,518,504 | 111dfdcb594cdd3d1f83d470cb0d455455c1e34e | /src/main/java/io/reflectoring/cleantimetracker/timecontext/adapter/out/persistence/TimeRecordEntity.java | e8978dec5b26e112e7713cbc7c26f636731e9d59 | [] | no_license | JNec/clean-timetracker | https://github.com/JNec/clean-timetracker | 7fc7c2d50c3317ed71979dcf8fc62497e2061139 | faabf1d54503f401be983b18575fe5079fdd60ef | refs/heads/master | 2022-04-07T00:23:13.707000 | 2018-10-23T04:02:03 | 2018-10-23T04:02:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.reflectoring.cleantimetracker.timecontext.adapter.out.persistence;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDate;
import io.reflectoring.cleantimetracker.timecontext.domain.entity.TimeRecordStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "TIME_RECORD")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TimeRecordEntity {
@Id
@GeneratedValue
private Long id;
@Column(name = "DATE")
private LocalDate date;
@Column(name = "MINUTES")
private Integer minutes;
@Column(name = "STATUS")
@Enumerated(EnumType.STRING)
private TimeRecordStatus status;
@Column(name = "TASK_ID")
private Long taskId;
}
| UTF-8 | Java | 968 | java | TimeRecordEntity.java | Java | [] | null | [] | package io.reflectoring.cleantimetracker.timecontext.adapter.out.persistence;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDate;
import io.reflectoring.cleantimetracker.timecontext.domain.entity.TimeRecordStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "TIME_RECORD")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TimeRecordEntity {
@Id
@GeneratedValue
private Long id;
@Column(name = "DATE")
private LocalDate date;
@Column(name = "MINUTES")
private Integer minutes;
@Column(name = "STATUS")
@Enumerated(EnumType.STRING)
private TimeRecordStatus status;
@Column(name = "TASK_ID")
private Long taskId;
}
| 968 | 0.792355 | 0.792355 | 44 | 21 | 18.28064 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.431818 | false | false | 9 |
ea733355032cb66acab9bb47fc6c63889296a891 | 10,307,921,542,601 | 18e2d7049b085a328ab44c065e87555fc84d935a | /spring-boot-starter-jsondoc/src/main/java/org/jsondoc/spring/boot/starter/JSONDocProperties.java | 2d52db9c96041e3d77744fbddce63f5bbbbb29e2 | [
"MIT"
] | permissive | alessioarsuffi/jsondoc | https://github.com/alessioarsuffi/jsondoc | 30a1f6ce15b3847be76026afb84f83d8953a9d60 | 7f295d5b3dd293c601402c848fd5d6258c402033 | refs/heads/master | 2021-04-30T23:05:33.516000 | 2015-07-14T16:30:56 | 2015-07-14T16:30:56 | 35,299,436 | 1 | 0 | null | true | 2015-06-26T20:42:21 | 2015-05-08T20:06:30 | 2015-05-08T20:06:31 | 2015-06-26T20:42:20 | 3,696 | 0 | 0 | 0 | Java | null | null | package org.jsondoc.spring.boot.starter;
import org.jsondoc.core.pojo.JSONDoc.MethodDisplay;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
@ConfigurationProperties(prefix = JSONDocConfig.JSONDOC_PROPERTIES_PREFIX)
public class JSONDocProperties {
/**
* The version of your API.
*/
private String version;
/**
* The base path of your API, for example http://localhost:8080.
*/
private String basePath;
/**
* The list of packages that JSONDoc will scan to look for annotated classes
* to be documented.
*/
private List<String> packages = new ArrayList<String>();
/**
* Whether the playground should be enabled in the UI or not. Defaults to
* true.
*/
private boolean playgroundEnabled = true;
/**
* Whether to display methods as URIs or with a short description (summary attribute in the @ApiMethod annotation).
* Allowed values are URI and SUMMARY.
*/
private MethodDisplay displayMethodAs = MethodDisplay.URI;
/**
* Whether to enable CORS (Cross Origin Resource Sharing) or not.
* For more information visit: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing;
*/
private boolean corsEnabled;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public List<String> getPackages() {
return packages;
}
public void setPackages(List<String> packages) {
this.packages = packages;
}
public boolean isPlaygroundEnabled() {
return playgroundEnabled;
}
public void setPlaygroundEnabled(boolean playgroundEnabled) {
this.playgroundEnabled = playgroundEnabled;
}
public MethodDisplay getDisplayMethodAs() {
return displayMethodAs;
}
public void setDisplayMethodAs(MethodDisplay displayMethodAs) {
this.displayMethodAs = displayMethodAs;
}
public boolean isCorsEnabled() {
return corsEnabled;
}
public void setCorsEnabled(boolean corsEnabled) {
this.corsEnabled = corsEnabled;
}
}
| UTF-8 | Java | 2,192 | java | JSONDocProperties.java | Java | [] | null | [] | package org.jsondoc.spring.boot.starter;
import org.jsondoc.core.pojo.JSONDoc.MethodDisplay;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
@ConfigurationProperties(prefix = JSONDocConfig.JSONDOC_PROPERTIES_PREFIX)
public class JSONDocProperties {
/**
* The version of your API.
*/
private String version;
/**
* The base path of your API, for example http://localhost:8080.
*/
private String basePath;
/**
* The list of packages that JSONDoc will scan to look for annotated classes
* to be documented.
*/
private List<String> packages = new ArrayList<String>();
/**
* Whether the playground should be enabled in the UI or not. Defaults to
* true.
*/
private boolean playgroundEnabled = true;
/**
* Whether to display methods as URIs or with a short description (summary attribute in the @ApiMethod annotation).
* Allowed values are URI and SUMMARY.
*/
private MethodDisplay displayMethodAs = MethodDisplay.URI;
/**
* Whether to enable CORS (Cross Origin Resource Sharing) or not.
* For more information visit: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing;
*/
private boolean corsEnabled;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public List<String> getPackages() {
return packages;
}
public void setPackages(List<String> packages) {
this.packages = packages;
}
public boolean isPlaygroundEnabled() {
return playgroundEnabled;
}
public void setPlaygroundEnabled(boolean playgroundEnabled) {
this.playgroundEnabled = playgroundEnabled;
}
public MethodDisplay getDisplayMethodAs() {
return displayMethodAs;
}
public void setDisplayMethodAs(MethodDisplay displayMethodAs) {
this.displayMethodAs = displayMethodAs;
}
public boolean isCorsEnabled() {
return corsEnabled;
}
public void setCorsEnabled(boolean corsEnabled) {
this.corsEnabled = corsEnabled;
}
}
| 2,192 | 0.731296 | 0.729471 | 93 | 22.569893 | 25.724512 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.946237 | false | false | 9 |
d8da2e78f713a71fa5105b53f3b083c9f0947dbf | 10,307,921,542,289 | 8276edba56bca39776adacc1f8db534deb8355a1 | /03-Fragments-ViewPager-MasterDetailFlow-App/app/src/main/java/com/example/rahul/assignment3/MasterDetailActivity.java | d5c9eb2ef03897b2a6c4706b48ba7641fdcd43e3 | [] | no_license | rahulkadamid/AndroidDemoApps | https://github.com/rahulkadamid/AndroidDemoApps | 423219fc5e63245513fba91dc42e78c030d6b439 | 47b744764360ecad6d5bd5ab86f3a2cb1bfb2141 | refs/heads/master | 2021-09-09T16:24:35.024000 | 2018-03-17T23:46:08 | 2018-03-17T23:46:08 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.rahul.assignment3;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
public class MasterDetailActivity extends AppCompatActivity implements MasterFragment.CustomOnClickMasterFragmentListener
{
MovieData movieData;
boolean mTwoPane = false;
Fragment mcontent;
public void onMasterFragmentButtonClicked (View v, int index)
{
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction fT = fm.beginTransaction();
if (mTwoPane == true)
{
fT.replace(R.id.masterslave, MovieFragment.newInstance(movieData.getItem(index)));
fT.commit();
}
else
{
fT.replace(R.id.masterdetailframelayout, MovieFragment.newInstance(movieData.getItem(index)));
fT.addToBackStack(null);
fT.commit();
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
movieData = new MovieData();
setContentView(R.layout.activity_master_detail);
if (savedInstanceState == null)
{
mcontent = MasterFragment.newInstance(R.id.masterfragmentlayout);
}
if( findViewById (R.id.masterslave) != null ) {
mTwoPane = true;
getSupportFragmentManager().beginTransaction().replace(R.id.masterdetailframelayout,
mcontent).commit();
}
else
{
getSupportFragmentManager().beginTransaction().replace(R.id.masterdetailframelayout,
mcontent).addToBackStack(null).commit();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, "mcontent", mcontent);
}
}
| UTF-8 | Java | 2,061 | java | MasterDetailActivity.java | Java | [
{
"context": "package com.example.rahul.assignment3;\n\nimport android.os.Bundle;\nimport an",
"end": 25,
"score": 0.8613120913505554,
"start": 20,
"tag": "USERNAME",
"value": "rahul"
}
] | null | [] | package com.example.rahul.assignment3;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
public class MasterDetailActivity extends AppCompatActivity implements MasterFragment.CustomOnClickMasterFragmentListener
{
MovieData movieData;
boolean mTwoPane = false;
Fragment mcontent;
public void onMasterFragmentButtonClicked (View v, int index)
{
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction fT = fm.beginTransaction();
if (mTwoPane == true)
{
fT.replace(R.id.masterslave, MovieFragment.newInstance(movieData.getItem(index)));
fT.commit();
}
else
{
fT.replace(R.id.masterdetailframelayout, MovieFragment.newInstance(movieData.getItem(index)));
fT.addToBackStack(null);
fT.commit();
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
movieData = new MovieData();
setContentView(R.layout.activity_master_detail);
if (savedInstanceState == null)
{
mcontent = MasterFragment.newInstance(R.id.masterfragmentlayout);
}
if( findViewById (R.id.masterslave) != null ) {
mTwoPane = true;
getSupportFragmentManager().beginTransaction().replace(R.id.masterdetailframelayout,
mcontent).commit();
}
else
{
getSupportFragmentManager().beginTransaction().replace(R.id.masterdetailframelayout,
mcontent).addToBackStack(null).commit();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, "mcontent", mcontent);
}
}
| 2,061 | 0.665211 | 0.662785 | 63 | 31.714285 | 29.744108 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.539683 | false | false | 9 |
ea6b1a968b76b3257c63a173e455dae92c7d84b7 | 10,307,921,542,598 | 9332d946f75801bccff1d4524638691e7c9c98bc | /code/android/PosterMaster/app/src/main/java/com/murey/poster/postermaster/communication/message/data/Student.java | d09f015f349a8dd6015acb25d6ea6f650ec4201c | [] | no_license | GuillaumeMuret/PosterMaster | https://github.com/GuillaumeMuret/PosterMaster | 3fee6692ed8361f45c253e90e39209f42ae42820 | 68ead454280cffd9f21fe09c975bc8c70cabb428 | refs/heads/master | 2021-09-06T14:45:29.264000 | 2018-02-07T18:30:13 | 2018-02-07T18:30:13 | 120,653,226 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.murey.poster.postermaster.communication.message.data;
import com.google.gson.annotations.SerializedName;
import com.murey.poster.postermaster.communication.requests.protocole.ProtocolVocabulary;
public class Student {
@SerializedName(ProtocolVocabulary.JSON_KEY_USER_ID)
private int userId;
@SerializedName(ProtocolVocabulary.JSON_KEY_FORENAME)
private String lastName;
@SerializedName(ProtocolVocabulary.JSON_KEY_SURNAME)
private String firstName;
public int getUserServerEseoId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
| UTF-8 | Java | 952 | java | Student.java | Java | [] | null | [] | package com.murey.poster.postermaster.communication.message.data;
import com.google.gson.annotations.SerializedName;
import com.murey.poster.postermaster.communication.requests.protocole.ProtocolVocabulary;
public class Student {
@SerializedName(ProtocolVocabulary.JSON_KEY_USER_ID)
private int userId;
@SerializedName(ProtocolVocabulary.JSON_KEY_FORENAME)
private String lastName;
@SerializedName(ProtocolVocabulary.JSON_KEY_SURNAME)
private String firstName;
public int getUserServerEseoId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
| 952 | 0.703781 | 0.703781 | 40 | 22.799999 | 22.711451 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 9 |
701d01aba8c47d7e716247c00fea08447d1f4e2b | 10,642,928,998,890 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/32/32_c29f001d8ef52b5c402b86b50e5f3b3f5bef3cab/DatasourceParsingErrorTable/32_c29f001d8ef52b5c402b86b50e5f3b3f5bef3cab_DatasourceParsingErrorTable_s.java | 753f7272a158d15b38570cfb62de08d9f8250fd8 | [] | no_license | zhongxingyu/Seer | https://github.com/zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false | /*******************************************************************************
* Copyright 2008(c) The OBiBa Consortium. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package org.obiba.opal.web.gwt.app.client.workbench.view;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.obiba.opal.web.gwt.app.client.i18n.Translations;
import org.obiba.opal.web.model.client.magma.DatasourceParsingErrorDto;
import org.obiba.opal.web.model.client.magma.DatasourceParsingErrorDto.ClientErrorDtoExtensions;
import org.obiba.opal.web.model.client.ws.ClientErrorDto;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.view.client.ListDataProvider;
/**
*
*/
public class DatasourceParsingErrorTable extends Table<DatasourceParsingErrorDto> {
//
// Static Variables
//
private static Translations translations = GWT.create(Translations.class);
private ListDataProvider<DatasourceParsingErrorDto> dataProvider = new ListDataProvider<DatasourceParsingErrorDto>();
public DatasourceParsingErrorTable() {
super();
initTable();
dataProvider.addDataDisplay(this);
}
public void setErrors(final ClientErrorDto errorDto) {
setErrors(extractDatasourceParsingErrors(errorDto));
}
public void setErrors(final List<DatasourceParsingErrorDto> errors) {
dataProvider.setList(errors);
dataProvider.refresh();
}
@SuppressWarnings("unchecked")
private List<DatasourceParsingErrorDto> extractDatasourceParsingErrors(ClientErrorDto dto) {
List<DatasourceParsingErrorDto> datasourceParsingErrors = new ArrayList<DatasourceParsingErrorDto>();
JsArray<DatasourceParsingErrorDto> errors = (JsArray<DatasourceParsingErrorDto>) dto.getExtension(ClientErrorDtoExtensions.errors);
if(errors != null) {
for(int i = 0; i < errors.length(); i++) {
datasourceParsingErrors.add(errors.get(i));
}
sortBySheetAndRow(datasourceParsingErrors);
}
return datasourceParsingErrors;
}
private void sortBySheetAndRow(List<DatasourceParsingErrorDto> errors) {
// sort alphabetically
Collections.sort(errors, new Comparator<DatasourceParsingErrorDto>() {
@Override
public int compare(DatasourceParsingErrorDto e1, DatasourceParsingErrorDto e2) {
int comp = e1.getArgumentsArray().get(0).compareTo(e2.getArgumentsArray().get(0));
if(comp == 0) {
comp = Integer.parseInt(e1.getArgumentsArray().get(1)) - Integer.parseInt(e2.getArgumentsArray().get(1));
}
return comp;
}
});
}
private void initTable() {
addTableColumns();
}
private void addTableColumns() {
addColumn(new TextColumn<DatasourceParsingErrorDto>() {
@Override
public String getValue(DatasourceParsingErrorDto dto) {
if(translations.datasourceParsingErrorMap().containsKey(dto.getKey()) == false) {
return dto.getDefaultMessage();
}
String msg = translations.datasourceParsingErrorMap().get(dto.getKey());
JsArrayString args = dto.getArgumentsArray();
if(args != null) {
for(int i = 0; i < args.length(); i++) {
msg = msg.replace("{" + i + "}", args.get(i));
}
}
return msg;
}
}, translations.errorLabel());
}
}
| UTF-8 | Java | 3,900 | java | 32_c29f001d8ef52b5c402b86b50e5f3b3f5bef3cab_DatasourceParsingErrorTable_s.java | Java | [] | null | [] | /*******************************************************************************
* Copyright 2008(c) The OBiBa Consortium. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package org.obiba.opal.web.gwt.app.client.workbench.view;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.obiba.opal.web.gwt.app.client.i18n.Translations;
import org.obiba.opal.web.model.client.magma.DatasourceParsingErrorDto;
import org.obiba.opal.web.model.client.magma.DatasourceParsingErrorDto.ClientErrorDtoExtensions;
import org.obiba.opal.web.model.client.ws.ClientErrorDto;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.view.client.ListDataProvider;
/**
*
*/
public class DatasourceParsingErrorTable extends Table<DatasourceParsingErrorDto> {
//
// Static Variables
//
private static Translations translations = GWT.create(Translations.class);
private ListDataProvider<DatasourceParsingErrorDto> dataProvider = new ListDataProvider<DatasourceParsingErrorDto>();
public DatasourceParsingErrorTable() {
super();
initTable();
dataProvider.addDataDisplay(this);
}
public void setErrors(final ClientErrorDto errorDto) {
setErrors(extractDatasourceParsingErrors(errorDto));
}
public void setErrors(final List<DatasourceParsingErrorDto> errors) {
dataProvider.setList(errors);
dataProvider.refresh();
}
@SuppressWarnings("unchecked")
private List<DatasourceParsingErrorDto> extractDatasourceParsingErrors(ClientErrorDto dto) {
List<DatasourceParsingErrorDto> datasourceParsingErrors = new ArrayList<DatasourceParsingErrorDto>();
JsArray<DatasourceParsingErrorDto> errors = (JsArray<DatasourceParsingErrorDto>) dto.getExtension(ClientErrorDtoExtensions.errors);
if(errors != null) {
for(int i = 0; i < errors.length(); i++) {
datasourceParsingErrors.add(errors.get(i));
}
sortBySheetAndRow(datasourceParsingErrors);
}
return datasourceParsingErrors;
}
private void sortBySheetAndRow(List<DatasourceParsingErrorDto> errors) {
// sort alphabetically
Collections.sort(errors, new Comparator<DatasourceParsingErrorDto>() {
@Override
public int compare(DatasourceParsingErrorDto e1, DatasourceParsingErrorDto e2) {
int comp = e1.getArgumentsArray().get(0).compareTo(e2.getArgumentsArray().get(0));
if(comp == 0) {
comp = Integer.parseInt(e1.getArgumentsArray().get(1)) - Integer.parseInt(e2.getArgumentsArray().get(1));
}
return comp;
}
});
}
private void initTable() {
addTableColumns();
}
private void addTableColumns() {
addColumn(new TextColumn<DatasourceParsingErrorDto>() {
@Override
public String getValue(DatasourceParsingErrorDto dto) {
if(translations.datasourceParsingErrorMap().containsKey(dto.getKey()) == false) {
return dto.getDefaultMessage();
}
String msg = translations.datasourceParsingErrorMap().get(dto.getKey());
JsArrayString args = dto.getArgumentsArray();
if(args != null) {
for(int i = 0; i < args.length(); i++) {
msg = msg.replace("{" + i + "}", args.get(i));
}
}
return msg;
}
}, translations.errorLabel());
}
}
| 3,900 | 0.669744 | 0.664359 | 112 | 33.8125 | 32.834141 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.419643 | false | false | 9 |
ee97aae15b855a829dcc3cdde750fb87b7935cc7 | 25,520,695,734,602 | 5edd38a1965ba8389708a11d3e803bdd53236328 | /src/cn/edu/nju/ws/expedia/model/rdf/Node.java | 93a5b8a0d23756597368d072b9983c399d1b0101 | [] | no_license | conndots/expedia | https://github.com/conndots/expedia | 98c682d92de122103c9fc8c7f97adcea5fe661d1 | 23760970ff0193b2430c83deb22d1a49537b0064 | refs/heads/master | 2021-01-21T07:39:32.344000 | 2015-08-24T16:55:25 | 2015-08-24T16:55:25 | 41,314,139 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.edu.nju.ws.expedia.model.rdf;
/**
* Created by Xiangqian on 2015/4/8.
*/
public interface Node {
public static final String URI_RESOURCE = "ures",
ENTITY = "ent",
CATEGORY = "cat",
ONT_CLASS = "class",
PROPERTY = "prop",
LITERAL = "lit";
public String getNodeType();
}
| UTF-8 | Java | 351 | java | Node.java | Java | [
{
"context": "n.edu.nju.ws.expedia.model.rdf;\n\n/**\n * Created by Xiangqian on 2015/4/8.\n */\npublic interface Node {\n publ",
"end": 69,
"score": 0.9962413907051086,
"start": 60,
"tag": "NAME",
"value": "Xiangqian"
}
] | null | [] | package cn.edu.nju.ws.expedia.model.rdf;
/**
* Created by Xiangqian on 2015/4/8.
*/
public interface Node {
public static final String URI_RESOURCE = "ures",
ENTITY = "ent",
CATEGORY = "cat",
ONT_CLASS = "class",
PROPERTY = "prop",
LITERAL = "lit";
public String getNodeType();
}
| 351 | 0.549858 | 0.532764 | 14 | 24.071428 | 15.681948 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false | 9 |
26ccafa52f0ae7f40c5f7ce92df450645a8c6965 | 15,187,004,406,560 | ce94867dd5f0ce6b85c9f68ff2576ef36a6e2bd1 | /common/src/main/java/com/cqrs/events/HolderCreationEvent.java | 30d7968f90d5b94a126f971dc56a4b84a10aeb16 | [] | no_license | StrongSoft/axon-cqrs-demo | https://github.com/StrongSoft/axon-cqrs-demo | 0ed4130cdff5a592c3ed5b29b82faee7ddd6e4f7 | 099d16d4278cfe49a26104114e325abe712422b2 | refs/heads/master | 2023-05-27T03:03:54.144000 | 2021-05-31T13:57:49 | 2021-05-31T13:57:49 | 365,933,529 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.cqrs.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.axonframework.serialization.Revision;
@AllArgsConstructor
@ToString
@Getter
@Revision("1.0")
public class HolderCreationEvent {
private final String holderID;
private final String holderName;
private final String tel;
private final String address;
private final String company;
}
| UTF-8 | Java | 408 | java | HolderCreationEvent.java | Java | [] | null | [] | package com.cqrs.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.axonframework.serialization.Revision;
@AllArgsConstructor
@ToString
@Getter
@Revision("1.0")
public class HolderCreationEvent {
private final String holderID;
private final String holderName;
private final String tel;
private final String address;
private final String company;
}
| 408 | 0.803922 | 0.79902 | 18 | 21.666666 | 13.38324 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 9 |
b26abe1401eb642ac976b89b5310afd501ad8e9c | 6,760,278,564,938 | f3c6a07b8154ac31e6b3d81bf8370bcdfaf9c352 | /hsweb-easy-orm-rdb/src/main/java/org/hswebframework/ezorm/rdb/supports/oracle/OraclePaginator.java | d4d0f9abfceec02cd29a01337d0d871ba6f2edf8 | [] | no_license | hs-web/hsweb-easy-orm | https://github.com/hs-web/hsweb-easy-orm | baf8fbec7b43a091a05499fae1ad6e012dc65cac | 8e9c254d932d56332e3c6a4e61978f8cf773d63d | refs/heads/master | 2023-08-22T02:08:20.194000 | 2023-08-11T12:15:07 | 2023-08-11T12:15:07 | 60,450,885 | 287 | 185 | null | false | 2023-09-12T02:36:57 | 2016-06-05T08:42:02 | 2023-09-11T06:26:23 | 2023-09-12T02:36:56 | 2,101 | 267 | 157 | 3 | Java | false | false | package org.hswebframework.ezorm.rdb.supports.oracle;
import org.hswebframework.ezorm.rdb.operator.builder.FragmentBlock;
import org.hswebframework.ezorm.rdb.operator.builder.Paginator;
import org.hswebframework.ezorm.rdb.operator.builder.fragments.*;
import static org.hswebframework.ezorm.rdb.operator.builder.fragments.PrepareSqlFragments.*;
public class OraclePaginator implements Paginator {
@Override
public SqlFragments doPaging(SqlFragments fragments, int pageIndex, int pageSize) {
if (fragments instanceof PrepareSqlFragments) {
PrepareSqlFragments paging = of();
paging.addSql("select * from ( SELECT row_.*, rownum rownum_ FROM (")
.addFragments(fragments)
.addSql(") row_ ) where rownum_ <= ? AND rownum_ > ?")
.addParameter((pageIndex + 1) * pageSize, pageIndex * pageSize);
return paging;
} else if (fragments instanceof BlockSqlFragments) {
BlockSqlFragments block = ((BlockSqlFragments) fragments);
block.addBlockFirst(FragmentBlock.before, of().addSql("select * from ( SELECT row_.*, rownum rownum_ FROM ("));
block.addBlock(FragmentBlock.after, of().addSql(") row_ ) where rownum_ <= ? AND rownum_ > ?")
.addParameter((pageIndex + 1) * pageSize, pageIndex * pageSize));
}
return fragments;
}
}
| UTF-8 | Java | 1,418 | java | OraclePaginator.java | Java | [] | null | [] | package org.hswebframework.ezorm.rdb.supports.oracle;
import org.hswebframework.ezorm.rdb.operator.builder.FragmentBlock;
import org.hswebframework.ezorm.rdb.operator.builder.Paginator;
import org.hswebframework.ezorm.rdb.operator.builder.fragments.*;
import static org.hswebframework.ezorm.rdb.operator.builder.fragments.PrepareSqlFragments.*;
public class OraclePaginator implements Paginator {
@Override
public SqlFragments doPaging(SqlFragments fragments, int pageIndex, int pageSize) {
if (fragments instanceof PrepareSqlFragments) {
PrepareSqlFragments paging = of();
paging.addSql("select * from ( SELECT row_.*, rownum rownum_ FROM (")
.addFragments(fragments)
.addSql(") row_ ) where rownum_ <= ? AND rownum_ > ?")
.addParameter((pageIndex + 1) * pageSize, pageIndex * pageSize);
return paging;
} else if (fragments instanceof BlockSqlFragments) {
BlockSqlFragments block = ((BlockSqlFragments) fragments);
block.addBlockFirst(FragmentBlock.before, of().addSql("select * from ( SELECT row_.*, rownum rownum_ FROM ("));
block.addBlock(FragmentBlock.after, of().addSql(") row_ ) where rownum_ <= ? AND rownum_ > ?")
.addParameter((pageIndex + 1) * pageSize, pageIndex * pageSize));
}
return fragments;
}
}
| 1,418 | 0.659379 | 0.657969 | 31 | 44.741936 | 36.925354 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.645161 | false | false | 9 |
6bb52785986ede3526e0d06dec240a954ca65b8d | 21,208,548,542,937 | 47bf12bfc06f7bdacb82ae03104f2f7682865d5d | /src/test/java/io/hemrlav/springsecurityjpah2/SpringSecurityJpaH2ApplicationTests.java | d2a74d5068326fbc023080dde7ac570e99495d25 | [] | no_license | hemrajanilavesh/spring-security-jpa | https://github.com/hemrajanilavesh/spring-security-jpa | 27890c5c14e764ca74ac4a8ca944bee4d6d761c3 | da9dd9780d38b4d190caaade0179f88b8a571c0a | refs/heads/main | 2023-06-23T05:02:06.503000 | 2021-07-21T04:47:15 | 2021-07-21T04:47:15 | 387,995,151 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.hemrlav.springsecurityjpah2;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringSecurityJpaH2ApplicationTests {
@Test
void contextLoads() {
}
}
| UTF-8 | Java | 235 | java | SpringSecurityJpaH2ApplicationTests.java | Java | [] | null | [] | package io.hemrlav.springsecurityjpah2;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringSecurityJpaH2ApplicationTests {
@Test
void contextLoads() {
}
}
| 235 | 0.808511 | 0.8 | 13 | 17.076923 | 19.77746 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 9 |
01856b76ab5d8f5a64be6b5e918cae4e7178a1ea | 20,547,123,565,391 | c0a32230d95ea6291a121a05f30f6197867afe51 | /app/src/main/java/com/stephen/fake_aidl/IBookManager.java | 7ef9ef2f79e3e624ddbb67f5fccf348294dbb351 | [] | no_license | StephenNeverMore/AndroidGroceryStore | https://github.com/StephenNeverMore/AndroidGroceryStore | 432c9cfe5e41777a3373b2916e26f99b54276b3c | 655407db04b5c0927afd131da64ad3e24927e1ef | refs/heads/master | 2021-01-15T08:14:11.479000 | 2019-04-15T08:27:14 | 2019-04-15T08:27:14 | 99,561,802 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.stephen.fake_aidl;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import java.util.List;
/**
* @author zhushuang
* @data 2017/7/31.
*/
public interface IBookManager extends IInterface {
static final String DESCRIPTOR = "com.stephen.fake_aidl.IBookManager";
static final int TRANSACTION_getBookList = IBinder.FIRST_CALL_TRANSACTION + 0;
static final int TRANSACTION_addBook = IBinder.FIRST_CALL_TRANSACTION + 1;
public List<Book> getBookList() throws RemoteException;
public List<String> addBook(Book book) throws RemoteException;
}
| UTF-8 | Java | 618 | java | IBookManager.java | Java | [
{
"context": "Exception;\n\nimport java.util.List;\n\n/**\n * @author zhushuang\n * @data 2017/7/31.\n */\n\npublic interface IBookMa",
"end": 173,
"score": 0.9995142221450806,
"start": 164,
"tag": "USERNAME",
"value": "zhushuang"
}
] | null | [] | package com.stephen.fake_aidl;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import java.util.List;
/**
* @author zhushuang
* @data 2017/7/31.
*/
public interface IBookManager extends IInterface {
static final String DESCRIPTOR = "com.stephen.fake_aidl.IBookManager";
static final int TRANSACTION_getBookList = IBinder.FIRST_CALL_TRANSACTION + 0;
static final int TRANSACTION_addBook = IBinder.FIRST_CALL_TRANSACTION + 1;
public List<Book> getBookList() throws RemoteException;
public List<String> addBook(Book book) throws RemoteException;
}
| 618 | 0.7589 | 0.744337 | 22 | 27.09091 | 28.051752 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false | 9 |
b8cd672dac465a7e667ea12838d791afb1e477e2 | 6,047,314,003,935 | f0e82dc35084bbd4afebce1dce98758d00b7128d | /src/problem_solutions/p024.java | 95eb4af47e10bbc003a9936c4e66e73ea5224fcf | [] | no_license | BenjiTrapp/ProjectEulerSolutions | https://github.com/BenjiTrapp/ProjectEulerSolutions | 364e45f45c8ee89396bb4f8d38b10d5c9f281b10 | 0e666bb0f29099d75bb84e67d3bdcc4098523d5e | refs/heads/master | 2021-01-12T09:04:24.722000 | 2016-12-18T01:15:19 | 2016-12-18T01:15:19 | 76,753,297 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package problem_solutions;
import utils.ProjectEulerLibrary;
public final class p024 implements EulerSolution
{
public static void main(String[] args) {
System.out.println(new p024().solve());
}
public String solve()
{
/* Initialize the Shit */
String ans = "";
int[] array = new int[10];
for (int i = 0; i < array.length; i++)
array[i] = i;
/* Permutete the initialized Shit */
for (int i = 0; i < 999999; i++)
if (!ProjectEulerLibrary.nextPermutation(array))
throw new AssertionError();
/* Pushover for a pretty output */
for (int i = 0; i < array.length; i++)
ans += array[i];
return ans;
}
} | UTF-8 | Java | 640 | java | p024.java | Java | [] | null | [] | package problem_solutions;
import utils.ProjectEulerLibrary;
public final class p024 implements EulerSolution
{
public static void main(String[] args) {
System.out.println(new p024().solve());
}
public String solve()
{
/* Initialize the Shit */
String ans = "";
int[] array = new int[10];
for (int i = 0; i < array.length; i++)
array[i] = i;
/* Permutete the initialized Shit */
for (int i = 0; i < 999999; i++)
if (!ProjectEulerLibrary.nextPermutation(array))
throw new AssertionError();
/* Pushover for a pretty output */
for (int i = 0; i < array.length; i++)
ans += array[i];
return ans;
}
} | 640 | 0.640625 | 0.614062 | 30 | 20.366667 | 17.094801 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.8 | false | false | 9 |
f8ff60bb3fdb399cbd2f98acc5d331dc1d24346b | 24,137,716,215,648 | 3f240ae88098b5c23713f2b0b368fcfd7a697002 | /src/main/java/it/univpm/CovidForecast/filters/FilterTemperature.java | 25f9b72fcee328b347428752c44a814bba06eae8 | [
"MIT"
] | permissive | emanuelefrisi/CovidForecast | https://github.com/emanuelefrisi/CovidForecast | a1b9b6d117b3275a448eef76cbe8cb7b05195993 | cf04ccb992a667a93c885722ca4696d381df4122 | refs/heads/master | 2023-02-21T10:43:51.850000 | 2021-01-25T10:55:58 | 2021-01-25T10:55:58 | 316,771,915 | 0 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package it.univpm.CovidForecast.filters;
import java.util.Vector;
import org.springframework.stereotype.Service;
import it.univpm.CovidForecast.model.MeteoCitta;
/**
* Classe che esegue il filtraggio in base alla temperatura
*
* @author domenicolaporta00
*
*/
@Service
public class FilterTemperature {
/**
* Vector contenente gli oggetti di tipo MeteoCitta filtarti per temperatura
*/
private Vector<MeteoCitta> vectFiltrato;
/**
* Metodo che esegue il filtraggio per temperatura su un Vector ricevuto in
* input
*
* @param vectDaFiltr Vector<MeteoCitta>
*
* @param tempInit Double
*
* @param tempFin Double
*
* @return Vector<MeteoCitta>
*
*/
public Vector<MeteoCitta> getFromTemperatureFilter(Vector<MeteoCitta> vectDaFiltr, Double tempInit,
Double tempFin) {
vectFiltrato = new Vector<MeteoCitta>();
for (int i = 0; i < vectDaFiltr.size(); i++) {
MeteoCitta mC = vectDaFiltr.get(i);
if (mC.getTemp() >= tempInit && mC.getTemp() <= tempFin) {
vectFiltrato.add(mC);
}
}
return vectFiltrato;
}
}
| UTF-8 | Java | 1,075 | java | FilterTemperature.java | Java | [
{
"context": "iltraggio in base alla temperatura \n * \n * @author domenicolaporta00\n * \n */\n@Service\npublic class FilterTemperature {",
"end": 263,
"score": 0.9969961643218994,
"start": 246,
"tag": "USERNAME",
"value": "domenicolaporta00"
}
] | null | [] | package it.univpm.CovidForecast.filters;
import java.util.Vector;
import org.springframework.stereotype.Service;
import it.univpm.CovidForecast.model.MeteoCitta;
/**
* Classe che esegue il filtraggio in base alla temperatura
*
* @author domenicolaporta00
*
*/
@Service
public class FilterTemperature {
/**
* Vector contenente gli oggetti di tipo MeteoCitta filtarti per temperatura
*/
private Vector<MeteoCitta> vectFiltrato;
/**
* Metodo che esegue il filtraggio per temperatura su un Vector ricevuto in
* input
*
* @param vectDaFiltr Vector<MeteoCitta>
*
* @param tempInit Double
*
* @param tempFin Double
*
* @return Vector<MeteoCitta>
*
*/
public Vector<MeteoCitta> getFromTemperatureFilter(Vector<MeteoCitta> vectDaFiltr, Double tempInit,
Double tempFin) {
vectFiltrato = new Vector<MeteoCitta>();
for (int i = 0; i < vectDaFiltr.size(); i++) {
MeteoCitta mC = vectDaFiltr.get(i);
if (mC.getTemp() >= tempInit && mC.getTemp() <= tempFin) {
vectFiltrato.add(mC);
}
}
return vectFiltrato;
}
}
| 1,075 | 0.700465 | 0.697674 | 50 | 20.5 | 24.230766 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.12 | false | false | 9 |
8bf57990c38f532ca086ddc08f01960ccb0e5cf4 | 15,350,213,150,607 | 0f95b5c41e60c35274c8ab4cc382a38b56ccbc12 | /my-gdx-game/src/com/rebelkeithy/ftl/crew/CrewEffects.java | df4d5efb3ae6cd93f20d8af912d93321c5120001 | [] | no_license | RebelKeithy/FTL-Hyperion | https://github.com/RebelKeithy/FTL-Hyperion | f87c409f5950fb6dd52e4d26dd54d4e3997cd1b2 | c05ff64307cb15bb1e9c8f607c4fad5cfdc04a0f | refs/heads/master | 2021-01-25T06:37:00.402000 | 2014-06-07T14:35:26 | 2014-06-07T14:35:26 | 20,405,947 | 7 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.rebelkeithy.ftl.crew;
import java.util.Set;
import com.google.common.eventbus.Subscribe;
import com.rebelkeithy.ftl.Main;
import com.rebelkeithy.ftl.event.CrewDamagedEvent;
import com.rebelkeithy.ftl.event.CrewUpdateEvent;
import com.rebelkeithy.ftl.event.GetSystemPowerEvent;
import com.rebelkeithy.ftl.event.ShipCreationEvent;
import com.rebelkeithy.ftl.properties.Properties;
import com.rebelkeithy.ftl.ship.Room;
import com.rebelkeithy.ftl.systems.AbstractShipSystem;
public class CrewEffects
{
private int dt;
public CrewEffects()
{
Main.GLOBAL_BUS.register(this);
}
@Subscribe
public void shipCreation(ShipCreationEvent event)
{
//event.ship.EVENT_BUS.register(this);
}
@Subscribe
public void crewUdate(CrewUpdateEvent event)
{
Crew crew = event.getCrew();
if(crew.getRace().equals("Lanius"))
{
if(crew.getRoom() != null)
{
Properties properties = crew.getRoom().getProperties();
double oxygen = properties.getDouble("oxygen");
oxygen -= 2 * dt;
if(oxygen < 0)
oxygen = 0;
properties.setDouble("oxygen", oxygen);
}
}
}
@Subscribe
public void crewDamagedEvent(CrewDamagedEvent event)
{
if(event.getSource().equals("oxygen"))
{
if(event.getCrew().getRace().equals("Lanius"))
{
event.cancel = true;
}
if(event.getCrew().getRace().equals("Crystal"))
{
event.damage *= 0.5;
}
}
}
@Subscribe
public void getPowerEvent(GetSystemPowerEvent event)
{
AbstractShipSystem system = event.ship.getSystem(event.system);
Room room = system.getRoom();
if(room != null)
{
Set<Crew> crew = room.getCrew();
for(Crew member : crew)
{
if(member.getRace().equals("Zoltan"))
{
// TODO: What if max power is 1 and there are 2 zoltans; calc additional power in loop then check to make sure it is not more than max power
// TODO: What if the system was at max power and a zoltan walks in; perhaps should be taken care of in the system, if power is greater than max, remove curr-max power
event.power++;
}
}
}
}
}
| UTF-8 | Java | 2,069 | java | CrewEffects.java | Java | [] | null | [] | package com.rebelkeithy.ftl.crew;
import java.util.Set;
import com.google.common.eventbus.Subscribe;
import com.rebelkeithy.ftl.Main;
import com.rebelkeithy.ftl.event.CrewDamagedEvent;
import com.rebelkeithy.ftl.event.CrewUpdateEvent;
import com.rebelkeithy.ftl.event.GetSystemPowerEvent;
import com.rebelkeithy.ftl.event.ShipCreationEvent;
import com.rebelkeithy.ftl.properties.Properties;
import com.rebelkeithy.ftl.ship.Room;
import com.rebelkeithy.ftl.systems.AbstractShipSystem;
public class CrewEffects
{
private int dt;
public CrewEffects()
{
Main.GLOBAL_BUS.register(this);
}
@Subscribe
public void shipCreation(ShipCreationEvent event)
{
//event.ship.EVENT_BUS.register(this);
}
@Subscribe
public void crewUdate(CrewUpdateEvent event)
{
Crew crew = event.getCrew();
if(crew.getRace().equals("Lanius"))
{
if(crew.getRoom() != null)
{
Properties properties = crew.getRoom().getProperties();
double oxygen = properties.getDouble("oxygen");
oxygen -= 2 * dt;
if(oxygen < 0)
oxygen = 0;
properties.setDouble("oxygen", oxygen);
}
}
}
@Subscribe
public void crewDamagedEvent(CrewDamagedEvent event)
{
if(event.getSource().equals("oxygen"))
{
if(event.getCrew().getRace().equals("Lanius"))
{
event.cancel = true;
}
if(event.getCrew().getRace().equals("Crystal"))
{
event.damage *= 0.5;
}
}
}
@Subscribe
public void getPowerEvent(GetSystemPowerEvent event)
{
AbstractShipSystem system = event.ship.getSystem(event.system);
Room room = system.getRoom();
if(room != null)
{
Set<Crew> crew = room.getCrew();
for(Crew member : crew)
{
if(member.getRace().equals("Zoltan"))
{
// TODO: What if max power is 1 and there are 2 zoltans; calc additional power in loop then check to make sure it is not more than max power
// TODO: What if the system was at max power and a zoltan walks in; perhaps should be taken care of in the system, if power is greater than max, remove curr-max power
event.power++;
}
}
}
}
}
| 2,069 | 0.698405 | 0.695022 | 85 | 23.341177 | 28.601337 | 171 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.176471 | false | false | 9 |
7b6ae6457c4a405d41806682e221a0ad21599e01 | 25,245,817,777,753 | c91c43a37ebe3895bfdbebb7119fa73700213237 | /HB_49_ManyToOne/src/main/java/com/nit/test/FetchAllStudent.java | dff65e7ff1fda63d0d9769fd0e609d2d1502861e | [] | no_license | Sachin97github/HIBERNATE | https://github.com/Sachin97github/HIBERNATE | e26afc8c00ab5a0e582927d387c5aadab0b1131b | 2cbedf8fe7852d2f82c0ca928ceceffdfbf798ce | refs/heads/master | 2023-01-09T01:36:09.812000 | 2020-11-15T14:52:56 | 2020-11-15T14:52:56 | 313,035,060 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nit.test;
import java.util.Date;
import com.nit.dao.IStudentDAO;
import com.nit.dao.StudentDAOImpl;
import com.nit.entity.Course;
import com.nit.entity.Student;
public class FetchAllStudent {
public static void main(String[] args) {
IStudentDAO dao=new StudentDAOImpl();
dao.getAllStudent();
}
}
| UTF-8 | Java | 339 | java | FetchAllStudent.java | Java | [] | null | [] | package com.nit.test;
import java.util.Date;
import com.nit.dao.IStudentDAO;
import com.nit.dao.StudentDAOImpl;
import com.nit.entity.Course;
import com.nit.entity.Student;
public class FetchAllStudent {
public static void main(String[] args) {
IStudentDAO dao=new StudentDAOImpl();
dao.getAllStudent();
}
}
| 339 | 0.713864 | 0.713864 | 17 | 17.941177 | 15.329597 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 9 |
ac634b805c042fcccbebb73a29f203b5ca7304c8 | 19,292,993,113,239 | f35fea318fe4da0b41188c88a44c328910bda87f | /src/TechProEd/C02_Varargs02.java | 032e733dab7d8c6891881225da5806f983432854 | [] | no_license | hakan44-star/Git_Test | https://github.com/hakan44-star/Git_Test | 72493943ab89e2f0f24094ffbdd9457fe725293f | db61c5c2e8d640a3d3d07b34292d12fdbc79c7a7 | refs/heads/master | 2023-07-17T22:55:25.746000 | 2021-08-19T14:30:37 | 2021-08-19T14:30:37 | 397,955,597 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package TechProEd;
public class C02_Varargs02 {
public static void main(String[] args) {
String s = "Hakan tetik";
concat(s);
System.out.println(s);
}
private static void concat(String s){
System.out.println(s+ "dagtekin");
}
}
| UTF-8 | Java | 282 | java | C02_Varargs02.java | Java | [
{
"context": " void main(String[] args) {\n\n\n String s = \"Hakan tetik\";\n concat(s);\n System.out.println(s",
"end": 127,
"score": 0.9963991045951843,
"start": 116,
"tag": "NAME",
"value": "Hakan tetik"
}
] | null | [] | package TechProEd;
public class C02_Varargs02 {
public static void main(String[] args) {
String s = "<NAME>";
concat(s);
System.out.println(s);
}
private static void concat(String s){
System.out.println(s+ "dagtekin");
}
}
| 277 | 0.585106 | 0.570922 | 17 | 15.588235 | 16.666483 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | false | false | 9 |
90474021ad965fd0d50051165a01c7f36948ca5b | 790,274,018,301 | 8ee107072d4d56f0966dc9800373e6a29b2ccecc | /src/main/java/ru/pizza/validator/OformlenieValidator.java | 07b189a7826155f3b63a31c3ffae9594a1288f40 | [] | no_license | SulaymonHursanov/PizzaOnline_SpringBoot | https://github.com/SulaymonHursanov/PizzaOnline_SpringBoot | eb40761866e752922d5a65a75ec7ff5c2f6b9754 | 175258cb71b9fdab8089cc4f7f874d9fdd1304c1 | refs/heads/master | 2021-09-24T02:07:00.699000 | 2018-10-01T18:41:32 | 2018-10-01T18:41:32 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.pizza.validator;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import ru.pizza.models.Oformlenie;
/**
* Created by Sulaymon on 17.12.2017.
*/
@Component
public class OformlenieValidator implements Validator {
@Override
public boolean supports(Class<?> aClass) {
return aClass.getName().equals(Oformlenie.class.getName());
}
@Override
public void validate(Object target, Errors errors) {
Oformlenie oformlenie = (Oformlenie)target;
System.out.println("yes");
if (oformlenie.getRadiotype().equals("takeme")){
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id_magaz", "empty.num", "выберите пицерию");
}else if (oformlenie.getRadiotype().equals("send")){
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "streetAndHouse", "empty.address","Заполните поле адрес");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "floor", "empty.floor","Заполните поле этаж");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "roomNumber", "empty.room","Заполните поле квартира");
}else errors.reject("bad.type", "Выберите один из типов");
}
}
| UTF-8 | Java | 1,412 | java | OformlenieValidator.java | Java | [
{
"context": "ort ru.pizza.models.Oformlenie;\n\n/**\n * Created by Sulaymon on 17.12.2017.\n */\n@Component\npublic class Oforml",
"end": 290,
"score": 0.992315948009491,
"start": 282,
"tag": "USERNAME",
"value": "Sulaymon"
}
] | null | [] | package ru.pizza.validator;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import ru.pizza.models.Oformlenie;
/**
* Created by Sulaymon on 17.12.2017.
*/
@Component
public class OformlenieValidator implements Validator {
@Override
public boolean supports(Class<?> aClass) {
return aClass.getName().equals(Oformlenie.class.getName());
}
@Override
public void validate(Object target, Errors errors) {
Oformlenie oformlenie = (Oformlenie)target;
System.out.println("yes");
if (oformlenie.getRadiotype().equals("takeme")){
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id_magaz", "empty.num", "выберите пицерию");
}else if (oformlenie.getRadiotype().equals("send")){
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "streetAndHouse", "empty.address","Заполните поле адрес");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "floor", "empty.floor","Заполните поле этаж");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "roomNumber", "empty.room","Заполните поле квартира");
}else errors.reject("bad.type", "Выберите один из типов");
}
}
| 1,412 | 0.718608 | 0.712557 | 34 | 37.882355 | 35.604664 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.823529 | false | false | 9 |
ea7c7185b9c9b62ffe74f16c437676429abc583f | 13,245,679,150,111 | 1e419c01779fd993cdd6bdf2e312e55a66d30ed5 | /src/main/java/com/carracing/dao/car/CarMapper.java | 7a5b51aa3aaa230e05ad03fb6a1b47f000c4446c | [] | no_license | razeenh/car-racing | https://github.com/razeenh/car-racing | 2fb7fc3a9fc7f6406ae3a61eddd8105a1dd444d3 | c6ba355af524498546bc560bd15d9ed25481d7f1 | refs/heads/main | 2023-01-21T13:36:46.385000 | 2020-11-18T07:37:48 | 2020-11-18T07:37:48 | 313,858,163 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.carracing.dao.car;
import com.carracing.sdk.dao.JdbcResultMapper;
public interface CarMapper extends JdbcResultMapper<Car> {
}
| UTF-8 | Java | 141 | java | CarMapper.java | Java | [] | null | [] | package com.carracing.dao.car;
import com.carracing.sdk.dao.JdbcResultMapper;
public interface CarMapper extends JdbcResultMapper<Car> {
}
| 141 | 0.815603 | 0.815603 | 6 | 22.5 | 23.606144 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
b7776a2dce8ee8e57e434dd226d0d8490215d1e8 | 25,598,005,126,212 | bd070f88b4b122e0628fe1b1b98e1fc10371da0d | /src/main/java/com/xie/rtc/cleaning/decoder/impl/JSONDecoder.java | 9cebf0554f5f9864cb5b91aa9c1d0e0cd977bb6d | [] | no_license | shpota2/rtc-data-cleaning | https://github.com/shpota2/rtc-data-cleaning | a12000c28e7981eb076b832c6863c71be76f3fd2 | 728c631fc0fb392e3ab3042a6a37ef1a5a5c89f8 | refs/heads/master | 2021-02-15T02:09:40.352000 | 2019-08-10T08:22:30 | 2019-08-10T08:22:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xie.rtc.cleaning.decoder.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.xie.rtc.cleaning.Context;
import com.xie.rtc.cleaning.decoder.Decoder;
import com.xie.rtc.cleaning.decoder.DecoderType;
import com.xie.rtc.cleaning.exception.InvalidParameterException;
/**
* @author xiejing.kane
*
*/
@DecoderType("json")
public class JSONDecoder implements Decoder {
private static final Logger LOGGER = LoggerFactory.getLogger(JSONDecoder.class);
@Override
public void init(Context decoderContext) throws InvalidParameterException {
}
@Override
public JSONObject decode(String source) {
JSONObject json = JSONObject.parseObject(source);
LOGGER.trace("decode result = " + json);
return json;
}
}
| UTF-8 | Java | 817 | java | JSONDecoder.java | Java | [
{
"context": "tion.InvalidParameterException;\r\n\r\n/**\r\n * @author xiejing.kane\r\n *\r\n */\r\n@DecoderType(\"json\")\r\npublic class JSON",
"end": 378,
"score": 0.9472594261169434,
"start": 366,
"tag": "NAME",
"value": "xiejing.kane"
}
] | null | [] | package com.xie.rtc.cleaning.decoder.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.xie.rtc.cleaning.Context;
import com.xie.rtc.cleaning.decoder.Decoder;
import com.xie.rtc.cleaning.decoder.DecoderType;
import com.xie.rtc.cleaning.exception.InvalidParameterException;
/**
* @author xiejing.kane
*
*/
@DecoderType("json")
public class JSONDecoder implements Decoder {
private static final Logger LOGGER = LoggerFactory.getLogger(JSONDecoder.class);
@Override
public void init(Context decoderContext) throws InvalidParameterException {
}
@Override
public JSONObject decode(String source) {
JSONObject json = JSONObject.parseObject(source);
LOGGER.trace("decode result = " + json);
return json;
}
}
| 817 | 0.75153 | 0.749082 | 31 | 24.354839 | 24.038342 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.806452 | false | false | 9 |
b1906ea7923e960fd448b84741c38b69bf70188e | 29,661,044,167,997 | b6a7381d232ddaf3fc757a4c3852e5fafd324cd6 | /archive/contests/contest1072/CUspetVse.java | 38b5a10652ae44a0891e7e3241d90bbe4c9dcbb6 | [] | no_license | prituladima/codeforces | https://github.com/prituladima/codeforces | eb0b7f1f37543c59b205c6c1c0c082a579d8b86e | fc8080b696058e7e4006fe9022149b7c7b283478 | refs/heads/master | 2021-06-03T21:02:39.628000 | 2021-05-29T17:14:26 | 2021-05-29T17:14:26 | 126,067,916 | 1 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.prituladima.codeforce.contests.contest1072;
import com.prituladima.codeforce.InputReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import static com.prituladima.codeforce.GeekDP.Pair;
public class CUspetVse {
int a, b;
int ans;
String s;
private List<Pair> pairs = new ArrayList<>();
public void solve(int testNumber, InputReader in, PrintWriter out) {
a = in.nextInt();
b = in.nextInt();
long sum = a + b;
int X = 0;
for (long x = 1; (x * (x + 1)) / 2 <= sum; x++) {
X = (int) x;
}
boolean[] used = new boolean[X + 1];
List<Integer> ansN = new ArrayList<>();
for (int i = X; i > 0; i--) {
if (!used[i] && a >= i) {
used[i] = true;
a -= i;
ansN.add(i);
}
}
List<Integer> ansM = new ArrayList<>();
for (int i = X; i > 0; i--) {
if (!used[i] && b >= i) {
used[i] = true;
b -= i;
ansM.add(i);
}
}
// if(a)
out.println(ansN.size());
for (int i = 0; i < ansN.size(); i++) {
out.print(ansN.get(i) + " ");
}
out.println();
out.println(ansM.size());
for (int i = 0; i < ansM.size(); i++) {
out.print(ansM.get(i) + " ");
}
// out.println(ans);
}
} | UTF-8 | Java | 1,483 | java | CUspetVse.java | Java | [] | null | [] | package com.prituladima.codeforce.contests.contest1072;
import com.prituladima.codeforce.InputReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import static com.prituladima.codeforce.GeekDP.Pair;
public class CUspetVse {
int a, b;
int ans;
String s;
private List<Pair> pairs = new ArrayList<>();
public void solve(int testNumber, InputReader in, PrintWriter out) {
a = in.nextInt();
b = in.nextInt();
long sum = a + b;
int X = 0;
for (long x = 1; (x * (x + 1)) / 2 <= sum; x++) {
X = (int) x;
}
boolean[] used = new boolean[X + 1];
List<Integer> ansN = new ArrayList<>();
for (int i = X; i > 0; i--) {
if (!used[i] && a >= i) {
used[i] = true;
a -= i;
ansN.add(i);
}
}
List<Integer> ansM = new ArrayList<>();
for (int i = X; i > 0; i--) {
if (!used[i] && b >= i) {
used[i] = true;
b -= i;
ansM.add(i);
}
}
// if(a)
out.println(ansN.size());
for (int i = 0; i < ansN.size(); i++) {
out.print(ansN.get(i) + " ");
}
out.println();
out.println(ansM.size());
for (int i = 0; i < ansM.size(); i++) {
out.print(ansM.get(i) + " ");
}
// out.println(ans);
}
} | 1,483 | 0.447741 | 0.438975 | 66 | 21.484848 | 18.439287 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.651515 | false | false | 9 |
f085e00dbbb9a405f749674e4c08c84b340f6aa9 | 2,250,562,928,711 | 70c47a4f070f8feb0a1b6eebac6a926bf3628118 | /src/main/java/net/therap/dao/ScreeningTestDaoImpl.java | e2d760b5049874dc82055885c8643be8dc1e679f | [] | no_license | rokon12/TherapJavaFestWebApp | https://github.com/rokon12/TherapJavaFestWebApp | 0c027652ed09d4097a972338766f575b776fa619 | eb4ab052a13fe8eee43ac2821c4dde174b149e16 | refs/heads/master | 2021-01-16T19:42:20.981000 | 2012-11-13T04:53:05 | 2012-11-13T04:53:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.therap.dao;
import net.therap.domain.Contestant;
import net.therap.domain.ScreeningTest;
import org.hibernate.Query;
import org.hibernate.Session;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.*;
import org.jboss.seam.log.Log;
import java.io.Serializable;
import java.util.List;
/**
* Created by
* User: tahmid
* Date: 7/30/12
* Time: 1:11 PM
*/
@Name("screeningTestDao")
@Scope(ScopeType.EVENT)
public class ScreeningTestDaoImpl implements ScreeningTestDao, Serializable {
@Logger
Log log;
@In
private Session session;
public void saveScreeningTest(ScreeningTest screeningTest) {
session.save(screeningTest);
}
public void updateScreeningTest(ScreeningTest screeningTest) {
session.update(screeningTest);
}
public Session getSession() {
return session;
}
public void setSession(Session session) {
this.session = session;
}
public ScreeningTest getScreeningTestForContestant(Contestant contestant) {
Query query = session.createQuery("from ScreeningTest screeningTest where screeningTest.screeningTestId = :screeningTestId");
query.setLong("screeningTestId",contestant.getScreeningTest().getScreeningTestId());
List<ScreeningTest> screeningTestList = (List<ScreeningTest>) query.list();
if (screeningTestList.size() != 0) {
log.info("not null");
session.merge(contestant.getScreeningTest());
return screeningTestList.get(0);
} else {
log.info("null");
return null;
}
}
}
| UTF-8 | Java | 1,621 | java | ScreeningTestDaoImpl.java | Java | [
{
"context": "import java.util.List;\n\n/**\n * Created by\n * User: tahmid\n * Date: 7/30/12\n * Time: 1:11 PM\n */\n\n@Name(\"scr",
"end": 348,
"score": 0.9994959831237793,
"start": 342,
"tag": "USERNAME",
"value": "tahmid"
}
] | null | [] | package net.therap.dao;
import net.therap.domain.Contestant;
import net.therap.domain.ScreeningTest;
import org.hibernate.Query;
import org.hibernate.Session;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.*;
import org.jboss.seam.log.Log;
import java.io.Serializable;
import java.util.List;
/**
* Created by
* User: tahmid
* Date: 7/30/12
* Time: 1:11 PM
*/
@Name("screeningTestDao")
@Scope(ScopeType.EVENT)
public class ScreeningTestDaoImpl implements ScreeningTestDao, Serializable {
@Logger
Log log;
@In
private Session session;
public void saveScreeningTest(ScreeningTest screeningTest) {
session.save(screeningTest);
}
public void updateScreeningTest(ScreeningTest screeningTest) {
session.update(screeningTest);
}
public Session getSession() {
return session;
}
public void setSession(Session session) {
this.session = session;
}
public ScreeningTest getScreeningTestForContestant(Contestant contestant) {
Query query = session.createQuery("from ScreeningTest screeningTest where screeningTest.screeningTestId = :screeningTestId");
query.setLong("screeningTestId",contestant.getScreeningTest().getScreeningTestId());
List<ScreeningTest> screeningTestList = (List<ScreeningTest>) query.list();
if (screeningTestList.size() != 0) {
log.info("not null");
session.merge(contestant.getScreeningTest());
return screeningTestList.get(0);
} else {
log.info("null");
return null;
}
}
}
| 1,621 | 0.686613 | 0.680444 | 65 | 23.938461 | 26.726465 | 133 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 9 |
cc7bf38eb1ad620da168f8769c9e4cf4564a20da | 5,841,155,537,421 | 002a5a5a7c38b7421ce5fc3e494d8cdbba223a58 | /src/main/java/com/cai2yy/armot/utils/mqttclient/MqttReceiveCallback.java | cc4942655834d35596fc5650580ff1af5746d0c1 | [] | no_license | bellmit/armot | https://github.com/bellmit/armot | 3887f039e2e925276ad87f150f161ffffa04b1d1 | 67b85db5087bb06c48bc4826d5b109b7ab615563 | refs/heads/master | 2023-04-04T17:14:09.336000 | 2020-09-29T01:12:39 | 2020-09-29T01:12:39 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.cai2yy.armot.utils.mqttclient;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import com.cai2yy.armot.core.ArmOT;
public class MqttReceiveCallback implements MqttCallback {
ArmOT armOT;
MqttReceiveCallback(ArmOT armOT) {
this.armOT = armOT;
}
@Override
public void connectionLost(Throwable cause) {
}
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
System.out.println("Client 接收消息主题 : " + topic);
System.out.println("Client 接收消息Qos : " + message.getQos());
System.out.println("Client 接收消息内容 : " + new String(message.getPayload()));
//this.armIot.eventBus.fireEvent("receiveMqttMsg", message);
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
}
}
| UTF-8 | Java | 967 | java | MqttReceiveCallback.java | Java | [] | null | [] | package com.cai2yy.armot.utils.mqttclient;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import com.cai2yy.armot.core.ArmOT;
public class MqttReceiveCallback implements MqttCallback {
ArmOT armOT;
MqttReceiveCallback(ArmOT armOT) {
this.armOT = armOT;
}
@Override
public void connectionLost(Throwable cause) {
}
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
System.out.println("Client 接收消息主题 : " + topic);
System.out.println("Client 接收消息Qos : " + message.getQos());
System.out.println("Client 接收消息内容 : " + new String(message.getPayload()));
//this.armIot.eventBus.fireEvent("receiveMqttMsg", message);
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
}
}
| 967 | 0.709091 | 0.703743 | 35 | 25.714285 | 27.585266 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.371429 | false | false | 9 |
ad0f636409d0f8dcbe56e9e82adbd096ba74a2d0 | 29,076,928,615,124 | 5e03805c039895272ed29685c7ca050380a1120d | /tests/com/enterprise/java/week2/FindAndReplaceTest.java | 44d4e715f97cc4eb6558ba1d9e1da800599d3308 | [] | no_license | turtlebro89/FindAndReplace | https://github.com/turtlebro89/FindAndReplace | e48cf60a6f1a376ed180dc38a0a2cefb16c76723 | beebb66881a15271a23d105ec7d1c3800946352c | refs/heads/master | 2021-01-10T21:54:34.322000 | 2015-09-22T01:39:47 | 2015-09-22T01:39:47 | 42,485,170 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.enterprise.java.week2;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* Created by student on 9/21/2015.
*/
public class FindAndReplaceTest extends TestCase {
@Rule
public ExpectedException thrown= ExpectedException.none();
@Test
public void testConstructor(){
FindAndReplace testCreation = new FindAndReplace(null, null, null);
assertNotNull(testCreation);
}
@Test
public void testReadInputFile() throws Exception {
FindAndReplace findAndReplace = new FindAndReplace("/tests/testDocuments/TestInput.txt",
"/tests/testDocuments/TestFindReplace.txt", "/test/testDocuments/testOutput.txt");
findAndReplace.readInputFile();
try(BufferedReader br = new BufferedReader(new FileReader("/test/testDocuments/testOutput.txt"))){
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@Test
public void testReplaceLineWithValueAddsToMap() throws Exception {
FindAndReplace findAndReplace = new FindAndReplace(null, null, null);
findAndReplace.replaceLineWithValue("Hello:Hi There!,Boom:BadaBoom");
assertTrue(findAndReplace.findReplaceValues != null);
}
@Test
public void testOutputFileWasCreated() throws Exception {
FindAndReplace testOuputFile = new FindAndReplace("hi", "there", "boom");
assertNotNull(testOuputFile.createOutputFile());
}
@Test(expected = IOException.class)
public void testOutputFileThrowsException() throws Exception {
FindAndReplace testFileNFound = new FindAndReplace("Boom!!", "/java/home/bananas", null);
testFileNFound.createOutputFile();
}
} | UTF-8 | Java | 1,929 | java | FindAndReplaceTest.java | Java | [
{
"context": "er;\nimport java.io.IOException;\n\n/**\n * Created by student on 9/21/2015.\n */\npublic class FindAndReplaceTest",
"end": 333,
"score": 0.813775360584259,
"start": 326,
"tag": "USERNAME",
"value": "student"
}
] | null | [] | package com.enterprise.java.week2;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* Created by student on 9/21/2015.
*/
public class FindAndReplaceTest extends TestCase {
@Rule
public ExpectedException thrown= ExpectedException.none();
@Test
public void testConstructor(){
FindAndReplace testCreation = new FindAndReplace(null, null, null);
assertNotNull(testCreation);
}
@Test
public void testReadInputFile() throws Exception {
FindAndReplace findAndReplace = new FindAndReplace("/tests/testDocuments/TestInput.txt",
"/tests/testDocuments/TestFindReplace.txt", "/test/testDocuments/testOutput.txt");
findAndReplace.readInputFile();
try(BufferedReader br = new BufferedReader(new FileReader("/test/testDocuments/testOutput.txt"))){
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@Test
public void testReplaceLineWithValueAddsToMap() throws Exception {
FindAndReplace findAndReplace = new FindAndReplace(null, null, null);
findAndReplace.replaceLineWithValue("Hello:Hi There!,Boom:BadaBoom");
assertTrue(findAndReplace.findReplaceValues != null);
}
@Test
public void testOutputFileWasCreated() throws Exception {
FindAndReplace testOuputFile = new FindAndReplace("hi", "there", "boom");
assertNotNull(testOuputFile.createOutputFile());
}
@Test(expected = IOException.class)
public void testOutputFileThrowsException() throws Exception {
FindAndReplace testFileNFound = new FindAndReplace("Boom!!", "/java/home/bananas", null);
testFileNFound.createOutputFile();
}
} | 1,929 | 0.711768 | 0.707621 | 62 | 30.129032 | 30.423613 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.548387 | false | false | 9 |
fe72cc05fd98f8d8dfe56781955c07a7604b6a2f | 29,076,928,616,639 | 0e15a745249d8bdd3bfbaa67c8466ad41dc92f3d | /app/src/main/java/com/aceplus/padc_poc_one/data/vo/CategoriesProgramsVO.java | 0866845978f03a9b6c8125aafb456a8eee91c325 | [] | no_license | KyawKyawKhing/SampleHabitMVP | https://github.com/KyawKyawKhing/SampleHabitMVP | c8cb03f4b4410f90ddd589e1d9d931546d39bc14 | cc1f3904513e08c75d35a3726fe2071471e9b161 | refs/heads/master | 2020-03-21T08:03:52.504000 | 2018-06-22T17:56:57 | 2018-06-22T17:56:57 | 138,317,501 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.aceplus.padc_poc_one.data.vo;
import com.google.gson.annotations.SerializedName;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
/**
* Created by kkk on 5/19/2018.
*/
public class CategoriesProgramsVO implements MainVO {
@SerializedName("category-id")
private String categoryId;
@SerializedName("title")
private String title;
@SerializedName("programs")
private ArrayList<CategoriesProgramsItemVO> categoriesProgramsItemVOS;
public String getCategoryId() {
return categoryId;
}
public String getTitle() {
return title;
}
public ArrayList<CategoriesProgramsItemVO> getCategoriesProgramsItemVOS() {
return categoriesProgramsItemVOS;
}
}
| UTF-8 | Java | 755 | java | CategoriesProgramsVO.java | Java | [
{
"context": "e;\n\nimport java.util.ArrayList;\n\n/**\n * Created by kkk on 5/19/2018.\n */\n\npublic class CategoriesProgram",
"end": 188,
"score": 0.9994915723800659,
"start": 185,
"tag": "USERNAME",
"value": "kkk"
}
] | null | [] | package com.aceplus.padc_poc_one.data.vo;
import com.google.gson.annotations.SerializedName;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
/**
* Created by kkk on 5/19/2018.
*/
public class CategoriesProgramsVO implements MainVO {
@SerializedName("category-id")
private String categoryId;
@SerializedName("title")
private String title;
@SerializedName("programs")
private ArrayList<CategoriesProgramsItemVO> categoriesProgramsItemVOS;
public String getCategoryId() {
return categoryId;
}
public String getTitle() {
return title;
}
public ArrayList<CategoriesProgramsItemVO> getCategoriesProgramsItemVOS() {
return categoriesProgramsItemVOS;
}
}
| 755 | 0.721854 | 0.712583 | 36 | 19.972221 | 21.833315 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.277778 | false | false | 9 |
52c814634b8008190ad3588c5a750881c0859bba | 17,428,977,288,636 | 0aff7a602bb5481a4a55da079774b69247d9016e | /src/Interface/Home.java | 2222cc15107b6e1d6d6957f36fa8622d1ca9d820 | [] | no_license | Hiro-1978/LibraryManagementSystem_java | https://github.com/Hiro-1978/LibraryManagementSystem_java | 97a630013f090edc466793757b675776e9398c59 | 93a2b27b5f716b5a99bdc21d264897462177b1ed | refs/heads/main | 2023-05-23T07:21:44.863000 | 2021-06-05T04:05:00 | 2021-06-05T04:05:00 | 374,016,408 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Interface;
import com.mysql.jdbc.Connection;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
public class Home extends javax.swing.JFrame {
Connection conn = null;
public Home() {
initComponents();
clock();
conn = DBConnect.connect();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
homeDesktop = new javax.swing.JDesktopPane();
jLabel4 = new javax.swing.JLabel();
lbpf = new javax.swing.JLabel();
lbDate = new javax.swing.JLabel();
lbTime = new javax.swing.JLabel();
btnhome = new javax.swing.JButton();
btnborrow = new javax.swing.JButton();
btnreturn = new javax.swing.JButton();
btnexit = new javax.swing.JButton();
btnaddBook = new javax.swing.JButton();
btnaddMember = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
btnallmem = new javax.swing.JButton();
btnallbook = new javax.swing.JButton();
btnlend = new javax.swing.JButton();
btnpend = new javax.swing.JButton();
btnbackup = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ระบบบริการจัดการห้องสมุด Petfriends V.103");
setMinimumSize(new java.awt.Dimension(1295, 695));
setResizable(false);
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 153, 0), 8, true));
jPanel1.setMaximumSize(new java.awt.Dimension(1295, 695));
jPanel1.setMinimumSize(new java.awt.Dimension(1295, 695));
jPanel1.setPreferredSize(new java.awt.Dimension(1295, 695));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
homeDesktop.setBackground(new java.awt.Color(240, 240, 240));
homeDesktop.setForeground(new java.awt.Color(240, 240, 240));
homeDesktop.setPreferredSize(new java.awt.Dimension(970, 530));
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/wallpaper.jpg"))); // NOI18N
homeDesktop.add(jLabel4);
jLabel4.setBounds(0, 0, 970, 530);
jPanel1.add(homeDesktop, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 150, 970, 530));
lbpf.setFont(new java.awt.Font("Kanit", 3, 60)); // NOI18N
lbpf.setForeground(new java.awt.Color(143, 60, 16));
lbpf.setText("Petfriends Library Book");
jPanel1.add(lbpf, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 750, 90));
lbDate.setBackground(new java.awt.Color(255, 255, 255));
lbDate.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N
lbDate.setForeground(new java.awt.Color(0, 0, 255));
lbDate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jPanel1.add(lbDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(780, 70, 210, 40));
lbTime.setBackground(new java.awt.Color(255, 255, 255));
lbTime.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N
lbTime.setForeground(new java.awt.Color(0, 0, 255));
lbTime.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jPanel1.add(lbTime, new org.netbeans.lib.awtextra.AbsoluteConstraints(1050, 70, 210, 40));
btnhome.setBackground(new java.awt.Color(255, 255, 255));
btnhome.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/iconHome1.png"))); // NOI18N
btnhome.setBorder(null);
btnhome.setBorderPainted(false);
btnhome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnhomeActionPerformed(evt);
}
});
jPanel1.add(btnhome, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 510, 60, 60));
btnborrow.setBackground(new java.awt.Color(255, 255, 255));
btnborrow.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnborrow.setForeground(new java.awt.Color(255, 255, 255));
btnborrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnbr1.png"))); // NOI18N
btnborrow.setBorder(null);
btnborrow.setBorderPainted(false);
btnborrow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnborrow.setMaximumSize(new java.awt.Dimension(170, 30));
btnborrow.setMinimumSize(new java.awt.Dimension(170, 30));
btnborrow.setPreferredSize(new java.awt.Dimension(170, 30));
btnborrow.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnborrow.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnborrow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnborrowActionPerformed(evt);
}
});
jPanel1.add(btnborrow, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 270, 160, 30));
btnreturn.setBackground(new java.awt.Color(255, 255, 255));
btnreturn.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnreturn.setForeground(new java.awt.Color(255, 255, 255));
btnreturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnrt1.png"))); // NOI18N
btnreturn.setBorder(null);
btnreturn.setBorderPainted(false);
btnreturn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnreturn.setPreferredSize(new java.awt.Dimension(170, 30));
btnreturn.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnreturn.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnreturn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnreturnActionPerformed(evt);
}
});
jPanel1.add(btnreturn, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 330, 160, 30));
btnexit.setBackground(new java.awt.Color(255, 255, 255));
btnexit.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnexit.setForeground(new java.awt.Color(255, 255, 255));
btnexit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnet1.png"))); // NOI18N
btnexit.setBorder(null);
btnexit.setBorderPainted(false);
btnexit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnexit.setPreferredSize(new java.awt.Dimension(170, 30));
btnexit.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnexit.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnexit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnexitActionPerformed(evt);
}
});
jPanel1.add(btnexit, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 610, 160, 30));
btnaddBook.setBackground(new java.awt.Color(255, 255, 255));
btnaddBook.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnaddBook.setForeground(new java.awt.Color(255, 255, 255));
btnaddBook.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnaddbook1.png"))); // NOI18N
btnaddBook.setBorder(null);
btnaddBook.setBorderPainted(false);
btnaddBook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnaddBook.setPreferredSize(new java.awt.Dimension(170, 30));
btnaddBook.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnaddBook.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnaddBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnaddBookActionPerformed(evt);
}
});
jPanel1.add(btnaddBook, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 390, 160, 30));
btnaddMember.setBackground(new java.awt.Color(255, 255, 255));
btnaddMember.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnaddMember.setForeground(new java.awt.Color(255, 255, 255));
btnaddMember.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnaddmember1.png"))); // NOI18N
btnaddMember.setBorder(null);
btnaddMember.setBorderPainted(false);
btnaddMember.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnaddMember.setPreferredSize(new java.awt.Dimension(170, 30));
btnaddMember.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnaddMember.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnaddMember.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnaddMemberActionPerformed(evt);
}
});
jPanel1.add(btnaddMember, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 450, 160, 30));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/logo2.png"))); // NOI18N
jLabel3.setPreferredSize(new java.awt.Dimension(260, 110));
jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, 290, 110));
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 0), 2));
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 42, 1290, 100));
jLabel2.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 0), 2));
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 140, 300, 550));
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
jToolBar1.setMaximumSize(new java.awt.Dimension(1295, 33));
jToolBar1.setMinimumSize(new java.awt.Dimension(1295, 33));
jToolBar1.setPreferredSize(new java.awt.Dimension(1300, 33));
btnallmem.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnallmem.setForeground(new java.awt.Color(143, 60, 16));
btnallmem.setText("รายชื่อหนังสือ");
btnallmem.setFocusable(false);
btnallmem.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnallmem.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnallmem.setMaximumSize(new java.awt.Dimension(200, 25));
btnallmem.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnallmem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnallmemActionPerformed(evt);
}
});
jToolBar1.add(btnallmem);
btnallbook.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnallbook.setForeground(new java.awt.Color(143, 60, 16));
btnallbook.setText("รายชื่อสมาชิก");
btnallbook.setFocusable(false);
btnallbook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnallbook.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnallbook.setMaximumSize(new java.awt.Dimension(200, 25));
btnallbook.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnallbook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnallbookActionPerformed(evt);
}
});
jToolBar1.add(btnallbook);
btnlend.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnlend.setForeground(new java.awt.Color(143, 60, 16));
btnlend.setText("ประวัติการยืม");
btnlend.setFocusable(false);
btnlend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnlend.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnlend.setMaximumSize(new java.awt.Dimension(200, 25));
btnlend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnlend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnlendActionPerformed(evt);
}
});
jToolBar1.add(btnlend);
btnpend.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnpend.setForeground(new java.awt.Color(143, 60, 16));
btnpend.setText("หนังสือที่ถูกยืมอยู่");
btnpend.setFocusable(false);
btnpend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnpend.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnpend.setMaximumSize(new java.awt.Dimension(200, 25));
btnpend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnpend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnpendActionPerformed(evt);
}
});
jToolBar1.add(btnpend);
btnbackup.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
btnbackup.setForeground(new java.awt.Color(143, 60, 16));
btnbackup.setText("Backup And Restore");
btnbackup.setFocusable(false);
btnbackup.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnbackup.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnbackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackupActionPerformed(evt);
}
});
jToolBar1.add(btnbackup);
jPanel1.add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 1278, 30));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
public void clock() {
Thread clock = new Thread() {
public void run() {
try {
while (true) {
Calendar cal = new GregorianCalendar();
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
int second = cal.get(Calendar.SECOND);
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
lbTime.setText(hour + ":" + minute + ":" + second);
lbDate.setText(day + "-" + month + "-" + year);
sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
clock.start();
}
private void btnborrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnborrowActionPerformed
homeDesktop.removeAll();
Borrow br = new Borrow();
homeDesktop.add(br).setVisible(true);
}//GEN-LAST:event_btnborrowActionPerformed
private void btnreturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnreturnActionPerformed
homeDesktop.removeAll();
Return rt = new Return();
homeDesktop.add(rt).setVisible(true);
}//GEN-LAST:event_btnreturnActionPerformed
private void btnexitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnexitActionPerformed
if(JOptionPane.showConfirmDialog(this ,"ยืนยันการปิดโปรแกรม","ยืนยัน",JOptionPane.YES_NO_CANCEL_OPTION)==JOptionPane.YES_NO_OPTION)
{System.exit(0);}
}//GEN-LAST:event_btnexitActionPerformed
private void btnaddBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddBookActionPerformed
homeDesktop.removeAll();
addbook adb = new addbook();
homeDesktop.add(adb).setVisible(true);
}//GEN-LAST:event_btnaddBookActionPerformed
private void btnaddMemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddMemberActionPerformed
homeDesktop.removeAll();
addmember adm = new addmember();
homeDesktop.add(adm).setVisible(true);
}//GEN-LAST:event_btnaddMemberActionPerformed
private void btnallmemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnallmemActionPerformed
homeDesktop.removeAll();
allbook alb = new allbook();
homeDesktop.add(alb).setVisible(true);
}//GEN-LAST:event_btnallmemActionPerformed
private void btnallbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnallbookActionPerformed
homeDesktop.removeAll();
allmember alm = new allmember();
homeDesktop.add(alm).setVisible(true);
}//GEN-LAST:event_btnallbookActionPerformed
private void btnlendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnlendActionPerformed
homeDesktop.removeAll();
lendhis lend = new lendhis();
homeDesktop.add(lend).setVisible(true);
}//GEN-LAST:event_btnlendActionPerformed
private void btnpendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnpendActionPerformed
homeDesktop.removeAll();
pending pend = new pending();
homeDesktop.add(pend).setVisible(true);
}//GEN-LAST:event_btnpendActionPerformed
private void btnhomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnhomeActionPerformed
homeDesktop.removeAll();
Home2 h2 = new Home2();
homeDesktop.add(h2).setVisible(true);
}//GEN-LAST:event_btnhomeActionPerformed
private void btnbackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbackupActionPerformed
homeDesktop.removeAll();
SQLBackupAndRestore bk = new SQLBackupAndRestore();
homeDesktop.add(bk).setVisible(true);
}//GEN-LAST:event_btnbackupActionPerformed
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Home().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnaddBook;
private javax.swing.JButton btnaddMember;
private javax.swing.JButton btnallbook;
private javax.swing.JButton btnallmem;
private javax.swing.JButton btnbackup;
private javax.swing.JButton btnborrow;
private javax.swing.JButton btnexit;
private javax.swing.JButton btnhome;
private javax.swing.JButton btnlend;
private javax.swing.JButton btnpend;
private javax.swing.JButton btnreturn;
private javax.swing.JDesktopPane homeDesktop;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JLabel lbDate;
private javax.swing.JLabel lbTime;
private javax.swing.JLabel lbpf;
// End of variables declaration//GEN-END:variables
}
| UTF-8 | Java | 21,015 | java | Home.java | Java | [] | null | [] | package Interface;
import com.mysql.jdbc.Connection;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
public class Home extends javax.swing.JFrame {
Connection conn = null;
public Home() {
initComponents();
clock();
conn = DBConnect.connect();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
homeDesktop = new javax.swing.JDesktopPane();
jLabel4 = new javax.swing.JLabel();
lbpf = new javax.swing.JLabel();
lbDate = new javax.swing.JLabel();
lbTime = new javax.swing.JLabel();
btnhome = new javax.swing.JButton();
btnborrow = new javax.swing.JButton();
btnreturn = new javax.swing.JButton();
btnexit = new javax.swing.JButton();
btnaddBook = new javax.swing.JButton();
btnaddMember = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
btnallmem = new javax.swing.JButton();
btnallbook = new javax.swing.JButton();
btnlend = new javax.swing.JButton();
btnpend = new javax.swing.JButton();
btnbackup = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ระบบบริการจัดการห้องสมุด Petfriends V.103");
setMinimumSize(new java.awt.Dimension(1295, 695));
setResizable(false);
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 153, 0), 8, true));
jPanel1.setMaximumSize(new java.awt.Dimension(1295, 695));
jPanel1.setMinimumSize(new java.awt.Dimension(1295, 695));
jPanel1.setPreferredSize(new java.awt.Dimension(1295, 695));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
homeDesktop.setBackground(new java.awt.Color(240, 240, 240));
homeDesktop.setForeground(new java.awt.Color(240, 240, 240));
homeDesktop.setPreferredSize(new java.awt.Dimension(970, 530));
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/wallpaper.jpg"))); // NOI18N
homeDesktop.add(jLabel4);
jLabel4.setBounds(0, 0, 970, 530);
jPanel1.add(homeDesktop, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 150, 970, 530));
lbpf.setFont(new java.awt.Font("Kanit", 3, 60)); // NOI18N
lbpf.setForeground(new java.awt.Color(143, 60, 16));
lbpf.setText("Petfriends Library Book");
jPanel1.add(lbpf, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 750, 90));
lbDate.setBackground(new java.awt.Color(255, 255, 255));
lbDate.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N
lbDate.setForeground(new java.awt.Color(0, 0, 255));
lbDate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jPanel1.add(lbDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(780, 70, 210, 40));
lbTime.setBackground(new java.awt.Color(255, 255, 255));
lbTime.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N
lbTime.setForeground(new java.awt.Color(0, 0, 255));
lbTime.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jPanel1.add(lbTime, new org.netbeans.lib.awtextra.AbsoluteConstraints(1050, 70, 210, 40));
btnhome.setBackground(new java.awt.Color(255, 255, 255));
btnhome.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/iconHome1.png"))); // NOI18N
btnhome.setBorder(null);
btnhome.setBorderPainted(false);
btnhome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnhomeActionPerformed(evt);
}
});
jPanel1.add(btnhome, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 510, 60, 60));
btnborrow.setBackground(new java.awt.Color(255, 255, 255));
btnborrow.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnborrow.setForeground(new java.awt.Color(255, 255, 255));
btnborrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnbr1.png"))); // NOI18N
btnborrow.setBorder(null);
btnborrow.setBorderPainted(false);
btnborrow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnborrow.setMaximumSize(new java.awt.Dimension(170, 30));
btnborrow.setMinimumSize(new java.awt.Dimension(170, 30));
btnborrow.setPreferredSize(new java.awt.Dimension(170, 30));
btnborrow.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnborrow.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnborrow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnborrowActionPerformed(evt);
}
});
jPanel1.add(btnborrow, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 270, 160, 30));
btnreturn.setBackground(new java.awt.Color(255, 255, 255));
btnreturn.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnreturn.setForeground(new java.awt.Color(255, 255, 255));
btnreturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnrt1.png"))); // NOI18N
btnreturn.setBorder(null);
btnreturn.setBorderPainted(false);
btnreturn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnreturn.setPreferredSize(new java.awt.Dimension(170, 30));
btnreturn.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnreturn.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnreturn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnreturnActionPerformed(evt);
}
});
jPanel1.add(btnreturn, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 330, 160, 30));
btnexit.setBackground(new java.awt.Color(255, 255, 255));
btnexit.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnexit.setForeground(new java.awt.Color(255, 255, 255));
btnexit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnet1.png"))); // NOI18N
btnexit.setBorder(null);
btnexit.setBorderPainted(false);
btnexit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnexit.setPreferredSize(new java.awt.Dimension(170, 30));
btnexit.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnexit.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnexit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnexitActionPerformed(evt);
}
});
jPanel1.add(btnexit, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 610, 160, 30));
btnaddBook.setBackground(new java.awt.Color(255, 255, 255));
btnaddBook.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnaddBook.setForeground(new java.awt.Color(255, 255, 255));
btnaddBook.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnaddbook1.png"))); // NOI18N
btnaddBook.setBorder(null);
btnaddBook.setBorderPainted(false);
btnaddBook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnaddBook.setPreferredSize(new java.awt.Dimension(170, 30));
btnaddBook.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnaddBook.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnaddBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnaddBookActionPerformed(evt);
}
});
jPanel1.add(btnaddBook, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 390, 160, 30));
btnaddMember.setBackground(new java.awt.Color(255, 255, 255));
btnaddMember.setFont(new java.awt.Font("Angsana New", 3, 40)); // NOI18N
btnaddMember.setForeground(new java.awt.Color(255, 255, 255));
btnaddMember.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/btnaddmember1.png"))); // NOI18N
btnaddMember.setBorder(null);
btnaddMember.setBorderPainted(false);
btnaddMember.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnaddMember.setPreferredSize(new java.awt.Dimension(170, 30));
btnaddMember.setVerticalAlignment(javax.swing.SwingConstants.TOP);
btnaddMember.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
btnaddMember.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnaddMemberActionPerformed(evt);
}
});
jPanel1.add(btnaddMember, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 450, 160, 30));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interface/img/logo2.png"))); // NOI18N
jLabel3.setPreferredSize(new java.awt.Dimension(260, 110));
jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, 290, 110));
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 0), 2));
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 42, 1290, 100));
jLabel2.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 0), 2));
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 140, 300, 550));
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
jToolBar1.setMaximumSize(new java.awt.Dimension(1295, 33));
jToolBar1.setMinimumSize(new java.awt.Dimension(1295, 33));
jToolBar1.setPreferredSize(new java.awt.Dimension(1300, 33));
btnallmem.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnallmem.setForeground(new java.awt.Color(143, 60, 16));
btnallmem.setText("รายชื่อหนังสือ");
btnallmem.setFocusable(false);
btnallmem.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnallmem.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnallmem.setMaximumSize(new java.awt.Dimension(200, 25));
btnallmem.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnallmem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnallmemActionPerformed(evt);
}
});
jToolBar1.add(btnallmem);
btnallbook.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnallbook.setForeground(new java.awt.Color(143, 60, 16));
btnallbook.setText("รายชื่อสมาชิก");
btnallbook.setFocusable(false);
btnallbook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnallbook.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnallbook.setMaximumSize(new java.awt.Dimension(200, 25));
btnallbook.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnallbook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnallbookActionPerformed(evt);
}
});
jToolBar1.add(btnallbook);
btnlend.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnlend.setForeground(new java.awt.Color(143, 60, 16));
btnlend.setText("ประวัติการยืม");
btnlend.setFocusable(false);
btnlend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnlend.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnlend.setMaximumSize(new java.awt.Dimension(200, 25));
btnlend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnlend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnlendActionPerformed(evt);
}
});
jToolBar1.add(btnlend);
btnpend.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnpend.setForeground(new java.awt.Color(143, 60, 16));
btnpend.setText("หนังสือที่ถูกยืมอยู่");
btnpend.setFocusable(false);
btnpend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnpend.setMargin(new java.awt.Insets(2, 20, 2, 20));
btnpend.setMaximumSize(new java.awt.Dimension(200, 25));
btnpend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnpend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnpendActionPerformed(evt);
}
});
jToolBar1.add(btnpend);
btnbackup.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
btnbackup.setForeground(new java.awt.Color(143, 60, 16));
btnbackup.setText("Backup And Restore");
btnbackup.setFocusable(false);
btnbackup.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnbackup.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnbackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackupActionPerformed(evt);
}
});
jToolBar1.add(btnbackup);
jPanel1.add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 1278, 30));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
public void clock() {
Thread clock = new Thread() {
public void run() {
try {
while (true) {
Calendar cal = new GregorianCalendar();
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
int second = cal.get(Calendar.SECOND);
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
lbTime.setText(hour + ":" + minute + ":" + second);
lbDate.setText(day + "-" + month + "-" + year);
sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
clock.start();
}
private void btnborrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnborrowActionPerformed
homeDesktop.removeAll();
Borrow br = new Borrow();
homeDesktop.add(br).setVisible(true);
}//GEN-LAST:event_btnborrowActionPerformed
private void btnreturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnreturnActionPerformed
homeDesktop.removeAll();
Return rt = new Return();
homeDesktop.add(rt).setVisible(true);
}//GEN-LAST:event_btnreturnActionPerformed
private void btnexitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnexitActionPerformed
if(JOptionPane.showConfirmDialog(this ,"ยืนยันการปิดโปรแกรม","ยืนยัน",JOptionPane.YES_NO_CANCEL_OPTION)==JOptionPane.YES_NO_OPTION)
{System.exit(0);}
}//GEN-LAST:event_btnexitActionPerformed
private void btnaddBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddBookActionPerformed
homeDesktop.removeAll();
addbook adb = new addbook();
homeDesktop.add(adb).setVisible(true);
}//GEN-LAST:event_btnaddBookActionPerformed
private void btnaddMemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddMemberActionPerformed
homeDesktop.removeAll();
addmember adm = new addmember();
homeDesktop.add(adm).setVisible(true);
}//GEN-LAST:event_btnaddMemberActionPerformed
private void btnallmemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnallmemActionPerformed
homeDesktop.removeAll();
allbook alb = new allbook();
homeDesktop.add(alb).setVisible(true);
}//GEN-LAST:event_btnallmemActionPerformed
private void btnallbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnallbookActionPerformed
homeDesktop.removeAll();
allmember alm = new allmember();
homeDesktop.add(alm).setVisible(true);
}//GEN-LAST:event_btnallbookActionPerformed
private void btnlendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnlendActionPerformed
homeDesktop.removeAll();
lendhis lend = new lendhis();
homeDesktop.add(lend).setVisible(true);
}//GEN-LAST:event_btnlendActionPerformed
private void btnpendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnpendActionPerformed
homeDesktop.removeAll();
pending pend = new pending();
homeDesktop.add(pend).setVisible(true);
}//GEN-LAST:event_btnpendActionPerformed
private void btnhomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnhomeActionPerformed
homeDesktop.removeAll();
Home2 h2 = new Home2();
homeDesktop.add(h2).setVisible(true);
}//GEN-LAST:event_btnhomeActionPerformed
private void btnbackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbackupActionPerformed
homeDesktop.removeAll();
SQLBackupAndRestore bk = new SQLBackupAndRestore();
homeDesktop.add(bk).setVisible(true);
}//GEN-LAST:event_btnbackupActionPerformed
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Home().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnaddBook;
private javax.swing.JButton btnaddMember;
private javax.swing.JButton btnallbook;
private javax.swing.JButton btnallmem;
private javax.swing.JButton btnbackup;
private javax.swing.JButton btnborrow;
private javax.swing.JButton btnexit;
private javax.swing.JButton btnhome;
private javax.swing.JButton btnlend;
private javax.swing.JButton btnpend;
private javax.swing.JButton btnreturn;
private javax.swing.JDesktopPane homeDesktop;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JLabel lbDate;
private javax.swing.JLabel lbTime;
private javax.swing.JLabel lbpf;
// End of variables declaration//GEN-END:variables
}
| 21,015 | 0.675386 | 0.641919 | 415 | 49.113255 | 31.700392 | 152 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.130121 | false | false | 9 |
452a4f6d09d7c642c1b61dd043915afcc6828c03 | 13,443,247,685,607 | d2cdecc76ef09f4c50977fbcc11573748bf366d6 | /src/simplejava/factorial.java | 4780ceb7f343398bd9aea29198a8adfa9617f0a8 | [] | no_license | AvishMadan/Playground | https://github.com/AvishMadan/Playground | 941316f7271446d2140445a9aa57ea9b56581648 | a8078560f5308f8e120dbc42925176027055fbc8 | refs/heads/master | 2020-03-20T18:22:17.849000 | 2018-06-17T11:34:24 | 2018-06-17T11:34:24 | 137,585,073 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package simplejava;
public class factorial {
int fact=1;
int n=1;
int num1=1;
public void fact(int num)
{num1=num;
for(int i=0;i<num-1;i++){
fact=num1*fact;
num1=num1-1;
}
System.out.println(fact);
}
public static void main(String[] args) {
factorial factorial=new factorial();
factorial.fact(7
);
}
}
| UTF-8 | Java | 357 | java | factorial.java | Java | [] | null | [] | package simplejava;
public class factorial {
int fact=1;
int n=1;
int num1=1;
public void fact(int num)
{num1=num;
for(int i=0;i<num-1;i++){
fact=num1*fact;
num1=num1-1;
}
System.out.println(fact);
}
public static void main(String[] args) {
factorial factorial=new factorial();
factorial.fact(7
);
}
}
| 357 | 0.59944 | 0.565826 | 32 | 10.15625 | 11.611173 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.65625 | false | false | 9 |
cc805f8bdd748da25d83dcf1a7bed20d3d5612a6 | 14,319,420,968,604 | 38354418d052c1443ada5c035838e9f0d537028f | /src/nao/ConsoleOutputStream.java | d457d07e03e9bfa31f8a9ae4e6ae7e06e6eea86e | [] | no_license | Jannilol12/Nao-Client | https://github.com/Jannilol12/Nao-Client | 25d0dbf8b4ff8aa02313c6ff7011f439488f87e4 | 351a4d0ecb5a4ba944aca86e21b893296e42fc11 | refs/heads/master | 2020-06-17T09:06:32.886000 | 2020-02-01T14:04:41 | 2020-02-01T14:04:41 | 195,873,773 | 1 | 0 | null | false | 2019-07-19T17:20:25 | 2019-07-08T19:26:59 | 2019-07-13T11:28:57 | 2019-07-19T17:20:25 | 197 | 1 | 0 | 0 | Java | false | false | package nao;
import components.json.JSONObject;
import nao.controllers.Console;
import java.io.*;
/**
* This Method is for the Console on the client.
*/
public class ConsoleOutputStream extends OutputStream {
private StringBuilder builder;
private PrintStream stream;
/**
* Setting everything up
*/
public ConsoleOutputStream(){
stream = System.out; //getting the console from the Nao.
System.setOut(new PrintStream(this)); //instead of writing in the console, write here
builder = new StringBuilder(); //instead of sending every single char to the client, make a String
}
/**
* Writing the bytes from the console into a String and write it into the Console of the Client
* @param b char from the console as an int
* @throws IOException Exception
*/
@Override
public void write(int b) throws IOException {
char c = (char) b;
if(c != '\n'){ //if not a "new Line"
stream.write(c); //write into the Console from the nao, because otherwise there isn't anything because of the System.setOut in line 23
builder.append(c); //add the char to the StringBuilder to receive a String in the End
}else{
stream.write(c);
String finalString = builder.toString(); //make a new String out of the chars
Console.c.setClientConsoleTextArea(finalString); //write it into the Console of the Client
builder = new StringBuilder(); //make a new StringBuilder, so emptying the old
}
}
}
| UTF-8 | Java | 1,564 | java | ConsoleOutputStream.java | Java | [] | null | [] | package nao;
import components.json.JSONObject;
import nao.controllers.Console;
import java.io.*;
/**
* This Method is for the Console on the client.
*/
public class ConsoleOutputStream extends OutputStream {
private StringBuilder builder;
private PrintStream stream;
/**
* Setting everything up
*/
public ConsoleOutputStream(){
stream = System.out; //getting the console from the Nao.
System.setOut(new PrintStream(this)); //instead of writing in the console, write here
builder = new StringBuilder(); //instead of sending every single char to the client, make a String
}
/**
* Writing the bytes from the console into a String and write it into the Console of the Client
* @param b char from the console as an int
* @throws IOException Exception
*/
@Override
public void write(int b) throws IOException {
char c = (char) b;
if(c != '\n'){ //if not a "new Line"
stream.write(c); //write into the Console from the nao, because otherwise there isn't anything because of the System.setOut in line 23
builder.append(c); //add the char to the StringBuilder to receive a String in the End
}else{
stream.write(c);
String finalString = builder.toString(); //make a new String out of the chars
Console.c.setClientConsoleTextArea(finalString); //write it into the Console of the Client
builder = new StringBuilder(); //make a new StringBuilder, so emptying the old
}
}
}
| 1,564 | 0.657928 | 0.65665 | 44 | 34.545456 | 37.021156 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false | 9 |
c74e758d961cc37823f80b9b207c64ff4adc1056 | 10,960,756,563,444 | dc9d3ce2303b6d8cb63a77d286aba0624c489491 | /src/main/java/edu/ben/model/Video.java | a49a110b6de94f48c39944f7ecd720349f9e921e | [] | no_license | Schultz2873/UListIt | https://github.com/Schultz2873/UListIt | 67875bb041c8cbbbbc7051cdd5702078524db744 | 9c160ab864bababb109410362e1218cfecac08ad | refs/heads/master | 2022-12-24T15:09:23.099000 | 2020-09-27T18:19:39 | 2020-09-27T18:19:39 | 299,091,241 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.ben.model;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity(name = "video")
@Table(name = "video")
@Transactional
public class Video {
@Id
@Column(name = "video_ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int videoID;
@Column(name = "title")
private String title;
@Column(name = "video_path")
private String videoPath;
@Column(name = "date_created")
private Timestamp dateCreated;
@Column(name = "type")
private String type;
public Video() {
}
public Video(int videoID, String title, String videoPath, Timestamp dateCreated) {
this.videoID = videoID;
this.title = title;
this.videoPath = videoPath;
this.dateCreated = dateCreated;
}
public Video(String title, String videoPath, Timestamp dateCreated) {
this.title = title;
this.videoPath = videoPath;
this.dateCreated = dateCreated;
}
public Video(String title, String videoPath) {
this.title = title;
this.videoPath = videoPath;
}
public int getVideoID() {
return videoID;
}
public void setVideoID(int videoID) {
this.videoID = videoID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getVideoPath() {
return videoPath;
}
public void setVideoPath(String videoPath) {
this.videoPath = videoPath;
}
public Timestamp getDateCreated() {
return dateCreated;
}
public void setDateCreated(Timestamp dateCreated) {
this.dateCreated = dateCreated;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
| UTF-8 | Java | 1,908 | java | Video.java | Java | [] | null | [] | package edu.ben.model;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity(name = "video")
@Table(name = "video")
@Transactional
public class Video {
@Id
@Column(name = "video_ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int videoID;
@Column(name = "title")
private String title;
@Column(name = "video_path")
private String videoPath;
@Column(name = "date_created")
private Timestamp dateCreated;
@Column(name = "type")
private String type;
public Video() {
}
public Video(int videoID, String title, String videoPath, Timestamp dateCreated) {
this.videoID = videoID;
this.title = title;
this.videoPath = videoPath;
this.dateCreated = dateCreated;
}
public Video(String title, String videoPath, Timestamp dateCreated) {
this.title = title;
this.videoPath = videoPath;
this.dateCreated = dateCreated;
}
public Video(String title, String videoPath) {
this.title = title;
this.videoPath = videoPath;
}
public int getVideoID() {
return videoID;
}
public void setVideoID(int videoID) {
this.videoID = videoID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getVideoPath() {
return videoPath;
}
public void setVideoPath(String videoPath) {
this.videoPath = videoPath;
}
public Timestamp getDateCreated() {
return dateCreated;
}
public void setDateCreated(Timestamp dateCreated) {
this.dateCreated = dateCreated;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
| 1,908 | 0.627358 | 0.627358 | 92 | 19.73913 | 18.655848 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.369565 | false | false | 9 |
88949a2c60c413b35de1adac467e9a462fdf3871 | 34,797,825,073,245 | f23c6ef6fa6838f465e4a07afb505bda0c44d72e | /spsdklib/src/main/java/eu/hithredin/spsdk/ui/recycler/AdapterLinearLayout.java | d564ad1ca6a0ee0dbebfac3b71eec7ca04a27f17 | [] | no_license | bdelville/spsdk | https://github.com/bdelville/spsdk | 4105b093fcf3b7fb73443dc926e37c2920e0fc1b | aca95c34ee0184b704e57ed8bee7e2eecd4f895e | refs/heads/master | 2020-04-17T02:37:34.577000 | 2016-08-20T04:40:59 | 2016-08-20T04:40:59 | 49,136,836 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package eu.hithredin.spsdk.ui.recycler;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewParent;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import java.util.ArrayList;
import java.util.List;
import eu.hithredin.spsdk.data.DeviceData;
/**
* Behave like a RecyclerView, but use a LinearLayout instead
* Useful to use a Recycler adapter pattern inside a ScrollView when the cell number is limited
* TODO handle the recycling of CellHolder and scrolling items within virtual height
*/
public class AdapterLinearLayout extends LinearLayout implements OnTouchListener, OnClickListener {
private RecyclerAdapter adapter;
private OnItemClickListener listener;
private ScrollView scrollParent;
private SparseArray<List<ReCellHolder>> recycled = new SparseArray<>();
private List<Integer> typeActive = new ArrayList<>();
private RecyclerView.AdapterDataObserver dataSetObserver = new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
invalidateViews();
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
invalidateViews();
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount, Object payload) {
super.onItemRangeChanged(positionStart, itemCount, payload);
invalidateViews();
}
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
invalidateViews();
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
invalidateViews();
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
super.onItemRangeRemoved(positionStart, itemCount);
invalidateViews();
}
};
@SuppressLint("NewApi")
public AdapterLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public AdapterLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public AdapterLinearLayout(Context context) {
this(context, null);
}
@SuppressLint("NewApi")
private void init() {
//Check if the orientation was set from XML in the constructor before setting default
if (!orientationSetted) {
setOrientation(LinearLayout.VERTICAL);
}
if (DeviceData.get().getSdk() > 10) {
setMotionEventSplittingEnabled(false);
}
}
private boolean orientationSetted = false;
public void setOrientation(int orientation) {
orientationSetted = true;
super.setOrientation(orientation);
}
public RecyclerView.Adapter getAdapter() {
return adapter;
}
public void setAdapter(RecyclerAdapter newAdapter) {
if (adapter != null && dataSetObserver != null) {
adapter.unregisterAdapterDataObserver(dataSetObserver);
}
this.adapter = newAdapter;
adapter.registerAdapterDataObserver(dataSetObserver);
invalidateViews();
}
public void invalidateView(int i) {
removeViewAt(i);
addView(createViewAt(i), i);
}
/*public void setOnScrollEndedListener(ScrollEndListener scrollEnded) {
ScrollView sparent = getScrollParent();
if (sparent == null || !(sparent instanceof EndScrollView)) {
Log.w("setOnScrollEndedListener", "No ScrollView as a parent of the Layout");
return;
}
((EndScrollView) sparent).setListenerEnd(scrollEnded);
}*/
public void invalidateView(Object item) {
for (int i = 0; i < adapter.getItemCount(); i++) {
Object realItem = adapter.getItem(i);
if (realItem.equals(item)) {
removeViewAt(i);
addView(createViewAt(i), i);
return;
}
}
}
public ScrollView getScrollParent() {
if (scrollParent == null) {
ViewParent parent = getParent();
while (parent != null) {
if (parent instanceof ScrollView) {
scrollParent = (ScrollView) parent;
break;
}
parent = parent.getParent();
}
}
return scrollParent;
}
public void invalidateViews() {
if (adapter == null) {
return;
}
ScrollView sparent = getScrollParent();
int scrollY = -1;
if (sparent != null) {
scrollY = sparent.getScrollY();
}
while (getChildCount() > 0) {
removeViewAt(0);
}
for (int i = 0; i < adapter.getItemCount(); i++) {
addView(createViewAt(i));
}
if (scrollY >= 0 && sparent != null) {
// le getMax retourne une valeur bizarre... On utilise toujours le scrollY du coup
sparent.scrollTo(getScrollX(), scrollY);
}
}
// RECYCLAGE
private View createViewAt(int i) {
int type = adapter.getItemViewType(i);
List<ReCellHolder> recycledView = recycled.get(type);
ReCellHolder cellHolder = null;
if (recycledView != null && recycledView.size() > 0) {
cellHolder = recycledView.remove(0);
} else {
cellHolder = adapter.onCreateViewHolder(this, type);
}
//View v = adapter.getView(i, temp, this);
adapter.bindViewHolder(cellHolder, i);
if (listener != null) {
if (cellHolder.getView() == null) {
Log.e("AdapterLinearLayout", "Cas etrange, dans createViewAt, getView return null for cell=" + i);
} else {
cellHolder.getView().setFocusable(true);
cellHolder.getView().setClickable(true);
cellHolder.getView().setOnClickListener(this);
}
}
if (i < typeActive.size()) {
typeActive.set(i, type);
} else {
typeActive.add(type);
}
return cellHolder.getView();
}
public void removeViewAt(int i) {
/*int type = typeActive.get(i);
typeActive.remove(i);
View view = getChildAt(i);
List<ReCellHolder> recycledView = recycled.get(type);
if (recycledView == null) {
recycledView = new ArrayList<>();
recycled.put(type, recycledView);
}
recycledView.add(view);*/
super.removeViewAt(i);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.listener = listener;
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
v.setFocusable(true);
v.setClickable(true);
v.setOnClickListener(this);
}
}
public int getFirstVisiblePosition() {
return 0;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
@Override
public void onClick(View v) {
if (listener == null) {
return;
}
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) == v) {
listener.onItemClick(null, v, i, 0);
return;
}
}
}
}
| UTF-8 | Java | 8,082 | java | AdapterLinearLayout.java | Java | [] | null | [] | package eu.hithredin.spsdk.ui.recycler;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewParent;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import java.util.ArrayList;
import java.util.List;
import eu.hithredin.spsdk.data.DeviceData;
/**
* Behave like a RecyclerView, but use a LinearLayout instead
* Useful to use a Recycler adapter pattern inside a ScrollView when the cell number is limited
* TODO handle the recycling of CellHolder and scrolling items within virtual height
*/
public class AdapterLinearLayout extends LinearLayout implements OnTouchListener, OnClickListener {
private RecyclerAdapter adapter;
private OnItemClickListener listener;
private ScrollView scrollParent;
private SparseArray<List<ReCellHolder>> recycled = new SparseArray<>();
private List<Integer> typeActive = new ArrayList<>();
private RecyclerView.AdapterDataObserver dataSetObserver = new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
invalidateViews();
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
invalidateViews();
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount, Object payload) {
super.onItemRangeChanged(positionStart, itemCount, payload);
invalidateViews();
}
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
invalidateViews();
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
invalidateViews();
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
super.onItemRangeRemoved(positionStart, itemCount);
invalidateViews();
}
};
@SuppressLint("NewApi")
public AdapterLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public AdapterLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public AdapterLinearLayout(Context context) {
this(context, null);
}
@SuppressLint("NewApi")
private void init() {
//Check if the orientation was set from XML in the constructor before setting default
if (!orientationSetted) {
setOrientation(LinearLayout.VERTICAL);
}
if (DeviceData.get().getSdk() > 10) {
setMotionEventSplittingEnabled(false);
}
}
private boolean orientationSetted = false;
public void setOrientation(int orientation) {
orientationSetted = true;
super.setOrientation(orientation);
}
public RecyclerView.Adapter getAdapter() {
return adapter;
}
public void setAdapter(RecyclerAdapter newAdapter) {
if (adapter != null && dataSetObserver != null) {
adapter.unregisterAdapterDataObserver(dataSetObserver);
}
this.adapter = newAdapter;
adapter.registerAdapterDataObserver(dataSetObserver);
invalidateViews();
}
public void invalidateView(int i) {
removeViewAt(i);
addView(createViewAt(i), i);
}
/*public void setOnScrollEndedListener(ScrollEndListener scrollEnded) {
ScrollView sparent = getScrollParent();
if (sparent == null || !(sparent instanceof EndScrollView)) {
Log.w("setOnScrollEndedListener", "No ScrollView as a parent of the Layout");
return;
}
((EndScrollView) sparent).setListenerEnd(scrollEnded);
}*/
public void invalidateView(Object item) {
for (int i = 0; i < adapter.getItemCount(); i++) {
Object realItem = adapter.getItem(i);
if (realItem.equals(item)) {
removeViewAt(i);
addView(createViewAt(i), i);
return;
}
}
}
public ScrollView getScrollParent() {
if (scrollParent == null) {
ViewParent parent = getParent();
while (parent != null) {
if (parent instanceof ScrollView) {
scrollParent = (ScrollView) parent;
break;
}
parent = parent.getParent();
}
}
return scrollParent;
}
public void invalidateViews() {
if (adapter == null) {
return;
}
ScrollView sparent = getScrollParent();
int scrollY = -1;
if (sparent != null) {
scrollY = sparent.getScrollY();
}
while (getChildCount() > 0) {
removeViewAt(0);
}
for (int i = 0; i < adapter.getItemCount(); i++) {
addView(createViewAt(i));
}
if (scrollY >= 0 && sparent != null) {
// le getMax retourne une valeur bizarre... On utilise toujours le scrollY du coup
sparent.scrollTo(getScrollX(), scrollY);
}
}
// RECYCLAGE
private View createViewAt(int i) {
int type = adapter.getItemViewType(i);
List<ReCellHolder> recycledView = recycled.get(type);
ReCellHolder cellHolder = null;
if (recycledView != null && recycledView.size() > 0) {
cellHolder = recycledView.remove(0);
} else {
cellHolder = adapter.onCreateViewHolder(this, type);
}
//View v = adapter.getView(i, temp, this);
adapter.bindViewHolder(cellHolder, i);
if (listener != null) {
if (cellHolder.getView() == null) {
Log.e("AdapterLinearLayout", "Cas etrange, dans createViewAt, getView return null for cell=" + i);
} else {
cellHolder.getView().setFocusable(true);
cellHolder.getView().setClickable(true);
cellHolder.getView().setOnClickListener(this);
}
}
if (i < typeActive.size()) {
typeActive.set(i, type);
} else {
typeActive.add(type);
}
return cellHolder.getView();
}
public void removeViewAt(int i) {
/*int type = typeActive.get(i);
typeActive.remove(i);
View view = getChildAt(i);
List<ReCellHolder> recycledView = recycled.get(type);
if (recycledView == null) {
recycledView = new ArrayList<>();
recycled.put(type, recycledView);
}
recycledView.add(view);*/
super.removeViewAt(i);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.listener = listener;
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
v.setFocusable(true);
v.setClickable(true);
v.setOnClickListener(this);
}
}
public int getFirstVisiblePosition() {
return 0;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
@Override
public void onClick(View v) {
if (listener == null) {
return;
}
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) == v) {
listener.onItemClick(null, v, i, 0);
return;
}
}
}
}
| 8,082 | 0.60245 | 0.600594 | 270 | 28.933332 | 24.818661 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.574074 | false | false | 9 |
4b510b513cb76528e0793d70849df7366cb9145c | 38,525,856,658,591 | 8ee6de9a7e32c0bd9e109355294d0cbd532970b3 | /JavaAnalyzer/src/tool/compiler/java/visit/InfoVariable.java | 51abfd9841d701bd90da00655a12e480facff877 | [] | no_license | LeeSeungWhui/JavaAnalyzer | https://github.com/LeeSeungWhui/JavaAnalyzer | d89624a614c6bbe804f59d3a9cced4c42d041a77 | 4d0a5dabdc609f89d98b9516379cf2c1ed7fe971 | refs/heads/master | 2021-01-16T22:03:16.780000 | 2016-03-05T14:47:34 | 2016-03-05T14:47:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tool.compiler.java.visit;
import polyglot.ext.jl5.types.JL5SubstClassType;
import polyglot.types.Type;
public abstract class InfoVariable implements Info {
private Type type;
private long idNum;
/**
* @return the type
*/
@Override
public Type getType() {
return type;
}
/**
*
*/
@Override
public Type getBaseType() {
if(type instanceof JL5SubstClassType) {
return ((JL5SubstClassType)type).base();
}
return getType();
}
/**
* @param type the type to set
*/
public void setType(Type type) {
this.type = type;
}
/**
* @return the ID number
*/
protected final long idNum() {
return idNum;
}
/**
* @return the kind of program point
*/
protected abstract String kind();
/**
* @return the ID number to set
*/
protected abstract long generateIDNum();
/**
* generate the ID
*/
protected final void generateID() {
idNum = generateIDNum();
}
/**
* @return the ID
*/
public String getID() {
return kind() + idNum();
}
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return getID();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
} | UTF-8 | Java | 1,347 | java | InfoVariable.java | Java | [] | null | [] | package tool.compiler.java.visit;
import polyglot.ext.jl5.types.JL5SubstClassType;
import polyglot.types.Type;
public abstract class InfoVariable implements Info {
private Type type;
private long idNum;
/**
* @return the type
*/
@Override
public Type getType() {
return type;
}
/**
*
*/
@Override
public Type getBaseType() {
if(type instanceof JL5SubstClassType) {
return ((JL5SubstClassType)type).base();
}
return getType();
}
/**
* @param type the type to set
*/
public void setType(Type type) {
this.type = type;
}
/**
* @return the ID number
*/
protected final long idNum() {
return idNum;
}
/**
* @return the kind of program point
*/
protected abstract String kind();
/**
* @return the ID number to set
*/
protected abstract long generateIDNum();
/**
* generate the ID
*/
protected final void generateID() {
idNum = generateIDNum();
}
/**
* @return the ID
*/
public String getID() {
return kind() + idNum();
}
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return getID();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
} | 1,347 | 0.594655 | 0.591685 | 83 | 14.253012 | 14.546016 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.253012 | false | false | 9 |
164231d8656e721f46cf838494caa1079a2bc775 | 23,227,183,188,515 | 64ff9f6a962cef5e496a59eba7a3ee8d993491b8 | /conctf/mobile/sources/a/f/k/e.java | f03a6875ca095558dc0482152f25b0570978d047 | [] | no_license | prashanthar2000/ctf-junk | https://github.com/prashanthar2000/ctf-junk | 45548fb9109e1837c5cdd8aa381dc967eb261e7d | ac27c97f3d90e9017a84a849c9a14c5bbe658bc9 | refs/heads/master | 2023-06-22T10:59:16.113000 | 2021-07-26T21:27:59 | 2021-07-26T21:27:59 | 389,772,070 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package a.f.k;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
public class e {
/* renamed from: a reason: collision with root package name */
public ViewParent f318a;
/* renamed from: b reason: collision with root package name */
public ViewParent f319b;
public final View c;
public boolean d;
public int[] e;
public e(View view) {
this.c = view;
}
public final ViewParent a(int i) {
if (i == 0) {
return this.f318a;
}
if (i != 1) {
return null;
}
return this.f319b;
}
public final boolean a(int i, int i2, int i3, int i4, int[] iArr, int i5, int[] iArr2) {
ViewParent a2;
int i6;
int i7;
int[] iArr3;
int[] iArr4 = iArr;
int i8 = i5;
if (!this.d || (a2 = a(i8)) == null) {
return false;
}
if (i == 0 && i2 == 0 && i3 == 0 && i4 == 0) {
if (iArr4 != null) {
iArr4[0] = 0;
iArr4[1] = 0;
}
return false;
}
if (iArr4 != null) {
this.c.getLocationInWindow(iArr4);
i7 = iArr4[0];
i6 = iArr4[1];
} else {
i7 = 0;
i6 = 0;
}
if (iArr2 == null) {
if (this.e == null) {
this.e = new int[2];
}
int[] iArr5 = this.e;
iArr5[0] = 0;
iArr5[1] = 0;
iArr3 = iArr5;
} else {
iArr3 = iArr2;
}
View view = this.c;
if (a2 instanceof g) {
((g) a2).a(view, i, i2, i3, i4, i5, iArr3);
} else {
iArr3[0] = iArr3[0] + i3;
iArr3[1] = iArr3[1] + i4;
if (a2 instanceof f) {
((f) a2).a(view, i, i2, i3, i4, i5);
} else if (i8 == 0) {
try {
a2.onNestedScroll(view, i, i2, i3, i4);
} catch (AbstractMethodError e2) {
Log.e("ViewParentCompat", "ViewParent " + a2 + " does not implement interface method onNestedScroll", e2);
}
}
}
if (iArr4 != null) {
this.c.getLocationInWindow(iArr4);
iArr4[0] = iArr4[0] - i7;
iArr4[1] = iArr4[1] - i6;
}
return true;
}
}
| UTF-8 | Java | 2,430 | java | e.java | Java | [] | null | [] | package a.f.k;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
public class e {
/* renamed from: a reason: collision with root package name */
public ViewParent f318a;
/* renamed from: b reason: collision with root package name */
public ViewParent f319b;
public final View c;
public boolean d;
public int[] e;
public e(View view) {
this.c = view;
}
public final ViewParent a(int i) {
if (i == 0) {
return this.f318a;
}
if (i != 1) {
return null;
}
return this.f319b;
}
public final boolean a(int i, int i2, int i3, int i4, int[] iArr, int i5, int[] iArr2) {
ViewParent a2;
int i6;
int i7;
int[] iArr3;
int[] iArr4 = iArr;
int i8 = i5;
if (!this.d || (a2 = a(i8)) == null) {
return false;
}
if (i == 0 && i2 == 0 && i3 == 0 && i4 == 0) {
if (iArr4 != null) {
iArr4[0] = 0;
iArr4[1] = 0;
}
return false;
}
if (iArr4 != null) {
this.c.getLocationInWindow(iArr4);
i7 = iArr4[0];
i6 = iArr4[1];
} else {
i7 = 0;
i6 = 0;
}
if (iArr2 == null) {
if (this.e == null) {
this.e = new int[2];
}
int[] iArr5 = this.e;
iArr5[0] = 0;
iArr5[1] = 0;
iArr3 = iArr5;
} else {
iArr3 = iArr2;
}
View view = this.c;
if (a2 instanceof g) {
((g) a2).a(view, i, i2, i3, i4, i5, iArr3);
} else {
iArr3[0] = iArr3[0] + i3;
iArr3[1] = iArr3[1] + i4;
if (a2 instanceof f) {
((f) a2).a(view, i, i2, i3, i4, i5);
} else if (i8 == 0) {
try {
a2.onNestedScroll(view, i, i2, i3, i4);
} catch (AbstractMethodError e2) {
Log.e("ViewParentCompat", "ViewParent " + a2 + " does not implement interface method onNestedScroll", e2);
}
}
}
if (iArr4 != null) {
this.c.getLocationInWindow(iArr4);
iArr4[0] = iArr4[0] - i7;
iArr4[1] = iArr4[1] - i6;
}
return true;
}
}
| 2,430 | 0.424691 | 0.379012 | 91 | 25.703297 | 19.532724 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.769231 | false | false | 9 |
8b092981972700722384dda57c5d2b07a157fbf0 | 37,125,697,330,321 | d3f354a6b1efc976e7f09ce275ac92516c526ba5 | /CS100s/CS161/ClassLabs/Lab12a/List/UrlListIfc.java | dcb4d6c6d715459875db2c6ccb4ff324220fbd29 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | AndrewZurn/sju-compsci-archive | https://github.com/AndrewZurn/sju-compsci-archive | 94918af0b3f28b7a3b6379100b43fb93482884d3 | 3ea0e4f0db8453a011fc7511140df788dde5aae2 | refs/heads/master | 2016-09-10T01:02:09.344000 | 2015-01-09T17:34:14 | 2015-01-09T17:34:14 | 29,027,250 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import objectdraw.*;
import java.awt.*;
// Interface for classes representing lists of URLs
public interface UrlListIfc {
// returns a list of all entries starting with prefix
public UrlListIfc getMatches( String prefix );
// determines whether the collection contains url
public boolean contains( String url );
// Convert list to a string with entries separated by new lines
public String toString();
}
| UTF-8 | Java | 439 | java | UrlListIfc.java | Java | [] | null | [] | import objectdraw.*;
import java.awt.*;
// Interface for classes representing lists of URLs
public interface UrlListIfc {
// returns a list of all entries starting with prefix
public UrlListIfc getMatches( String prefix );
// determines whether the collection contains url
public boolean contains( String url );
// Convert list to a string with entries separated by new lines
public String toString();
}
| 439 | 0.722096 | 0.722096 | 14 | 30.357143 | 22.279417 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false | 9 |
7928e1a0485d7aa1c96da04f759085338c1e934b | 39,316,130,629,796 | 7be412be012fa4d8678d9d616a27c8626b44cda4 | /PasswordGenerator.java | 071595c03c3aef1cd536683361db444debda29ea | [] | no_license | Dyeh310/Password-Generator | https://github.com/Dyeh310/Password-Generator | 1d8a75db298787dea4aad4e7d24dbf444bfad441 | bf8de09f1219e2fffd4a36341d90379efca0d49e | refs/heads/master | 2021-04-26T08:53:35.169000 | 2017-10-29T01:36:09 | 2017-10-29T01:36:09 | 106,948,987 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package logic;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class PasswordGenerator {
private int passwordLength;
private Random random;
private char[] punct = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ':', '<', '>', '?' };// 14
private int sbLength;
private StringBuilder sb;
private char rpwChar;
private char rpwP;
private int rpwNum;
public PasswordGenerator() {
this.random = new Random();
this.sbLength = sbLength;
this.sb = new StringBuilder("");
this.rpwChar = rpwChar;
this.rpwP = rpwP;
this.rpwNum = rpwNum;
}
public int getPasswordLength() {
return passwordLength;
}
public void setPasswordLength(int passwordLength) {
this.passwordLength = passwordLength;
}
public String generateRandomChar() {
for (int i = 0; i < passwordLength; i++) {
int choice = random.nextInt(3);
rpwChar = (char) (random.nextInt(26) + 'a');
if (random.nextInt(2) == 1) {
rpwChar = Character.toUpperCase(rpwChar);
}
rpwP = punct[i];
rpwNum = random.nextInt(10);
if (sbLength < passwordLength && choice == 0) {
sb.append(rpwChar);
sbLength++;
}
if (sbLength < passwordLength && choice == 1) {
sb.append(rpwNum);
sbLength++;
}
if (sbLength < passwordLength && choice == 2) {
sb.append(rpwP);
sbLength++;
}
}
Collections.shuffle(Arrays.asList(sb));
return sb.toString();
}
}
| UTF-8 | Java | 1,456 | java | PasswordGenerator.java | Java | [] | null | [] | package logic;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class PasswordGenerator {
private int passwordLength;
private Random random;
private char[] punct = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ':', '<', '>', '?' };// 14
private int sbLength;
private StringBuilder sb;
private char rpwChar;
private char rpwP;
private int rpwNum;
public PasswordGenerator() {
this.random = new Random();
this.sbLength = sbLength;
this.sb = new StringBuilder("");
this.rpwChar = rpwChar;
this.rpwP = rpwP;
this.rpwNum = rpwNum;
}
public int getPasswordLength() {
return passwordLength;
}
public void setPasswordLength(int passwordLength) {
this.passwordLength = passwordLength;
}
public String generateRandomChar() {
for (int i = 0; i < passwordLength; i++) {
int choice = random.nextInt(3);
rpwChar = (char) (random.nextInt(26) + 'a');
if (random.nextInt(2) == 1) {
rpwChar = Character.toUpperCase(rpwChar);
}
rpwP = punct[i];
rpwNum = random.nextInt(10);
if (sbLength < passwordLength && choice == 0) {
sb.append(rpwChar);
sbLength++;
}
if (sbLength < passwordLength && choice == 1) {
sb.append(rpwNum);
sbLength++;
}
if (sbLength < passwordLength && choice == 2) {
sb.append(rpwP);
sbLength++;
}
}
Collections.shuffle(Arrays.asList(sb));
return sb.toString();
}
}
| 1,456 | 0.629808 | 0.620879 | 67 | 20.716417 | 18.521311 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.373134 | false | false | 9 |
cd2089d66710afd7cab46af211cf7f5b55a11506 | 39,316,130,631,366 | ab183c7c688b6d42fdefa0618ecc483e6498f925 | /src/main/java/cn/zz/user/common/util/lang/Callback2.java | 4f0476dfc6ae1ffb875d61190020e66eb6c651d7 | [
"Apache-2.0"
] | permissive | zhourui392/springBootCase | https://github.com/zhourui392/springBootCase | b479ec44b8229bb30ef2076bd8c2890c179e8619 | 0988ea9991573b47ebcd2772597bb85c6a89e09d | refs/heads/master | 2021-01-22T10:56:43.230000 | 2019-09-26T06:51:59 | 2019-09-26T06:51:59 | 82,054,632 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.zz.user.common.util.lang;
/**
* 带两个参数的通用回调接口
* @author zhourui(zhourui0125@gmail.com)
* @param <T>
*/
public interface Callback2<T0, T1> {
void invoke(T0 arg0, T1 arg1);
} | UTF-8 | Java | 217 | java | Callback2.java | Java | [
{
"context": ".common.util.lang;\n\n/**\n * 带两个参数的通用回调接口\n * @author zhourui(zhourui0125@gmail.com)\n * @param <T>\n */\npublic i",
"end": 76,
"score": 0.8833793997764587,
"start": 69,
"tag": "USERNAME",
"value": "zhourui"
},
{
"context": "til.lang;\n\n/**\n * 带两个参数的通用回调接口\n * @autho... | null | [] | package cn.zz.user.common.util.lang;
/**
* 带两个参数的通用回调接口
* @author zhourui(<EMAIL>)
* @param <T>
*/
public interface Callback2<T0, T1> {
void invoke(T0 arg0, T1 arg1);
} | 203 | 0.668394 | 0.611399 | 12 | 15.166667 | 16.025154 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 9 |
7d0e97883d958cd0997c4023d7a906fc48e2c036 | 19,121,194,403,013 | adae5130c1b37455616fea646de8a69f4df32200 | /src/main/java/com/netty/redis/msg/RedisCmd.java | 6ffe8650059cfefd22cf407f12cea5777777a2c7 | [] | no_license | lengyul/netty-study | https://github.com/lengyul/netty-study | bb2e1e3753989c7c1d73a9a3e558fb7469cdd256 | 8bb9621eecaf13f97a523eed152c1c08af9f821c | refs/heads/master | 2020-04-13T19:03:58.120000 | 2019-05-13T02:50:45 | 2019-05-13T02:50:45 | 163,392,134 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.netty.redis.msg;
public enum RedisCmd {
SET,
GET
}
| UTF-8 | Java | 75 | java | RedisCmd.java | Java | [] | null | [] | package com.netty.redis.msg;
public enum RedisCmd {
SET,
GET
}
| 75 | 0.626667 | 0.626667 | 7 | 8.714286 | 10.552106 | 28 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 9 |
0d17e270555d9012b19a2e6dfcf45bc05337d706 | 31,937,376,879,280 | 87d7554d85377455c34c764b47a9b1031b28007d | /lesamisdelescalade-business/src/main/java/com/charles/lesamisdelescalade/business/utils/bean/UtilisateurManager.java | 4fa6688976b0611d28fbfe6b16e2a25dbbb9516b | [] | no_license | ccathala/lesamisdelescalade | https://github.com/ccathala/lesamisdelescalade | 26a2b1a36accc9171c45f63a466dfdb581f8565b | a352e21d446e89105378bfcf683a825ac483cde2 | refs/heads/master | 2020-07-01T20:24:12.672000 | 2019-11-09T17:08:40 | 2019-11-09T17:08:40 | 201,011,933 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.charles.lesamisdelescalade.business.utils.bean;
public interface UtilisateurManager {
}
| UTF-8 | Java | 102 | java | UtilisateurManager.java | Java | [] | null | [] | package com.charles.lesamisdelescalade.business.utils.bean;
public interface UtilisateurManager {
}
| 102 | 0.833333 | 0.833333 | 5 | 19.4 | 24.368832 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 9 |
061bf2d8ffed81b60bd86463469fe5b07e5564d6 | 24,876,450,591,052 | df8b07b73c6cc6cd70845c4b66deb4b0785e876e | /src/main/java/javaBase/reflect/factoryReflect/fruit.java | a8fbdfd6d3e8fa82cb36f2e9b3bc3b7bee1edbc3 | [] | no_license | gemeiren/gradle-demo | https://github.com/gemeiren/gradle-demo | 455d5c761a7a5c41bfa74fb463d80b0fb7710e57 | f5d99385f8b3dcaf4fe119573281b1a5eb642232 | refs/heads/master | 2021-01-23T22:05:30.939000 | 2018-08-05T09:55:30 | 2018-08-05T09:55:30 | 83,116,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package javaBase.reflect.factoryReflect;
public interface fruit {
public abstract void eat();
}
| UTF-8 | Java | 98 | java | fruit.java | Java | [] | null | [] | package javaBase.reflect.factoryReflect;
public interface fruit {
public abstract void eat();
}
| 98 | 0.785714 | 0.785714 | 5 | 18.6 | 15.692037 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 9 |
3832488fd3fc4629f116752a71d788a239fa01cd | 33,337,536,218,884 | 8e5447df0d61d33b427e2a49a11edb51d949e4fd | /StudyJavaProject/src/testFactory/Product.java | 6883a1ef492eeb573494885d49696d006de5df43 | [] | no_license | bestRookieLee/testGitSubmit | https://github.com/bestRookieLee/testGitSubmit | 3e6d911f8012eb86b2fccc8613a97a8bc2f5ea71 | d672b125be4ed3144f34e3b570a27bdb75d4705b | refs/heads/master | 2022-03-04T01:20:27.590000 | 2022-02-17T11:12:08 | 2022-02-17T11:12:08 | 195,743,062 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package testFactory;
public interface Product {
void operation1(String wantdo);
}
| UTF-8 | Java | 87 | java | Product.java | Java | [] | null | [] | package testFactory;
public interface Product {
void operation1(String wantdo);
}
| 87 | 0.758621 | 0.747126 | 5 | 16.4 | 13.836185 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
61f7d204c414a6f0a2ea82e12af952ec35ddc137 | 14,946,486,210,436 | 6bb4cda917b8e1a48374ddb1d7f902f1a01a9859 | /app/src/main/java/com/david0926/safecall/model/ChatModel.java | f014255ce7510bac73f79f54d14c43a4fbeb6759 | [] | no_license | roian6/SafeCallApp | https://github.com/roian6/SafeCallApp | 4f265af5493983a338e1ca5e06c117071b92046f | 659c9783dddf4ff71567d63b7005a8d958c6c31a | refs/heads/master | 2023-02-06T17:31:42.391000 | 2020-12-16T09:56:31 | 2020-12-16T09:56:31 | 321,859,801 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.david0926.safecall.model;
public class ChatModel {
private String type, question, answer;
public ChatModel(){}
public ChatModel(String type, String question, String answer) {
this.type = type;
this.question = question;
this.answer = answer;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
}
| UTF-8 | Java | 727 | java | ChatModel.java | Java | [
{
"context": "package com.david0926.safecall.model;\n\npublic class ChatModel {\n\n ",
"end": 19,
"score": 0.6924443244934082,
"start": 17,
"tag": "USERNAME",
"value": "09"
}
] | null | [] | package com.david0926.safecall.model;
public class ChatModel {
private String type, question, answer;
public ChatModel(){}
public ChatModel(String type, String question, String answer) {
this.type = type;
this.question = question;
this.answer = answer;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
}
| 727 | 0.6011 | 0.595598 | 38 | 18.131578 | 17.200323 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.394737 | false | false | 4 |
4daf9fefd848cfb778f973a0ac53e592cf01c902 | 12,223,476,949,455 | 54b7bc8b0dbf3921ec36ab658f1eb726e44d1e08 | /CommonTools/src/main/java/com/tyrcho/gui/toolkit/calendar/HourChooser.java | 4f8652318029fd97705d37d2b06a0a4534d9ce15 | [] | no_license | tyrcho/dict | https://github.com/tyrcho/dict | bfe75ad24caeb01f0000b2c64c4d328ba7c13ee3 | 016b00ce9dbb126967cf614c3c0edf0130d4c0e2 | refs/heads/master | 2021-06-11T17:01:28.606000 | 2020-06-03T19:23:55 | 2020-06-03T19:23:55 | 24,987,191 | 0 | 0 | null | false | 2021-05-18T18:53:25 | 2014-10-09T11:58:39 | 2020-06-03T19:23:59 | 2021-05-18T18:53:21 | 194 | 0 | 0 | 5 | Java | false | false | package com.tyrcho.gui.toolkit.calendar;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javax.swing.SwingConstants;
/**
* Allows the user to choose an hour in a SpinnerComboBox.
*
* @author MDA
* @version NP
*/
public class HourChooser extends IntegerChooser
{
public static final int MIN_HOUR_DEFAULT=0;
public static final int MAX_HOUR_DEFAULT=23;
/**
* Constructs the HourChooser with the spinner on the right.
*/
public HourChooser()
{
this(SwingConstants.RIGHT, MIN_HOUR_DEFAULT, MAX_HOUR_DEFAULT);
}
/**
* Constructs the HourChooser.
*
* @param spinnerPosition either SwingConstants.LEFT or SwingConstants.RIGHT
* @param minHour the first possible value to initialize the combo box
* @param maxHour the last possible value to initialize the combo box
* @throws IllegalArgumentException if another value is used for spinnerPosition
* or if maxHour is lower than minHour
*/
public HourChooser(int spinnerPosition, int minHour, int maxHour)
{
this(spinnerPosition, getIntegerRange(minHour, maxHour));
}
/**
* Constructs the HourChooser.
*
* @param spinnerPosition either SwingConstants.LEFT or SwingConstants.RIGHT
* @param defaultData the array to initialize the combo box
* @throws IllegalArgumentException if another value is used for spinnerPosition
*/
public HourChooser(int spinnerPosition, Integer[] defaultData)
{
super(spinnerPosition, defaultData, new DecimalFormat("00"));
}
public static void main(String[] s)
{
JFrame frame = new JFrame("HourChooser");
HourChooser chooser=new HourChooser();
chooser.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
System.out.println(e.getItem());
}
});
frame.getContentPane().add(chooser);
frame.pack();
frame.setVisible(true);
}
} | UTF-8 | Java | 2,022 | java | HourChooser.java | Java | [
{
"context": "hoose an hour in a SpinnerComboBox.\n * \n * @author MDA\n * @version NP\n */\npublic class HourChooser exten",
"end": 288,
"score": 0.9966428279876709,
"start": 285,
"tag": "USERNAME",
"value": "MDA"
}
] | null | [] | package com.tyrcho.gui.toolkit.calendar;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javax.swing.SwingConstants;
/**
* Allows the user to choose an hour in a SpinnerComboBox.
*
* @author MDA
* @version NP
*/
public class HourChooser extends IntegerChooser
{
public static final int MIN_HOUR_DEFAULT=0;
public static final int MAX_HOUR_DEFAULT=23;
/**
* Constructs the HourChooser with the spinner on the right.
*/
public HourChooser()
{
this(SwingConstants.RIGHT, MIN_HOUR_DEFAULT, MAX_HOUR_DEFAULT);
}
/**
* Constructs the HourChooser.
*
* @param spinnerPosition either SwingConstants.LEFT or SwingConstants.RIGHT
* @param minHour the first possible value to initialize the combo box
* @param maxHour the last possible value to initialize the combo box
* @throws IllegalArgumentException if another value is used for spinnerPosition
* or if maxHour is lower than minHour
*/
public HourChooser(int spinnerPosition, int minHour, int maxHour)
{
this(spinnerPosition, getIntegerRange(minHour, maxHour));
}
/**
* Constructs the HourChooser.
*
* @param spinnerPosition either SwingConstants.LEFT or SwingConstants.RIGHT
* @param defaultData the array to initialize the combo box
* @throws IllegalArgumentException if another value is used for spinnerPosition
*/
public HourChooser(int spinnerPosition, Integer[] defaultData)
{
super(spinnerPosition, defaultData, new DecimalFormat("00"));
}
public static void main(String[] s)
{
JFrame frame = new JFrame("HourChooser");
HourChooser chooser=new HourChooser();
chooser.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
System.out.println(e.getItem());
}
});
frame.getContentPane().add(chooser);
frame.pack();
frame.setVisible(true);
}
} | 2,022 | 0.698813 | 0.69634 | 71 | 27.492958 | 26.297792 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.661972 | false | false | 4 |
ec3c239b44798d43704141b2aecac2c7e8266a73 | 17,643,725,656,359 | 2fc02e01848503da5f577e2093f07e9738bf2e46 | /GenApp2.java | de126ced35be49b127258b53214bbb7526dd6bf5 | [] | no_license | idlanirined/Method-Generic | https://github.com/idlanirined/Method-Generic | 0435690936c2eddc76b6c0ec93b57582aae47704 | f86b0e335e1b9e535cb1171d0db49e7d7f93f900 | refs/heads/master | 2021-06-21T17:16:21.186000 | 2017-06-09T15:45:47 | 2017-06-09T15:45:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package methodgeneric;
/**
*
* @author Deni Rinaldi
*/
public class GenApp2 <T> {
private T type;
public T getType() {
return type;
}
public void setType (T type) {
this.type = type;
}
private static <Z> void whatYouDo (){
System.out.println();
}
private static <N,T> void anythingYouWanted(N freeParType, T freeTwo) {
System.out.println(freeParType);
System.out.println(freeTwo);
}
public static void main (String[]Args) {
anythingYouWanted(1,"Deni");
}
} | UTF-8 | Java | 620 | java | GenApp2.java | Java | [
{
"context": "package methodgeneric;\r\n\r\n/**\r\n *\r\n * @author Deni Rinaldi\r\n */\r\npublic class GenApp2 <T> {\r\n private T t",
"end": 58,
"score": 0.9998770952224731,
"start": 46,
"tag": "NAME",
"value": "Deni Rinaldi"
}
] | null | [] | package methodgeneric;
/**
*
* @author <NAME>
*/
public class GenApp2 <T> {
private T type;
public T getType() {
return type;
}
public void setType (T type) {
this.type = type;
}
private static <Z> void whatYouDo (){
System.out.println();
}
private static <N,T> void anythingYouWanted(N freeParType, T freeTwo) {
System.out.println(freeParType);
System.out.println(freeTwo);
}
public static void main (String[]Args) {
anythingYouWanted(1,"Deni");
}
} | 614 | 0.527419 | 0.524194 | 31 | 18.064516 | 17.325974 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.354839 | false | false | 4 |
fabecf0021111bc4f11ad268a86145e956e30084 | 19,937,238,216,151 | cc4ee99ff9928c3d5de73ef945b16aeefc295063 | /Taller2POO2/src/com/company/ExistenceException.java | 52243ce61cb00293bbc20e91aa6465d6a540069f | [] | no_license | katherin-perez/SegundaActividadPOO2 | https://github.com/katherin-perez/SegundaActividadPOO2 | 12a188ffcd02fbf596ebcb5669f6f053c6586386 | 69569fe576b839dabd5fc7d0a2220bdb6548e79e | refs/heads/main | 2023-04-07T10:37:36.164000 | 2021-04-06T21:31:27 | 2021-04-06T21:31:27 | 355,334,393 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company;
public class ExistenceException extends Exception{
private final int code;
public ExistenceException(int code) {
super();
this.code = code;
}
public ExistenceException(String message, int code) {
super(message);
this.code = code;
}
public int getCode() {
return code;
}
}
| UTF-8 | Java | 386 | java | ExistenceException.java | Java | [] | null | [] | package com.company;
public class ExistenceException extends Exception{
private final int code;
public ExistenceException(int code) {
super();
this.code = code;
}
public ExistenceException(String message, int code) {
super(message);
this.code = code;
}
public int getCode() {
return code;
}
}
| 386 | 0.57772 | 0.57772 | 20 | 17.299999 | 16.970858 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
96183e79785f527c483775ccdc240ab8af585ef9 | 695,784,737,640 | de0be190667d0d2bdd69d78fbe2ea7e773ca876c | /main/java/com/company/library/dao/pool/exception/PoolNotInitException.java | fc8ea9eaa3e84329d7ae0dbae05cd906533c5e7f | [] | no_license | wazza123/library | https://github.com/wazza123/library | 53d43103d853fd312748866627e40bb3529adef6 | 8b3aa826e9c216e10de5a7762b2356d0572cea8b | refs/heads/master | 2020-03-14T16:53:06.336000 | 2018-05-01T11:47:46 | 2018-05-01T11:47:46 | 56,751,806 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company.library.dao.pool.exception;
public class PoolNotInitException extends Exception {
public PoolNotInitException(String s) {
super(s);
}
}
| UTF-8 | Java | 176 | java | PoolNotInitException.java | Java | [] | null | [] | package com.company.library.dao.pool.exception;
public class PoolNotInitException extends Exception {
public PoolNotInitException(String s) {
super(s);
}
}
| 176 | 0.715909 | 0.715909 | 10 | 16.6 | 21.039011 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 4 |
e7c4cd18246765d74bcf227f33362565e9b58794 | 10,943,576,707,732 | 8654ea8d0e75503bccbc78df882e1b346a5476db | /challenge/HashTable/app/src/main/java/Hashtable/queue/QNode.java | 869becac0436ff8b357eb5b3e01fa76ac5cb8de5 | [
"MIT"
] | permissive | morjaradat/401-data-structures-and-algorithms | https://github.com/morjaradat/401-data-structures-and-algorithms | c14982153f3e8b0b7e247e3d084ea5ef941a7449 | 60721c25604348fe4ab5eef461877939a47edd60 | refs/heads/main | 2023-07-13T19:39:34.873000 | 2021-08-24T19:11:06 | 2021-08-24T19:11:06 | 380,757,289 | 0 | 0 | MIT | false | 2021-08-24T19:11:06 | 2021-06-27T14:13:48 | 2021-08-23T20:03:49 | 2021-08-24T19:11:06 | 3,331 | 0 | 0 | 0 | Java | false | false | package Hashtable.queue;
public class QNode<T> {
private T data;
private QNode<T> next;
public QNode() {
}
public QNode(T data) {
this.data = data;
}
public void setData(T data) {
this.data = data;
}
public T getData() {
return data;
}
public QNode<T> getNext() {
return next;
}
public void setNext(QNode<T> next) {
this.next = next;
}
}
| UTF-8 | Java | 443 | java | QNode.java | Java | [] | null | [] | package Hashtable.queue;
public class QNode<T> {
private T data;
private QNode<T> next;
public QNode() {
}
public QNode(T data) {
this.data = data;
}
public void setData(T data) {
this.data = data;
}
public T getData() {
return data;
}
public QNode<T> getNext() {
return next;
}
public void setNext(QNode<T> next) {
this.next = next;
}
}
| 443 | 0.523702 | 0.523702 | 30 | 13.766666 | 12.414194 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.266667 | false | false | 4 |
dfd266bc6bebdb5996815148925bfa486145e3e6 | 3,848,290,729,578 | bf2678c6cf3b922fe9eba19344939e3ba5ba5d33 | /src/main/java/org/bian/dto/BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord.java | 4860809d25da5e8999e9f71f3ada865581b455ed | [
"Apache-2.0"
] | permissive | bianapis/sd-card-collections-v2.0 | https://github.com/bianapis/sd-card-collections-v2.0 | 9369a2a03eb8ad6a797afd4de60fb2a117ee555d | 24d8d77138aaee76ede1f09fecd7c7570af6c463 | refs/heads/master | 2020-07-11T04:17:42.302000 | 2019-09-02T07:17:21 | 2019-09-02T07:17:21 | 204,443,657 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.bian.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.bian.dto.BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions;
import javax.validation.Valid;
/**
* BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord
*/
public class BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord {
private String productInstanceReference = null;
private String productServiceType = null;
private String customerReference = null;
private String cardType = null;
private String cardAccountStatus = null;
private BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions paymentTransactions = null;
private String cardCollectionsProcessingSchedule = null;
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to the associated product instance in collections
* @return productInstanceReference
**/
public String getProductInstanceReference() {
return productInstanceReference;
}
public void setProductInstanceReference(String productInstanceReference) {
this.productInstanceReference = productInstanceReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The type of product
* @return productServiceType
**/
public String getProductServiceType() {
return productServiceType;
}
public void setProductServiceType(String productServiceType) {
this.productServiceType = productServiceType;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to the account primary party/owner
* @return customerReference
**/
public String getCustomerReference() {
return customerReference;
}
public void setCustomerReference(String customerReference) {
this.customerReference = customerReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The type of card
* @return cardType
**/
public String getCardType() {
return cardType;
}
public void setCardType(String cardType) {
this.cardType = cardType;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The status of the account (e.g. active, cancelled, blocked, closed,...)
* @return cardAccountStatus
**/
public String getCardAccountStatus() {
return cardAccountStatus;
}
public void setCardAccountStatus(String cardAccountStatus) {
this.cardAccountStatus = cardAccountStatus;
}
/**
* Get paymentTransactions
* @return paymentTransactions
**/
public BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions getPaymentTransactions() {
return paymentTransactions;
}
public void setPaymentTransactions(BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions paymentTransactions) {
this.paymentTransactions = paymentTransactions;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The processing schedule for resolution of the collections process and final decision
* @return cardCollectionsProcessingSchedule
**/
public String getCardCollectionsProcessingSchedule() {
return cardCollectionsProcessingSchedule;
}
public void setCardCollectionsProcessingSchedule(String cardCollectionsProcessingSchedule) {
this.cardCollectionsProcessingSchedule = cardCollectionsProcessingSchedule;
}
}
| UTF-8 | Java | 3,966 | java | BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord.java | Java | [] | null | [] | package org.bian.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.bian.dto.BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions;
import javax.validation.Valid;
/**
* BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord
*/
public class BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecord {
private String productInstanceReference = null;
private String productServiceType = null;
private String customerReference = null;
private String cardType = null;
private String cardAccountStatus = null;
private BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions paymentTransactions = null;
private String cardCollectionsProcessingSchedule = null;
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to the associated product instance in collections
* @return productInstanceReference
**/
public String getProductInstanceReference() {
return productInstanceReference;
}
public void setProductInstanceReference(String productInstanceReference) {
this.productInstanceReference = productInstanceReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The type of product
* @return productServiceType
**/
public String getProductServiceType() {
return productServiceType;
}
public void setProductServiceType(String productServiceType) {
this.productServiceType = productServiceType;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to the account primary party/owner
* @return customerReference
**/
public String getCustomerReference() {
return customerReference;
}
public void setCustomerReference(String customerReference) {
this.customerReference = customerReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The type of card
* @return cardType
**/
public String getCardType() {
return cardType;
}
public void setCardType(String cardType) {
this.cardType = cardType;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The status of the account (e.g. active, cancelled, blocked, closed,...)
* @return cardAccountStatus
**/
public String getCardAccountStatus() {
return cardAccountStatus;
}
public void setCardAccountStatus(String cardAccountStatus) {
this.cardAccountStatus = cardAccountStatus;
}
/**
* Get paymentTransactions
* @return paymentTransactions
**/
public BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions getPaymentTransactions() {
return paymentTransactions;
}
public void setPaymentTransactions(BQPaymentRetrieveOutputModelCardCollectionsProcedureInstanceRecordPaymentTransactions paymentTransactions) {
this.paymentTransactions = paymentTransactions;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The processing schedule for resolution of the collections process and final decision
* @return cardCollectionsProcessingSchedule
**/
public String getCardCollectionsProcessingSchedule() {
return cardCollectionsProcessingSchedule;
}
public void setCardCollectionsProcessingSchedule(String cardCollectionsProcessingSchedule) {
this.cardCollectionsProcessingSchedule = cardCollectionsProcessingSchedule;
}
}
| 3,966 | 0.781896 | 0.779375 | 128 | 29.976563 | 44.273911 | 207 | false | false | 0 | 0 | 0 | 0 | 85 | 0.119264 | 0.25 | false | false | 4 |
80bb1abf114e81f5e8e24394a43a6fca8f9bef0c | 22,230,750,754,708 | a5dc92f5f792098d47020f45a90955967470495e | /SGPF/src/java/Tema.java | b5b606c19d35becd175aba293b88d9ebe1b077e2 | [] | no_license | PatiMendess/PSW2 | https://github.com/PatiMendess/PSW2 | 7304596504b92ad1386f17139ff3c5115a356f1f | 274593d7ff2bae537f8992de7fd70b94af3c3be2 | refs/heads/master | 2020-04-06T06:54:12.742000 | 2016-09-14T01:27:09 | 2016-09-14T01:27:09 | 64,264,411 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author RA21504781
*/
@Entity
public class Tema {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String titulo;
private String segmento;
private String plataforma;
private String descricao;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getSegmento() {
return segmento;
}
public void setSegmento(String segmento) {
this.segmento = segmento;
}
public String getPlataforma() {
return plataforma;
}
public void setPlataforma(String plataforma) {
this.plataforma = plataforma;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
}
| UTF-8 | Java | 1,356 | java | Tema.java | Java | [
{
"context": "the template in the editor.\n */\n\n/**\n *\n * @author RA21504781\n */\n@Entity\npublic class Tema {\n \n @Id\n ",
"end": 360,
"score": 0.9990515112876892,
"start": 350,
"tag": "USERNAME",
"value": "RA21504781"
}
] | null | [] |
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author RA21504781
*/
@Entity
public class Tema {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String titulo;
private String segmento;
private String plataforma;
private String descricao;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getSegmento() {
return segmento;
}
public void setSegmento(String segmento) {
this.segmento = segmento;
}
public String getPlataforma() {
return plataforma;
}
public void setPlataforma(String plataforma) {
this.plataforma = plataforma;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
}
| 1,356 | 0.637906 | 0.632006 | 70 | 18.342857 | 17.976879 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.314286 | false | false | 4 |
3a1ec2c076f0684f952bdb3be5641339ba4b65a9 | 33,706,903,340,427 | a5445000d0e1374cba5e31e8fe00d82a675b680a | /oauth2-social-login-sample/src/main/java/com/example/security/oauth/exception/OAuthProviderMissMatchException.java | b264e03bcdb648d7fa116d5ee1a4bce7a02b6f97 | [] | no_license | eungsu/sample-projects | https://github.com/eungsu/sample-projects | e4839f1ff14ff8cdc8627545ca782c6314ce31c1 | d129732e0759328e7ef993189f1629493ed935be | refs/heads/main | 2023-03-09T11:55:05.293000 | 2023-03-03T15:30:09 | 2023-03-03T15:30:09 | 595,473,990 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.security.oauth.exception;
public class OAuthProviderMissMatchException extends RuntimeException {
private static final long serialVersionUID = 7938123176061362252L;
public OAuthProviderMissMatchException(String message) {
super(message);
}
}
| UTF-8 | Java | 270 | java | OAuthProviderMissMatchException.java | Java | [] | null | [] | package com.example.security.oauth.exception;
public class OAuthProviderMissMatchException extends RuntimeException {
private static final long serialVersionUID = 7938123176061362252L;
public OAuthProviderMissMatchException(String message) {
super(message);
}
}
| 270 | 0.82963 | 0.759259 | 10 | 26 | 28.875595 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 4 |
76814c6000c5367964a1fd570e01d37b905a0ad2 | 32,452,772,891,703 | 6ed4dedf08a83576a935d5b954bb74e1e155152f | /L2EmuProject-DataPack/data/scripts/custom/ShadowWeapons/ShadowWeapons.java | 198c64134dcedaf33ed4b73158b6811b00de4406 | [] | no_license | lordrex34/l2emu | https://github.com/lordrex34/l2emu | ca3482a8a459850e99e829c492bd5a5a9d497a74 | 6c6a9abadeaf141e7b2034abd079f68f7563ebcc | refs/heads/master | 2020-03-04T06:01:42.193000 | 2011-04-22T18:06:14 | 2011-04-22T18:06:14 | 35,040,735 | 0 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package custom.ShadowWeapons;
import net.l2emuproject.gameserver.services.quest.QuestState;
import net.l2emuproject.gameserver.services.quest.jython.QuestJython;
import net.l2emuproject.gameserver.world.object.L2Npc;
import net.l2emuproject.gameserver.world.object.L2Player;
/**
* @author L0ngh0rn
*/
public final class ShadowWeapons extends QuestJython
{
private static final String QN = "ShadowWeapons";
private static final int[] NPC =
{
30037, 30066, 30070, 30109, 30115, 30120, 30174, 30175,
30176, 30187, 30191, 30195, 30288, 30289, 30290, 30297,
30373, 30462, 30474, 30498, 30499, 30500, 30503, 30504,
30505, 30511, 30512, 30513, 30595, 30676, 30677, 30681,
30685, 30687, 30689, 30694, 30699, 30704, 30845, 30847,
30849, 30854, 30857, 30862, 30865, 30894, 30897, 30900,
30905, 30910, 30913, 31269, 31272, 31288, 31314, 31317,
31321, 31324, 31326, 31328, 31331, 31334, 31336, 31965,
31974, 31276, 31285, 31958, 31961, 31996, 31968, 31977,
32092, 32093, 32094, 32095, 32096, 32097, 32098, 32193,
32196, 32199, 32202, 32205, 32206, 32213, 32214, 32217,
32218, 32221, 32222, 32229, 32230, 32233,32234
};
private static final int D_COUPON = 8869;
private static final int C_COUPON = 8870;
public ShadowWeapons(int questId, String name, String descr, String folder)
{
super(questId, name, descr, folder);
for (int npc : NPC)
{
addStartNpc(npc);
addTalkId(npc);
}
}
@Override
public final String onTalk(L2Npc npc, L2Player player)
{
String htmltext = NO_QUEST;
QuestState st = player.getQuestState(QN);
if (st == null)
return htmltext;
boolean has_d = st.getQuestItemsCount(D_COUPON) >= 1;
boolean has_c = st.getQuestItemsCount(C_COUPON) >= 1;
htmltext = "exchange_dc.htm";
if (has_d || has_c)
{
if (!has_d)
htmltext = "exchange_c.htm";
else if (!has_c)
htmltext = "exchange_d.htm";
}
else
htmltext = "exchange-no.htm";
st.exitQuest(true);
return htmltext;
}
public static void main(String[] args)
{
new ShadowWeapons(4000, QN, "Shadow Weapons", "custom");
}
}
| UTF-8 | Java | 2,845 | java | ShadowWeapons.java | Java | [
{
"context": "meserver.world.object.L2Player;\r\n\r\n/**\r\n * @author L0ngh0rn\r\n */\r\npublic final class ShadowWeapons extends Qu",
"end": 975,
"score": 0.9995787143707275,
"start": 967,
"tag": "USERNAME",
"value": "L0ngh0rn"
}
] | null | [] | /*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package custom.ShadowWeapons;
import net.l2emuproject.gameserver.services.quest.QuestState;
import net.l2emuproject.gameserver.services.quest.jython.QuestJython;
import net.l2emuproject.gameserver.world.object.L2Npc;
import net.l2emuproject.gameserver.world.object.L2Player;
/**
* @author L0ngh0rn
*/
public final class ShadowWeapons extends QuestJython
{
private static final String QN = "ShadowWeapons";
private static final int[] NPC =
{
30037, 30066, 30070, 30109, 30115, 30120, 30174, 30175,
30176, 30187, 30191, 30195, 30288, 30289, 30290, 30297,
30373, 30462, 30474, 30498, 30499, 30500, 30503, 30504,
30505, 30511, 30512, 30513, 30595, 30676, 30677, 30681,
30685, 30687, 30689, 30694, 30699, 30704, 30845, 30847,
30849, 30854, 30857, 30862, 30865, 30894, 30897, 30900,
30905, 30910, 30913, 31269, 31272, 31288, 31314, 31317,
31321, 31324, 31326, 31328, 31331, 31334, 31336, 31965,
31974, 31276, 31285, 31958, 31961, 31996, 31968, 31977,
32092, 32093, 32094, 32095, 32096, 32097, 32098, 32193,
32196, 32199, 32202, 32205, 32206, 32213, 32214, 32217,
32218, 32221, 32222, 32229, 32230, 32233,32234
};
private static final int D_COUPON = 8869;
private static final int C_COUPON = 8870;
public ShadowWeapons(int questId, String name, String descr, String folder)
{
super(questId, name, descr, folder);
for (int npc : NPC)
{
addStartNpc(npc);
addTalkId(npc);
}
}
@Override
public final String onTalk(L2Npc npc, L2Player player)
{
String htmltext = NO_QUEST;
QuestState st = player.getQuestState(QN);
if (st == null)
return htmltext;
boolean has_d = st.getQuestItemsCount(D_COUPON) >= 1;
boolean has_c = st.getQuestItemsCount(C_COUPON) >= 1;
htmltext = "exchange_dc.htm";
if (has_d || has_c)
{
if (!has_d)
htmltext = "exchange_c.htm";
else if (!has_c)
htmltext = "exchange_d.htm";
}
else
htmltext = "exchange-no.htm";
st.exitQuest(true);
return htmltext;
}
public static void main(String[] args)
{
new ShadowWeapons(4000, QN, "Shadow Weapons", "custom");
}
}
| 2,845 | 0.679438 | 0.503691 | 89 | 29.966291 | 26.789419 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.05618 | false | false | 4 |
09dca1bef54bb8ae68141b8898f449c492c7f0ad | 28,132,035,796,050 | 6296bc32a59391de75995b993fcf340603d6bd3c | /src/main/java/mx/appwhere/gestores/front/application/constants/ViewsLocation.java | e2461aa91a63d69bb94d7582b1ce983d9e1676c1 | [] | no_license | jdomingob/BSFMF4_MdlLimites | https://github.com/jdomingob/BSFMF4_MdlLimites | 121e67fc89687f1959884d880bd1e1569a1fb4a6 | 7076063b025c5297fcd3eb08c1156e8c30a49ac9 | refs/heads/master | 2020-04-07T13:56:42.276000 | 2018-11-22T02:16:14 | 2018-11-22T02:16:14 | 158,428,271 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mx.appwhere.gestores.front.application.constants;
public final class ViewsLocation {
//Main
public static final String MAIN_VIEW = "main/main.html";
//Example
public static final String EXAMPLE_VIEW = "example/example.html";
//Vistas Administración de Documentos
public static final String VISTA_PRINCIPAL = "limites/vista-principal.html";
public static final String VISTA_LIMITES = "limites/vista-limites.html";
}
| UTF-8 | Java | 459 | java | ViewsLocation.java | Java | [] | null | [] | package mx.appwhere.gestores.front.application.constants;
public final class ViewsLocation {
//Main
public static final String MAIN_VIEW = "main/main.html";
//Example
public static final String EXAMPLE_VIEW = "example/example.html";
//Vistas Administración de Documentos
public static final String VISTA_PRINCIPAL = "limites/vista-principal.html";
public static final String VISTA_LIMITES = "limites/vista-limites.html";
}
| 459 | 0.735808 | 0.735808 | 17 | 25.941177 | 30.149569 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | false | false | 4 |
0b14a6d0fbf1e8079cbbb081fdca2fe104879784 | 32,298,154,075,449 | 565f571e69dc6fd89cc31bbfba2f6ed86cb59c93 | /src/ca/ubc/cpsc304/r3/db/BorrowingDao.java | ef5c110ff650c16be9788fbd0b42c2a720161984 | [] | no_license | rc9/cpsc304 | https://github.com/rc9/cpsc304 | c13dcf49eae381ad93d96b2712d086e08dfc974f | a5898fa327fa0d1dba35e6211855894e5ad80637 | refs/heads/master | 2021-01-18T18:09:22.919000 | 2011-11-29T22:04:34 | 2011-11-29T22:04:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ca.ubc.cpsc304.r3.db;
//general sql imports
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import ca.ubc.cpsc304.r3.dto.BookCheckoutReportDto;
import ca.ubc.cpsc304.r3.dto.BookDto;
import ca.ubc.cpsc304.r3.dto.BorrowingDetailedDto;
import ca.ubc.cpsc304.r3.dto.BorrowingDto;
import ca.ubc.cpsc304.r3.dto.CheckedOutBookDto;
import ca.ubc.cpsc304.r3.util.DNEException;
import ca.ubc.cpsc304.r3.util.DaoUtility;
public class BorrowingDao {
private ConnectionService connService;
public BorrowingDao(ConnectionService connService) {
this.connService = connService;
}
public List<BorrowingDto> getBorrowedByID(int id) throws SQLException {
List<BorrowingDto> queryResult = new ArrayList<BorrowingDto>();
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("SELECT * " + "FROM borrowing "
+ "WHERE inDate IS NULL AND " + "bid=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
// for each row, put the data in the dto
// and add it to list of results
BorrowingDto dto = new BorrowingDto();
dto.setBorid(rs.getInt("borid"));
dto.setBid(rs.getInt("bid"));
dto.setCallNumber(rs.getInt("callNumber"));
dto.setCopyNo(rs.getInt("copyNo"));
dto.setOutDate(rs.getDate("outDate"));
dto.setInDate(rs.getDate("inDate"));
queryResult.add(dto);
}
} catch (SQLException e) {
// two options here. either don't catch this exception and
// make the caller handle it, or wrap it in a more
// descriptive exception depending on the situation.
// I'll just throw it
throw e;
} finally {
// don't forget to close the connection
// when you're done with it
if (conn != null) {
conn.close();
}
}
return queryResult;
}
public List<BorrowingDetailedDto> getBorrowedDetailedByID(int id) throws SQLException{
List<BorrowingDetailedDto> queryResult = new ArrayList<BorrowingDetailedDto>();
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn.prepareStatement(
"SELECT BO.borid, BO.bid, BO.callNumber, BO.copyNo, BO.outDate, BO.inDate, B.title, B.mainAuthor "+
"FROM borrowing BO, book B " +
"WHERE BO.inDate IS NULL AND BO.callNumber=B.callNumber AND " +
"BO.bid=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
while(rs.next()){
// for each row, put the data in the dto
// and add it to list of results
BorrowingDetailedDto dto = new BorrowingDetailedDto();
dto.setBorid(rs.getInt("BO.borid"));
dto.setBid(rs.getInt("BO.bid"));
dto.setCallNumber(rs.getInt("BO.callNumber"));
dto.setCopyNo(rs.getInt("BO.copyNo"));
dto.setOutDate(rs.getDate("BO.outDate"));
dto.setInDate(rs.getDate("BO.inDate"));
dto.setMainAuthor(rs.getString("B.mainAuthor"));
dto.setTitle(rs.getString("B.title"));
queryResult.add(dto);
}
} finally {
// don't forget to close the connection
// when you're done with it
if(conn != null){
conn.close();
}
}
return queryResult;
}
public List<CheckedOutBookDto> generateCheckedOutBooksReport(String subject)
throws SQLException {
Connection conn = null;
try {
// is subject valid?
boolean hasSubject = (subject != null && !subject.isEmpty());
String query = "SELECT DISTINCT BC.callNumber, BC.copyNo, BK.title, BORRWRING.outDate, BT.bookTimeLimit "
+ "FROM bookcopy BC, borrowing BORRWRING, borrower B, book BK, hassubject HS, borrowertype BT "
+ "WHERE BC.status='out' AND BC.callNumber=BORRWRING.callNumber AND BC.copyNo=BORRWRING.copyNo AND BORRWRING.bid=B.bid AND B.btype=BT.btype AND BK.callNumber=BC.callNumber AND BORRWRING.inDate IS NULL ";
if (hasSubject) {
query = query
+ "AND BC.callNumber=HS.callNumber AND HS.subject=? ";
}
query = query + "ORDER BY callNumber;";
conn = this.connService.getConnection();
PreparedStatement ps = conn.prepareStatement(query);
// set the subject parameter if subject is valid
if (hasSubject) {
ps.setString(1, subject);
}
ResultSet rs = ps.executeQuery();
List<CheckedOutBookDto> results = new ArrayList<CheckedOutBookDto>();
while (rs.next()) {
CheckedOutBookDto dto = new CheckedOutBookDto();
dto.setCallNumber(rs.getInt("BC.callNumber"));
dto.setCopyNo(rs.getInt("BC.copyNo"));
dto.setTitle(rs.getString("BK.title"));
Date outDate = rs.getDate("BORRWRING.outDate");
dto.setOutDate(outDate);
int timeLimitWeeks = Integer.parseInt(rs
.getString("BT.bookTimeLimit"));
// dueDate = checkoutDate + (num of weeks allowed * length of
// week)
dto.setDueDate(new Date(outDate.getTime()
+ (timeLimitWeeks * DaoUtility.WEEK)));
// add it to list
results.add(dto);
}
return results;
} finally {
if (conn != null) {
conn.close();
}
}
}
/**
* Generates a collection of the most popular books that have been checked
* out during the given year.
*
* The query: - filters by year (starting Jan 1 and ending just prior to Jan
* 1 of the following year) - orders by number of times borrowed
*
* @param year
* the year in which to filter by
* @param limit
* the maximum number of results to return
* @return a list of BookCheckOutReportDto's, sorted by the number of times
* the book has been checked out during the year (descending). The
* size of the collection will always be <= limit.
* @throws SQLException
*/
public List<BookCheckoutReportDto> generateMostPopularBooksReport(int year,
int limit) throws SQLException {
Connection conn = null;
try {
conn = connService.getConnection();
// gets the first day of the year specified
Date yearStart = new Date(new GregorianCalendar(year,
Calendar.JANUARY, 1).getTime().getTime());
// gets the very first day of the next year.
// the query will be: yearStart <= validResult < yearEnd
Date yearEnd = new Date(new GregorianCalendar(year + 1,
Calendar.JANUARY, 1).getTime().getTime());
PreparedStatement ps = conn
.prepareStatement("SELECT book.callNumber, book.title, book.mainAuthor, COUNT(*) AS borrCount "
+ "FROM borrowing, book "
+ "WHERE borrowing.outdate >= ? AND borrowing.outdate < ? AND borrowing.callNumber=book.callNumber "
+ "GROUP BY book.callNumber "
+ "ORDER BY borrCount DESC " + "LIMIT ?");
ps.setDate(1, yearStart);
ps.setDate(2, yearEnd);
ps.setInt(3, limit);
ResultSet rs = ps.executeQuery();
List<BookCheckoutReportDto> results = new ArrayList<BookCheckoutReportDto>();
while (rs.next()) {
BookCheckoutReportDto dto = new BookCheckoutReportDto();
dto.setCallNumber(rs.getInt("book.callNumber"));
dto.setTitle(rs.getString("book.title"));
dto.setMainAuthor(rs.getString("book.mainAuthor"));
dto.setBorrowedCount(rs.getInt("borrCount"));
results.add(dto);
}
return results;
} finally {
if (conn != null) {
conn.close();
}
}
}
/**
* Checks out item. If borrower has a fine then does not check item out and
* will display fine. If no available boo
*
*/
public Date borrowItem(int bid, int callNo) throws Exception {
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
Date duedate=null;
try {
conn = connService.getConnection();
conn.setAutoCommit(false);
// Check if has overdue book
ps = conn
.prepareStatement("SELECT amount FROM Fine F, Borrowing B "
+ "WHERE F.paidDate IS NULL AND B.borid=F.borid AND B.bid=?");
ps.setInt(1, bid);
rs = ps.executeQuery();
// Get the fine if it exists
if (rs.next()) {
int fine = rs.getInt("amount");
throw new DNEException("Borrower ID " + bid
+ " currently has a fine of $" + fine
+ " and has been blocked from borrowing.");
}
// Check the book is in the database
ps = conn
.prepareStatement("SELECT COUNT(*) AS 'present' FROM Book WHERE callNumber=?");
ps.setInt(1, callNo);
rs = ps.executeQuery();
if (!rs.next() || 0 >= rs.getInt("present"))
throw new SQLException("Unknown call number");
// update if borrower had it on hold
int hid = hadOnHold(bid, callNo);
availableFromHold(hid, callNo);
// get an available copy
int copy = findAvailableCopy(callNo);
if (copy == -1) {
throw new DNEException("Not enough available copies for call number "
+ callNo + ".<br>");
}
// Create new borrowing record
ps = conn
.prepareStatement("INSERT into Borrowing(bid, callNumber, copyNo, outDate) "
+ "values (?,?,?,?)");
ps.setInt(1, bid);
ps.setInt(2, callNo);
ps.setInt(3, copy);
ps.setDate(4, DaoUtility.makeDate(0));
// Update book copy to "out"
ps.executeUpdate();
ps = conn.prepareStatement("UPDATE BookCopy "
+ "SET status='out' WHERE callNumber=? AND copyNo=?");
ps.setInt(1, callNo);
ps.setInt(2, copy);
ps.executeUpdate();
ps = conn.prepareStatement("SELECT bookTimeLimit FROM Borrower, BorrowerType WHERE bid=?");
ps.setInt(1, bid);
rs = ps.executeQuery();
if (!rs.next())
throw new SQLException("BID " + bid + " not found.");
duedate = DaoUtility.makeDate(DaoUtility.calcBorrowLimit(rs
.getString("bookTimeLimit")));
} finally {
conn.commit();
if (conn != null)
conn.close();
}
return duedate;
}
public BookDto findBookByCallNum(int callNum, int bid) throws SQLException,
DNEException {
Connection conn = null;
BookDto dto = new BookDto();
try {
conn = connService.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT * "
+ "FROM book " + "WHERE callNumber=?");
ps.setInt(1, callNum);
ResultSet rs = ps.executeQuery();
if (!rs.next())
throw new SQLException();
// for each row, put the data in the dto
// and add it to list of results
dto.setCallNumber(rs.getInt("callNumber"));
dto.setIsbn(rs.getInt("isbn"));
dto.setTitle(rs.getString("title"));
dto.setMainAuthor(rs.getString("mainAuthor"));
dto.setPublisher(rs.getString("publisher"));
dto.setYear(rs.getInt("year"));
if (findAvailableCopy(callNum) == -1
&& hadOnHold(bid, callNum) == -1)
throw new DNEException("Not enough available copies for call number "
+ callNum + ".<br>");
} finally {
// don't forget to close the connection
// when you're done with it
if (conn != null) {
conn.close();
}
}
return dto;
}
// Helper to find first available copy of a book.
// returns -1 if no copies are available.
private int findAvailableCopy(int callNum) throws SQLException {
Connection conn = null;
try {
conn = connService.getConnection();
ResultSet rs = null;
PreparedStatement ps = conn.prepareStatement("SELECT copyNo FROM bookCopy "
+ "WHERE status='in' AND callNumber=?");
ps.setInt(1, callNum);
rs = ps.executeQuery();
if (rs.next()) {
int i = rs.getInt(1);
if (conn != null)
conn.close();
return i;
}
return -1;
} finally {
if (conn != null)
conn.close();
}
}
//Helper function to find hid or requested item.
//Returns -1 if given borrower has no requests for the item.
private int hadOnHold(int bid, int callNum) throws SQLException {
Connection conn = null;
ResultSet rs = null;
int hid = -1;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("SELECT hid FROM HoldRequest HR "
+ "WHERE HR.bid=? AND HR.callNumber=? AND HR.issuedDate < ALL "
+ "(SELECT issuedDate FROM HoldRequest H2 WHERE HR.hid<>H2.hid AND H2.callNumber=?)");
ps.setInt(1, bid);
ps.setInt(2, callNum);
ps.setInt(3, callNum);
rs = ps.executeQuery();
if (rs.next())
hid = rs.getInt("hid");
} finally {
if (conn != null)
conn.close();
}
return hid;
}
//Helper function that updates a copy back to in for a requesting borrower to borrow.
//Makes on hold status available and deletes that hold request.
private void availableFromHold(int hid, int callNum) throws SQLException {
if(hid==-1)
return;
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("UPDATE BookCopy SET status='in' WHERE status='on hold' AND callNumber=? LIMIT 1");
ps.setInt(1, callNum);
int i = ps.executeUpdate();
if (i>0) {
ps = conn
.prepareStatement("DELETE FROM HoldRequest WHERE hid=?");
ps.setInt(1, hid);
ps.executeUpdate();
}
} finally {
if (conn != null)
conn.close();
}
}
}
| UTF-8 | Java | 12,891 | java | BorrowingDao.java | Java | [] | null | [] | package ca.ubc.cpsc304.r3.db;
//general sql imports
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import ca.ubc.cpsc304.r3.dto.BookCheckoutReportDto;
import ca.ubc.cpsc304.r3.dto.BookDto;
import ca.ubc.cpsc304.r3.dto.BorrowingDetailedDto;
import ca.ubc.cpsc304.r3.dto.BorrowingDto;
import ca.ubc.cpsc304.r3.dto.CheckedOutBookDto;
import ca.ubc.cpsc304.r3.util.DNEException;
import ca.ubc.cpsc304.r3.util.DaoUtility;
public class BorrowingDao {
private ConnectionService connService;
public BorrowingDao(ConnectionService connService) {
this.connService = connService;
}
public List<BorrowingDto> getBorrowedByID(int id) throws SQLException {
List<BorrowingDto> queryResult = new ArrayList<BorrowingDto>();
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("SELECT * " + "FROM borrowing "
+ "WHERE inDate IS NULL AND " + "bid=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
// for each row, put the data in the dto
// and add it to list of results
BorrowingDto dto = new BorrowingDto();
dto.setBorid(rs.getInt("borid"));
dto.setBid(rs.getInt("bid"));
dto.setCallNumber(rs.getInt("callNumber"));
dto.setCopyNo(rs.getInt("copyNo"));
dto.setOutDate(rs.getDate("outDate"));
dto.setInDate(rs.getDate("inDate"));
queryResult.add(dto);
}
} catch (SQLException e) {
// two options here. either don't catch this exception and
// make the caller handle it, or wrap it in a more
// descriptive exception depending on the situation.
// I'll just throw it
throw e;
} finally {
// don't forget to close the connection
// when you're done with it
if (conn != null) {
conn.close();
}
}
return queryResult;
}
public List<BorrowingDetailedDto> getBorrowedDetailedByID(int id) throws SQLException{
List<BorrowingDetailedDto> queryResult = new ArrayList<BorrowingDetailedDto>();
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn.prepareStatement(
"SELECT BO.borid, BO.bid, BO.callNumber, BO.copyNo, BO.outDate, BO.inDate, B.title, B.mainAuthor "+
"FROM borrowing BO, book B " +
"WHERE BO.inDate IS NULL AND BO.callNumber=B.callNumber AND " +
"BO.bid=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
while(rs.next()){
// for each row, put the data in the dto
// and add it to list of results
BorrowingDetailedDto dto = new BorrowingDetailedDto();
dto.setBorid(rs.getInt("BO.borid"));
dto.setBid(rs.getInt("BO.bid"));
dto.setCallNumber(rs.getInt("BO.callNumber"));
dto.setCopyNo(rs.getInt("BO.copyNo"));
dto.setOutDate(rs.getDate("BO.outDate"));
dto.setInDate(rs.getDate("BO.inDate"));
dto.setMainAuthor(rs.getString("B.mainAuthor"));
dto.setTitle(rs.getString("B.title"));
queryResult.add(dto);
}
} finally {
// don't forget to close the connection
// when you're done with it
if(conn != null){
conn.close();
}
}
return queryResult;
}
public List<CheckedOutBookDto> generateCheckedOutBooksReport(String subject)
throws SQLException {
Connection conn = null;
try {
// is subject valid?
boolean hasSubject = (subject != null && !subject.isEmpty());
String query = "SELECT DISTINCT BC.callNumber, BC.copyNo, BK.title, BORRWRING.outDate, BT.bookTimeLimit "
+ "FROM bookcopy BC, borrowing BORRWRING, borrower B, book BK, hassubject HS, borrowertype BT "
+ "WHERE BC.status='out' AND BC.callNumber=BORRWRING.callNumber AND BC.copyNo=BORRWRING.copyNo AND BORRWRING.bid=B.bid AND B.btype=BT.btype AND BK.callNumber=BC.callNumber AND BORRWRING.inDate IS NULL ";
if (hasSubject) {
query = query
+ "AND BC.callNumber=HS.callNumber AND HS.subject=? ";
}
query = query + "ORDER BY callNumber;";
conn = this.connService.getConnection();
PreparedStatement ps = conn.prepareStatement(query);
// set the subject parameter if subject is valid
if (hasSubject) {
ps.setString(1, subject);
}
ResultSet rs = ps.executeQuery();
List<CheckedOutBookDto> results = new ArrayList<CheckedOutBookDto>();
while (rs.next()) {
CheckedOutBookDto dto = new CheckedOutBookDto();
dto.setCallNumber(rs.getInt("BC.callNumber"));
dto.setCopyNo(rs.getInt("BC.copyNo"));
dto.setTitle(rs.getString("BK.title"));
Date outDate = rs.getDate("BORRWRING.outDate");
dto.setOutDate(outDate);
int timeLimitWeeks = Integer.parseInt(rs
.getString("BT.bookTimeLimit"));
// dueDate = checkoutDate + (num of weeks allowed * length of
// week)
dto.setDueDate(new Date(outDate.getTime()
+ (timeLimitWeeks * DaoUtility.WEEK)));
// add it to list
results.add(dto);
}
return results;
} finally {
if (conn != null) {
conn.close();
}
}
}
/**
* Generates a collection of the most popular books that have been checked
* out during the given year.
*
* The query: - filters by year (starting Jan 1 and ending just prior to Jan
* 1 of the following year) - orders by number of times borrowed
*
* @param year
* the year in which to filter by
* @param limit
* the maximum number of results to return
* @return a list of BookCheckOutReportDto's, sorted by the number of times
* the book has been checked out during the year (descending). The
* size of the collection will always be <= limit.
* @throws SQLException
*/
public List<BookCheckoutReportDto> generateMostPopularBooksReport(int year,
int limit) throws SQLException {
Connection conn = null;
try {
conn = connService.getConnection();
// gets the first day of the year specified
Date yearStart = new Date(new GregorianCalendar(year,
Calendar.JANUARY, 1).getTime().getTime());
// gets the very first day of the next year.
// the query will be: yearStart <= validResult < yearEnd
Date yearEnd = new Date(new GregorianCalendar(year + 1,
Calendar.JANUARY, 1).getTime().getTime());
PreparedStatement ps = conn
.prepareStatement("SELECT book.callNumber, book.title, book.mainAuthor, COUNT(*) AS borrCount "
+ "FROM borrowing, book "
+ "WHERE borrowing.outdate >= ? AND borrowing.outdate < ? AND borrowing.callNumber=book.callNumber "
+ "GROUP BY book.callNumber "
+ "ORDER BY borrCount DESC " + "LIMIT ?");
ps.setDate(1, yearStart);
ps.setDate(2, yearEnd);
ps.setInt(3, limit);
ResultSet rs = ps.executeQuery();
List<BookCheckoutReportDto> results = new ArrayList<BookCheckoutReportDto>();
while (rs.next()) {
BookCheckoutReportDto dto = new BookCheckoutReportDto();
dto.setCallNumber(rs.getInt("book.callNumber"));
dto.setTitle(rs.getString("book.title"));
dto.setMainAuthor(rs.getString("book.mainAuthor"));
dto.setBorrowedCount(rs.getInt("borrCount"));
results.add(dto);
}
return results;
} finally {
if (conn != null) {
conn.close();
}
}
}
/**
* Checks out item. If borrower has a fine then does not check item out and
* will display fine. If no available boo
*
*/
public Date borrowItem(int bid, int callNo) throws Exception {
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
Date duedate=null;
try {
conn = connService.getConnection();
conn.setAutoCommit(false);
// Check if has overdue book
ps = conn
.prepareStatement("SELECT amount FROM Fine F, Borrowing B "
+ "WHERE F.paidDate IS NULL AND B.borid=F.borid AND B.bid=?");
ps.setInt(1, bid);
rs = ps.executeQuery();
// Get the fine if it exists
if (rs.next()) {
int fine = rs.getInt("amount");
throw new DNEException("Borrower ID " + bid
+ " currently has a fine of $" + fine
+ " and has been blocked from borrowing.");
}
// Check the book is in the database
ps = conn
.prepareStatement("SELECT COUNT(*) AS 'present' FROM Book WHERE callNumber=?");
ps.setInt(1, callNo);
rs = ps.executeQuery();
if (!rs.next() || 0 >= rs.getInt("present"))
throw new SQLException("Unknown call number");
// update if borrower had it on hold
int hid = hadOnHold(bid, callNo);
availableFromHold(hid, callNo);
// get an available copy
int copy = findAvailableCopy(callNo);
if (copy == -1) {
throw new DNEException("Not enough available copies for call number "
+ callNo + ".<br>");
}
// Create new borrowing record
ps = conn
.prepareStatement("INSERT into Borrowing(bid, callNumber, copyNo, outDate) "
+ "values (?,?,?,?)");
ps.setInt(1, bid);
ps.setInt(2, callNo);
ps.setInt(3, copy);
ps.setDate(4, DaoUtility.makeDate(0));
// Update book copy to "out"
ps.executeUpdate();
ps = conn.prepareStatement("UPDATE BookCopy "
+ "SET status='out' WHERE callNumber=? AND copyNo=?");
ps.setInt(1, callNo);
ps.setInt(2, copy);
ps.executeUpdate();
ps = conn.prepareStatement("SELECT bookTimeLimit FROM Borrower, BorrowerType WHERE bid=?");
ps.setInt(1, bid);
rs = ps.executeQuery();
if (!rs.next())
throw new SQLException("BID " + bid + " not found.");
duedate = DaoUtility.makeDate(DaoUtility.calcBorrowLimit(rs
.getString("bookTimeLimit")));
} finally {
conn.commit();
if (conn != null)
conn.close();
}
return duedate;
}
public BookDto findBookByCallNum(int callNum, int bid) throws SQLException,
DNEException {
Connection conn = null;
BookDto dto = new BookDto();
try {
conn = connService.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT * "
+ "FROM book " + "WHERE callNumber=?");
ps.setInt(1, callNum);
ResultSet rs = ps.executeQuery();
if (!rs.next())
throw new SQLException();
// for each row, put the data in the dto
// and add it to list of results
dto.setCallNumber(rs.getInt("callNumber"));
dto.setIsbn(rs.getInt("isbn"));
dto.setTitle(rs.getString("title"));
dto.setMainAuthor(rs.getString("mainAuthor"));
dto.setPublisher(rs.getString("publisher"));
dto.setYear(rs.getInt("year"));
if (findAvailableCopy(callNum) == -1
&& hadOnHold(bid, callNum) == -1)
throw new DNEException("Not enough available copies for call number "
+ callNum + ".<br>");
} finally {
// don't forget to close the connection
// when you're done with it
if (conn != null) {
conn.close();
}
}
return dto;
}
// Helper to find first available copy of a book.
// returns -1 if no copies are available.
private int findAvailableCopy(int callNum) throws SQLException {
Connection conn = null;
try {
conn = connService.getConnection();
ResultSet rs = null;
PreparedStatement ps = conn.prepareStatement("SELECT copyNo FROM bookCopy "
+ "WHERE status='in' AND callNumber=?");
ps.setInt(1, callNum);
rs = ps.executeQuery();
if (rs.next()) {
int i = rs.getInt(1);
if (conn != null)
conn.close();
return i;
}
return -1;
} finally {
if (conn != null)
conn.close();
}
}
//Helper function to find hid or requested item.
//Returns -1 if given borrower has no requests for the item.
private int hadOnHold(int bid, int callNum) throws SQLException {
Connection conn = null;
ResultSet rs = null;
int hid = -1;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("SELECT hid FROM HoldRequest HR "
+ "WHERE HR.bid=? AND HR.callNumber=? AND HR.issuedDate < ALL "
+ "(SELECT issuedDate FROM HoldRequest H2 WHERE HR.hid<>H2.hid AND H2.callNumber=?)");
ps.setInt(1, bid);
ps.setInt(2, callNum);
ps.setInt(3, callNum);
rs = ps.executeQuery();
if (rs.next())
hid = rs.getInt("hid");
} finally {
if (conn != null)
conn.close();
}
return hid;
}
//Helper function that updates a copy back to in for a requesting borrower to borrow.
//Makes on hold status available and deletes that hold request.
private void availableFromHold(int hid, int callNum) throws SQLException {
if(hid==-1)
return;
Connection conn = null;
try {
conn = connService.getConnection();
PreparedStatement ps = conn
.prepareStatement("UPDATE BookCopy SET status='in' WHERE status='on hold' AND callNumber=? LIMIT 1");
ps.setInt(1, callNum);
int i = ps.executeUpdate();
if (i>0) {
ps = conn
.prepareStatement("DELETE FROM HoldRequest WHERE hid=?");
ps.setInt(1, hid);
ps.executeUpdate();
}
} finally {
if (conn != null)
conn.close();
}
}
}
| 12,891 | 0.664805 | 0.658987 | 437 | 28.498856 | 25.209749 | 208 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.038902 | false | false | 4 |
0ab64c7784276c4d234e6026995cbff86b960928 | 16,157,667,014,639 | 960be492ed6e8b0151f8e00e6604d93b23fcb196 | /src/main/java/com/james/NQueen51/Solution3.java | 9d1b12680e92b31b963d654dd9ea3195deca7928 | [] | no_license | ChinKofa/algorithm_practice | https://github.com/ChinKofa/algorithm_practice | aca052487b5e94050e7fc41ed315d4a0e090a519 | 8f725d97b2cac55ca6072e7eb8f7b4c481027b69 | refs/heads/master | 2020-12-14T07:11:32.746000 | 2020-01-18T03:50:44 | 2020-01-18T03:50:44 | 234,677,710 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.james.NQueen51;
import java.util.ArrayList;
import java.util.List;
class Solution3 {
public List<List<String>> solveNQueens(int n) {
String[][] board = new String[n][n];
for(int i = 0; i < board.length; i ++) {
for(int j = 0; j < board[0].length; j ++) {
board[i][j] = ".";
}
}
List<List<String>> result = new ArrayList<> ();
helper(board, result, 0);
return result;
}
public void helper(String[][] board, List<List<String>> result, int row) {
if(row == board.length) {
addToList(board, result);
} else {
for(int c = 0; c < board.length; c ++) {
if(isValidBoard(board, row, c)) {
board[row][c] = "Q";
helper(board, result, row + 1);
board[row][c] = ".";
}
}
}
}
private boolean isValidBoard(String[][] board, int row, int col) {
for(int i = 0; i < board.length; i++) {
if(i != col && board[row][i] == "Q") {
//System.out.println(col + "," + i + ", " + board[row][i]);
return false;
}
}
//System.out.println("row...");
for(int i = 0; i < board[0].length; i++) {
if(i != row && board[i][col] == "Q") {
return false;
}
}
//System.out.println("col...");
//left up
int i = row - 1;
int j = col - 1;
while(i >= 0 && j >= 0) {
if(board[i][j] == "Q") {
return false;
}
i --;
j --;
}
//right down
i = row + 1;
j = col + 1;
while(i < board.length && j < board.length) {
if(board[i][j] == "Q") {
return false;
}
i ++;
j ++;
}
//left down
i = row - 1;
j = col + 1;
while(i >= 0 && j < board.length) {
if(board[i][j] == "Q") {
return false;
}
i --;
j ++;
}
i = row + 1;
j = col - 1;
while(i < board.length && j >= 0) {
if(board[i][j] == "Q") {
return false;
}
i ++;
j --;
}
return true;
}
private void addToList(String[][] board, List<List<String>> result) {
List<String> temp = new ArrayList<String>();
for(int i = 0; i < board.length; i ++) {
StringBuilder sb = new StringBuilder();
for(int j = 0; j < board[0].length; j++) {
sb.append(board[i][j]);
}
temp.add(sb.toString());
}
result.add(new ArrayList<>(temp));
}
} | UTF-8 | Java | 2,854 | java | Solution3.java | Java | [] | null | [] | package com.james.NQueen51;
import java.util.ArrayList;
import java.util.List;
class Solution3 {
public List<List<String>> solveNQueens(int n) {
String[][] board = new String[n][n];
for(int i = 0; i < board.length; i ++) {
for(int j = 0; j < board[0].length; j ++) {
board[i][j] = ".";
}
}
List<List<String>> result = new ArrayList<> ();
helper(board, result, 0);
return result;
}
public void helper(String[][] board, List<List<String>> result, int row) {
if(row == board.length) {
addToList(board, result);
} else {
for(int c = 0; c < board.length; c ++) {
if(isValidBoard(board, row, c)) {
board[row][c] = "Q";
helper(board, result, row + 1);
board[row][c] = ".";
}
}
}
}
private boolean isValidBoard(String[][] board, int row, int col) {
for(int i = 0; i < board.length; i++) {
if(i != col && board[row][i] == "Q") {
//System.out.println(col + "," + i + ", " + board[row][i]);
return false;
}
}
//System.out.println("row...");
for(int i = 0; i < board[0].length; i++) {
if(i != row && board[i][col] == "Q") {
return false;
}
}
//System.out.println("col...");
//left up
int i = row - 1;
int j = col - 1;
while(i >= 0 && j >= 0) {
if(board[i][j] == "Q") {
return false;
}
i --;
j --;
}
//right down
i = row + 1;
j = col + 1;
while(i < board.length && j < board.length) {
if(board[i][j] == "Q") {
return false;
}
i ++;
j ++;
}
//left down
i = row - 1;
j = col + 1;
while(i >= 0 && j < board.length) {
if(board[i][j] == "Q") {
return false;
}
i --;
j ++;
}
i = row + 1;
j = col - 1;
while(i < board.length && j >= 0) {
if(board[i][j] == "Q") {
return false;
}
i ++;
j --;
}
return true;
}
private void addToList(String[][] board, List<List<String>> result) {
List<String> temp = new ArrayList<String>();
for(int i = 0; i < board.length; i ++) {
StringBuilder sb = new StringBuilder();
for(int j = 0; j < board[0].length; j++) {
sb.append(board[i][j]);
}
temp.add(sb.toString());
}
result.add(new ArrayList<>(temp));
}
} | 2,854 | 0.385074 | 0.375613 | 103 | 26.718447 | 18.569427 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.68932 | false | false | 4 |
d4b29993d4ea2a137d1ff779b1a4c0b4778f1df5 | 32,641,751,471,081 | ec5aea5b4562440d3edb631396fc1a6fcdbe4411 | /src/main/java/org/fenixedu/ulisboa/applications/ui/FenixeduULisboaApplicationsBaseController.java | c777dc9df3b0cb9097b86835d62909f930168daa | [] | no_license | qub-it/fenixedu-ulisboa-applications | https://github.com/qub-it/fenixedu-ulisboa-applications | 96d78bd7864f3a0c0692ada66748e4be63e20fb0 | 22bf81d7329a1f3536e1853f7d080c19ed234ec2 | refs/heads/master | 2023-08-19T04:20:22.777000 | 2023-08-17T07:06:47 | 2023-08-17T07:06:47 | 117,565,226 | 0 | 1 | null | false | 2018-08-21T10:09:48 | 2018-01-15T15:54:19 | 2018-05-09T10:45:31 | 2018-08-17T09:03:37 | 28 | 0 | 1 | 0 | JavaScript | false | null | package org.fenixedu.ulisboa.applications.ui;
import java.io.IOException;
import java.util.concurrent.ThreadLocalRandom;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.fenixedu.bennu.spring.FenixEDUBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import com.google.gson.GsonBuilder;
public class FenixeduULisboaApplicationsBaseController extends FenixEDUBaseController {
//The HTTP Request that can be used internally in the controller
protected @Autowired HttpServletRequest request;
@ModelAttribute
protected void addModelProperties(Model model) {
super.addModelProperties(model, request);
String infoMessages = request.getParameter(INFO_MESSAGES);
if (infoMessages != null) {
addInfoMessage(infoMessages, model);
}
String warningMessages = request.getParameter(WARNING_MESSAGES);
if (warningMessages != null) {
addWarningMessage(warningMessages, model);
}
String errorMessages = request.getParameter(ERROR_MESSAGES);
if (errorMessages != null) {
addErrorMessage(errorMessages, model);
}
}
@Override
protected void registerTypeAdapters(GsonBuilder builder) {
super.registerTypeAdapters(builder);
}
protected void writeFile(final HttpServletResponse response, final String filename, final String contentType,
final byte[] content) throws IOException {
response.setContentLength(content.length);
response.setContentType(contentType);
response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
try (ServletOutputStream outputStream = response.getOutputStream()) {
outputStream.write(content);
outputStream.flush();
response.flushBuffer();
}
}
protected static class SecToken {
private static String SEED = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
private static int DEFAULT_KEY_SIZE = 16;
public static String generate(int keySize) {
char[] key = new char[keySize];
for (int i = 0; i < keySize; i++) {
key[i] = SEED.charAt(ThreadLocalRandom.current().nextInt(0, (SEED.length() - 1)));
}
return String.valueOf(key);
}
public static String generate() {
return generate(DEFAULT_KEY_SIZE);
}
}
}
| UTF-8 | Java | 2,676 | java | FenixeduULisboaApplicationsBaseController.java | Java | [
{
"context": " SecToken {\n private static String SEED = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\";\n private static int DEFAULT_KEY_SIZE = 1",
"end": 2206,
"score": 0.996395468711853,
"start": 2142,
"tag": "KEY",
"value": "abcdefghijklmnopqrstuvwxyzA... | null | [] | package org.fenixedu.ulisboa.applications.ui;
import java.io.IOException;
import java.util.concurrent.ThreadLocalRandom;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.fenixedu.bennu.spring.FenixEDUBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import com.google.gson.GsonBuilder;
public class FenixeduULisboaApplicationsBaseController extends FenixEDUBaseController {
//The HTTP Request that can be used internally in the controller
protected @Autowired HttpServletRequest request;
@ModelAttribute
protected void addModelProperties(Model model) {
super.addModelProperties(model, request);
String infoMessages = request.getParameter(INFO_MESSAGES);
if (infoMessages != null) {
addInfoMessage(infoMessages, model);
}
String warningMessages = request.getParameter(WARNING_MESSAGES);
if (warningMessages != null) {
addWarningMessage(warningMessages, model);
}
String errorMessages = request.getParameter(ERROR_MESSAGES);
if (errorMessages != null) {
addErrorMessage(errorMessages, model);
}
}
@Override
protected void registerTypeAdapters(GsonBuilder builder) {
super.registerTypeAdapters(builder);
}
protected void writeFile(final HttpServletResponse response, final String filename, final String contentType,
final byte[] content) throws IOException {
response.setContentLength(content.length);
response.setContentType(contentType);
response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
try (ServletOutputStream outputStream = response.getOutputStream()) {
outputStream.write(content);
outputStream.flush();
response.flushBuffer();
}
}
protected static class SecToken {
private static String SEED = "<KEY>";
private static int DEFAULT_KEY_SIZE = 16;
public static String generate(int keySize) {
char[] key = new char[keySize];
for (int i = 0; i < keySize; i++) {
key[i] = SEED.charAt(ThreadLocalRandom.current().nextInt(0, (SEED.length() - 1)));
}
return String.valueOf(key);
}
public static String generate() {
return generate(DEFAULT_KEY_SIZE);
}
}
}
| 2,617 | 0.687967 | 0.682362 | 76 | 34.210526 | 28.872368 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.578947 | false | false | 4 |
f314df25e8b86f4733b930dae67b597ebf221c82 | 24,412,594,140,020 | 4e2c542cfc9b2b270e28e917626a9e413d2b90ce | /Applications/back/edycem/src/main/java/fr/imie/edycem/model/Response/ProjectResponse.java | 0dd419a42a34755630ec68bad83588edc26a691b | [] | no_license | g7team/Edycem_IMIE | https://github.com/g7team/Edycem_IMIE | 30db0728d284bd9bdd1b12c6c7875fa163e0b853 | 37905631e820999888814dfd1813831e42d7d160 | refs/heads/master | 2023-05-25T20:41:33.775000 | 2019-07-11T14:39:08 | 2019-07-11T14:39:08 | 194,690,237 | 0 | 1 | null | false | 2023-05-22T22:29:33 | 2019-07-01T14:36:36 | 2019-07-11T14:39:19 | 2023-05-22T22:29:32 | 12,513 | 0 | 1 | 31 | Java | false | false | package fr.imie.edycem.model.Response;
import fr.imie.edycem.model.Project;
public class ProjectResponse extends Project {
private Integer id;
private String name;
private String society;
}
| UTF-8 | Java | 208 | java | ProjectResponse.java | Java | [] | null | [] | package fr.imie.edycem.model.Response;
import fr.imie.edycem.model.Project;
public class ProjectResponse extends Project {
private Integer id;
private String name;
private String society;
}
| 208 | 0.745192 | 0.745192 | 13 | 15 | 17.02035 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 4 |
d6a1e829fe87286d1206088fd97f24b89089fcbd | 28,080,496,189,658 | 2d0f1014d640a523bde317b367dc46fef517e037 | /src/main/java/org/foobarspam/mrmeeseeks/Doable.java | bd593eab4c9c60a8134d29b0e03fa475adf13d3e | [] | no_license | AlejandroSuarezA/ExamenMrMeeseeks | https://github.com/AlejandroSuarezA/ExamenMrMeeseeks | 3995d1be45ec2bf06c5dd7e6af06e6a4fceba4b7 | 5319aa6842962eba184c2be90e92e75e51ee7103 | refs/heads/master | 2021-04-14T03:04:14.268000 | 2017-06-16T15:23:19 | 2017-06-16T15:23:19 | 94,555,675 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.foobarspam.mrmeeseeks;
public interface Doable extends DoSomethingSimple<String, String> {
}
| UTF-8 | Java | 107 | java | Doable.java | Java | [] | null | [] | package org.foobarspam.mrmeeseeks;
public interface Doable extends DoSomethingSimple<String, String> {
}
| 107 | 0.813084 | 0.813084 | 5 | 20.4 | 26.702808 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
2677db1fccbb8c585c7d2aaab52198dbda80994b | 3,831,110,838,257 | 9e7f9f0b7a965818a6ff06b8bc3142ec5cf079a2 | /src/bank/BankAccount.java | e2b717f44c462d40ee8f7e1c08956954a7c310a0 | [] | no_license | PeterYangIO/Bank | https://github.com/PeterYangIO/Bank | d898627325df3f40bf93afb51156ed07d39c29b8 | 8ea826edebc1cfa72381e9ab43e373fdd91332f7 | refs/heads/master | 2021-05-29T10:18:04.456000 | 2015-07-17T08:06:39 | 2015-07-17T08:06:39 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bank;
import java.util.Scanner;
import java.text.NumberFormat;
/**
@author Peter
*/
public class BankAccount{
private String username;
private int pin;
private double balance;
public BankAccount(String u, int p){
username = u;
pin = p;
balance = 0;
}
public String getUsername(){
return username;
}
// GREAT SECURITY MATE
public int getPin(){
return pin;
}
public String getBalance(){
NumberFormat f = NumberFormat.getCurrencyInstance();
return f.format(balance);
}
public void setUserName(String s){
username = s;
}
public void setPin(){
System.out.println("Please enter your old PIN to continue.");
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
if (input != pin){
System.out.println("I'm sorry. The PIN you entered is incorrect.\nAction failed.");
}
else{
System.out.println("Enter in your new PIN.");
input = sc.nextInt();
int tempPin = input;
System.out.println("Reenter your new PIN to confirm");
input = sc.nextInt();
if (tempPin == input){
System.out.println("Your PIN has been successfully set!");
}
else{
System.out.println("I'm sorry. The two values do not match.\nAction failed.");
}
}
}
public boolean withdraw(double amount){
if (amount <= 0){
return false;
}
Scanner sc = new Scanner(System.in);
System.out.println(username + ", please enter your PIN.");
int input = sc.nextInt();
if (input != pin){
System.out.println("That PIN is not correct.\nAction failed.");
return false;
}
int hundredDollar, twentyDollar, fiveDollar, oneDollar;
int quarter, nickel, penny;
hundredDollar = twentyDollar = fiveDollar = oneDollar = 0;
quarter = nickel = penny = 0;
if (amount > balance){
System.out.println("You do not have sufficient funds in your account.");
return false;
}
// Removes the parameter amount from the actual object's balance
balance -= amount;
// Dishes out denominations, removing from the parameter value until all the money has been handed out
while (amount > 100){
hundredDollar++;
amount -= 100;
}
while (amount > 20){
twentyDollar++;
amount -= 20;
}
while (amount > 5){
fiveDollar++;
amount -= 5;
}
while (amount > 1){
oneDollar++;
amount -= 1;
}
while (amount > .25){
quarter++;
amount -= .25;
}
while (amount > .05){
nickel++;
amount -= .05;
}
while (amount > 0){
penny++;
amount -= .01;
}
System.out.println("You have been handed: ");
if (hundredDollar != 0)
System.out.println(hundredDollar + " hundred dollar bill(s)");
if (twentyDollar != 0)
System.out.println(twentyDollar + " twenty dollar bill(s)");
if (fiveDollar != 0)
System.out.println(fiveDollar + " five dollar bill(s)");
if (oneDollar != 0)
System.out.println(oneDollar + " one dollar bill(s)");
if (quarter != 0)
System.out.println(quarter + " quarter(s)");
if (nickel != 0)
System.out.println(nickel + " nickel(s)");
if (penny != 0)
System.out.println(penny + " one cent thing(s)");
System.out.println("Your new balance is: " + getBalance() + ".");
return true;
}
public boolean deposit(double amount){
if (amount <= 0){
System.out.println("Please enter in a value greater than 0.\nAction failed.");
return false;
}
else{
balance += amount;
System.out.println("Transaction successful! The balance for " + username + " is "
+ getBalance() + ".");
return true;
}
}
}
| UTF-8 | Java | 4,297 | java | BankAccount.java | Java | [
{
"context": "ner;\nimport java.text.NumberFormat;\n\n/**\n\n @author Peter\n */\npublic class BankAccount{\n\n private String",
"end": 92,
"score": 0.9986690282821655,
"start": 87,
"tag": "NAME",
"value": "Peter"
},
{
"context": "c BankAccount(String u, int p){\n username ... | null | [] | package bank;
import java.util.Scanner;
import java.text.NumberFormat;
/**
@author Peter
*/
public class BankAccount{
private String username;
private int pin;
private double balance;
public BankAccount(String u, int p){
username = u;
pin = p;
balance = 0;
}
public String getUsername(){
return username;
}
// GREAT SECURITY MATE
public int getPin(){
return pin;
}
public String getBalance(){
NumberFormat f = NumberFormat.getCurrencyInstance();
return f.format(balance);
}
public void setUserName(String s){
username = s;
}
public void setPin(){
System.out.println("Please enter your old PIN to continue.");
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
if (input != pin){
System.out.println("I'm sorry. The PIN you entered is incorrect.\nAction failed.");
}
else{
System.out.println("Enter in your new PIN.");
input = sc.nextInt();
int tempPin = input;
System.out.println("Reenter your new PIN to confirm");
input = sc.nextInt();
if (tempPin == input){
System.out.println("Your PIN has been successfully set!");
}
else{
System.out.println("I'm sorry. The two values do not match.\nAction failed.");
}
}
}
public boolean withdraw(double amount){
if (amount <= 0){
return false;
}
Scanner sc = new Scanner(System.in);
System.out.println(username + ", please enter your PIN.");
int input = sc.nextInt();
if (input != pin){
System.out.println("That PIN is not correct.\nAction failed.");
return false;
}
int hundredDollar, twentyDollar, fiveDollar, oneDollar;
int quarter, nickel, penny;
hundredDollar = twentyDollar = fiveDollar = oneDollar = 0;
quarter = nickel = penny = 0;
if (amount > balance){
System.out.println("You do not have sufficient funds in your account.");
return false;
}
// Removes the parameter amount from the actual object's balance
balance -= amount;
// Dishes out denominations, removing from the parameter value until all the money has been handed out
while (amount > 100){
hundredDollar++;
amount -= 100;
}
while (amount > 20){
twentyDollar++;
amount -= 20;
}
while (amount > 5){
fiveDollar++;
amount -= 5;
}
while (amount > 1){
oneDollar++;
amount -= 1;
}
while (amount > .25){
quarter++;
amount -= .25;
}
while (amount > .05){
nickel++;
amount -= .05;
}
while (amount > 0){
penny++;
amount -= .01;
}
System.out.println("You have been handed: ");
if (hundredDollar != 0)
System.out.println(hundredDollar + " hundred dollar bill(s)");
if (twentyDollar != 0)
System.out.println(twentyDollar + " twenty dollar bill(s)");
if (fiveDollar != 0)
System.out.println(fiveDollar + " five dollar bill(s)");
if (oneDollar != 0)
System.out.println(oneDollar + " one dollar bill(s)");
if (quarter != 0)
System.out.println(quarter + " quarter(s)");
if (nickel != 0)
System.out.println(nickel + " nickel(s)");
if (penny != 0)
System.out.println(penny + " one cent thing(s)");
System.out.println("Your new balance is: " + getBalance() + ".");
return true;
}
public boolean deposit(double amount){
if (amount <= 0){
System.out.println("Please enter in a value greater than 0.\nAction failed.");
return false;
}
else{
balance += amount;
System.out.println("Transaction successful! The balance for " + username + " is "
+ getBalance() + ".");
return true;
}
}
}
| 4,297 | 0.520596 | 0.511752 | 145 | 28.634483 | 23.633936 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.517241 | false | false | 4 |
b5e58a7e64d7a54034a3a1ad342ac5d2ae70a4f5 | 32,882,269,645,873 | 9974e5530b0cd7dd86c9e9cdf8004cabb03ea7d7 | /joyqueue-common/joyqueue-toolkit/src/main/java/org/joyqueue/toolkit/lang/Getters.java | fb17fb0068388c75b5005be5bd832d3894a36bdf | [
"Apache-2.0"
] | permissive | liyue2008/joyqueue | https://github.com/liyue2008/joyqueue | f41c2344b3f127fb5599549889fa66ec655f9459 | 554ac6f89213bbb8a91af798eb1f8210bf16a976 | refs/heads/master | 2020-06-23T12:52:50.062000 | 2020-05-25T01:52:28 | 2020-05-25T01:52:28 | 198,607,462 | 2 | 2 | Apache-2.0 | true | 2019-07-24T09:54:19 | 2019-07-24T09:54:18 | 2019-07-24T08:42:09 | 2019-07-24T04:35:56 | 13,858 | 0 | 0 | 0 | null | false | false | /**
* Copyright 2019 The JoyQueue Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.joyqueue.toolkit.lang;
import org.joyqueue.toolkit.reflect.Reflect;
import java.lang.reflect.Field;
/**
* Created by hexiaofeng on 16-8-11.
*/
public class Getters {
/**
* 常量获取器
*
* @param value 常量
* @return 常量
*/
public static Getter constant(final Object value) {
return new ConstantGetter(value);
}
/**
* 字段值获取器
*
* @param field 字段
* @param target 目标对象
* @param cache 是否缓存
* @return 目标对象字段值
*/
public static Getter field(final Field field, final Object target, final boolean cache) {
return new FieldGetter(field, target, cache);
}
/**
* 自动值获取器
* Created by hexiaofeng on 16-8-11.
*/
protected static class FieldGetter implements Getter {
// 字段
protected Field field;
// 对象
protected Object target;
// 是否缓存
protected boolean cache;
// 值
protected Object value;
// 是否初始化
protected boolean flag;
public FieldGetter(final Field field, final Object target, final boolean cache) {
this.field = field;
this.target = target;
if (!field.isAccessible()) {
field.setAccessible(true);
}
}
@Override
public Object get() {
if (!cache) {
return Reflect.get(field, target);
} else if (!flag) {
// 获取该字段的值
value = Reflect.get(field, target);
flag = true;
}
return value;
}
}
/**
* 常量获取器
* Created by hexiaofeng on 16-8-11.
*/
protected static class ConstantGetter implements Getter {
protected Object value;
public ConstantGetter(Object value) {
this.value = value;
}
@Override
public Object get() {
return value;
}
}
}
| UTF-8 | Java | 2,692 | java | Getters.java | Java | [
{
"context": "import java.lang.reflect.Field;\n\n/**\n * Created by hexiaofeng on 16-8-11.\n */\npublic class Getters {\n\n /**\n ",
"end": 749,
"score": 0.9997156262397766,
"start": 739,
"tag": "USERNAME",
"value": "hexiaofeng"
},
{
"context": ");\n }\n\n\n /**\n * 自动值获... | null | [] | /**
* Copyright 2019 The JoyQueue Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.joyqueue.toolkit.lang;
import org.joyqueue.toolkit.reflect.Reflect;
import java.lang.reflect.Field;
/**
* Created by hexiaofeng on 16-8-11.
*/
public class Getters {
/**
* 常量获取器
*
* @param value 常量
* @return 常量
*/
public static Getter constant(final Object value) {
return new ConstantGetter(value);
}
/**
* 字段值获取器
*
* @param field 字段
* @param target 目标对象
* @param cache 是否缓存
* @return 目标对象字段值
*/
public static Getter field(final Field field, final Object target, final boolean cache) {
return new FieldGetter(field, target, cache);
}
/**
* 自动值获取器
* Created by hexiaofeng on 16-8-11.
*/
protected static class FieldGetter implements Getter {
// 字段
protected Field field;
// 对象
protected Object target;
// 是否缓存
protected boolean cache;
// 值
protected Object value;
// 是否初始化
protected boolean flag;
public FieldGetter(final Field field, final Object target, final boolean cache) {
this.field = field;
this.target = target;
if (!field.isAccessible()) {
field.setAccessible(true);
}
}
@Override
public Object get() {
if (!cache) {
return Reflect.get(field, target);
} else if (!flag) {
// 获取该字段的值
value = Reflect.get(field, target);
flag = true;
}
return value;
}
}
/**
* 常量获取器
* Created by hexiaofeng on 16-8-11.
*/
protected static class ConstantGetter implements Getter {
protected Object value;
public ConstantGetter(Object value) {
this.value = value;
}
@Override
public Object get() {
return value;
}
}
}
| 2,692 | 0.576053 | 0.567083 | 104 | 23.653847 | 21.81027 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.317308 | false | false | 4 |
604d5f8ddfbe03d2ae0683baa02ad269e4cc8776 | 27,616,639,740,138 | 1c05346f592ca1d712d56c8312eb8a8bb5c2b309 | /match-core/src/main/java/cn/com/jrj/vtmatch/basicmatch/matchcore/service/impl/MatchTeamJoinHistoryServiceImpl.java | d1a91b003c302840955a93ca26a039c01021d9f2 | [] | no_license | pengfangxing123/secshow | https://github.com/pengfangxing123/secshow | a2c39f0dbe9eaec243d16b16498e012ecc0547e1 | 9a31ddbb03884046cb1d5371a36be32a0127df51 | refs/heads/master | 2022-06-21T20:16:46.576000 | 2019-05-24T10:08:12 | 2019-05-24T10:08:12 | 188,399,934 | 0 | 0 | null | false | 2022-06-17T02:10:16 | 2019-05-24T10:08:10 | 2019-05-24T10:08:25 | 2022-06-17T02:10:15 | 171 | 0 | 0 | 2 | Java | false | false | package cn.com.jrj.vtmatch.basicmatch.matchcore.service.impl;
import cn.com.jrj.vtmatch.basicmatch.matchcore.entity.match.MatchTeamJoinHistory;
import cn.com.jrj.vtmatch.basicmatch.matchcore.dao.MatchTeamJoinHistoryMapper;
import cn.com.jrj.vtmatch.basicmatch.matchcore.service.IMatchTeamJoinHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 战队加入退出历史表 服务实现类
* </p>
*
* @author jobob
* @since 2018-10-31
*/
@Service
public class MatchTeamJoinHistoryServiceImpl extends ServiceImpl<MatchTeamJoinHistoryMapper, MatchTeamJoinHistory> implements IMatchTeamJoinHistoryService {
}
| UTF-8 | Java | 705 | java | MatchTeamJoinHistoryServiceImpl.java | Java | [
{
"context": "**\n * <p>\n * 战队加入退出历史表 服务实现类\n * </p>\n *\n * @author jobob\n * @since 2018-10-31\n */\n@Service\npublic class Ma",
"end": 482,
"score": 0.9996966123580933,
"start": 477,
"tag": "USERNAME",
"value": "jobob"
}
] | null | [] | package cn.com.jrj.vtmatch.basicmatch.matchcore.service.impl;
import cn.com.jrj.vtmatch.basicmatch.matchcore.entity.match.MatchTeamJoinHistory;
import cn.com.jrj.vtmatch.basicmatch.matchcore.dao.MatchTeamJoinHistoryMapper;
import cn.com.jrj.vtmatch.basicmatch.matchcore.service.IMatchTeamJoinHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 战队加入退出历史表 服务实现类
* </p>
*
* @author jobob
* @since 2018-10-31
*/
@Service
public class MatchTeamJoinHistoryServiceImpl extends ServiceImpl<MatchTeamJoinHistoryMapper, MatchTeamJoinHistory> implements IMatchTeamJoinHistoryService {
}
| 705 | 0.824225 | 0.812408 | 20 | 32.849998 | 41.19014 | 156 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35 | false | false | 4 |
45905ae4e73e0a111952314a3bb17f7555e2c4cd | 16,630,113,409,128 | 14233e322718a1f1e470d8e7c251e954c85a9e43 | /src/main/java/com/celfocus/training/bugtrackerbackoffice/controller/GenericCrudController.java | fa15846e7b6fb50df11431999de993daa3d47bbe | [] | no_license | BrunoCaetanoDev/bug-tracker-backend | https://github.com/BrunoCaetanoDev/bug-tracker-backend | 3ae2707f2d2457121452298470e391f93252127f | ff5f3b7090888ef9b51aca1e1e744f5e757ffff0 | refs/heads/master | 2020-07-29T04:01:37.639000 | 2019-09-19T22:54:37 | 2019-09-19T22:54:37 | 209,661,793 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.celfocus.training.bugtrackerbackoffice.controller;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public interface GenericCrudController <T extends Object, V extends Object> {
ResponseEntity<Page<T>> findAll(int page, int size);
ResponseEntity<T> find(Long id);
ResponseEntity<T> save(V request);
ResponseEntity<HttpStatus> update(Long id, V request);
ResponseEntity<HttpStatus> patch(Long id, V request);
ResponseEntity<HttpStatus> delete(Long id);
}
| UTF-8 | Java | 582 | java | GenericCrudController.java | Java | [] | null | [] | package com.celfocus.training.bugtrackerbackoffice.controller;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public interface GenericCrudController <T extends Object, V extends Object> {
ResponseEntity<Page<T>> findAll(int page, int size);
ResponseEntity<T> find(Long id);
ResponseEntity<T> save(V request);
ResponseEntity<HttpStatus> update(Long id, V request);
ResponseEntity<HttpStatus> patch(Long id, V request);
ResponseEntity<HttpStatus> delete(Long id);
}
| 582 | 0.778351 | 0.778351 | 16 | 35.375 | 25.548666 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.875 | false | false | 4 |
f53546a754b57f5dfcef240c0bec9af5f607ff2a | 16,630,113,412,312 | 6746d531236b968d9944f776263f4fa45b76f4f1 | /src/main/java/com/springboot/employees/domain/AbstractLinkableEntity.java | 46ab1cf25b01a61e82c5dc4afbf35666b71dc9b3 | [] | no_license | Vishwanath-Patil/springboot-crud-demo | https://github.com/Vishwanath-Patil/springboot-crud-demo | e17dbb6d499e7cf8334f3b322b1df656a18dff40 | 64981bd5232681a86abc2c9db09f532c97deccae | refs/heads/main | 2023-02-17T01:13:55.464000 | 2021-01-19T19:55:30 | 2021-01-19T19:55:30 | 330,893,383 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.springboot.employees.domain;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.springboot.employees.util.JsonDateDeserializer;
import com.springboot.employees.util.JsonDateSerializer;
import java.text.ParseException;
import java.time.LocalDateTime;
public abstract class AbstractLinkableEntity {
@JsonSerialize(using = JsonDateSerializer.class)
@JsonDeserialize(using = JsonDateDeserializer.class)
private LocalDateTime createdAt;
@JsonSerialize(using = JsonDateSerializer.class)
@JsonDeserialize(using = JsonDateDeserializer.class)
private LocalDateTime updatedAt;
public LocalDateTime getCreatedAt() throws ParseException {
return this.createdAt == null?null: LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(createdAt)));
}
public LocalDateTime getUpdatedAt() throws ParseException {
return this.updatedAt == null?null: LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(updatedAt)));
}
public void setCreatedAt(LocalDateTime date) throws ParseException {
this.createdAt = date == null?LocalDateTime.now(): LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(date)));
}
public void setUpdatedAt(LocalDateTime date) throws ParseException {
this.updatedAt = date == null?LocalDateTime.now(): LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(date)));
}
public void cleanUp() throws ParseException {
setCreatedAt(null);
setUpdatedAt(null);
}
}
| UTF-8 | Java | 1,728 | java | AbstractLinkableEntity.java | Java | [] | null | [] | package com.springboot.employees.domain;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.springboot.employees.util.JsonDateDeserializer;
import com.springboot.employees.util.JsonDateSerializer;
import java.text.ParseException;
import java.time.LocalDateTime;
public abstract class AbstractLinkableEntity {
@JsonSerialize(using = JsonDateSerializer.class)
@JsonDeserialize(using = JsonDateDeserializer.class)
private LocalDateTime createdAt;
@JsonSerialize(using = JsonDateSerializer.class)
@JsonDeserialize(using = JsonDateDeserializer.class)
private LocalDateTime updatedAt;
public LocalDateTime getCreatedAt() throws ParseException {
return this.createdAt == null?null: LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(createdAt)));
}
public LocalDateTime getUpdatedAt() throws ParseException {
return this.updatedAt == null?null: LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(updatedAt)));
}
public void setCreatedAt(LocalDateTime date) throws ParseException {
this.createdAt = date == null?LocalDateTime.now(): LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(date)));
}
public void setUpdatedAt(LocalDateTime date) throws ParseException {
this.updatedAt = date == null?LocalDateTime.now(): LocalDateTime.from(JsonDateSerializer.formatter.parse(JsonDateSerializer.formatter.format(date)));
}
public void cleanUp() throws ParseException {
setCreatedAt(null);
setUpdatedAt(null);
}
}
| 1,728 | 0.780093 | 0.780093 | 42 | 40.142857 | 44.129986 | 157 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false | 4 |
e2a0138c120ed807caef45f199ac931894388db2 | 10,462,540,343,128 | 32785209a0c944a9d6b4bacf83440f6ded4790ec | /1116-1122/src/com/company/Mammal.java | 40fd5fb9aee7bb691629a34e2c96b2d2aa5a9775 | [] | no_license | Tuzson/Progmatic-to-Git | https://github.com/Tuzson/Progmatic-to-Git | 46295bacb33c080031d9ab135701e6d39d15761b | d1a795d640f505f5cb60afe4386c3bec0c7bb08b | refs/heads/master | 2023-02-13T06:29:17.567000 | 2021-01-21T08:09:02 | 2021-01-21T08:09:02 | 306,321,940 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company;
public abstract class Mammal extends Animal {
public Mammal(String type, String livingArea, int age) {
super(type, livingArea, age);
}
}
| UTF-8 | Java | 179 | java | Mammal.java | Java | [] | null | [] | package com.company;
public abstract class Mammal extends Animal {
public Mammal(String type, String livingArea, int age) {
super(type, livingArea, age);
}
}
| 179 | 0.675978 | 0.675978 | 11 | 15.272727 | 21.006886 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 4 |
2a11e919c2165bfa3cd61537a5dd77b5dd071f49 | 2,095,944,097,932 | 9313e576832a6aa7b0b55eafc4257d7d673c0dd4 | /src/main/java/com/bestvike/linq/adapter/enumerable/ShortArrayEnumerable.java | e2f7c6752894fc41fe977424c133002b957551ef | [
"Apache-2.0"
] | permissive | timandy/linq | https://github.com/timandy/linq | 677eaa52b0ce33b081447bf0622436742e974149 | 62f0a2cf1089cb02c206647bf38c1ca7849d9f64 | refs/heads/master | 2023-06-10T04:45:43.264000 | 2023-06-07T08:50:16 | 2023-06-07T09:13:24 | 98,953,540 | 172 | 43 | Apache-2.0 | false | 2023-09-05T00:28:24 | 2017-08-01T03:06:30 | 2023-08-26T08:48:52 | 2023-09-05T00:28:23 | 3,511 | 164 | 42 | 4 | Java | false | false | package com.bestvike.linq.adapter.enumerable;
import com.bestvike.collections.generic.IArray;
import com.bestvike.function.Predicate1;
import com.bestvike.linq.IEnumerator;
import com.bestvike.linq.adapter.enumerator.ShortArrayEnumerator;
import com.bestvike.linq.exception.ExceptionArgument;
import com.bestvike.linq.exception.ThrowHelper;
import com.bestvike.linq.util.ArrayUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**
* Created by 许崇雷 on 2019-04-16.
*/
public final class ShortArrayEnumerable implements IArray<Short> {
private final short[] source;
public ShortArrayEnumerable(short[] source) {
this.source = source;
}
@Override
public IEnumerator<Short> enumerator() {
return new ShortArrayEnumerator(this.source);
}
@Override
public Object getArray() {
return this.source;
}
@Override
public Short get(int index) {
return this.source[index];
}
@Override
public int _indexOf(Short item) {
if (item == null)
return -1;
for (int i = 0; i < this.source.length; i++) {
if (this.source[i] == item)
return i;
}
return -1;
}
@Override
public int _lastIndexOf(Short item) {
if (item == null)
return -1;
for (int i = this.source.length - 1; i >= 0; i--) {
if (this.source[i] == item)
return i;
}
return -1;
}
@Override
public int _findIndex(Predicate1<Short> match) {
if (match == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.match);
for (int i = 0; i < this.source.length; i++) {
if (match.apply(this.source[i]))
return i;
}
return -1;
}
@Override
public int _findLastIndex(Predicate1<Short> match) {
if (match == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.match);
for (int i = this.source.length - 1; i >= 0; i--) {
if (match.apply(this.source[i]))
return i;
}
return -1;
}
@Override
public Collection<Short> getCollection() {
return ArrayUtils.toCollection(this._toArray());
}
@Override
public int _getCount() {
return this.source.length;
}
@Override
public boolean _contains(Short item) {
for (short value : this.source) {
if (Objects.equals(value, item))
return true;
}
return false;
}
@Override
public void _copyTo(Object[] array, int arrayIndex) {
for (short item : this.source)
array[arrayIndex++] = item;
}
@Override
public Short[] _toArray(Class<Short> clazz) {
Short[] array = ArrayUtils.newInstance(clazz, this.source.length);
for (int i = 0; i < array.length; i++)
array[i] = this.source[i];
return array;
}
@Override
public Object[] _toArray() {
Object[] array = new Object[this.source.length];
for (int i = 0; i < array.length; i++)
array[i] = this.source[i];
return array;
}
@Override
public List<Short> _toList() {
List<Short> list = new ArrayList<>(this.source.length);
for (short item : this.source)
list.add(item);
return list;
}
}
| UTF-8 | Java | 3,480 | java | ShortArrayEnumerable.java | Java | [
{
"context": "ist;\nimport java.util.Objects;\n\n/**\n * Created by 许崇雷 on 2019-04-16.\n */\npublic final class ShortArrayE",
"end": 513,
"score": 0.9997197985649109,
"start": 510,
"tag": "NAME",
"value": "许崇雷"
}
] | null | [] | package com.bestvike.linq.adapter.enumerable;
import com.bestvike.collections.generic.IArray;
import com.bestvike.function.Predicate1;
import com.bestvike.linq.IEnumerator;
import com.bestvike.linq.adapter.enumerator.ShortArrayEnumerator;
import com.bestvike.linq.exception.ExceptionArgument;
import com.bestvike.linq.exception.ThrowHelper;
import com.bestvike.linq.util.ArrayUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**
* Created by 许崇雷 on 2019-04-16.
*/
public final class ShortArrayEnumerable implements IArray<Short> {
private final short[] source;
public ShortArrayEnumerable(short[] source) {
this.source = source;
}
@Override
public IEnumerator<Short> enumerator() {
return new ShortArrayEnumerator(this.source);
}
@Override
public Object getArray() {
return this.source;
}
@Override
public Short get(int index) {
return this.source[index];
}
@Override
public int _indexOf(Short item) {
if (item == null)
return -1;
for (int i = 0; i < this.source.length; i++) {
if (this.source[i] == item)
return i;
}
return -1;
}
@Override
public int _lastIndexOf(Short item) {
if (item == null)
return -1;
for (int i = this.source.length - 1; i >= 0; i--) {
if (this.source[i] == item)
return i;
}
return -1;
}
@Override
public int _findIndex(Predicate1<Short> match) {
if (match == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.match);
for (int i = 0; i < this.source.length; i++) {
if (match.apply(this.source[i]))
return i;
}
return -1;
}
@Override
public int _findLastIndex(Predicate1<Short> match) {
if (match == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.match);
for (int i = this.source.length - 1; i >= 0; i--) {
if (match.apply(this.source[i]))
return i;
}
return -1;
}
@Override
public Collection<Short> getCollection() {
return ArrayUtils.toCollection(this._toArray());
}
@Override
public int _getCount() {
return this.source.length;
}
@Override
public boolean _contains(Short item) {
for (short value : this.source) {
if (Objects.equals(value, item))
return true;
}
return false;
}
@Override
public void _copyTo(Object[] array, int arrayIndex) {
for (short item : this.source)
array[arrayIndex++] = item;
}
@Override
public Short[] _toArray(Class<Short> clazz) {
Short[] array = ArrayUtils.newInstance(clazz, this.source.length);
for (int i = 0; i < array.length; i++)
array[i] = this.source[i];
return array;
}
@Override
public Object[] _toArray() {
Object[] array = new Object[this.source.length];
for (int i = 0; i < array.length; i++)
array[i] = this.source[i];
return array;
}
@Override
public List<Short> _toList() {
List<Short> list = new ArrayList<>(this.source.length);
for (short item : this.source)
list.add(item);
return list;
}
}
| 3,480 | 0.580023 | 0.572827 | 133 | 25.1203 | 20.07169 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.43609 | false | false | 4 |
15a9b19f474e8a883899ab1565f6258e83285e0a | 1,760,936,653,325 | ac9c10f62878cc09bc82931b372ab9c3e42454c9 | /desktop/src/com/mageshowdown/desktop/DesktopClientLauncher.java | 30d00b4cdf071b46c90d7468ad66d93f0e5f6e13 | [
"MIT"
] | permissive | AnitaMatei/Mage-Showdown | https://github.com/AnitaMatei/Mage-Showdown | 91b08ce8e83a2a36ef1dd3f48182539df2406dbe | d2fd8fd8c20299afba89300416e7c94bcd22e118 | refs/heads/master | 2020-05-09T11:19:12.571000 | 2020-02-23T15:16:44 | 2020-02-23T15:16:44 | 181,073,586 | 0 | 1 | MIT | false | 2019-04-12T22:40:49 | 2019-04-12T19:45:50 | 2019-04-12T22:29:08 | 2019-04-12T22:29:49 | 63 | 0 | 1 | 0 | Java | false | false | package com.mageshowdown.desktop;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import static com.mageshowdown.gameclient.ClientAssetLoader.prefs;
public class DesktopClientLauncher extends Application {
static Stage mainStage;
static Scene mainScene;
public static void main(String[] args) {
launch(args);
}
//Launcher entry point
@Override
public void start(Stage primaryStage) throws IOException {
prefs = new GamePreferences("config.xml");
mainStage = primaryStage;
mainStage.setTitle("Mage Showdown Launcher");
mainStage.setResizable(false);
mainScene = new Scene((Parent) FXMLLoader.load(new URL("file", "localhost",
"../../core/assets/resources/MainScene.fxml")));
mainStage.setScene(mainScene);
mainStage.show();
}
}
| UTF-8 | Java | 1,001 | java | DesktopClientLauncher.java | Java | [] | null | [] | package com.mageshowdown.desktop;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import static com.mageshowdown.gameclient.ClientAssetLoader.prefs;
public class DesktopClientLauncher extends Application {
static Stage mainStage;
static Scene mainScene;
public static void main(String[] args) {
launch(args);
}
//Launcher entry point
@Override
public void start(Stage primaryStage) throws IOException {
prefs = new GamePreferences("config.xml");
mainStage = primaryStage;
mainStage.setTitle("Mage Showdown Launcher");
mainStage.setResizable(false);
mainScene = new Scene((Parent) FXMLLoader.load(new URL("file", "localhost",
"../../core/assets/resources/MainScene.fxml")));
mainStage.setScene(mainScene);
mainStage.show();
}
}
| 1,001 | 0.701299 | 0.701299 | 37 | 26.054054 | 22.35457 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.567568 | false | false | 4 |
b5ae5c3c7e76f807862cf887488a613a02e99943 | 14,319,421,010,514 | 4d56c7f61252895270039e3f08e58e9737f653c4 | /gplog-rastreio-api/src/main/java/com/gplog/rastreio/model/Step.java | 4df200440e6fa9ca194f8d818a3044f3a540476e | [] | no_license | guilepaul/rastrear-encomenda | https://github.com/guilepaul/rastrear-encomenda | 39a0d34c9f928c946555629c2fafeb0bf5b4b4ab | c335bb13cb3be4320298e140909e705bc939c8fd | refs/heads/master | 2020-04-08T16:11:42.730000 | 2018-11-28T13:45:56 | 2018-11-28T13:45:56 | 159,508,485 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gplog.rastreio.model;
import java.time.LocalDateTime;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
@Entity
public class Step {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Encomenda encomenda;
@ManyToOne
@NotNull
private Local local;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Step other = (Step) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Encomenda getEncomenda() {
return encomenda;
}
public void setEncomenda(Encomenda encomenda) {
this.encomenda = encomenda;
}
public Local getLocal() {
return local;
}
public void setLocal(Local local) {
this.local = local;
}
public LocalDateTime getRecebimento() {
return recebimento;
}
public void setRecebimento(LocalDateTime recebimento) {
this.recebimento = recebimento;
}
@NotNull
private LocalDateTime recebimento;
}
| UTF-8 | Java | 1,541 | java | Step.java | Java | [] | null | [] | package com.gplog.rastreio.model;
import java.time.LocalDateTime;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
@Entity
public class Step {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Encomenda encomenda;
@ManyToOne
@NotNull
private Local local;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Step other = (Step) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Encomenda getEncomenda() {
return encomenda;
}
public void setEncomenda(Encomenda encomenda) {
this.encomenda = encomenda;
}
public Local getLocal() {
return local;
}
public void setLocal(Local local) {
this.local = local;
}
public LocalDateTime getRecebimento() {
return recebimento;
}
public void setRecebimento(LocalDateTime recebimento) {
this.recebimento = recebimento;
}
@NotNull
private LocalDateTime recebimento;
}
| 1,541 | 0.700195 | 0.697599 | 86 | 16.918604 | 15.428918 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.44186 | false | false | 4 |
af17d4394c9ef009837f24f425499ef5a10104aa | 1,468,878,875,124 | 9cf5f0595d7f31fb723801c0c59f84e0ed3cf430 | /ec/src/main/java/com/qilu/ec/main/util/Image.java | 293dd913bf95e8aa24f3c9d9d07c00eb0686855a | [] | no_license | reyesle/MagicMirror | https://github.com/reyesle/MagicMirror | 08015c0c2824abffbe2e2ac7d399a0094132eee8 | 9b2291d0b60aed0c29d96f3dc1cd043981ed3f97 | refs/heads/master | 2023-07-14T07:54:03.822000 | 2021-08-30T00:19:56 | 2021-08-30T00:19:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.qilu.ec.main.util;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import de.hdodenhof.circleimageview.CircleImageView;
public class Image {
/**
* 结果图显示到屏幕上
*/
public static void showResultImage(@Nullable String image, ImageView imageView) {
if (image != null && (!image.isEmpty())) {
byte[] bytes = Base64.decode(image, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
imageView.setImageBitmap(bitmap);
//自动缩放
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
}
}
public static void showResultImage(@Nullable String image, CircleImageView circleImageView) {
if (image != null && (!image.isEmpty())) {
byte[] bytes = Base64.decode(image, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
circleImageView.setImageBitmap(bitmap);
}
}
/**
* 将bitmap转为base64格式的字符串
*/
public static String BitmapToStrByBase64(Bitmap bit) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.JPEG, 100, bos);//参数100表示不压缩
byte[] bytes = bos.toByteArray();
return Base64.encodeToString(bytes, Base64.DEFAULT);
}
/**
* Drawable 转 bitmap
*/
public static Bitmap drawableToBitmap(Drawable img) {
BitmapDrawable bd = (BitmapDrawable) img;
return bd.getBitmap();
}
/**
* 文件转base64字符串
*
* @param file
* @return
*/
public static String fileToBase64(File file) {
String base64 = null;
InputStream in = null;
try {
in = new FileInputStream(file);
byte[] bytes = new byte[in.available()];
int length = in.read(bytes);
base64 = Base64.encodeToString(bytes, 0, length, Base64.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return base64;
}
/**
* base64字符串转文件
*
* @param base64
* @return
*/
public static File base64ToFile(String base64) {
File file = null;
String fileName = "testFile.jpg";
FileOutputStream out = null;
try {
// 解码,然后将字节转换为文件
File appDir = new File(Environment.getExternalStorageDirectory(), "MagicMirror");
if (!appDir.exists()) {
appDir.mkdir();
}
file = new File(appDir, fileName);
if (!file.exists())
file.createNewFile();
else {
Log.i("已经存在文件", "将其删除");
file.delete();
Log.i("文件是否被删除", String.valueOf(!file.exists()));
Log.i("新建文件", "");
file.createNewFile();
Log.i("文件是否被新建", String.valueOf(file.exists()));
}
byte[] bytes = Base64.decode(base64, Base64.DEFAULT);// 将字符串转换为byte数组
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
byte[] buffer = new byte[1024];
out = new FileOutputStream(file);
int bytesum = 0;
int byteread = 0;
while ((byteread = in.read(buffer)) != -1) {
bytesum += byteread;
out.write(buffer, 0, byteread); // 文件写操作
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return file;
}
/**
* base64转为bitmap
*
* @param base64Data
* @return
*/
public static Bitmap base64ToBitmap(String base64Data) {
byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
public static void saveImageToGallery(Context context, Bitmap bmp) {
// 首先保存图片
File appDir = new File(Environment.getExternalStorageDirectory(), "MagicMirror");
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = System.currentTimeMillis() + ".jpg";
File file = new File(appDir, fileName);
try {
FileOutputStream fos = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 最后通知图库更新
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(file.getPath()))));
}
}
| UTF-8 | Java | 6,012 | java | Image.java | Java | [] | null | [] | package com.qilu.ec.main.util;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import de.hdodenhof.circleimageview.CircleImageView;
public class Image {
/**
* 结果图显示到屏幕上
*/
public static void showResultImage(@Nullable String image, ImageView imageView) {
if (image != null && (!image.isEmpty())) {
byte[] bytes = Base64.decode(image, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
imageView.setImageBitmap(bitmap);
//自动缩放
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
}
}
public static void showResultImage(@Nullable String image, CircleImageView circleImageView) {
if (image != null && (!image.isEmpty())) {
byte[] bytes = Base64.decode(image, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
circleImageView.setImageBitmap(bitmap);
}
}
/**
* 将bitmap转为base64格式的字符串
*/
public static String BitmapToStrByBase64(Bitmap bit) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.JPEG, 100, bos);//参数100表示不压缩
byte[] bytes = bos.toByteArray();
return Base64.encodeToString(bytes, Base64.DEFAULT);
}
/**
* Drawable 转 bitmap
*/
public static Bitmap drawableToBitmap(Drawable img) {
BitmapDrawable bd = (BitmapDrawable) img;
return bd.getBitmap();
}
/**
* 文件转base64字符串
*
* @param file
* @return
*/
public static String fileToBase64(File file) {
String base64 = null;
InputStream in = null;
try {
in = new FileInputStream(file);
byte[] bytes = new byte[in.available()];
int length = in.read(bytes);
base64 = Base64.encodeToString(bytes, 0, length, Base64.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return base64;
}
/**
* base64字符串转文件
*
* @param base64
* @return
*/
public static File base64ToFile(String base64) {
File file = null;
String fileName = "testFile.jpg";
FileOutputStream out = null;
try {
// 解码,然后将字节转换为文件
File appDir = new File(Environment.getExternalStorageDirectory(), "MagicMirror");
if (!appDir.exists()) {
appDir.mkdir();
}
file = new File(appDir, fileName);
if (!file.exists())
file.createNewFile();
else {
Log.i("已经存在文件", "将其删除");
file.delete();
Log.i("文件是否被删除", String.valueOf(!file.exists()));
Log.i("新建文件", "");
file.createNewFile();
Log.i("文件是否被新建", String.valueOf(file.exists()));
}
byte[] bytes = Base64.decode(base64, Base64.DEFAULT);// 将字符串转换为byte数组
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
byte[] buffer = new byte[1024];
out = new FileOutputStream(file);
int bytesum = 0;
int byteread = 0;
while ((byteread = in.read(buffer)) != -1) {
bytesum += byteread;
out.write(buffer, 0, byteread); // 文件写操作
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return file;
}
/**
* base64转为bitmap
*
* @param base64Data
* @return
*/
public static Bitmap base64ToBitmap(String base64Data) {
byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
public static void saveImageToGallery(Context context, Bitmap bmp) {
// 首先保存图片
File appDir = new File(Environment.getExternalStorageDirectory(), "MagicMirror");
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = System.currentTimeMillis() + ".jpg";
File file = new File(appDir, fileName);
try {
FileOutputStream fos = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 最后通知图库更新
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(file.getPath()))));
}
}
| 6,012 | 0.574663 | 0.560664 | 183 | 30.617487 | 23.160315 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.639344 | false | false | 4 |
f5a8dc0cf388a143d421dae8e1a2e730f219a096 | 14,199,161,885,098 | 90619e40ed55e5db66e33f602a4e53a848bc3bd0 | /CSIS3475/TextbookCode/Trees/26.16.java | 906fe5cc046f8ac8ab77e937f6ab1c08da417e2c | [] | no_license | jasonn0118/DataStructure_Basic | https://github.com/jasonn0118/DataStructure_Basic | 3709f142ed2dd8f1bbfae142bcabf84a92e5bf17 | 52f8b0f858a647119828e5b1c246eed793a47729 | refs/heads/master | 2020-11-28T13:36:45.246000 | 2019-12-23T22:43:45 | 2019-12-23T22:43:45 | 229,832,339 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // @author Frank M. Carrano, Timothy M. Henry
// @version 5.0
public T add(T anEntry)
{
T result = null;
if (isEmpty())
setRootNode(new BinaryNode<>(anEntry));
else
result = addEntry(getRootNode(), anEntry);
return result;
} // end add
| UTF-8 | Java | 269 | java | 26.16.java | Java | [
{
"context": "// @author Frank M. Carrano, Timothy M. Henry\n// @version 5.0\n\npublic T add(T",
"end": 27,
"score": 0.9998571276664734,
"start": 11,
"tag": "NAME",
"value": "Frank M. Carrano"
},
{
"context": "// @author Frank M. Carrano, Timothy M. Henry\n// @version 5.0\n\npublic T... | null | [] | // @author <NAME>, <NAME>
// @version 5.0
public T add(T anEntry)
{
T result = null;
if (isEmpty())
setRootNode(new BinaryNode<>(anEntry));
else
result = addEntry(getRootNode(), anEntry);
return result;
} // end add
| 249 | 0.609665 | 0.60223 | 14 | 18.071428 | 16.223722 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 4 |
8b9f213374c4b4fb7e81c973f712eb89f6220fb3 | 7,284,264,546,263 | f6aa979520c383430e8b17a5e6648b51c480b36b | /koopey.android/app/src/main/java/com/koopey/view/CustomCalendarView.java | 6fc730c2a1876d884b1c57c6302a271669f4845f | [] | no_license | moleisking/koopey | https://github.com/moleisking/koopey | ce29fc27c940cae4eb30f1bb80a821ba0b2bef2b | 902da018576e25bc4a970ddbe70a8fbd28263ef0 | refs/heads/master | 2023-08-30T15:10:53.388000 | 2023-08-27T13:48:46 | 2023-08-27T13:48:46 | 227,432,881 | 0 | 1 | null | false | 2020-01-03T18:20:31 | 2019-12-11T18:25:55 | 2020-01-03T18:12:52 | 2020-01-03T18:12:50 | 24,889 | 0 | 0 | 0 | Java | false | false | package com.koopey.view;
import android.content.Context;
import android.graphics.Canvas;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CalendarView;
import java.util.Date;
/**
* Created by Scott on 19/07/2017.
*/
public class CustomCalendarView extends CalendarView {
private final String LOG_HEADER = "CAL:VW";
private Date previousSelectedDate = new Date();
private OnDateChangeListener listener;
private CheckSameSelectedDateAsyncTask task = new CheckSameSelectedDateAsyncTask();
public CustomCalendarView(Context context) {
super(context);
}
public CustomCalendarView(Context context, AttributeSet attribute) {
super(context, attribute);
}
public CustomCalendarView(Context context, AttributeSet attribute, int defStyle) {
super(context, attribute, defStyle);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if ((task.getStatus() == AsyncTask.Status.PENDING) || (task.getStatus() == AsyncTask.Status.FINISHED)) {
task = new CheckSameSelectedDateAsyncTask();
task.execute();
}
return false;
}
private void checkSameSelectedDate() {
Date selectedDate = new Date(super.getDate());
if (selectedDate.getDay() == previousSelectedDate.getDay() &&
selectedDate.getMonth() == previousSelectedDate.getMonth() &&
selectedDate.getYear() == previousSelectedDate.getYear()) {
if (listener != null) {
this.listener.onSameSelectedDayChange(this, selectedDate.getYear(), selectedDate.getMonth(), selectedDate.getDay());
}
}
this.previousSelectedDate = selectedDate;
}
public void setSameSelectedDayChangeListener(OnDateChangeListener listener) {
this.listener = listener;
}
public interface OnDateChangeListener extends CalendarView.OnDateChangeListener {
void onSameSelectedDayChange(CalendarView view, int year, int month, int day);
}
private class CheckSameSelectedDateAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
//Note: Breaking point between 75 - 100
Thread.sleep(300);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
checkSameSelectedDate();
}
}
}
| UTF-8 | Java | 2,694 | java | CustomCalendarView.java | Java | [
{
"context": "arView;\n\nimport java.util.Date;\n\n/**\n * Created by Scott on 19/07/2017.\n */\n\npublic class CustomCalendarVi",
"end": 321,
"score": 0.9870501756668091,
"start": 316,
"tag": "NAME",
"value": "Scott"
}
] | null | [] | package com.koopey.view;
import android.content.Context;
import android.graphics.Canvas;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CalendarView;
import java.util.Date;
/**
* Created by Scott on 19/07/2017.
*/
public class CustomCalendarView extends CalendarView {
private final String LOG_HEADER = "CAL:VW";
private Date previousSelectedDate = new Date();
private OnDateChangeListener listener;
private CheckSameSelectedDateAsyncTask task = new CheckSameSelectedDateAsyncTask();
public CustomCalendarView(Context context) {
super(context);
}
public CustomCalendarView(Context context, AttributeSet attribute) {
super(context, attribute);
}
public CustomCalendarView(Context context, AttributeSet attribute, int defStyle) {
super(context, attribute, defStyle);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if ((task.getStatus() == AsyncTask.Status.PENDING) || (task.getStatus() == AsyncTask.Status.FINISHED)) {
task = new CheckSameSelectedDateAsyncTask();
task.execute();
}
return false;
}
private void checkSameSelectedDate() {
Date selectedDate = new Date(super.getDate());
if (selectedDate.getDay() == previousSelectedDate.getDay() &&
selectedDate.getMonth() == previousSelectedDate.getMonth() &&
selectedDate.getYear() == previousSelectedDate.getYear()) {
if (listener != null) {
this.listener.onSameSelectedDayChange(this, selectedDate.getYear(), selectedDate.getMonth(), selectedDate.getDay());
}
}
this.previousSelectedDate = selectedDate;
}
public void setSameSelectedDayChangeListener(OnDateChangeListener listener) {
this.listener = listener;
}
public interface OnDateChangeListener extends CalendarView.OnDateChangeListener {
void onSameSelectedDayChange(CalendarView view, int year, int month, int day);
}
private class CheckSameSelectedDateAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
//Note: Breaking point between 75 - 100
Thread.sleep(300);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
checkSameSelectedDate();
}
}
}
| 2,694 | 0.662212 | 0.656273 | 83 | 31.45783 | 29.701447 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.542169 | false | false | 4 |
79f4e69c572e07c01c52f30781a4dfb807fe4c36 | 16,338,055,662,917 | 7653e008384de73b57411b7748dab52b561d51e6 | /SrcGame/dwo/scripts/ai/zone/HotSpringDisease.java | 1d07358425cbcd113961b8d92a19f402e3ae9ea5 | [] | no_license | BloodyDawn/Ertheia | https://github.com/BloodyDawn/Ertheia | 14520ecd79c38acf079de05c316766280ae6c0e8 | d90d7f079aa370b57999d483c8309ce833ff8af0 | refs/heads/master | 2021-01-11T22:10:19.455000 | 2017-01-14T12:15:56 | 2017-01-14T12:15:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dwo.scripts.ai.zone;
import dwo.gameserver.model.actor.L2Npc;
import dwo.gameserver.model.actor.instance.L2PcInstance;
import dwo.gameserver.model.skills.SkillTable;
import dwo.gameserver.model.world.quest.Quest;
import dwo.gameserver.util.Rnd;
import org.apache.commons.lang3.ArrayUtils;
/**
* Hot Spring Disease AI
*
* @author devO
*/
public class HotSpringDisease extends Quest
{
static final int[] disease1mobs = {
21314, 21316, 21317, 21319, 21321, 21322
}; // Monsters which cast Hot Spring Malaria (4554)
static final int[] disease2mobs = {21317, 21322}; // Monsters which cast Hot Springs Flu (4553)
static final int[] disease3mobs = {21316, 21319}; // Monsters which cast Hot Springs Cholera (4552)
static final int[] disease4mobs = {21314, 21321}; // Monsters which cast Hot Springs Rheumatism (4551)
// Chance to get infected by disease
private static final int DISEASE_CHANCE = 5;
public HotSpringDisease()
{
addAttackId(disease1mobs);
addAttackId(disease2mobs);
addAttackId(disease3mobs);
addAttackId(disease4mobs);
}
public static void main(String[] args)
{
new HotSpringDisease();
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
{
if(ArrayUtils.contains(disease1mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4554, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease2mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4553, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease3mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4552, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease4mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4551, Rnd.get(10) + 1));
}
}
return super.onAttack(npc, attacker, damage, isPet);
}
} | UTF-8 | Java | 2,151 | java | HotSpringDisease.java | Java | [
{
"context": "Utils;\n\n/**\n * Hot Spring Disease AI\n *\n * @author devO\n */\npublic class HotSpringDisease extends Quest\n{",
"end": 346,
"score": 0.9992532730102539,
"start": 342,
"tag": "USERNAME",
"value": "devO"
}
] | null | [] | package dwo.scripts.ai.zone;
import dwo.gameserver.model.actor.L2Npc;
import dwo.gameserver.model.actor.instance.L2PcInstance;
import dwo.gameserver.model.skills.SkillTable;
import dwo.gameserver.model.world.quest.Quest;
import dwo.gameserver.util.Rnd;
import org.apache.commons.lang3.ArrayUtils;
/**
* Hot Spring Disease AI
*
* @author devO
*/
public class HotSpringDisease extends Quest
{
static final int[] disease1mobs = {
21314, 21316, 21317, 21319, 21321, 21322
}; // Monsters which cast Hot Spring Malaria (4554)
static final int[] disease2mobs = {21317, 21322}; // Monsters which cast Hot Springs Flu (4553)
static final int[] disease3mobs = {21316, 21319}; // Monsters which cast Hot Springs Cholera (4552)
static final int[] disease4mobs = {21314, 21321}; // Monsters which cast Hot Springs Rheumatism (4551)
// Chance to get infected by disease
private static final int DISEASE_CHANCE = 5;
public HotSpringDisease()
{
addAttackId(disease1mobs);
addAttackId(disease2mobs);
addAttackId(disease3mobs);
addAttackId(disease4mobs);
}
public static void main(String[] args)
{
new HotSpringDisease();
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
{
if(ArrayUtils.contains(disease1mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4554, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease2mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4553, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease3mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4552, Rnd.get(10) + 1));
}
}
if(ArrayUtils.contains(disease4mobs, npc.getNpcId()))
{
if(Rnd.getChance(DISEASE_CHANCE))
{
npc.setTarget(attacker);
npc.doCast(SkillTable.getInstance().getInfo(4551, Rnd.get(10) + 1));
}
}
return super.onAttack(npc, attacker, damage, isPet);
}
} | 2,151 | 0.712692 | 0.655974 | 77 | 26.948051 | 26.898508 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.220779 | false | false | 4 |
7a98596e2845ab046335921cd05b97ba2042a39f | 26,362,509,293,294 | c011aa20fb91febbef6bf186e615f4e1b1774727 | /CalendarComplete/src/tests/EntryTest.java | 3516e2a1652183f764224ba7da5a8804133cbbeb | [] | no_license | UBCx-Software-Construction/long-form-problem-solutions | https://github.com/UBCx-Software-Construction/long-form-problem-solutions | ddc1fc902ee468707fe7170ce2e7bca224f6f2c8 | 5006f1e07d403a3e5a684b452e1503b75484364f | refs/heads/master | 2021-01-15T20:09:18.466000 | 2017-08-14T22:53:03 | 2017-08-14T22:53:03 | 99,843,793 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tests;
import model.*;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class EntryTest {
private Reminder reminder;
private Meeting meeting;
private Event event;
private Date d1;
private Date d2;
private Time t1;
private Time t2;
@Before
public void setUp(){
d1 = new Date (3, 6, 2017);
d2 = new Date (1, 1, 2018);
t1 = new Time(13, 2);
t2 = new Time(10, 13);
event = new Event(d1, t1, "Jen's birthday");
meeting = new Meeting(d2, t2, "Performance review");
reminder = new Reminder(d2, t1, "Make New Year's resolutions");
}
@Test
public void testConstructor(){
assertEquals(d1, event.getDate());
assertEquals(d2, meeting.getDate());
assertEquals(t1, event.getTime());
assertEquals(t2, meeting.getTime());
assertEquals("Jen's birthday", event.getLabel());
assertEquals("Make New Year's resolutions", reminder.getLabel());
}
@Test
public void testEntry(){
meeting.setRepeating(182); //6 months
assertTrue(meeting.isRepeating());
assertEquals(182, meeting.getIntervalOfRepetition());
meeting.setRepeating(0);
assertFalse(meeting.isRepeating());
}
@Test
public void testEvent(){
event.setReminder(reminder);
assertEquals(reminder, event.getReminder());
reminder = new Reminder(d1, t2, "Work launch party");
reminder.setNote("Bring chips and dip");
event.setReminder(reminder);
assertEquals("Bring chips and dip", event.getReminder().getNote());
}
@Test
public void testMeeting(){
List<String> attendees = new ArrayList<>();
attendees.add("Devon");
attendees.add("Aine");
attendees.add("Lironne");
meeting.addAttendee("Devon");
meeting.addAttendee("Aine");
meeting.addAttendee("Lironne");
assertEquals(attendees, meeting.getAttendees());
attendees.remove("Devon");
meeting.removeAttendee("Devon");
assertEquals(attendees, meeting.getAttendees());
}
@Test
public void testReminder(){
assertEquals("No note added", reminder.getNote());
reminder.setNote("Eat more vegetables");
assertEquals("Eat more vegetables", reminder.getNote());
}
}
| UTF-8 | Java | 2,631 | java | EntryTest.java | Java | [
{
"context": "ime(10, 13);\r\n event = new Event(d1, t1, \"Jen's birthday\");\r\n meeting = new Meeting(d2, ",
"end": 699,
"score": 0.5372595191001892,
"start": 697,
"tag": "NAME",
"value": "en"
},
{
"context": "dees = new ArrayList<>();\r\n attendees.add(\"Devon... | null | [] | package tests;
import model.*;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class EntryTest {
private Reminder reminder;
private Meeting meeting;
private Event event;
private Date d1;
private Date d2;
private Time t1;
private Time t2;
@Before
public void setUp(){
d1 = new Date (3, 6, 2017);
d2 = new Date (1, 1, 2018);
t1 = new Time(13, 2);
t2 = new Time(10, 13);
event = new Event(d1, t1, "Jen's birthday");
meeting = new Meeting(d2, t2, "Performance review");
reminder = new Reminder(d2, t1, "Make New Year's resolutions");
}
@Test
public void testConstructor(){
assertEquals(d1, event.getDate());
assertEquals(d2, meeting.getDate());
assertEquals(t1, event.getTime());
assertEquals(t2, meeting.getTime());
assertEquals("Jen's birthday", event.getLabel());
assertEquals("Make New Year's resolutions", reminder.getLabel());
}
@Test
public void testEntry(){
meeting.setRepeating(182); //6 months
assertTrue(meeting.isRepeating());
assertEquals(182, meeting.getIntervalOfRepetition());
meeting.setRepeating(0);
assertFalse(meeting.isRepeating());
}
@Test
public void testEvent(){
event.setReminder(reminder);
assertEquals(reminder, event.getReminder());
reminder = new Reminder(d1, t2, "Work launch party");
reminder.setNote("Bring chips and dip");
event.setReminder(reminder);
assertEquals("Bring chips and dip", event.getReminder().getNote());
}
@Test
public void testMeeting(){
List<String> attendees = new ArrayList<>();
attendees.add("Devon");
attendees.add("Aine");
attendees.add("Lironne");
meeting.addAttendee("Devon");
meeting.addAttendee("Aine");
meeting.addAttendee("Lironne");
assertEquals(attendees, meeting.getAttendees());
attendees.remove("Devon");
meeting.removeAttendee("Devon");
assertEquals(attendees, meeting.getAttendees());
}
@Test
public void testReminder(){
assertEquals("No note added", reminder.getNote());
reminder.setNote("Eat more vegetables");
assertEquals("Eat more vegetables", reminder.getNote());
}
}
| 2,631 | 0.610034 | 0.59217 | 86 | 28.593023 | 20.339775 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.94186 | false | false | 4 |
1d7fa87ba87e22073e35fc8ce0f8f8304ee1fad8 | 32,650,341,427,525 | c2c6ef1b6b1391d41bb3185d9cbd6419526fad54 | /src/org/pdes/rcp/core/ApplicationWorkbenchAdvisor.java | 683f4f6992135a815384613d7b81b20460ca98b9 | [] | no_license | mitsuyukiLab/pDES | https://github.com/mitsuyukiLab/pDES | f20959c8d89f24037aabce4d2c6165f6b2996779 | 09a264500686ea22d694d7a2af805c39d956a5b8 | refs/heads/master | 2020-03-09T21:28:39.913000 | 2019-01-09T09:41:59 | 2019-01-09T09:41:59 | 129,010,258 | 1 | 5 | null | false | 2020-03-30T08:57:25 | 2018-04-11T00:20:43 | 2019-12-23T09:07:36 | 2019-01-09T09:42:46 | 443 | 1 | 4 | 1 | Java | false | false | /*
* Copyright (c) 2016, Design Engineering Laboratory, The University of Tokyo.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.pdes.rcp.core;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
/**
* This workbench advisor creates the window advisor, and specifies the perspective id for the initial window.<br>
* @author Taiga Mitsuyuki <mitsuyuki@sys.t.u-tokyo.ac.jp>
*/
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
private static final String PERSPECTIVE_ID = "pDES.perspective"; //$NON-NLS-1$
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
*/
@Override
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
return new ApplicationWorkbenchWindowAdvisor(configurer);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
*/
@Override
public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
}
| UTF-8 | Java | 2,675 | java | ApplicationWorkbenchAdvisor.java | Java | [
{
"context": "spective id for the initial window.<br>\n * @author Taiga Mitsuyuki <mitsuyuki@sys.t.u-tokyo.ac.jp>\n */\npublic class ",
"end": 1944,
"score": 0.9998663067817688,
"start": 1929,
"tag": "NAME",
"value": "Taiga Mitsuyuki"
},
{
"context": "e initial window.<br>\n * @autho... | null | [] | /*
* Copyright (c) 2016, Design Engineering Laboratory, The University of Tokyo.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.pdes.rcp.core;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
/**
* This workbench advisor creates the window advisor, and specifies the perspective id for the initial window.<br>
* @author <NAME> <<EMAIL>>
*/
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
private static final String PERSPECTIVE_ID = "pDES.perspective"; //$NON-NLS-1$
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
*/
@Override
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
return new ApplicationWorkbenchWindowAdvisor(configurer);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
*/
@Override
public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
}
| 2,644 | 0.77757 | 0.774579 | 60 | 43.583332 | 35.697006 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.883333 | false | false | 4 |
ef770f919134b1fa4600bac1625b59837686232e | 31,782,758,047,964 | d645598f2267667ae5f75bc0f1d993b5c1f0610b | /pratica_01/src/test/java/CalculadoraTest.java | 47b2855bd45b70f9a2c1ec452119d08b88a26694 | [] | no_license | giovannaxavierm/lab_bd_vi | https://github.com/giovannaxavierm/lab_bd_vi | f0226b1b311f1066d533983d6227fa085f9de5f5 | e4eae74e018ac169e523d1dbaf2849542db43623 | refs/heads/main | 2023-06-07T16:27:05.476000 | 2021-06-25T17:13:36 | 2021-06-25T17:13:36 | 351,939,036 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CalculadoraTest {
// O método verificará se o calculo de raiz quadrada vai retorar o resultado correto
@Test
public void testeRaizQuadrada(){
Calculadora c = new Calculadora();
double result = c.raiz(4);
assertEquals(2,result);
}
}
| UTF-8 | Java | 415 | java | CalculadoraTest.java | Java | [] | null | [] | import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CalculadoraTest {
// O método verificará se o calculo de raiz quadrada vai retorar o resultado correto
@Test
public void testeRaizQuadrada(){
Calculadora c = new Calculadora();
double result = c.raiz(4);
assertEquals(2,result);
}
}
| 415 | 0.64891 | 0.644068 | 15 | 26.533333 | 26.071356 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
f5907fa23c593356a3ce4bb2a485e4a936d62993 | 2,181,843,428,582 | 0894081a71ea1a1319ca338a83e3a3ebb8aac99b | /src/main/java/io/github/glaucials/controleveiculos/entity/Veiculo.java | 3292b4a2e9088c1598ffeb0fd8ff379524ef127b | [] | no_license | GlauciaLS/controle-veiculos | https://github.com/GlauciaLS/controle-veiculos | 5677bdda7effcf488bdfa4bbda70fbe83906c710 | ad62133f9a13d45d98dba92bdef31b74c5d34737 | refs/heads/main | 2023-07-02T18:41:39.486000 | 2021-08-07T22:28:27 | 2021-08-07T22:28:27 | 383,983,336 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.glaucials.controleveiculos.entity;
import io.github.glaucials.controleveiculos.dto.VeiculoDTO;
import javax.persistence.*;
@Entity
@Table
public class Veiculo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable = false)
private long idProprietario;
@Column(nullable = false)
private String marca;
@Column(nullable = false)
private String modelo;
@Column(nullable = false)
private String ano;
@Column(nullable = false)
private String valor;
@Column(nullable = false)
private String diaRodizio;
private Boolean rodizioAtivo;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getIdProprietario() {
return idProprietario;
}
public void setIdProprietario(long idProprietario) {
this.idProprietario = idProprietario;
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public String getModelo() {
return modelo;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public String getAno() {
return ano;
}
public void setAno(String ano) {
this.ano = ano;
}
public String getValor() {
return valor;
}
public void setValor(String valor) {
this.valor = valor;
}
public String getDiaRodizio() {
return diaRodizio;
}
public void setDiaRodizio(String diaRodizio) {
this.diaRodizio = diaRodizio;
}
public Boolean getRodizioAtivo() {
return rodizioAtivo;
}
public void setRodizioAtivo(Boolean rodizioAtivo) {
this.rodizioAtivo = rodizioAtivo;
}
public Veiculo() {
}
public Veiculo(long id, long idProprietario, String marca, String modelo, String ano, String valor, String diaRodizio, Boolean rodizioAtivo) {
this.id = id;
this.idProprietario = idProprietario;
this.marca = marca;
this.modelo = modelo;
this.ano = ano;
this.valor = valor;
this.diaRodizio = diaRodizio;
this.rodizioAtivo = rodizioAtivo;
}
public Veiculo(VeiculoDTO veiculo) {
id = veiculo.getId();
idProprietario = veiculo.getIdProprietario();
marca = veiculo.getMarca();
modelo = veiculo.getModelo();
ano = veiculo.getAno();
valor = veiculo.getValor();
diaRodizio = veiculo.getDiaRodizio();
rodizioAtivo = veiculo.getRodizioAtivo();
}
}
| UTF-8 | Java | 2,654 | java | Veiculo.java | Java | [
{
"context": "package io.github.glaucials.controleveiculos.entity;\n\nimport io.github.glauci",
"end": 27,
"score": 0.9818745851516724,
"start": 18,
"tag": "USERNAME",
"value": "glaucials"
},
{
"context": "ucials.controleveiculos.entity;\n\nimport io.github.glaucials.controleveiculos... | null | [] | package io.github.glaucials.controleveiculos.entity;
import io.github.glaucials.controleveiculos.dto.VeiculoDTO;
import javax.persistence.*;
@Entity
@Table
public class Veiculo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable = false)
private long idProprietario;
@Column(nullable = false)
private String marca;
@Column(nullable = false)
private String modelo;
@Column(nullable = false)
private String ano;
@Column(nullable = false)
private String valor;
@Column(nullable = false)
private String diaRodizio;
private Boolean rodizioAtivo;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getIdProprietario() {
return idProprietario;
}
public void setIdProprietario(long idProprietario) {
this.idProprietario = idProprietario;
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public String getModelo() {
return modelo;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public String getAno() {
return ano;
}
public void setAno(String ano) {
this.ano = ano;
}
public String getValor() {
return valor;
}
public void setValor(String valor) {
this.valor = valor;
}
public String getDiaRodizio() {
return diaRodizio;
}
public void setDiaRodizio(String diaRodizio) {
this.diaRodizio = diaRodizio;
}
public Boolean getRodizioAtivo() {
return rodizioAtivo;
}
public void setRodizioAtivo(Boolean rodizioAtivo) {
this.rodizioAtivo = rodizioAtivo;
}
public Veiculo() {
}
public Veiculo(long id, long idProprietario, String marca, String modelo, String ano, String valor, String diaRodizio, Boolean rodizioAtivo) {
this.id = id;
this.idProprietario = idProprietario;
this.marca = marca;
this.modelo = modelo;
this.ano = ano;
this.valor = valor;
this.diaRodizio = diaRodizio;
this.rodizioAtivo = rodizioAtivo;
}
public Veiculo(VeiculoDTO veiculo) {
id = veiculo.getId();
idProprietario = veiculo.getIdProprietario();
marca = veiculo.getMarca();
modelo = veiculo.getModelo();
ano = veiculo.getAno();
valor = veiculo.getValor();
diaRodizio = veiculo.getDiaRodizio();
rodizioAtivo = veiculo.getRodizioAtivo();
}
}
| 2,654 | 0.622833 | 0.622833 | 123 | 20.577236 | 20.437098 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.406504 | false | false | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.