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
sequence | 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
sequence | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bff0b277227fd08f01dacb369b940bf6a8f697ce | 4,209,067,967,869 | 7af1e0e1542a01cba2f426e9a8db10f194bccb78 | /src/main/java/com/mitdbg/modeldb/databaseServices/MongoService.java | a6fe2b26ea81da1dff2644ed0322b72fc2cf8ba3 | [] | no_license | achalshant/modeldb-backend | https://github.com/achalshant/modeldb-backend | 3a7bc8d3aabf30b6f65bc9d4069b373e9c82c7a3 | d8db510173f87b10a5b10219cc8fffe77a0cb1ca | refs/heads/master | 2020-05-02T08:26:16.295000 | 2019-03-30T01:08:13 | 2019-03-30T01:08:13 | 177,842,882 | 0 | 0 | null | true | 2019-03-26T18:03:21 | 2019-03-26T18:03:20 | 2019-03-24T01:38:17 | 2019-03-24T01:38:15 | 108 | 0 | 0 | 0 | null | false | null | package com.mitdbg.modeldb.databaseServices;
import static com.mongodb.client.model.Filters.eq;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bson.Document;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageOrBuilder;
import com.mitdbg.modeldb.ModelDBConstants;
import com.mitdbg.modeldb.ModelDBUtils;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
public class MongoService implements DocumentService {
MongoDatabase database = null;
String TAG = this.getClass().getName();
private String collectionName = null;
public MongoService(MongoDatabase database) {
this.database = database;
}
/*
* Check availability of given collection name in database, if is not exist then create collection
* with given collection. This method called from each entity service Impl constructor.
*
* @param String collection
*/
@Override
public void checkCollectionAvailability(String collection) {
this.collectionName = collection;
Boolean availabilityStatus = false;
MongoIterable<String> collectionsNameList = this.database.listCollectionNames();
if (collectionsNameList != null) {
Iterator<String> iterator = collectionsNameList.iterator();
while (iterator.hasNext()) {
String collectionName = iterator.next();
if (collectionName.equals(collection)) {
availabilityStatus = true;
break;
}
}
}
if (!availabilityStatus || collectionsNameList == null) {
this.database.createCollection(collection);
}
}
/**
* Method convert Any ProtocolBuffer entity class to MongoDB Document object.
*
* @param object : is all ProtocolBuffer entity POJO.
* @return Document : is a MongoDB Object
* @throws InvalidProtocolBufferException
*/
private Document convertObjectToDocument(MessageOrBuilder object)
throws InvalidProtocolBufferException {
String json = ModelDBUtils.getStringFromProtoObject(object);
return Document.parse(json);
}
@Override
public void insertOne(MessageOrBuilder object) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = convertObjectToDocument(object);
collection.insertOne(document);
}
@Override
public void insertOne(Object object) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = (Document) object;
collection.insertOne(document);
}
@Override
public List<Document> find() {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find().into(new ArrayList<Document>());
}
@Override
public List<Document> findListByKey(
String key,
String value,
Integer pageNumber,
Integer pageLimit,
String order,
String sortBy) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryObj = new Document();
queryObj.put(key, value);
order = (order == null || order.isEmpty()) ? ModelDBConstants.ORDER_DESC : order;
sortBy = (sortBy == null || sortBy.isEmpty()) ? ModelDBConstants.DATE_CREATED : sortBy;
Document filter = new Document();
if (order.equalsIgnoreCase(ModelDBConstants.ORDER_ASC)) {
filter.append(sortBy, 1);
} else {
filter.append(sortBy, -1);
}
if (pageNumber == null || pageLimit == null) {
return collection.find(queryObj).sort(filter).into(new ArrayList<Document>());
}
// Calculate number of documents to skip
Integer skips = pageLimit * (pageNumber - 1);
return collection
.find(queryObj)
.skip(skips)
.limit(pageLimit)
.sort(filter)
.into(new ArrayList<Document>());
}
@Override
public Document findByKey(String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find(eq(key, value)).first();
}
@Override
public List<Document> findListByKey(String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find(eq(key, value)).into(new ArrayList<Document>());
}
@Override
public List<Document> findListByObject(
Object queryObj, Object projectionObj, Object sortObj, Integer recordLimit) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDoc = (Document) queryObj;
Document projectionDoc = new Document();
if (projectionObj != null) {
projectionDoc = (Document) projectionObj;
}
Document sortDoc = new Document();
if (sortObj != null) {
sortDoc = (Document) sortObj;
}
FindIterable<Document> documents =
collection.find(queryDoc).projection(projectionDoc).sort(sortDoc);
if (recordLimit != null) {
documents = documents.limit(recordLimit);
}
return documents.into(new ArrayList<Document>());
}
@Override
public List<Document> findListByAggregateObject(List<?> queryObj) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
List<Document> queryDoc = (List<Document>) queryObj;
return collection.aggregate(queryDoc).into(new ArrayList<Document>());
}
@Override
public Document findByObject(Object queryObj) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDoc = (Document) queryObj;
return collection.find(queryDoc).first();
}
@Override
public Boolean deleteOne(String collectionName, String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
DeleteResult deleteResult = collection.deleteOne(new Document(key, value));
return deleteResult.wasAcknowledged();
}
@Override
public long updateOne(String key, String value, MessageOrBuilder newObject)
throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = convertObjectToDocument(newObject);
UpdateResult updateResult =
collection.updateOne(eq(key, value), new Document("$set", document));
return updateResult.getModifiedCount();
}
@Override
public long updateOne(Object queryObj, Object updateObj) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDocument = (Document) queryObj;
Document updateDocument = (Document) updateObj;
UpdateResult updateResult = collection.updateOne(queryDocument, updateDocument);
return updateResult.getModifiedCount();
}
}
| UTF-8 | Java | 7,106 | java | MongoService.java | Java | [] | null | [] | package com.mitdbg.modeldb.databaseServices;
import static com.mongodb.client.model.Filters.eq;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bson.Document;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageOrBuilder;
import com.mitdbg.modeldb.ModelDBConstants;
import com.mitdbg.modeldb.ModelDBUtils;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
public class MongoService implements DocumentService {
MongoDatabase database = null;
String TAG = this.getClass().getName();
private String collectionName = null;
public MongoService(MongoDatabase database) {
this.database = database;
}
/*
* Check availability of given collection name in database, if is not exist then create collection
* with given collection. This method called from each entity service Impl constructor.
*
* @param String collection
*/
@Override
public void checkCollectionAvailability(String collection) {
this.collectionName = collection;
Boolean availabilityStatus = false;
MongoIterable<String> collectionsNameList = this.database.listCollectionNames();
if (collectionsNameList != null) {
Iterator<String> iterator = collectionsNameList.iterator();
while (iterator.hasNext()) {
String collectionName = iterator.next();
if (collectionName.equals(collection)) {
availabilityStatus = true;
break;
}
}
}
if (!availabilityStatus || collectionsNameList == null) {
this.database.createCollection(collection);
}
}
/**
* Method convert Any ProtocolBuffer entity class to MongoDB Document object.
*
* @param object : is all ProtocolBuffer entity POJO.
* @return Document : is a MongoDB Object
* @throws InvalidProtocolBufferException
*/
private Document convertObjectToDocument(MessageOrBuilder object)
throws InvalidProtocolBufferException {
String json = ModelDBUtils.getStringFromProtoObject(object);
return Document.parse(json);
}
@Override
public void insertOne(MessageOrBuilder object) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = convertObjectToDocument(object);
collection.insertOne(document);
}
@Override
public void insertOne(Object object) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = (Document) object;
collection.insertOne(document);
}
@Override
public List<Document> find() {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find().into(new ArrayList<Document>());
}
@Override
public List<Document> findListByKey(
String key,
String value,
Integer pageNumber,
Integer pageLimit,
String order,
String sortBy) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryObj = new Document();
queryObj.put(key, value);
order = (order == null || order.isEmpty()) ? ModelDBConstants.ORDER_DESC : order;
sortBy = (sortBy == null || sortBy.isEmpty()) ? ModelDBConstants.DATE_CREATED : sortBy;
Document filter = new Document();
if (order.equalsIgnoreCase(ModelDBConstants.ORDER_ASC)) {
filter.append(sortBy, 1);
} else {
filter.append(sortBy, -1);
}
if (pageNumber == null || pageLimit == null) {
return collection.find(queryObj).sort(filter).into(new ArrayList<Document>());
}
// Calculate number of documents to skip
Integer skips = pageLimit * (pageNumber - 1);
return collection
.find(queryObj)
.skip(skips)
.limit(pageLimit)
.sort(filter)
.into(new ArrayList<Document>());
}
@Override
public Document findByKey(String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find(eq(key, value)).first();
}
@Override
public List<Document> findListByKey(String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
return collection.find(eq(key, value)).into(new ArrayList<Document>());
}
@Override
public List<Document> findListByObject(
Object queryObj, Object projectionObj, Object sortObj, Integer recordLimit) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDoc = (Document) queryObj;
Document projectionDoc = new Document();
if (projectionObj != null) {
projectionDoc = (Document) projectionObj;
}
Document sortDoc = new Document();
if (sortObj != null) {
sortDoc = (Document) sortObj;
}
FindIterable<Document> documents =
collection.find(queryDoc).projection(projectionDoc).sort(sortDoc);
if (recordLimit != null) {
documents = documents.limit(recordLimit);
}
return documents.into(new ArrayList<Document>());
}
@Override
public List<Document> findListByAggregateObject(List<?> queryObj) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
List<Document> queryDoc = (List<Document>) queryObj;
return collection.aggregate(queryDoc).into(new ArrayList<Document>());
}
@Override
public Document findByObject(Object queryObj) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDoc = (Document) queryObj;
return collection.find(queryDoc).first();
}
@Override
public Boolean deleteOne(String collectionName, String key, String value) {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
DeleteResult deleteResult = collection.deleteOne(new Document(key, value));
return deleteResult.wasAcknowledged();
}
@Override
public long updateOne(String key, String value, MessageOrBuilder newObject)
throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document document = convertObjectToDocument(newObject);
UpdateResult updateResult =
collection.updateOne(eq(key, value), new Document("$set", document));
return updateResult.getModifiedCount();
}
@Override
public long updateOne(Object queryObj, Object updateObj) throws InvalidProtocolBufferException {
MongoCollection<Document> collection = this.database.getCollection(collectionName);
Document queryDocument = (Document) queryObj;
Document updateDocument = (Document) updateObj;
UpdateResult updateResult = collection.updateOne(queryDocument, updateDocument);
return updateResult.getModifiedCount();
}
}
| 7,106 | 0.731917 | 0.731494 | 203 | 34.004925 | 28.841591 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.561576 | false | false | 0 |
c29f6420838391095a60913ec99a2dd10d82f169 | 7,232,724,944,184 | 2120b55dd0cb005f38d0699f0bda21a5d756c91f | /jmeter-report-server/src/main/java/es/excentia/jmeter/report/server/testresults/ResettableStringWriter.java | e10ff69b272c5dbdb2a91c53545fcdf5070fcba0 | [] | no_license | drptbl/sonar-jmeter | https://github.com/drptbl/sonar-jmeter | 0fff55ad5cb10df22b79cbbfbafd2cd3c2c37e51 | c8d97cea0ef098396bbd92b5066244ad4dc2fed0 | refs/heads/master | 2021-01-18T11:08:01.591000 | 2015-08-11T16:05:24 | 2015-08-11T16:05:24 | 42,173,131 | 1 | 0 | null | true | 2015-09-09T10:53:32 | 2015-09-09T10:53:32 | 2015-09-09T10:53:26 | 2015-08-11T16:05:25 | 853 | 0 | 0 | 0 | null | null | null | /*
* JMeter Report Server
* Copyright (C) 2010 eXcentia
* dev@sonar.codehaus.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package es.excentia.jmeter.report.server.testresults;
import java.io.IOException;
import java.io.Writer;
/**
* A Writer that buffers the data in memory as a string. The buffer can be reset
* at any time and the contents of the buffer will be returned.
*/
public class ResettableStringWriter extends Writer {
/**
* The internal buffer used to store the data written to this stream.
*/
private StringBuilder mBuffer = new StringBuilder();
/**
* The maximum bytes this writer will buffer.
*/
private int mMaxBytes = 1024;
/**
* Constructs the writer which will hold a fixed maximum of bytes. If more
* bytes are written, an exception will be raised.
*
* @param maxBytes
* the maximum number of bytes this writer will buffer
*/
public ResettableStringWriter(int maxBytes) {
mMaxBytes = maxBytes;
}
@Override
public void close() throws IOException {
// no op
}
@Override
public void flush() throws IOException {
// no op
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
mBuffer.append(cbuf, off, len);
if (mBuffer.length() > mMaxBytes) {
throw new IOException("Memory buffer overflow");
}
}
/**
* Resets the stream to a length of zero. Any data written to the stream since
* the last call to reset will be returned.
*
* @return the contents of the stream buffer
*/
public String reset() {
String data = mBuffer.toString();
mBuffer.setLength(0);
return data;
}
} | UTF-8 | Java | 2,356 | java | ResettableStringWriter.java | Java | [
{
"context": "/*\n * JMeter Report Server\n * Copyright (C) 2010 eXcentia\n * dev@sonar.codehaus.org\n *\n * This program is f",
"end": 57,
"score": 0.9996554851531982,
"start": 49,
"tag": "USERNAME",
"value": "eXcentia"
},
{
"context": "er Report Server\n * Copyright (C) 2010 eXcentia\n * dev@sonar.codehaus.org\n *\n * This program is free software; you can redi",
"end": 83,
"score": 0.9999268651008606,
"start": 61,
"tag": "EMAIL",
"value": "dev@sonar.codehaus.org"
}
] | null | [] | /*
* JMeter Report Server
* Copyright (C) 2010 eXcentia
* <EMAIL>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package es.excentia.jmeter.report.server.testresults;
import java.io.IOException;
import java.io.Writer;
/**
* A Writer that buffers the data in memory as a string. The buffer can be reset
* at any time and the contents of the buffer will be returned.
*/
public class ResettableStringWriter extends Writer {
/**
* The internal buffer used to store the data written to this stream.
*/
private StringBuilder mBuffer = new StringBuilder();
/**
* The maximum bytes this writer will buffer.
*/
private int mMaxBytes = 1024;
/**
* Constructs the writer which will hold a fixed maximum of bytes. If more
* bytes are written, an exception will be raised.
*
* @param maxBytes
* the maximum number of bytes this writer will buffer
*/
public ResettableStringWriter(int maxBytes) {
mMaxBytes = maxBytes;
}
@Override
public void close() throws IOException {
// no op
}
@Override
public void flush() throws IOException {
// no op
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
mBuffer.append(cbuf, off, len);
if (mBuffer.length() > mMaxBytes) {
throw new IOException("Memory buffer overflow");
}
}
/**
* Resets the stream to a length of zero. Any data written to the stream since
* the last call to reset will be returned.
*
* @return the contents of the stream buffer
*/
public String reset() {
String data = mBuffer.toString();
mBuffer.setLength(0);
return data;
}
} | 2,341 | 0.697793 | 0.691851 | 83 | 27.397591 | 26.563831 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.337349 | false | false | 0 |
f583047972b30f28482e50d44680aa2bb9c007ba | 8,160,437,880,868 | 8cec49069bb217cf936e2af18ec58dc969f4a3ae | /msa-common/src/main/java/com/speeder/services/msa_common/models/base_data/Mobile.java | fbadfd1658650011e3d083b1c8a766657feec412 | [] | no_license | supeng911/Micro-Service-Architecture | https://github.com/supeng911/Micro-Service-Architecture | 274d09f18223b2799f0dc1c057123e234580d948 | 566ee30bb5785bb943d5791378a435c671b77726 | refs/heads/master | 2020-04-15T20:21:51.193000 | 2019-04-10T03:18:14 | 2019-04-10T03:18:14 | 164,990,119 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.speeder.services.msa_common.models.base_data;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class Mobile {
private Long id;
private Long uid;
private String code;
private String num;
private Timestamp updatedAt;
private Timestamp createdAt;
}
| UTF-8 | Java | 304 | java | Mobile.java | Java | [] | null | [] | package com.speeder.services.msa_common.models.base_data;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class Mobile {
private Long id;
private Long uid;
private String code;
private String num;
private Timestamp updatedAt;
private Timestamp createdAt;
}
| 304 | 0.713816 | 0.713816 | 23 | 12.217391 | 15.19999 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.391304 | false | false | 0 |
60d65eb715930707ccc21d5607e50c276793c438 | 3,908,420,255,442 | 918a874c69352206eb2d0ea562f5940ec4572e3c | /src/java/modelo/vo/Funciones.java | 23a4ec2be435110343387922b0a73174da2e498e | [] | no_license | MahnuelO/JavaImagen | https://github.com/MahnuelO/JavaImagen | fb3e1a9f4f72d78631db4bfa4a5cb5c39d48db58 | fd3e2a2022247c797ddd24cdb16a84d759716f3b | refs/heads/master | 2020-04-10T05:38:17.932000 | 2018-12-07T09:29:06 | 2018-12-07T09:29:06 | 160,833,440 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package modelo.vo;
public class Funciones {
private int id_funciones;
private int id_detalle_cargo;
private int id_cargo;
private int id_experiencia_laboral;
private int id_ocupacion;
private int tiempo;
public int getId_funciones() {
return id_funciones;
}
public void setId_funciones(int id_funciones) {
this.id_funciones = id_funciones;
}
public int getId_detalle_cargo() {
return id_detalle_cargo;
}
public void setId_detalle_cargo(int id_detalle_cargo) {
this.id_detalle_cargo = id_detalle_cargo;
}
public int getId_cargo() {
return id_cargo;
}
public void setId_cargo(int id_cargo) {
this.id_cargo = id_cargo;
}
public int getId_experiencia_laboral() {
return id_experiencia_laboral;
}
public void setId_experiencia_laboral(int id_experiencia_laboral) {
this.id_experiencia_laboral = id_experiencia_laboral;
}
public int getId_ocupacion() {
return id_ocupacion;
}
public void setId_ocupacion(int id_ocupacion) {
this.id_ocupacion = id_ocupacion;
}
public int getTiempo() {
return tiempo;
}
public void setTiempo(int tiempo) {
this.tiempo = tiempo;
}
}
| UTF-8 | Java | 1,361 | java | Funciones.java | Java | [] | null | [] | package modelo.vo;
public class Funciones {
private int id_funciones;
private int id_detalle_cargo;
private int id_cargo;
private int id_experiencia_laboral;
private int id_ocupacion;
private int tiempo;
public int getId_funciones() {
return id_funciones;
}
public void setId_funciones(int id_funciones) {
this.id_funciones = id_funciones;
}
public int getId_detalle_cargo() {
return id_detalle_cargo;
}
public void setId_detalle_cargo(int id_detalle_cargo) {
this.id_detalle_cargo = id_detalle_cargo;
}
public int getId_cargo() {
return id_cargo;
}
public void setId_cargo(int id_cargo) {
this.id_cargo = id_cargo;
}
public int getId_experiencia_laboral() {
return id_experiencia_laboral;
}
public void setId_experiencia_laboral(int id_experiencia_laboral) {
this.id_experiencia_laboral = id_experiencia_laboral;
}
public int getId_ocupacion() {
return id_ocupacion;
}
public void setId_ocupacion(int id_ocupacion) {
this.id_ocupacion = id_ocupacion;
}
public int getTiempo() {
return tiempo;
}
public void setTiempo(int tiempo) {
this.tiempo = tiempo;
}
}
| 1,361 | 0.592212 | 0.592212 | 60 | 20.683332 | 19.165501 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.316667 | false | false | 0 |
2bb99032c0a9b9462bc2e75ef2517ba81451bc21 | 12,446,815,238,688 | 08aebb6771a3c5f0ceded146774fb5593489ec17 | /ejbModule/bg/softuni/repository/UsersRepository.java | 41c1433589ae58955d1416913e4ae0e05fa1c38a | [] | no_license | kosio197/IpscCompetitionsEJB | https://github.com/kosio197/IpscCompetitionsEJB | 99a9593bb7b201898e59d1a5f570e0c4cee2320e | 4816fe97669ec704a7b5f6d1c7d0311eb324347e | refs/heads/master | 2020-12-24T11:46:11.931000 | 2017-12-31T21:24:42 | 2017-12-31T21:24:42 | 73,014,629 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bg.softuni.repository;
import java.util.List;
import javax.ejb.Local;
import bg.softuni.model.competition.Competition;
import bg.softuni.model.user.User;
@Local
public interface UsersRepository {
boolean usernameExists(String username);
boolean emailExists(String email);
void addUser(User user);
void editUser(User logetUser, User user);
void removeUser(String username);
void editUserRole(User user);
User getUser(String username);
List<User> getRegisteredCompetitors(Competition competition);
List<User> getAllUsers();
}
| UTF-8 | Java | 581 | java | UsersRepository.java | Java | [] | null | [] | package bg.softuni.repository;
import java.util.List;
import javax.ejb.Local;
import bg.softuni.model.competition.Competition;
import bg.softuni.model.user.User;
@Local
public interface UsersRepository {
boolean usernameExists(String username);
boolean emailExists(String email);
void addUser(User user);
void editUser(User logetUser, User user);
void removeUser(String username);
void editUserRole(User user);
User getUser(String username);
List<User> getRegisteredCompetitors(Competition competition);
List<User> getAllUsers();
}
| 581 | 0.746988 | 0.746988 | 30 | 18.366667 | 19.420752 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 0 |
a92a10308fc5efb616fef1057d5327ad40c8c9a3 | 21,871 | 46058529be3de9d3188bf1fbb9abe7185ce874b6 | /common/src/org/riotfamily/common/beans/override/MapMergeProcessor.java | 879e50b4f52e528716352418bd34669215b1d61c | [
"Apache-2.0"
] | permissive | evgeniy-fitsner/riot | https://github.com/evgeniy-fitsner/riot | 6d2cacb80f79cfdddf4d743d8390cbff15d1d881 | 1107e587af0e646599a5b5ed39f422ee524ac88a | refs/heads/9.1.x | 2021-01-12T21:28:56.337000 | 2014-07-17T07:39:38 | 2014-07-17T07:42:51 | 29,406,556 | 0 | 1 | null | true | 2015-01-17T21:38:48 | 2015-01-17T21:38:48 | 2015-01-17T10:31:10 | 2014-12-04T09:30:08 | 24,699 | 0 | 0 | 0 | null | null | null | /* 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.riotfamily.common.beans.override;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.MapFactoryBean;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.core.PriorityOrdered;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* @author Felix Gnass [fgnass at neteye dot de]
* @since 6.5
*/
public class MapMergeProcessor implements BeanFactoryPostProcessor, PriorityOrdered {
private Logger log = LoggerFactory.getLogger(MapMergeProcessor.class);
private String ref;
private String property;
private Map<?, ?> entries;
private int order = 1;
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
public void setRef(String ref) {
this.ref = ref;
}
public void setProperty(String property) {
this.property = property;
}
public void setEntries(Map<?, ?> entries) {
this.entries = entries;
}
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory)
throws BeansException {
BeanDefinition bd = beanFactory.getBeanDefinition(ref);
if (property == null) {
Assert.state(MapFactoryBean.class.getName().equals(bd.getBeanClassName()),
"Bean [" + ref + "] must be a MapFactoryBean");
property = "sourceMap";
}
if (log.isInfoEnabled()) {
String keys = StringUtils.collectionToCommaDelimitedString(entries.keySet());
log.debug("Adding [" + keys + "] to " + ref + "." + property);
}
PropertyValue pv = bd.getPropertyValues().getPropertyValue(property);
if (pv == null) {
// No map set on the target bean, create a new one ...
ManagedMap map = new ManagedMap();
map.putAll(entries);
bd.getPropertyValues().addPropertyValue(property, map);
}
else {
Object value = pv.getValue();
if (value instanceof RuntimeBeanReference) {
RuntimeBeanReference ref = (RuntimeBeanReference) value;
value = beanFactory.getBean(ref.getBeanName());
}
Assert.isInstanceOf(Map.class, value);
Map map = (Map) value;
map.putAll(entries);
}
}
}
| UTF-8 | Java | 3,125 | java | MapMergeProcessor.java | Java | [
{
"context": ".springframework.util.StringUtils;\n\n/**\n * @author Felix Gnass [fgnass at neteye dot de]\n * @since 6.5\n */\npubli",
"end": 1358,
"score": 0.9998771548271179,
"start": 1347,
"tag": "NAME",
"value": "Felix Gnass"
}
] | null | [] | /* 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.riotfamily.common.beans.override;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.MapFactoryBean;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.core.PriorityOrdered;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* @author <NAME> [fgnass at neteye dot de]
* @since 6.5
*/
public class MapMergeProcessor implements BeanFactoryPostProcessor, PriorityOrdered {
private Logger log = LoggerFactory.getLogger(MapMergeProcessor.class);
private String ref;
private String property;
private Map<?, ?> entries;
private int order = 1;
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
public void setRef(String ref) {
this.ref = ref;
}
public void setProperty(String property) {
this.property = property;
}
public void setEntries(Map<?, ?> entries) {
this.entries = entries;
}
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory)
throws BeansException {
BeanDefinition bd = beanFactory.getBeanDefinition(ref);
if (property == null) {
Assert.state(MapFactoryBean.class.getName().equals(bd.getBeanClassName()),
"Bean [" + ref + "] must be a MapFactoryBean");
property = "sourceMap";
}
if (log.isInfoEnabled()) {
String keys = StringUtils.collectionToCommaDelimitedString(entries.keySet());
log.debug("Adding [" + keys + "] to " + ref + "." + property);
}
PropertyValue pv = bd.getPropertyValues().getPropertyValue(property);
if (pv == null) {
// No map set on the target bean, create a new one ...
ManagedMap map = new ManagedMap();
map.putAll(entries);
bd.getPropertyValues().addPropertyValue(property, map);
}
else {
Object value = pv.getValue();
if (value instanceof RuntimeBeanReference) {
RuntimeBeanReference ref = (RuntimeBeanReference) value;
value = beanFactory.getBean(ref.getBeanName());
}
Assert.isInstanceOf(Map.class, value);
Map map = (Map) value;
map.putAll(entries);
}
}
}
| 3,120 | 0.74208 | 0.7392 | 102 | 29.637255 | 25.861921 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.705882 | false | false | 0 |
96a65d3ed1b82ee06cf020f9c6f0c522495b725e | 30,734,785,987,168 | eb40b0c7ca1b3020595e3c09db3e1f88a778d8aa | /src/main/java/com/zking/erp/basic/service/Impl/GoodsServiceImpl.java | e7508150ef3d13bc1b0330c4ebcc9b7ee24ef0dd | [] | no_license | libe8013/erp | https://github.com/libe8013/erp | d6ad64d39d66c542dde7ad941133e02ff79de537 | 490c2ff02364358d7209588b80bd42f1a9bed176 | refs/heads/master | 2020-04-11T12:51:38.817000 | 2019-01-02T18:27:12 | 2019-01-02T18:27:12 | 161,794,686 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zking.erp.basic.service.Impl;
import com.zking.erp.base.util.PageBean;
import com.zking.erp.basic.mapper.GoodsMapper;
import com.zking.erp.basic.model.Goods;
import com.zking.erp.basic.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsServiceImpl implements IGoodsService {
@Autowired
private GoodsMapper goodsMapper;
@Override
public int deleteByPrimaryKey(String uuid) {
return goodsMapper.deleteByPrimaryKey(uuid);
}
@Override
public int insert(Goods record) {
return goodsMapper.insert(record);
}
@Override
public int insertSelective(Goods record) {
return goodsMapper.insertSelective(record);
}
@Override
public Goods selectByPrimaryKey(String uuid) {
return goodsMapper.selectByPrimaryKey(uuid);
}
@Override
public int updateByPrimaryKeySelective(Goods record) {
return goodsMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(Goods record) {
return goodsMapper.updateByPrimaryKey(record);
}
@Override
public List<Goods> queryGoodsLikePager(Goods goods, PageBean pageBean) {
return goodsMapper.queryGoodsLikePager(goods);
}
}
| UTF-8 | Java | 1,370 | java | GoodsServiceImpl.java | Java | [] | null | [] | package com.zking.erp.basic.service.Impl;
import com.zking.erp.base.util.PageBean;
import com.zking.erp.basic.mapper.GoodsMapper;
import com.zking.erp.basic.model.Goods;
import com.zking.erp.basic.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsServiceImpl implements IGoodsService {
@Autowired
private GoodsMapper goodsMapper;
@Override
public int deleteByPrimaryKey(String uuid) {
return goodsMapper.deleteByPrimaryKey(uuid);
}
@Override
public int insert(Goods record) {
return goodsMapper.insert(record);
}
@Override
public int insertSelective(Goods record) {
return goodsMapper.insertSelective(record);
}
@Override
public Goods selectByPrimaryKey(String uuid) {
return goodsMapper.selectByPrimaryKey(uuid);
}
@Override
public int updateByPrimaryKeySelective(Goods record) {
return goodsMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(Goods record) {
return goodsMapper.updateByPrimaryKey(record);
}
@Override
public List<Goods> queryGoodsLikePager(Goods goods, PageBean pageBean) {
return goodsMapper.queryGoodsLikePager(goods);
}
}
| 1,370 | 0.732847 | 0.732847 | 52 | 25.346153 | 23.126646 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.326923 | false | false | 0 |
ec82878befad914706cf6c7be3de75e634458203 | 10,539,849,767,744 | 834c0aa4f565e3c51533819d96ead1ced151a62e | /src/main/java/com/hw/services/impl/BaseLotteryInfoServiceImpl.java | 2efd421415fd74528b87451a8f5500a899646bbd | [
"Apache-2.0"
] | permissive | ioplee/kuaile | https://github.com/ioplee/kuaile | 3e64b16b76675164d5d8acf3e0d4455469c12893 | f74111643b8a58cb9acc18565f1927fbd3a52bab | refs/heads/master | 2020-05-30T05:03:16.088000 | 2019-05-31T07:58:37 | 2019-05-31T07:58:37 | 189,552,462 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hw.services.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.hw.utils.BaseResultDTO;
import com.hw.utils.BatchResultDTO;
import com.hw.utils.ResultDTO;
import com.hw.dao.BaseLotteryInfoDAO;
import com.hw.bean.PO.BaseLotteryInfoPO;
import com.hw.bean.VO.BaseLotteryInfoVO;
import com.hw.bean.BO.QueryBaseLotteryInfoPage;
import com.hw.bean.BO.QueryBaseLotteryInfoByPrimaryKey;
import com.hw.services.BaseLotteryInfoService;
import java.util.ArrayList;
import java.util.List;
/**
* @author: Robin
* @create: 2019-05-10 00:12:49
* @description: 玩家福利列表 Service 实现类
**/
@Service
@Slf4j
@Transactional(rollbackFor = RuntimeException.class)
public class BaseLotteryInfoServiceImpl implements BaseLotteryInfoService{
@Autowired
private BaseLotteryInfoDAO baseLotteryInfoDAO;
@Override
public BaseResultDTO addBaseLotteryInfo(BaseLotteryInfoPO baseLotteryInfoPO){
BaseResultDTO addResultDTO = new BaseResultDTO();
try{
Integer number = baseLotteryInfoDAO.insertBaseLotteryInfo(baseLotteryInfoPO);
if(number == 1){
addResultDTO.setResultCode("1");
addResultDTO.setSuccess(true);
}else{
addResultDTO.setErrorDetail("添加玩家福利列表信息失败");
addResultDTO.setSuccess(true);
addResultDTO.setResultCode("0");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called addBaseLotteryInfo error#",e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
addResultDTO.setResultCode("0");
addResultDTO.setSuccess(false);
addResultDTO.setErrorDetail("添加玩家福利列表出错");
}
return addResultDTO;
}
@Override
public BaseResultDTO modifyBaseLotteryInfo(BaseLotteryInfoPO baseLotteryInfoPO){
BaseResultDTO modifyResultDTO = new BaseResultDTO();
try{
Integer number = baseLotteryInfoDAO.updateBaseLotteryInfo(baseLotteryInfoPO);
if(number == 1){
modifyResultDTO.setResultCode("1");
modifyResultDTO.setSuccess(true);
}else{
modifyResultDTO.setErrorDetail("修改玩家福利列表信息失败");
modifyResultDTO.setSuccess(true);
modifyResultDTO.setResultCode("0");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called modifyBaseLotteryInfo error#",e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
modifyResultDTO.setResultCode("0");
modifyResultDTO.setSuccess(false);
modifyResultDTO.setErrorDetail("修改玩家福利列表出错");
}
return modifyResultDTO;
}
@Override
public BatchResultDTO<BaseLotteryInfoVO> getBaseLotteryInfoList(QueryBaseLotteryInfoPage queryBaseLotteryInfoPage){
BatchResultDTO<BaseLotteryInfoVO> resultDTO = new BatchResultDTO<BaseLotteryInfoVO>();
try{
Integer record = baseLotteryInfoDAO.getPageCount(queryBaseLotteryInfoPage);
queryBaseLotteryInfoPage.setRecord(record);
resultDTO.setRecord(record);
if (queryBaseLotteryInfoPage.getPageNo() > queryBaseLotteryInfoPage.getTotalPages()){
resultDTO.setErrorDetail("获取玩家福利列表列表失败,参悟有误.");
resultDTO.setResultCode("0");
resultDTO.setSuccess(true);
resultDTO.setModule(new ArrayList<>());
resultDTO.setRecord(0);
}
List<BaseLotteryInfoVO> module = baseLotteryInfoDAO.getPageList(queryBaseLotteryInfoPage);
resultDTO.setResultCode("1");
resultDTO.setSuccess(true);
if (null != module && !module.isEmpty()){
resultDTO.setModule(module);
}else {
resultDTO.setModule(new ArrayList<>());
}
}catch(Exception e){
log.error("#BaseLotteryInfoServiceImpl called getBaseLotteryInfoList error#",e);
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表列表失败");
resultDTO.setModule(new ArrayList<>());
resultDTO.setRecord(0);
}
return resultDTO;
}
@Override
public ResultDTO<BaseLotteryInfoVO> getbaseLotteryInfo(QueryBaseLotteryInfoByPrimaryKey queryBaseLotteryInfoByPrimaryKey){
ResultDTO<BaseLotteryInfoVO> resultDTO = new ResultDTO<BaseLotteryInfoVO>();
try{
BaseLotteryInfoVO baseLotteryInfoVO = baseLotteryInfoDAO.getBaseLotteryInfoByPrimaryKey(queryBaseLotteryInfoByPrimaryKey.getLotteryId());
if(null != baseLotteryInfoVO){
resultDTO.setResultCode("1");
resultDTO.setSuccess(true);
resultDTO.setModule(baseLotteryInfoVO);
}else{
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表对象失败");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called getBaseLotteryInfo error#",e);
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表对象失败");
}
return resultDTO;
}
}
| UTF-8 | Java | 5,837 | java | BaseLotteryInfoServiceImpl.java | Java | [
{
"context": ".ArrayList;\nimport java.util.List;\n\n/**\n* @author: Robin\n* @create: 2019-05-10 00:12:49\n* @description: 玩家",
"end": 765,
"score": 0.9855389595031738,
"start": 760,
"tag": "NAME",
"value": "Robin"
}
] | null | [] | package com.hw.services.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.hw.utils.BaseResultDTO;
import com.hw.utils.BatchResultDTO;
import com.hw.utils.ResultDTO;
import com.hw.dao.BaseLotteryInfoDAO;
import com.hw.bean.PO.BaseLotteryInfoPO;
import com.hw.bean.VO.BaseLotteryInfoVO;
import com.hw.bean.BO.QueryBaseLotteryInfoPage;
import com.hw.bean.BO.QueryBaseLotteryInfoByPrimaryKey;
import com.hw.services.BaseLotteryInfoService;
import java.util.ArrayList;
import java.util.List;
/**
* @author: Robin
* @create: 2019-05-10 00:12:49
* @description: 玩家福利列表 Service 实现类
**/
@Service
@Slf4j
@Transactional(rollbackFor = RuntimeException.class)
public class BaseLotteryInfoServiceImpl implements BaseLotteryInfoService{
@Autowired
private BaseLotteryInfoDAO baseLotteryInfoDAO;
@Override
public BaseResultDTO addBaseLotteryInfo(BaseLotteryInfoPO baseLotteryInfoPO){
BaseResultDTO addResultDTO = new BaseResultDTO();
try{
Integer number = baseLotteryInfoDAO.insertBaseLotteryInfo(baseLotteryInfoPO);
if(number == 1){
addResultDTO.setResultCode("1");
addResultDTO.setSuccess(true);
}else{
addResultDTO.setErrorDetail("添加玩家福利列表信息失败");
addResultDTO.setSuccess(true);
addResultDTO.setResultCode("0");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called addBaseLotteryInfo error#",e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
addResultDTO.setResultCode("0");
addResultDTO.setSuccess(false);
addResultDTO.setErrorDetail("添加玩家福利列表出错");
}
return addResultDTO;
}
@Override
public BaseResultDTO modifyBaseLotteryInfo(BaseLotteryInfoPO baseLotteryInfoPO){
BaseResultDTO modifyResultDTO = new BaseResultDTO();
try{
Integer number = baseLotteryInfoDAO.updateBaseLotteryInfo(baseLotteryInfoPO);
if(number == 1){
modifyResultDTO.setResultCode("1");
modifyResultDTO.setSuccess(true);
}else{
modifyResultDTO.setErrorDetail("修改玩家福利列表信息失败");
modifyResultDTO.setSuccess(true);
modifyResultDTO.setResultCode("0");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called modifyBaseLotteryInfo error#",e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
modifyResultDTO.setResultCode("0");
modifyResultDTO.setSuccess(false);
modifyResultDTO.setErrorDetail("修改玩家福利列表出错");
}
return modifyResultDTO;
}
@Override
public BatchResultDTO<BaseLotteryInfoVO> getBaseLotteryInfoList(QueryBaseLotteryInfoPage queryBaseLotteryInfoPage){
BatchResultDTO<BaseLotteryInfoVO> resultDTO = new BatchResultDTO<BaseLotteryInfoVO>();
try{
Integer record = baseLotteryInfoDAO.getPageCount(queryBaseLotteryInfoPage);
queryBaseLotteryInfoPage.setRecord(record);
resultDTO.setRecord(record);
if (queryBaseLotteryInfoPage.getPageNo() > queryBaseLotteryInfoPage.getTotalPages()){
resultDTO.setErrorDetail("获取玩家福利列表列表失败,参悟有误.");
resultDTO.setResultCode("0");
resultDTO.setSuccess(true);
resultDTO.setModule(new ArrayList<>());
resultDTO.setRecord(0);
}
List<BaseLotteryInfoVO> module = baseLotteryInfoDAO.getPageList(queryBaseLotteryInfoPage);
resultDTO.setResultCode("1");
resultDTO.setSuccess(true);
if (null != module && !module.isEmpty()){
resultDTO.setModule(module);
}else {
resultDTO.setModule(new ArrayList<>());
}
}catch(Exception e){
log.error("#BaseLotteryInfoServiceImpl called getBaseLotteryInfoList error#",e);
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表列表失败");
resultDTO.setModule(new ArrayList<>());
resultDTO.setRecord(0);
}
return resultDTO;
}
@Override
public ResultDTO<BaseLotteryInfoVO> getbaseLotteryInfo(QueryBaseLotteryInfoByPrimaryKey queryBaseLotteryInfoByPrimaryKey){
ResultDTO<BaseLotteryInfoVO> resultDTO = new ResultDTO<BaseLotteryInfoVO>();
try{
BaseLotteryInfoVO baseLotteryInfoVO = baseLotteryInfoDAO.getBaseLotteryInfoByPrimaryKey(queryBaseLotteryInfoByPrimaryKey.getLotteryId());
if(null != baseLotteryInfoVO){
resultDTO.setResultCode("1");
resultDTO.setSuccess(true);
resultDTO.setModule(baseLotteryInfoVO);
}else{
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表对象失败");
}
}catch (Exception e){
log.error("#BaseLotteryInfoServiceImpl called getBaseLotteryInfo error#",e);
resultDTO.setResultCode("0");
resultDTO.setSuccess(false);
resultDTO.setErrorDetail("获取玩家福利列表对象失败");
}
return resultDTO;
}
}
| 5,837 | 0.665186 | 0.659321 | 139 | 39.482014 | 29.453379 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.597122 | false | false | 0 |
9d0fa5e2e5e79f3635c61d1e91a5a9bb3cd23513 | 32,813,550,158,543 | b92a009041cee3b0dd615ee9b94daade0379bd6d | /athena-executor/src/main/java/com/ccb/athena/executor/scheduler/counter/Counter.java | 60a94459e4381affdc5ecff78950902c86100ef7 | [] | no_license | pandong912/athena | https://github.com/pandong912/athena | 9c847ad56a9724e505b1d67bdd17bbfbbf2d5d6d | a308506074dcc1ce8f4134440ba1ab5180877631 | refs/heads/master | 2021-01-12T03:56:47.949000 | 2017-02-08T07:09:21 | 2017-02-08T07:09:21 | 81,299,721 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ccb.athena.executor.scheduler.counter;
public interface Counter {
void increase(String key);
void decrease(String key);
int sum(String key);
}
| UTF-8 | Java | 164 | java | Counter.java | Java | [] | null | [] | package com.ccb.athena.executor.scheduler.counter;
public interface Counter {
void increase(String key);
void decrease(String key);
int sum(String key);
}
| 164 | 0.743902 | 0.743902 | 10 | 15.4 | 16.451139 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.9 | false | false | 0 |
044f227cb25b5c31245f38b0f7e2b303b5b85e67 | 20,426,864,478,687 | ba1512f6fe865d49f2c1267faeaa4c07f2dae2e6 | /test/unit/com/google/enterprise/connector/util/filter/DeletePropertyFilterTest.java | b30602c22b823cb36027841c499833dd9a4cd549 | [] | no_license | lizunmvn/google-connector-manager | https://github.com/lizunmvn/google-connector-manager | 971af9be14ab7613fe25e85f3143ae74883a2f9b | b6adcd4aee552459d27ee847a6003d55622aa3db | refs/heads/master | 2017-04-24T20:40:15.144000 | 2013-02-01T16:21:51 | 2013-02-01T16:21:51 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.enterprise.connector.util.filter;
import com.google.enterprise.connector.spi.Document;
import com.google.enterprise.connector.spi.Value;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
/**
* Tests DeletePropertyFilter.
*/
public class DeletePropertyFilterTest extends DocumentFilterTest {
/** Creates a DeletePropertyFilter. */
protected Document createFilter() {
HashSet<String> deletes = new HashSet<String>();
deletes.add(PROP1);
deletes.add(PROP3);
return createFilter(deletes);
}
protected Document createFilter(Set<String>deletes) {
DeletePropertyFilter factory = new DeletePropertyFilter();
factory.setPropertyNames(deletes);
return factory.newDocumentFilter(createDocument());
}
/** Tests the Factory constructor with illegal arguments. */
public void testFactoryIllegalArgs() throws Exception {
DeletePropertyFilter factory = new DeletePropertyFilter();
try {
factory.setPropertyName(null);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException expected) {
// Expected.
}
try {
factory.setPropertyName("");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException expected) {
// Expected.
}
try {
factory.setPropertyNames((Set<String>) null);
fail("NullPointerException expected");
} catch (NullPointerException expected) {
// Expected.
}
}
/** Tests illegal state if configuration setters are not called. */
public void testFactoryIllegalState() throws Exception {
checkIllegalState(new DeletePropertyFilter());
}
/** Tests for non-existent property should return null. */
public void testNonExistentProperty() throws Exception {
HashSet<String>deletes = new HashSet<String>();
deletes.add("foo");
Document filter = createFilter(deletes);
assertNull(filter.findProperty("foo"));
assertNull(filter.findProperty("nonExistentProperty"));
}
/** Test deletes do not show up in the property names. */
public void testDeletedNotInPropertyNames() throws Exception {
Document filter = createFilter();
Set<String> names = filter.getPropertyNames();
assertFalse(names.contains(PROP1));
assertFalse(names.contains(PROP3));
// Make sure all the remaining properties are there.
Set<String> origNames = new HashSet<String>(createProperties().keySet());
origNames.remove(PROP1);
origNames.remove(PROP3);
assertTrue(names.containsAll(origNames));
}
/** Test the remaining property values should not be modified. */
public void testNonDeletedProperties() throws Exception {
Map<String, List<Value>> expectedProps = createProperties();
expectedProps.remove(PROP1);
expectedProps.remove(PROP3);
checkDocument(createFilter(), expectedProps);
}
/** Test toString(). */
public void testToString() {
DeletePropertyFilter factory = new DeletePropertyFilter();
factory.setPropertyName("foo");
assertEquals("DeletePropertyFilter: [foo]", factory.toString());
}
}
| UTF-8 | Java | 3,750 | java | DeletePropertyFilterTest.java | Java | [] | null | [] | // Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.enterprise.connector.util.filter;
import com.google.enterprise.connector.spi.Document;
import com.google.enterprise.connector.spi.Value;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
/**
* Tests DeletePropertyFilter.
*/
public class DeletePropertyFilterTest extends DocumentFilterTest {
/** Creates a DeletePropertyFilter. */
protected Document createFilter() {
HashSet<String> deletes = new HashSet<String>();
deletes.add(PROP1);
deletes.add(PROP3);
return createFilter(deletes);
}
protected Document createFilter(Set<String>deletes) {
DeletePropertyFilter factory = new DeletePropertyFilter();
factory.setPropertyNames(deletes);
return factory.newDocumentFilter(createDocument());
}
/** Tests the Factory constructor with illegal arguments. */
public void testFactoryIllegalArgs() throws Exception {
DeletePropertyFilter factory = new DeletePropertyFilter();
try {
factory.setPropertyName(null);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException expected) {
// Expected.
}
try {
factory.setPropertyName("");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException expected) {
// Expected.
}
try {
factory.setPropertyNames((Set<String>) null);
fail("NullPointerException expected");
} catch (NullPointerException expected) {
// Expected.
}
}
/** Tests illegal state if configuration setters are not called. */
public void testFactoryIllegalState() throws Exception {
checkIllegalState(new DeletePropertyFilter());
}
/** Tests for non-existent property should return null. */
public void testNonExistentProperty() throws Exception {
HashSet<String>deletes = new HashSet<String>();
deletes.add("foo");
Document filter = createFilter(deletes);
assertNull(filter.findProperty("foo"));
assertNull(filter.findProperty("nonExistentProperty"));
}
/** Test deletes do not show up in the property names. */
public void testDeletedNotInPropertyNames() throws Exception {
Document filter = createFilter();
Set<String> names = filter.getPropertyNames();
assertFalse(names.contains(PROP1));
assertFalse(names.contains(PROP3));
// Make sure all the remaining properties are there.
Set<String> origNames = new HashSet<String>(createProperties().keySet());
origNames.remove(PROP1);
origNames.remove(PROP3);
assertTrue(names.containsAll(origNames));
}
/** Test the remaining property values should not be modified. */
public void testNonDeletedProperties() throws Exception {
Map<String, List<Value>> expectedProps = createProperties();
expectedProps.remove(PROP1);
expectedProps.remove(PROP3);
checkDocument(createFilter(), expectedProps);
}
/** Test toString(). */
public void testToString() {
DeletePropertyFilter factory = new DeletePropertyFilter();
factory.setPropertyName("foo");
assertEquals("DeletePropertyFilter: [foo]", factory.toString());
}
}
| 3,750 | 0.722667 | 0.7184 | 114 | 31.894737 | 24.418633 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.447368 | false | false | 0 |
5067dadcf2c462e6da24e9e9dae2ddc82572a917 | 33,105,607,938,091 | 387a65c018915b1f2b771aaf3a83257f44b2e1a9 | /AlgoEx/src/ShortestPathVisitingAllNodes.java | 69686bcb052a5778584d1a62df1dae2ec9633d76 | [] | no_license | zhwcris/AlgorithmEx | https://github.com/zhwcris/AlgorithmEx | fe00fe6c910f3108ab105459da3a180286950eda | 531104f61c3b98c09afbc1d49ce0d525c0e74fae | refs/heads/master | 2023-08-25T02:54:05.586000 | 2021-10-03T23:49:05 | 2021-10-03T23:49:05 | 111,509,124 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
public class ShortestPathVisitingAllNodes {
public int shortestPathLength(int[][] graph) {//bfs
int N = graph.length, mask = 1, count = 0;
Set<String> set = new HashSet<>();
Queue<int[]> q = new LinkedList<>();
for (int i = 0; i < N; i++) {
mask |= (1 << i);
int[] make = new int[] {(1<<i),i};
set.add(make[0] + "+" + make[1]);
q.offer(make);
}
while (true) {
int len = q.size();
for (int i = 0; i < len; i++) {
int[] curr = q.poll();
if (curr[0] == mask) return count;
for (int next : graph[curr[1]]) {
int nextPath = curr[0] | (1 << next);
if (!set.add(nextPath + "+" + next)) continue;
q.offer(new int[]{nextPath,next});
}
}
count++;
}
}
}
/** c++ version bfs使用数组代表当前状态 i代表访问到第一个节点, vis二进制数据代表哪些节点访问过了
*
* struct State {
* int node;
* int vis;
* int step;
*
* State(int node, int vis, int step):node(node), vis(vis), step(step) {}
* };
*
* class Solution {
* private:
* public:
* int shortestPathLength(vector<vector<int>>& graph) {
* int n = graph.size();
*
* queue<State> q;
* vector<vector<bool>> vis(n, vector<bool>(1 << n, false));
*
* for (int i = 0; i < n; ++i) {
* q.push(State(i, 1 << i, 0));
* vis[i][1 << i] = true;
* }
*
* int res = -1;
* while (!q.empty()) {
* State s = q.front();
* q.pop();
*
* if (s.vis == ((1 << n) - 1)) {
* res = s.step;
* break;
* }
*
* for (int next : graph[s.node]) {
* int nvis = s.vis | (1 << next);
* if (!vis[next][nvis]) {
* q.push(State(next, nvis, s.step + 1));
* vis[next][nvis] = true;
* }
* }
* }
*
* return res;
* }
* };
*/
| UTF-8 | Java | 2,296 | java | ShortestPathVisitingAllNodes.java | Java | [] | null | [] | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
public class ShortestPathVisitingAllNodes {
public int shortestPathLength(int[][] graph) {//bfs
int N = graph.length, mask = 1, count = 0;
Set<String> set = new HashSet<>();
Queue<int[]> q = new LinkedList<>();
for (int i = 0; i < N; i++) {
mask |= (1 << i);
int[] make = new int[] {(1<<i),i};
set.add(make[0] + "+" + make[1]);
q.offer(make);
}
while (true) {
int len = q.size();
for (int i = 0; i < len; i++) {
int[] curr = q.poll();
if (curr[0] == mask) return count;
for (int next : graph[curr[1]]) {
int nextPath = curr[0] | (1 << next);
if (!set.add(nextPath + "+" + next)) continue;
q.offer(new int[]{nextPath,next});
}
}
count++;
}
}
}
/** c++ version bfs使用数组代表当前状态 i代表访问到第一个节点, vis二进制数据代表哪些节点访问过了
*
* struct State {
* int node;
* int vis;
* int step;
*
* State(int node, int vis, int step):node(node), vis(vis), step(step) {}
* };
*
* class Solution {
* private:
* public:
* int shortestPathLength(vector<vector<int>>& graph) {
* int n = graph.size();
*
* queue<State> q;
* vector<vector<bool>> vis(n, vector<bool>(1 << n, false));
*
* for (int i = 0; i < n; ++i) {
* q.push(State(i, 1 << i, 0));
* vis[i][1 << i] = true;
* }
*
* int res = -1;
* while (!q.empty()) {
* State s = q.front();
* q.pop();
*
* if (s.vis == ((1 << n) - 1)) {
* res = s.step;
* break;
* }
*
* for (int next : graph[s.node]) {
* int nvis = s.vis | (1 << next);
* if (!vis[next][nvis]) {
* q.push(State(next, nvis, s.step + 1));
* vis[next][nvis] = true;
* }
* }
* }
*
* return res;
* }
* };
*/
| 2,296 | 0.402878 | 0.392986 | 79 | 27.151899 | 19.710621 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.759494 | false | false | 0 |
ed3033d1b924aff44f182606b5cf2f6cde4e9995 | 13,529,147,005,680 | ccdfac45bfb4c6f9eafc720d126d4f4585e640df | /myris/core/src/dot/empire/myris/Settings.java | 3165d1da8d82f704052fe545a4c119e697e34839 | [
"MIT",
"CC-BY-4.0"
] | permissive | Blunderchips/myris | https://github.com/Blunderchips/myris | 8ba308f32ad02f9f096de5950172da85b677978e | d7014714b41e41deedd5e1e10e163f84d876ee1e | refs/heads/master | 2020-04-05T05:39:45.456000 | 2018-12-31T12:00:53 | 2018-12-31T12:00:53 | 156,605,074 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dot.empire.myris;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import dot.empire.myris.gfx.ScoreLabel;
import java.util.Locale;
/**
* General settings and preferences. Created 16/11/2018.
*
* @author Matthew 'siD' Van der Bijl
* @see com.badlogic.gdx.Preferences
*/
public final class Settings {
/**
* Location of brightness setting value in preference map (float).
*/
private static final String BRIGHTNESS = "brightness";
/**
* Location of brightness setting value in preference map (float).
*/
private static final String CONTRAST = "contrast";
/**
* Location of brightness setting value in preference map (bool).
*/
private static final String IS_MUTED = "muted";
/**
* Location of high score in preference map (long).
*/
private static final String HIGH_SCORE = "high_score";
/**
* Preference map.
*/
private final Preferences preferences;
public Settings() {
this.preferences = Gdx.app.getPreferences(Myris.TAG);
}
/**
* @return overall brightness setting
* @see dot.empire.myris.gfx.ShaderBatch
*/
public float getBrightness() {
return preferences.getFloat(BRIGHTNESS, 0);
}
public void setBrightness(float brightness) {
this.preferences.putFloat(BRIGHTNESS, brightness);
this.preferences.flush();
}
/**
* @return overall contrast setting
* @see dot.empire.myris.gfx.ShaderBatch
*/
public float getContrast() {
return preferences.getFloat(CONTRAST, 1);
}
public void setContrast(float contrast) {
this.preferences.putFloat(CONTRAST, contrast);
this.preferences.flush();
}
/**
* @return whether all sounds should be muted or not
*/
public boolean isMuted() {
return preferences.getBoolean(IS_MUTED, false);
}
public void setIsMuted(boolean isMuted) {
Gdx.app.debug(Myris.TAG, "Muted = " + isMuted);
this.preferences.putBoolean(IS_MUTED, isMuted);
this.preferences.flush();
}
/**
* @return user's high score
*/
public long getHighScore() {
return this.preferences.getLong(HIGH_SCORE, 0);
}
/**
* @param score in-game score
* @see #setHighScore(long)
*/
public void setHighScore(ScoreLabel score) {
this.setHighScore(score.getScore());
}
public void setHighScore(long score) {
final long current = getHighScore(); // current high score saved
if (current >= score && score != -1) {
Gdx.app.log(Myris.TAG, String.format(Locale.ENGLISH, "Highscore not set (%s > %s)",
Long.toString(current), Long.toString(score)));
} else {
Gdx.app.log(Myris.TAG, String.format(Locale.ENGLISH, "Highscore set (%s)", Long.toString(score)));
this.preferences.putLong(HIGH_SCORE, score == -1 ? 0 : score);
this.preferences.flush();
}
}
}
| UTF-8 | Java | 3,029 | java | Settings.java | Java | [
{
"context": "and preferences. Created 16/11/2018.\n *\n * @author Matthew 'siD' Van der Bijl\n * @see com.badlogic.gdx.Prefe",
"end": 242,
"score": 0.999807596206665,
"start": 235,
"tag": "NAME",
"value": "Matthew"
},
{
"context": "ences. Created 16/11/2018.\n *\n * @author Matthew 'siD' Van der Bijl\n * @see com.badlogic.gdx.Preference",
"end": 247,
"score": 0.9992325901985168,
"start": 244,
"tag": "USERNAME",
"value": "siD"
},
{
"context": "s. Created 16/11/2018.\n *\n * @author Matthew 'siD' Van der Bijl\n * @see com.badlogic.gdx.Preferences\n */\npublic f",
"end": 261,
"score": 0.9998141527175903,
"start": 249,
"tag": "NAME",
"value": "Van der Bijl"
}
] | null | [] | package dot.empire.myris;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import dot.empire.myris.gfx.ScoreLabel;
import java.util.Locale;
/**
* General settings and preferences. Created 16/11/2018.
*
* @author Matthew 'siD' <NAME>
* @see com.badlogic.gdx.Preferences
*/
public final class Settings {
/**
* Location of brightness setting value in preference map (float).
*/
private static final String BRIGHTNESS = "brightness";
/**
* Location of brightness setting value in preference map (float).
*/
private static final String CONTRAST = "contrast";
/**
* Location of brightness setting value in preference map (bool).
*/
private static final String IS_MUTED = "muted";
/**
* Location of high score in preference map (long).
*/
private static final String HIGH_SCORE = "high_score";
/**
* Preference map.
*/
private final Preferences preferences;
public Settings() {
this.preferences = Gdx.app.getPreferences(Myris.TAG);
}
/**
* @return overall brightness setting
* @see dot.empire.myris.gfx.ShaderBatch
*/
public float getBrightness() {
return preferences.getFloat(BRIGHTNESS, 0);
}
public void setBrightness(float brightness) {
this.preferences.putFloat(BRIGHTNESS, brightness);
this.preferences.flush();
}
/**
* @return overall contrast setting
* @see dot.empire.myris.gfx.ShaderBatch
*/
public float getContrast() {
return preferences.getFloat(CONTRAST, 1);
}
public void setContrast(float contrast) {
this.preferences.putFloat(CONTRAST, contrast);
this.preferences.flush();
}
/**
* @return whether all sounds should be muted or not
*/
public boolean isMuted() {
return preferences.getBoolean(IS_MUTED, false);
}
public void setIsMuted(boolean isMuted) {
Gdx.app.debug(Myris.TAG, "Muted = " + isMuted);
this.preferences.putBoolean(IS_MUTED, isMuted);
this.preferences.flush();
}
/**
* @return user's high score
*/
public long getHighScore() {
return this.preferences.getLong(HIGH_SCORE, 0);
}
/**
* @param score in-game score
* @see #setHighScore(long)
*/
public void setHighScore(ScoreLabel score) {
this.setHighScore(score.getScore());
}
public void setHighScore(long score) {
final long current = getHighScore(); // current high score saved
if (current >= score && score != -1) {
Gdx.app.log(Myris.TAG, String.format(Locale.ENGLISH, "Highscore not set (%s > %s)",
Long.toString(current), Long.toString(score)));
} else {
Gdx.app.log(Myris.TAG, String.format(Locale.ENGLISH, "Highscore set (%s)", Long.toString(score)));
this.preferences.putLong(HIGH_SCORE, score == -1 ? 0 : score);
this.preferences.flush();
}
}
}
| 3,023 | 0.621327 | 0.616705 | 109 | 26.78899 | 24.864799 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.40367 | false | false | 0 |
7134cbea922607df50fa5c85122ba200adedf4b5 | 3,633,542,349,022 | 8c59146063417a9b28e3197c516d1aca4b89a786 | /src/String/IsRotation.java | 3bef2f8ab0c7ad33452b8b240446ef30f3f0aa42 | [] | no_license | yafeites/code | https://github.com/yafeites/code | 2218b5a0251981c5fe6c355a6facb3fad3a42854 | ba966939b6615ddecb8332abd0f9b6cd5c854d7b | refs/heads/master | 2020-09-02T14:27:29.365000 | 2020-05-07T12:17:18 | 2020-05-07T12:17:18 | 219,241,083 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package String;
public class IsRotation {
public static boolean isRotation(String s1,String s2)
{
if(s1.length()!=s2.length())
{
return false;
}
s1=s1+s1;
if(s1.contains(s2))
{
return true;
}
return false;
}
}
| UTF-8 | Java | 313 | java | IsRotation.java | Java | [] | null | [] | package String;
public class IsRotation {
public static boolean isRotation(String s1,String s2)
{
if(s1.length()!=s2.length())
{
return false;
}
s1=s1+s1;
if(s1.contains(s2))
{
return true;
}
return false;
}
}
| 313 | 0.476038 | 0.447284 | 17 | 17.411764 | 14.229459 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false | 0 |
0c4410eadd29af1b5615593ff8b7ba7e5b76bf1e | 19,585,050,888,915 | d50c18ed3da75b019de0ce39ba5a021aa10c4f0a | /ALGORITHM.java | 6fce1253a0e1bfcdea321b17d8427766c252aba0 | [] | no_license | compstki/letterCount | https://github.com/compstki/letterCount | ccc29c91fd19e16472097bb2f8480cc3ea27665e | 5e27af746d102f976020a2863f687509e421686c | refs/heads/master | 2021-01-10T13:09:18.553000 | 2016-09-15T20:53:03 | 2016-09-15T20:53:03 | 43,682,142 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import javax.swing.JOptionPane;
public class ALGORITHM
{
// declare an array which can store DATA objects
private DATA[] dataList;
// constructor
public ALGORITHM()
{
// set the size of the array
dataList = new DATA[200];
}
// populate the array with DATA objects
public void setUpDataList()
{
for (int i=0; i<200; i++) {
//create a new DATA object and store in next array position
dataList[i] = new DATA();
System.out.print(dataList[i].getData());
}
System.out.println();
}
// standard algorithm to find smallest value, tracking position of value
public void findMinData()
{
// choose position of first value
int minDataPosition = 0;
// repeat for the rest of the array
for (int i=1; i<200; i++) {
//compare current value with best value
if (dataList[i].getData() < dataList[minDataPosition].getData()) {
// update the position of the best value
minDataPosition = i;
}
}
// display results: position and the best (max) value
System.out.print("Position is:" + minDataPosition + " , Value is:");
dataList[minDataPosition].displayData();
System.out.println();
}
public void countValue() {
// set the count to start at 0
int count = 0;
// ask user for a target character to count
char target = enterChar();
// loop for each item in the array
for (int i = 0; i < 200; i++)
{
// decide if item at current index position matches target
if (dataList[i].getData() == target )
{
// add 1 to count
count = count +1;
}
}
// display the final count
System.out.println("Total is : " + count);
}
private char enterChar() {
char userChar = JOptionPane.showInputDialog("Enter character").charAt(0);
return userChar;
}
public void searchA() {
// ask the user to key in a target character
char target = enterChar();
// clear the found flag, target not yet found
boolean found = false;
// loop for each position in the array
for (int i=0; i<200; i++) {
// decide if item at current index position matches target
if(dataList[i].getData() == target) {
// set the found flag, target has been found
found = true;
}
}
// decide if the target was found
if (found) {
//display success message with target
System.out.println("Found " + target);
} else {
// display not found message
System.out.println("Not Found " + target);
}
}
public void searchB() {
char target = enterChar();
boolean found = false;
long startTime = System.nanoTime();
for (int i=0; i<200; i++) {
if(dataList[i].getData() == target) {
found = true;
System.out.println("Found " + target +" at " + i);
}
}
if (!found) {
System.out.println("Not Found " + target);
}
long estimatedTime = System.nanoTime() - startTime;
System.out.println("Time " + estimatedTime);
}
public void searchC() {
char target = enterChar();
boolean found = false;
int index = 0;
int listLimit = dataList.length;
long startTime = System.nanoTime();
do {
if(dataList[index].getData() == target) {
found = true;
System.out.println("Found " + target +" at " + index);
}
index++;
} while ((index<listLimit) && (found != true));
if (!found) {
System.out.println("Not Found " + target);
}
long estimatedTime = System.nanoTime() - startTime;
System.out.println("Time " + estimatedTime);
}
}
| UTF-8 | Java | 4,124 | java | ALGORITHM.java | Java | [] | null | [] | import javax.swing.JOptionPane;
public class ALGORITHM
{
// declare an array which can store DATA objects
private DATA[] dataList;
// constructor
public ALGORITHM()
{
// set the size of the array
dataList = new DATA[200];
}
// populate the array with DATA objects
public void setUpDataList()
{
for (int i=0; i<200; i++) {
//create a new DATA object and store in next array position
dataList[i] = new DATA();
System.out.print(dataList[i].getData());
}
System.out.println();
}
// standard algorithm to find smallest value, tracking position of value
public void findMinData()
{
// choose position of first value
int minDataPosition = 0;
// repeat for the rest of the array
for (int i=1; i<200; i++) {
//compare current value with best value
if (dataList[i].getData() < dataList[minDataPosition].getData()) {
// update the position of the best value
minDataPosition = i;
}
}
// display results: position and the best (max) value
System.out.print("Position is:" + minDataPosition + " , Value is:");
dataList[minDataPosition].displayData();
System.out.println();
}
public void countValue() {
// set the count to start at 0
int count = 0;
// ask user for a target character to count
char target = enterChar();
// loop for each item in the array
for (int i = 0; i < 200; i++)
{
// decide if item at current index position matches target
if (dataList[i].getData() == target )
{
// add 1 to count
count = count +1;
}
}
// display the final count
System.out.println("Total is : " + count);
}
private char enterChar() {
char userChar = JOptionPane.showInputDialog("Enter character").charAt(0);
return userChar;
}
public void searchA() {
// ask the user to key in a target character
char target = enterChar();
// clear the found flag, target not yet found
boolean found = false;
// loop for each position in the array
for (int i=0; i<200; i++) {
// decide if item at current index position matches target
if(dataList[i].getData() == target) {
// set the found flag, target has been found
found = true;
}
}
// decide if the target was found
if (found) {
//display success message with target
System.out.println("Found " + target);
} else {
// display not found message
System.out.println("Not Found " + target);
}
}
public void searchB() {
char target = enterChar();
boolean found = false;
long startTime = System.nanoTime();
for (int i=0; i<200; i++) {
if(dataList[i].getData() == target) {
found = true;
System.out.println("Found " + target +" at " + i);
}
}
if (!found) {
System.out.println("Not Found " + target);
}
long estimatedTime = System.nanoTime() - startTime;
System.out.println("Time " + estimatedTime);
}
public void searchC() {
char target = enterChar();
boolean found = false;
int index = 0;
int listLimit = dataList.length;
long startTime = System.nanoTime();
do {
if(dataList[index].getData() == target) {
found = true;
System.out.println("Found " + target +" at " + index);
}
index++;
} while ((index<listLimit) && (found != true));
if (!found) {
System.out.println("Not Found " + target);
}
long estimatedTime = System.nanoTime() - startTime;
System.out.println("Time " + estimatedTime);
}
}
| 4,124 | 0.524491 | 0.517216 | 144 | 27.638889 | 21.999247 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.388889 | false | false | 0 |
4f6ca91196f98df3d56916784b8e66fd0fe0ea82 | 25,503,515,846,883 | c04d4314f452cfd7627b02a8500d050455c3dbc3 | /src/Print_Chief_Notice.java | 039d3dc7ee3c1b8f4440b4ca4cdba2f22062df58 | [] | no_license | aarjaycreation/virtualbox | https://github.com/aarjaycreation/virtualbox | 7c5c0392e483d4186b98215682f0a3f1c2b7d3c9 | bef5887fa268b22146868af82b4c15c3731bf1b7 | refs/heads/master | 2023-08-21T06:29:21.722000 | 2021-10-26T17:46:43 | 2021-10-26T17:46:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Print_Chief_Notice extends JInternalFrame implements ActionListener
{
JLabel title=new JLabel("Print Chief Notice",JLabel.CENTER);
JComboBox com1=new JComboBox();
JComboBox com2=new JComboBox();
JLabel l1=new JLabel("Select Chief Name :",JLabel.RIGHT);
JLabel l3=new JLabel();
JLabel l2=new JLabel("Designation :",JLabel.RIGHT);
JLabel l4=new JLabel("Select Year & Batch :",JLabel.RIGHT);
JTextArea ta=new JTextArea();
JButton b1=new JButton("Print This Notice");
Connection con,con1;
Statement st,st1;
ResultSet rs,rs1;
ResultSetMetaData rsmt,rsmt1;
Print_Chief_Notice()
{
super("Print Chief Notice",false,true,false,true);
Container c=getContentPane();
c.setLayout(null);
com1.addItem("");
dataConnection();
Com1Show();
JScrollPane js=new JScrollPane(ta);
ta.setForeground(Color.black);
ta.setBackground(Color.white);
js.setBounds(10,140,370,160);
c.add(js);
title.setBounds(10,5,370,35);
l1.setBounds(10,50,170,20);
com1.setBounds(200,50,180,20);
l2.setBounds(10,80,170,20);
l3.setBounds(200,80,180,20);
l4.setBounds(10,110,170,20);
com2.setBounds(200,110,180,20);
b1.setBounds(100,320,200,30);
com1.addActionListener(this);
com2.addActionListener(this);
b1.addActionListener(this);
b1.setMnemonic('P');
c.add(title);
c.add(l1);
c.add(l2);
c.add(l3);
c.add(l4);
c.add(b1);
c.add(com1);
c.add(com2);
title.setFont(new Font("Dialog", 1, 20));
title.setBorder(BorderFactory.createRaisedBevelBorder());
title.setForeground(Color.blue);
title.setBackground(Color.red);
ta.setFont(new Font("Dialog", 0, 14));
com2.setEnabled(false);
l3.setBorder(BorderFactory.createRaisedBevelBorder());
l3.setForeground(Color.black);
l3.setBackground(Color.gray);
b1.setBackground(Color.black);
b1.setForeground(Color.white);
b1.setBorder(BorderFactory.createRaisedBevelBorder());
com1.setBorder(BorderFactory.createRaisedBevelBorder());
com2.setBorder(BorderFactory.createRaisedBevelBorder());
setBackground(Color.white);
setSize(400,390);
setLocation((Toolkit.getDefaultToolkit().getScreenSize().width-getWidth())/2,(Toolkit.getDefaultToolkit().getScreenSize().height-getHeight())/2-50);
setResizable(false);
show();
}
public void dataConnection()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/db","root","0000");
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=st.executeQuery("select * from Chief");
}
catch(Exception ce)
{
JOptionPane.showMessageDialog(null,ce);
}
}
public void dataConnection1()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con1=DriverManager.getConnection("jdbc:mysql://localhost/db","root","0000");
st1=con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch(Exception ce1)
{
JOptionPane.showMessageDialog(null,ce1);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==com1)
{
com1.removeItem("");
com2.setEnabled(true);
com2.removeAllItems();
dataConnection1();
ta.setText("");
try
{
String comname=((String)com1.getSelectedItem());
rs1=st1.executeQuery("select * from Notice where N_Name='"+comname+"'");
while(rs1.next())
{
com2.addItem((Object)rs1.getString(2));
}
}
catch(Exception e5)
{
System.out.print(e5);
}
try
{
String comname=((String)com1.getSelectedItem());
rs=st.executeQuery("select * from Chief where C_Name='"+comname+"'");
while(rs.next())
{
l3.setText(rs.getString(3));
}
}
catch(Exception e55)
{
System.out.print(e55);
}
}
if(e.getSource()==com2)
{
dataConnection1();
try
{
String comname=(String)com1.getSelectedItem();
String comyear=(String)com2.getSelectedItem();
rs=st.executeQuery("select * from Notice where N_Name='"+comname+"' and YearBatch='"+comyear+"'");
while(rs.next())
{
ta.setText(rs.getString(3));
}
}
catch(Exception e6)
{
System.out.print(e6);
}
}
if(e.getSource()==b1)
{if(com2.getSelectedItem()==null)
JOptionPane.showMessageDialog(this,"No data to print");
else
{
try
{
FileWriter fw=new FileWriter("Notice of "+com1.getSelectedItem()+".txt",true);
fw.write("CHIEF NOTICE"+"\r\n");
fw.write("~~~~~~~~~~~~~~~"+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write("Notice For "+com2.getSelectedItem()+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(ta.getText()+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(com1.getSelectedItem()+"\r\n");
fw.write(l3.getText()+"\r\n");
fw.close();
}catch(Exception e222){}
JOptionPane.showMessageDialog(this,"Printed in file successfully.");
}
}
}
public void Com1Show()
{
try
{
while(rs.next())
{
com1.addItem((Object)rs.getString(1));
}
}
catch(Exception e4)
{
System.out.print(e4);
}
dataConnection1();
try
{
String comname=l2.getText();
rs1=st1.executeQuery("select * from Notice where N_Name='"+comname+"'");
while(rs1.next())
{
com1.addItem((Object)rs1.getString(2));
}
}
catch(Exception e5)
{
System.out.print(e5);
}
}
}
| UTF-8 | Java | 5,983 | java | Print_Chief_Notice.java | Java | [] | null | [] | import java.io.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Print_Chief_Notice extends JInternalFrame implements ActionListener
{
JLabel title=new JLabel("Print Chief Notice",JLabel.CENTER);
JComboBox com1=new JComboBox();
JComboBox com2=new JComboBox();
JLabel l1=new JLabel("Select Chief Name :",JLabel.RIGHT);
JLabel l3=new JLabel();
JLabel l2=new JLabel("Designation :",JLabel.RIGHT);
JLabel l4=new JLabel("Select Year & Batch :",JLabel.RIGHT);
JTextArea ta=new JTextArea();
JButton b1=new JButton("Print This Notice");
Connection con,con1;
Statement st,st1;
ResultSet rs,rs1;
ResultSetMetaData rsmt,rsmt1;
Print_Chief_Notice()
{
super("Print Chief Notice",false,true,false,true);
Container c=getContentPane();
c.setLayout(null);
com1.addItem("");
dataConnection();
Com1Show();
JScrollPane js=new JScrollPane(ta);
ta.setForeground(Color.black);
ta.setBackground(Color.white);
js.setBounds(10,140,370,160);
c.add(js);
title.setBounds(10,5,370,35);
l1.setBounds(10,50,170,20);
com1.setBounds(200,50,180,20);
l2.setBounds(10,80,170,20);
l3.setBounds(200,80,180,20);
l4.setBounds(10,110,170,20);
com2.setBounds(200,110,180,20);
b1.setBounds(100,320,200,30);
com1.addActionListener(this);
com2.addActionListener(this);
b1.addActionListener(this);
b1.setMnemonic('P');
c.add(title);
c.add(l1);
c.add(l2);
c.add(l3);
c.add(l4);
c.add(b1);
c.add(com1);
c.add(com2);
title.setFont(new Font("Dialog", 1, 20));
title.setBorder(BorderFactory.createRaisedBevelBorder());
title.setForeground(Color.blue);
title.setBackground(Color.red);
ta.setFont(new Font("Dialog", 0, 14));
com2.setEnabled(false);
l3.setBorder(BorderFactory.createRaisedBevelBorder());
l3.setForeground(Color.black);
l3.setBackground(Color.gray);
b1.setBackground(Color.black);
b1.setForeground(Color.white);
b1.setBorder(BorderFactory.createRaisedBevelBorder());
com1.setBorder(BorderFactory.createRaisedBevelBorder());
com2.setBorder(BorderFactory.createRaisedBevelBorder());
setBackground(Color.white);
setSize(400,390);
setLocation((Toolkit.getDefaultToolkit().getScreenSize().width-getWidth())/2,(Toolkit.getDefaultToolkit().getScreenSize().height-getHeight())/2-50);
setResizable(false);
show();
}
public void dataConnection()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/db","root","0000");
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=st.executeQuery("select * from Chief");
}
catch(Exception ce)
{
JOptionPane.showMessageDialog(null,ce);
}
}
public void dataConnection1()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con1=DriverManager.getConnection("jdbc:mysql://localhost/db","root","0000");
st1=con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch(Exception ce1)
{
JOptionPane.showMessageDialog(null,ce1);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==com1)
{
com1.removeItem("");
com2.setEnabled(true);
com2.removeAllItems();
dataConnection1();
ta.setText("");
try
{
String comname=((String)com1.getSelectedItem());
rs1=st1.executeQuery("select * from Notice where N_Name='"+comname+"'");
while(rs1.next())
{
com2.addItem((Object)rs1.getString(2));
}
}
catch(Exception e5)
{
System.out.print(e5);
}
try
{
String comname=((String)com1.getSelectedItem());
rs=st.executeQuery("select * from Chief where C_Name='"+comname+"'");
while(rs.next())
{
l3.setText(rs.getString(3));
}
}
catch(Exception e55)
{
System.out.print(e55);
}
}
if(e.getSource()==com2)
{
dataConnection1();
try
{
String comname=(String)com1.getSelectedItem();
String comyear=(String)com2.getSelectedItem();
rs=st.executeQuery("select * from Notice where N_Name='"+comname+"' and YearBatch='"+comyear+"'");
while(rs.next())
{
ta.setText(rs.getString(3));
}
}
catch(Exception e6)
{
System.out.print(e6);
}
}
if(e.getSource()==b1)
{if(com2.getSelectedItem()==null)
JOptionPane.showMessageDialog(this,"No data to print");
else
{
try
{
FileWriter fw=new FileWriter("Notice of "+com1.getSelectedItem()+".txt",true);
fw.write("CHIEF NOTICE"+"\r\n");
fw.write("~~~~~~~~~~~~~~~"+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write("Notice For "+com2.getSelectedItem()+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(ta.getText()+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(""+"\r\n");
fw.write(com1.getSelectedItem()+"\r\n");
fw.write(l3.getText()+"\r\n");
fw.close();
}catch(Exception e222){}
JOptionPane.showMessageDialog(this,"Printed in file successfully.");
}
}
}
public void Com1Show()
{
try
{
while(rs.next())
{
com1.addItem((Object)rs.getString(1));
}
}
catch(Exception e4)
{
System.out.print(e4);
}
dataConnection1();
try
{
String comname=l2.getText();
rs1=st1.executeQuery("select * from Notice where N_Name='"+comname+"'");
while(rs1.next())
{
com1.addItem((Object)rs1.getString(2));
}
}
catch(Exception e5)
{
System.out.print(e5);
}
}
}
| 5,983 | 0.60722 | 0.571954 | 267 | 20.400749 | 22.812878 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.580524 | false | false | 0 |
c0f3c69bf33feabda64637d5ae1fb0fd734307e0 | 10,144,712,784,798 | 2e1abd1236a6c0ea4b9b8ecf97b604d9cb9a8582 | /src/pres/playerui/PlayerScreenPanel.java | 071c227acf983916013e36bfa91829d21423ebb0 | [] | no_license | doraczp/NBADataAnalyzer | https://github.com/doraczp/NBADataAnalyzer | df8cb1f6965012c5e1db3a61141a1e666044a1a3 | 2d5c236b2a07b3d5fd2f7e95b0271f146f9cbbf9 | refs/heads/master | 2021-05-29T02:21:04.324000 | 2015-05-10T15:33:45 | 2015-05-10T15:33:45 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pres.playerui;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableColumn;
import bl.playerbl.PlayerBL;
import blservice.playerblservice.PlayerBLService;
import constantinfo.Constant;
import constantinfo.ScreenBy;
import constantinfo.SortBy;
import pres.playerui.PlayerMainPanel.backlistener;
import pres.playerui.PlayerMainPanel.screenlistener;
import pres.playerui.PlayerMainPanel.seasonslistener;
import pres.uitools.CommonButton;
import pres.uitools.CommonPanel;
import pres.uitools.CommonTable;
import vo.playerVO;
public class PlayerScreenPanel extends CommonPanel{
CommonButton screen;
CommonButton back;
JTextField minimum;
JTextField maximum;
/*ButtonGroup positions;
ButtonGroup EW;
ButtonGroup sortbys;*/
JLabel min;
JLabel max;
JLabel playerinfo;
JLabel position;
JLabel EorW;
JLabel league;
JLabel sortby;
JLabel range;
JLabel chooseseason;
JComboBox seasons;
JComboBox positions;
JComboBox EW;
JComboBox Leagues;
JComboBox sortbys;
String season="13-14";
PlayerBLService playerblservice;
ArrayList<playerVO> screenedlist;
Object[][] screeneddata;
/*JRadioButton F=new JRadioButton("前锋");
JRadioButton C=new JRadioButton("中锋");
JRadioButton G=new JRadioButton("后卫");
JRadioButton E=new JRadioButton("东部");
JRadioButton W=new JRadioButton("西部");
JRadioButton score=new JRadioButton("得分");
JRadioButton rebound=new JRadioButton("篮板");
JRadioButton assist=new JRadioButton("助攻");
JRadioButton sra=new JRadioButton("得分+篮板+助攻");
JRadioButton rejection=new JRadioButton("盖帽");
JRadioButton steal=new JRadioButton("抢断");
JRadioButton foul=new JRadioButton("犯规");
JRadioButton turnover=new JRadioButton("失误");
JRadioButton time=new JRadioButton("在场时间");
JRadioButton efficiency=new JRadioButton("效率");
JRadioButton threepoint=new JRadioButton("三分(命中率)");
JRadioButton freethrow=new JRadioButton("罚球(命中率)");
JRadioButton pairs=new JRadioButton("两双");
JRadioButton shots=new JRadioButton("出手");*/
public PlayerScreenPanel() {
super("graphics/detailpanel/detail_background.png");
playerblservice=new PlayerBL();
Font font1=new Font("微软雅黑",Font.BOLD,12);
Font font2=new Font("微软雅黑",Font.BOLD,16);
playerinfo=new JLabel(new ImageIcon("graphics/detailpanel/playerinfo_label.png"));
playerinfo.setBounds(500, 20, 180, 45);
playerinfo.setVisible(true);
functionlabel.add(playerinfo);
position=new JLabel("场上位置:");
position.setFont(font2);
position.setBounds(350, 150,100, 20);
position.setVisible(true);
functionlabel.add(position);
EorW=new JLabel("东/西部:");
EorW.setFont(font2);
EorW.setBounds(350, 230, 100, 20);
EorW.setVisible(true);
functionlabel.add(EorW);
league=new JLabel("联盟:");
league.setFont(font2);
league.setBounds(350, 310, 100, 20);
league.setVisible(true);
functionlabel.add(league);
sortby=new JLabel("排序依据:");
sortby.setFont(font2);
sortby.setBounds(350, 390, 100, 20);
sortby.setVisible(true);
functionlabel.add(sortby);
range=new JLabel("范围:");
range.setFont(font2);
range.setBounds(350, 470, 100, 20);
range.setVisible(true);
//functionlabel.add(range);
min=new JLabel("最小值");
min.setFont(font2);
min.setBounds(470, 470, 100,20);
min.setVisible(true);
//functionlabel.add(min);
max=new JLabel("最大值");
max.setFont(font2);
max.setBounds(670, 470, 100, 20);
max.setVisible(true);
//functionlabel.add(max);
minimum=new JTextField(10);
minimum.setBounds(550,470,100,20);
minimum.setBorder(BorderFactory.createEmptyBorder());
minimum.setVisible(true);
//functionlabel.add(minimum);
maximum=new JTextField(10);
maximum.setBounds(750,470,100,20);
maximum.setBorder(BorderFactory.createEmptyBorder());
maximum.setVisible(true);
//functionlabel.add(maximum);
chooseseason=new JLabel("选择赛季");
chooseseason.setFont(font2);
chooseseason.setBounds(45, 220, 100, 30);
chooseseason.setVisible(true);
functionlabel.add(chooseseason);
String[] allpositions={"前锋","中锋","后卫"};
String[] eorw={"东部","西部"};
String[] leagues={"Southeast","Atlantic","Central","Northwest","Pacific","Southwest"};
String[] sorts={"得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
positions=new JComboBox(allpositions);
positions.setBounds(700, 150, 120, 35);
positions.setFont(font1);
positions.setBorder(BorderFactory.createEmptyBorder());
positions.setSelectedItem(null);
positions.setVisible(true);
functionlabel.add(positions);
EW=new JComboBox(eorw);
EW.setBounds(700, 230, 120, 35);
EW.setFont(font1);
EW.setBorder(BorderFactory.createEmptyBorder());
EW.setSelectedItem(null);
EW.setVisible(true);
functionlabel.add(EW);
Leagues=new JComboBox(leagues);
Leagues.setBounds(700, 310, 120, 35);
Leagues.setFont(font1);
Leagues.setBorder(BorderFactory.createEmptyBorder());
Leagues.setSelectedItem(null);
Leagues.setVisible(true);
functionlabel.add(Leagues);
sortbys=new JComboBox(sorts);
sortbys.setBounds(700, 390, 120, 35);
sortbys.setFont(font1);
sortbys.setBorder(BorderFactory.createEmptyBorder());
sortbys.setSelectedItem(null);
sortbys.setVisible(true);
functionlabel.add(sortbys);
seasons=new JComboBox(new String[]{"12-13","13-14","14-15"});
seasons.setBounds(140, 220, 120, 35);
seasons.setFont(font1);
seasons.setBorder(BorderFactory.createEmptyBorder());
seasons.setSelectedItem(null);
//seasons.addActionListener(new seasonslistener());
seasons.setVisible(true);
functionlabel.add(seasons);
/*F.setBounds(300, 300, 80, 30);
F.setVisible(true);
functionlabel.add(F);
F.setBounds(400, 300, 80, 30);
F.setVisible(true);
functionlabel.add(C);
F.setBounds(500, 300, 80, 30);
F.setVisible(true);
functionlabel.add(G);
positions.add(F);
positions.add(C);
positions.add(G);
E.setBounds(300, 350, 80, 30);
E.setVisible(true);
functionlabel.add(E);
W.setBounds(400, 350, 80, 30);
W.setVisible(true);
functionlabel.add(W);
EW.add(E);
EW.add(W);
score.setBounds(300, 400, 50, 30);
score.setVisible(true);
functionlabel.add(score);
rebound.setBounds(350, 400, 50, 30);
rebound.setVisible(true);
functionlabel.add(rebound);
assist.setBounds(400, 400, 50, 30);
assist.setVisible(true);
functionlabel.add(assist);
sra.setBounds(450, 400, 50, 30);
sra.setVisible(true);
functionlabel.add(sra);
rejection.setBounds(500, 400, 50, 30);
rejection.setVisible(true);
functionlabel.add(rejection);
steal.setBounds(550, 400, 50, 30);
steal.setVisible(true);
functionlabel.add(steal);
foul.setBounds(600, 400, 50, 30);
foul.setVisible(true);
functionlabel.add(foul);
turnover.setBounds(300, 400, 50, 30);
turnover.setVisible(true);
functionlabel.add(turnover);
time.setBounds(350, 450, 50, 30);
time.setVisible(true);
functionlabel.add(time);
efficiency.setBounds(400, 450, 50, 30);
efficiency.setVisible(true);
functionlabel.add(efficiency);
threepoint.setBounds(450, 450, 50, 30);
threepoint.setVisible(true);
functionlabel.add(threepoint);
freethrow.setBounds(500, 450, 50, 30);
freethrow.setVisible(true);
functionlabel.add(freethrow);
pairs.setBounds(550, 450, 50, 30);
pairs.setVisible(true);
functionlabel.add(pairs);
shots.setBounds(600, 450, 50, 30);
shots.setVisible(true);
functionlabel.add(shots);
sortbys.add(rebound);
sortbys.add(assist);
sortbys.add(efficiency);
sortbys.add(foul);
sortbys.add(freethrow);
sortbys.add(pairs);
sortbys.add(rejection);
sortbys.add(score);
sortbys.add(shots);
sortbys.add(sra);
sortbys.add(steal);
sortbys.add(threepoint);
sortbys.add(time);
sortbys.add(turnover);*/
screen=new CommonButton("graphics/actionbutton/screen.png","graphics/actionbutton/screen_dark_pressed.png","graphics/actionbutton/screen_dark_pressed.png");
screen.setBounds(400, 600, 240, 60);
screen.addActionListener(new screenlistener());
screen.setVisible(true);
functionlabel.add(screen);
back=new CommonButton("graphics/actionbutton/back_pressed.png","graphics/actionbutton/back.png","graphics/actionbutton/back.png");
back.setBounds(400+320, 600, 240, 60);
back.addActionListener(new backlistener());
back.setVisible(true);
functionlabel.add(back);
// TODO Auto-generated constructor stub
}
class screenlistener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
int toscreenposition=positions.getSelectedIndex();
int toscreeneorw=EW.getSelectedIndex();
int toscreenleagues=Leagues.getSelectedIndex();
int toscreensortbys=sortbys.getSelectedIndex();
if(seasons.getSelectedItem()!=null){
season=seasons.getSelectedItem().toString();
}
ArrayList<ScreenBy> toscreen=new ArrayList<ScreenBy>();
SortBy sort=SortBy.SCREEN_SCORE;//默认按总得分筛选
switch (toscreenposition){
case 0:
toscreen.add(ScreenBy.F);break;
case 1:
toscreen.add(ScreenBy.C);break;
case 2:
toscreen.add(ScreenBy.G);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreeneorw){
case 0:
toscreen.add(ScreenBy.E);break;
case 1:
toscreen.add(ScreenBy.W);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreenleagues){
case 0:
toscreen.add(ScreenBy.SOUTHEAST);break;
case 1:
toscreen.add(ScreenBy.ATLANTIC);break;
case 2:
toscreen.add(ScreenBy.CENTRAL);break;
case 3:
toscreen.add(ScreenBy.NORTHWEST);break;
case 4:
toscreen.add(ScreenBy.PACIFIC);break;
case 5:
toscreen.add(ScreenBy.SOUTHWEST);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreensortbys){
case 0:
sort=SortBy.SCREEN_SCORE;break;
case 1:
sort=SortBy.SCREEN_REBOUND;break;
case 2:
sort=SortBy.SCREEN_ASSIST;break;
case 3:
sort=SortBy.SCREEN_SRA;break;
case 4:
sort=SortBy.SCREEN_REJECTION;break;
case 5:
sort=SortBy.SCREEN_STEAL;break;
case 6:
sort=SortBy.SCREEN_FOUL;break;
case 7:
sort=SortBy.SCREEN_TURNOVER;break;
case 8:
sort=SortBy.SCREEN_TIME;break;
case 9:
sort=SortBy.SCREEN_EFFICIENCY;break;
case 10:
sort=SortBy.SCREEN_SHOTS;break;
case 11:
sort=SortBy.SCREEN_THREEPOINT;break;
case 12:
sort=SortBy.SCREEN_FREETHROW;break;
case 13:
sort=SortBy.SCREEN_PAIRS;break;
default:
}
functionlabel.remove(EW);
functionlabel.remove(EorW);
functionlabel.remove(league);
functionlabel.remove(Leagues);
functionlabel.remove(max);
functionlabel.remove(maximum);
functionlabel.remove(min);
functionlabel.remove(minimum);
functionlabel.remove(position);
functionlabel.remove(positions);
functionlabel.remove(range);
functionlabel.remove(screen);
functionlabel.remove(sortby);
functionlabel.remove(sortbys);
if(season==null)
season="13-14";//默认13-14赛季
screenedlist=playerblservice.screen(toscreen,sort,playerblservice.findAll(season));//返回一组已筛选的且大小符合要求的球员信息
//String[] colomn = {"球员姓名","位置","联盟","得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
String[] colomn = {"球员姓名","位置","得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
int length=0;
screeneddata=new Object[50][16];
for(playerVO list:screenedlist){
screeneddata[length][0]=list.name;
screeneddata[length][1]=list.position;
screeneddata[length][2]=list.totalScores;
screeneddata[length][3]=list.totalRebounds;
screeneddata[length][4]=list.totalAssists;
screeneddata[length][5]=list.totalAssists+list.totalRebounds+list.totalScores;
screeneddata[length][6]=list.totalRejection;
screeneddata[length][7]=list.totalSteals;
screeneddata[length][8]=list.totalFouls;
screeneddata[length][9]=list.totalTurnovers;
screeneddata[length][10]=list.timeOnCourt;
screeneddata[length][11]=list.efficiency;
screeneddata[length][12]=list.totalshots;
screeneddata[length][13]=list.totalThreePointShots;
screeneddata[length][14]=list.totalFreeThrows;
screeneddata[length][15]=list.pairs;
length++;
}
JScrollPane scroll;
CommonTable screenedtable=new CommonTable(screeneddata,colomn);
screenedtable.setPreferredScrollableViewportSize(new Dimension(500,300));
screenedtable.setRowHeight(20);
screenedtable.setFont(new Font("微软雅黑",Font.BOLD,15));
for(int i=0;i<screenedtable.getColumnCount();i++){
TableColumn tc=screenedtable.getColumn(screenedtable.getColumnName(i));
if(i==0)
tc.setMinWidth(150);
else
tc.setMinWidth(80);
}
screenedtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
screenedtable.getTableHeader().setPreferredSize(new Dimension (screenedtable.getTableHeader().getMinimumSize().width,30));
screenedtable.updateUI();
scroll = new JScrollPane(screenedtable);
scroll.setLocation(400,250);
scroll.setSize(500, 301);
scroll.setVisible(true);
functionlabel.add(scroll);
Constant.mainframe.repaint();
// TODO Auto-generated method stub
}
}
class backlistener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
Constant.mainframe.showPlayerMainPanel();
// TODO Auto-generated method stub
}
}
}
| GB18030 | Java | 14,275 | java | PlayerScreenPanel.java | Java | [] | null | [] | package pres.playerui;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableColumn;
import bl.playerbl.PlayerBL;
import blservice.playerblservice.PlayerBLService;
import constantinfo.Constant;
import constantinfo.ScreenBy;
import constantinfo.SortBy;
import pres.playerui.PlayerMainPanel.backlistener;
import pres.playerui.PlayerMainPanel.screenlistener;
import pres.playerui.PlayerMainPanel.seasonslistener;
import pres.uitools.CommonButton;
import pres.uitools.CommonPanel;
import pres.uitools.CommonTable;
import vo.playerVO;
public class PlayerScreenPanel extends CommonPanel{
CommonButton screen;
CommonButton back;
JTextField minimum;
JTextField maximum;
/*ButtonGroup positions;
ButtonGroup EW;
ButtonGroup sortbys;*/
JLabel min;
JLabel max;
JLabel playerinfo;
JLabel position;
JLabel EorW;
JLabel league;
JLabel sortby;
JLabel range;
JLabel chooseseason;
JComboBox seasons;
JComboBox positions;
JComboBox EW;
JComboBox Leagues;
JComboBox sortbys;
String season="13-14";
PlayerBLService playerblservice;
ArrayList<playerVO> screenedlist;
Object[][] screeneddata;
/*JRadioButton F=new JRadioButton("前锋");
JRadioButton C=new JRadioButton("中锋");
JRadioButton G=new JRadioButton("后卫");
JRadioButton E=new JRadioButton("东部");
JRadioButton W=new JRadioButton("西部");
JRadioButton score=new JRadioButton("得分");
JRadioButton rebound=new JRadioButton("篮板");
JRadioButton assist=new JRadioButton("助攻");
JRadioButton sra=new JRadioButton("得分+篮板+助攻");
JRadioButton rejection=new JRadioButton("盖帽");
JRadioButton steal=new JRadioButton("抢断");
JRadioButton foul=new JRadioButton("犯规");
JRadioButton turnover=new JRadioButton("失误");
JRadioButton time=new JRadioButton("在场时间");
JRadioButton efficiency=new JRadioButton("效率");
JRadioButton threepoint=new JRadioButton("三分(命中率)");
JRadioButton freethrow=new JRadioButton("罚球(命中率)");
JRadioButton pairs=new JRadioButton("两双");
JRadioButton shots=new JRadioButton("出手");*/
public PlayerScreenPanel() {
super("graphics/detailpanel/detail_background.png");
playerblservice=new PlayerBL();
Font font1=new Font("微软雅黑",Font.BOLD,12);
Font font2=new Font("微软雅黑",Font.BOLD,16);
playerinfo=new JLabel(new ImageIcon("graphics/detailpanel/playerinfo_label.png"));
playerinfo.setBounds(500, 20, 180, 45);
playerinfo.setVisible(true);
functionlabel.add(playerinfo);
position=new JLabel("场上位置:");
position.setFont(font2);
position.setBounds(350, 150,100, 20);
position.setVisible(true);
functionlabel.add(position);
EorW=new JLabel("东/西部:");
EorW.setFont(font2);
EorW.setBounds(350, 230, 100, 20);
EorW.setVisible(true);
functionlabel.add(EorW);
league=new JLabel("联盟:");
league.setFont(font2);
league.setBounds(350, 310, 100, 20);
league.setVisible(true);
functionlabel.add(league);
sortby=new JLabel("排序依据:");
sortby.setFont(font2);
sortby.setBounds(350, 390, 100, 20);
sortby.setVisible(true);
functionlabel.add(sortby);
range=new JLabel("范围:");
range.setFont(font2);
range.setBounds(350, 470, 100, 20);
range.setVisible(true);
//functionlabel.add(range);
min=new JLabel("最小值");
min.setFont(font2);
min.setBounds(470, 470, 100,20);
min.setVisible(true);
//functionlabel.add(min);
max=new JLabel("最大值");
max.setFont(font2);
max.setBounds(670, 470, 100, 20);
max.setVisible(true);
//functionlabel.add(max);
minimum=new JTextField(10);
minimum.setBounds(550,470,100,20);
minimum.setBorder(BorderFactory.createEmptyBorder());
minimum.setVisible(true);
//functionlabel.add(minimum);
maximum=new JTextField(10);
maximum.setBounds(750,470,100,20);
maximum.setBorder(BorderFactory.createEmptyBorder());
maximum.setVisible(true);
//functionlabel.add(maximum);
chooseseason=new JLabel("选择赛季");
chooseseason.setFont(font2);
chooseseason.setBounds(45, 220, 100, 30);
chooseseason.setVisible(true);
functionlabel.add(chooseseason);
String[] allpositions={"前锋","中锋","后卫"};
String[] eorw={"东部","西部"};
String[] leagues={"Southeast","Atlantic","Central","Northwest","Pacific","Southwest"};
String[] sorts={"得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
positions=new JComboBox(allpositions);
positions.setBounds(700, 150, 120, 35);
positions.setFont(font1);
positions.setBorder(BorderFactory.createEmptyBorder());
positions.setSelectedItem(null);
positions.setVisible(true);
functionlabel.add(positions);
EW=new JComboBox(eorw);
EW.setBounds(700, 230, 120, 35);
EW.setFont(font1);
EW.setBorder(BorderFactory.createEmptyBorder());
EW.setSelectedItem(null);
EW.setVisible(true);
functionlabel.add(EW);
Leagues=new JComboBox(leagues);
Leagues.setBounds(700, 310, 120, 35);
Leagues.setFont(font1);
Leagues.setBorder(BorderFactory.createEmptyBorder());
Leagues.setSelectedItem(null);
Leagues.setVisible(true);
functionlabel.add(Leagues);
sortbys=new JComboBox(sorts);
sortbys.setBounds(700, 390, 120, 35);
sortbys.setFont(font1);
sortbys.setBorder(BorderFactory.createEmptyBorder());
sortbys.setSelectedItem(null);
sortbys.setVisible(true);
functionlabel.add(sortbys);
seasons=new JComboBox(new String[]{"12-13","13-14","14-15"});
seasons.setBounds(140, 220, 120, 35);
seasons.setFont(font1);
seasons.setBorder(BorderFactory.createEmptyBorder());
seasons.setSelectedItem(null);
//seasons.addActionListener(new seasonslistener());
seasons.setVisible(true);
functionlabel.add(seasons);
/*F.setBounds(300, 300, 80, 30);
F.setVisible(true);
functionlabel.add(F);
F.setBounds(400, 300, 80, 30);
F.setVisible(true);
functionlabel.add(C);
F.setBounds(500, 300, 80, 30);
F.setVisible(true);
functionlabel.add(G);
positions.add(F);
positions.add(C);
positions.add(G);
E.setBounds(300, 350, 80, 30);
E.setVisible(true);
functionlabel.add(E);
W.setBounds(400, 350, 80, 30);
W.setVisible(true);
functionlabel.add(W);
EW.add(E);
EW.add(W);
score.setBounds(300, 400, 50, 30);
score.setVisible(true);
functionlabel.add(score);
rebound.setBounds(350, 400, 50, 30);
rebound.setVisible(true);
functionlabel.add(rebound);
assist.setBounds(400, 400, 50, 30);
assist.setVisible(true);
functionlabel.add(assist);
sra.setBounds(450, 400, 50, 30);
sra.setVisible(true);
functionlabel.add(sra);
rejection.setBounds(500, 400, 50, 30);
rejection.setVisible(true);
functionlabel.add(rejection);
steal.setBounds(550, 400, 50, 30);
steal.setVisible(true);
functionlabel.add(steal);
foul.setBounds(600, 400, 50, 30);
foul.setVisible(true);
functionlabel.add(foul);
turnover.setBounds(300, 400, 50, 30);
turnover.setVisible(true);
functionlabel.add(turnover);
time.setBounds(350, 450, 50, 30);
time.setVisible(true);
functionlabel.add(time);
efficiency.setBounds(400, 450, 50, 30);
efficiency.setVisible(true);
functionlabel.add(efficiency);
threepoint.setBounds(450, 450, 50, 30);
threepoint.setVisible(true);
functionlabel.add(threepoint);
freethrow.setBounds(500, 450, 50, 30);
freethrow.setVisible(true);
functionlabel.add(freethrow);
pairs.setBounds(550, 450, 50, 30);
pairs.setVisible(true);
functionlabel.add(pairs);
shots.setBounds(600, 450, 50, 30);
shots.setVisible(true);
functionlabel.add(shots);
sortbys.add(rebound);
sortbys.add(assist);
sortbys.add(efficiency);
sortbys.add(foul);
sortbys.add(freethrow);
sortbys.add(pairs);
sortbys.add(rejection);
sortbys.add(score);
sortbys.add(shots);
sortbys.add(sra);
sortbys.add(steal);
sortbys.add(threepoint);
sortbys.add(time);
sortbys.add(turnover);*/
screen=new CommonButton("graphics/actionbutton/screen.png","graphics/actionbutton/screen_dark_pressed.png","graphics/actionbutton/screen_dark_pressed.png");
screen.setBounds(400, 600, 240, 60);
screen.addActionListener(new screenlistener());
screen.setVisible(true);
functionlabel.add(screen);
back=new CommonButton("graphics/actionbutton/back_pressed.png","graphics/actionbutton/back.png","graphics/actionbutton/back.png");
back.setBounds(400+320, 600, 240, 60);
back.addActionListener(new backlistener());
back.setVisible(true);
functionlabel.add(back);
// TODO Auto-generated constructor stub
}
class screenlistener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
int toscreenposition=positions.getSelectedIndex();
int toscreeneorw=EW.getSelectedIndex();
int toscreenleagues=Leagues.getSelectedIndex();
int toscreensortbys=sortbys.getSelectedIndex();
if(seasons.getSelectedItem()!=null){
season=seasons.getSelectedItem().toString();
}
ArrayList<ScreenBy> toscreen=new ArrayList<ScreenBy>();
SortBy sort=SortBy.SCREEN_SCORE;//默认按总得分筛选
switch (toscreenposition){
case 0:
toscreen.add(ScreenBy.F);break;
case 1:
toscreen.add(ScreenBy.C);break;
case 2:
toscreen.add(ScreenBy.G);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreeneorw){
case 0:
toscreen.add(ScreenBy.E);break;
case 1:
toscreen.add(ScreenBy.W);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreenleagues){
case 0:
toscreen.add(ScreenBy.SOUTHEAST);break;
case 1:
toscreen.add(ScreenBy.ATLANTIC);break;
case 2:
toscreen.add(ScreenBy.CENTRAL);break;
case 3:
toscreen.add(ScreenBy.NORTHWEST);break;
case 4:
toscreen.add(ScreenBy.PACIFIC);break;
case 5:
toscreen.add(ScreenBy.SOUTHWEST);break;
default:
toscreen.add(ScreenBy.DEFAULT);
}
switch (toscreensortbys){
case 0:
sort=SortBy.SCREEN_SCORE;break;
case 1:
sort=SortBy.SCREEN_REBOUND;break;
case 2:
sort=SortBy.SCREEN_ASSIST;break;
case 3:
sort=SortBy.SCREEN_SRA;break;
case 4:
sort=SortBy.SCREEN_REJECTION;break;
case 5:
sort=SortBy.SCREEN_STEAL;break;
case 6:
sort=SortBy.SCREEN_FOUL;break;
case 7:
sort=SortBy.SCREEN_TURNOVER;break;
case 8:
sort=SortBy.SCREEN_TIME;break;
case 9:
sort=SortBy.SCREEN_EFFICIENCY;break;
case 10:
sort=SortBy.SCREEN_SHOTS;break;
case 11:
sort=SortBy.SCREEN_THREEPOINT;break;
case 12:
sort=SortBy.SCREEN_FREETHROW;break;
case 13:
sort=SortBy.SCREEN_PAIRS;break;
default:
}
functionlabel.remove(EW);
functionlabel.remove(EorW);
functionlabel.remove(league);
functionlabel.remove(Leagues);
functionlabel.remove(max);
functionlabel.remove(maximum);
functionlabel.remove(min);
functionlabel.remove(minimum);
functionlabel.remove(position);
functionlabel.remove(positions);
functionlabel.remove(range);
functionlabel.remove(screen);
functionlabel.remove(sortby);
functionlabel.remove(sortbys);
if(season==null)
season="13-14";//默认13-14赛季
screenedlist=playerblservice.screen(toscreen,sort,playerblservice.findAll(season));//返回一组已筛选的且大小符合要求的球员信息
//String[] colomn = {"球员姓名","位置","联盟","得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
String[] colomn = {"球员姓名","位置","得分","篮板","助攻","得分/篮板/助攻","盖帽","抢断","犯规","失误","分钟","效率","投篮","三分","罚球","两双"};
int length=0;
screeneddata=new Object[50][16];
for(playerVO list:screenedlist){
screeneddata[length][0]=list.name;
screeneddata[length][1]=list.position;
screeneddata[length][2]=list.totalScores;
screeneddata[length][3]=list.totalRebounds;
screeneddata[length][4]=list.totalAssists;
screeneddata[length][5]=list.totalAssists+list.totalRebounds+list.totalScores;
screeneddata[length][6]=list.totalRejection;
screeneddata[length][7]=list.totalSteals;
screeneddata[length][8]=list.totalFouls;
screeneddata[length][9]=list.totalTurnovers;
screeneddata[length][10]=list.timeOnCourt;
screeneddata[length][11]=list.efficiency;
screeneddata[length][12]=list.totalshots;
screeneddata[length][13]=list.totalThreePointShots;
screeneddata[length][14]=list.totalFreeThrows;
screeneddata[length][15]=list.pairs;
length++;
}
JScrollPane scroll;
CommonTable screenedtable=new CommonTable(screeneddata,colomn);
screenedtable.setPreferredScrollableViewportSize(new Dimension(500,300));
screenedtable.setRowHeight(20);
screenedtable.setFont(new Font("微软雅黑",Font.BOLD,15));
for(int i=0;i<screenedtable.getColumnCount();i++){
TableColumn tc=screenedtable.getColumn(screenedtable.getColumnName(i));
if(i==0)
tc.setMinWidth(150);
else
tc.setMinWidth(80);
}
screenedtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
screenedtable.getTableHeader().setPreferredSize(new Dimension (screenedtable.getTableHeader().getMinimumSize().width,30));
screenedtable.updateUI();
scroll = new JScrollPane(screenedtable);
scroll.setLocation(400,250);
scroll.setSize(500, 301);
scroll.setVisible(true);
functionlabel.add(scroll);
Constant.mainframe.repaint();
// TODO Auto-generated method stub
}
}
class backlistener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
Constant.mainframe.showPlayerMainPanel();
// TODO Auto-generated method stub
}
}
}
| 14,275 | 0.715135 | 0.677206 | 488 | 27.256147 | 19.872286 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.270492 | false | false | 0 |
ae294c69e3b5ed27f90fd357438d83a880480146 | 15,582,141,358,805 | d0b199b999ecdf4e4f4e2d5fe2d8bbba0f112be8 | /es/hol/iberians/Arena.java | 402965dd56110ba5b21d226ec68e52e56457dc2c | [] | no_license | jesus997/CreativePVP | https://github.com/jesus997/CreativePVP | 76344539c6bbc5f69bfcfa6f1bb0ff03540ac7e2 | 083b845783249e678fdd08ab9faa3a89633f4d01 | refs/heads/master | 2016-09-16T01:17:10.236000 | 2014-05-17T23:09:20 | 2014-05-17T23:09:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package es.hol.iberians;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
public class Arena {
@SuppressWarnings({ "unchecked", "rawtypes" })
private int id = 0;
private List<Location> spawns = new ArrayList<>();
private List<Location> respawn = new ArrayList<>();
private int maxPlayers = 10;
private List<String> players = new ArrayList<>();
private HashMap<String, Location> usedSpawns = new HashMap<>();
private int state = 0;
private HashMap<String, Integer> lives = new HashMap<>();
private ScoreboardAPI sbapi = new ScoreboardAPI();
protected boolean gameOver;
public Arena(List<Location> list, int id, List<Location> respawn) {
this.spawns = list;
this.id = id;
this.respawn = respawn;
}
public int getState() {
return this.state;
}
public void nextState() {
this.state++;
}
public void resetState() {
this.state = 0;
}
public Integer getLives(String p) {
if(this.lives.get(p) != null){
return this.lives.get(p);
}
return null;
}
public void setLives(String p, int l) {
this.lives.remove(p);
this.lives.put(p, l);
}
public void addLives(String p, int l) {
this.lives.put(p, l);
}
public int getId() {
return this.id;
}
public HashMap<String, Location> getUsedSpawns() {
return this.usedSpawns;
}
public List<String> getPlayers() {
return this.players;
}
public void setId(int i) {
this.id = i;
}
public List<Location> getSpawn() {
return spawns;
}
public Location getNextSpawn() {
for(Location l: this.spawns) {
if(!usedSpawns.containsValue(l)) {
return l;
} else {
continue;
}
}
System.out.print("NO SPAWN?? :(");
return spawns.get(0);
}
public List<Location> getRespawn(){
return respawn;
}
public int getMaxPlayers(){
return this.maxPlayers;
}
public void setMaxPlayers(int maxPlayers){
this.maxPlayers = maxPlayers;
}
public ScoreboardAPI getSBApi() {
return this.sbapi;
}
public void removeLives(String name) {
this.lives.remove(name);
}
}
| UTF-8 | Java | 2,418 | java | Arena.java | Java | [] | null | [] | package es.hol.iberians;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
public class Arena {
@SuppressWarnings({ "unchecked", "rawtypes" })
private int id = 0;
private List<Location> spawns = new ArrayList<>();
private List<Location> respawn = new ArrayList<>();
private int maxPlayers = 10;
private List<String> players = new ArrayList<>();
private HashMap<String, Location> usedSpawns = new HashMap<>();
private int state = 0;
private HashMap<String, Integer> lives = new HashMap<>();
private ScoreboardAPI sbapi = new ScoreboardAPI();
protected boolean gameOver;
public Arena(List<Location> list, int id, List<Location> respawn) {
this.spawns = list;
this.id = id;
this.respawn = respawn;
}
public int getState() {
return this.state;
}
public void nextState() {
this.state++;
}
public void resetState() {
this.state = 0;
}
public Integer getLives(String p) {
if(this.lives.get(p) != null){
return this.lives.get(p);
}
return null;
}
public void setLives(String p, int l) {
this.lives.remove(p);
this.lives.put(p, l);
}
public void addLives(String p, int l) {
this.lives.put(p, l);
}
public int getId() {
return this.id;
}
public HashMap<String, Location> getUsedSpawns() {
return this.usedSpawns;
}
public List<String> getPlayers() {
return this.players;
}
public void setId(int i) {
this.id = i;
}
public List<Location> getSpawn() {
return spawns;
}
public Location getNextSpawn() {
for(Location l: this.spawns) {
if(!usedSpawns.containsValue(l)) {
return l;
} else {
continue;
}
}
System.out.print("NO SPAWN?? :(");
return spawns.get(0);
}
public List<Location> getRespawn(){
return respawn;
}
public int getMaxPlayers(){
return this.maxPlayers;
}
public void setMaxPlayers(int maxPlayers){
this.maxPlayers = maxPlayers;
}
public ScoreboardAPI getSBApi() {
return this.sbapi;
}
public void removeLives(String name) {
this.lives.remove(name);
}
}
| 2,418 | 0.574028 | 0.571547 | 99 | 23.424242 | 17.446074 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.50505 | false | false | 0 |
8090e01a687145dea94cb8652bbf3c61b6c155c8 | 21,801,254,015,698 | 055fd536839fcc13de74a3369e670de62583a589 | /21/2월/0210/Main_BJ_16926_배열돌리기1.java | e269540910b5b5f77251b3a81a17e92b41e30650 | [] | no_license | SeonA1223/Algorithm | https://github.com/SeonA1223/Algorithm | b37517e1137d10beb5648df26a9015c459aa704f | b7e1cb374eb50c12177e450699b2f9d7d9d75d06 | refs/heads/main | 2023-08-03T22:44:08.001000 | 2021-09-07T12:18:19 | 2021-09-13T12:31:16 | 398,503,297 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package problem210210;
import java.util.Scanner;
public class Main_BJ_16926_배열돌리기1 {
static int N, M, R;
static int[] dy = { 0, 1, 0, -1 };//행인덱스
static int[] dx = { 1, 0, -1, 0 };//열인덱스
//우 아 좌 상
static int[][] arr;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//배열의 크기 N*M
N = sc.nextInt(); // 행크기
M = sc.nextInt(); // 열크기
R = sc.nextInt(); // 회전 수
arr = new int[N][M];
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
arr[i][j] = sc.nextInt();//배열 숫자 입력
}
}
int s = Math.min(N, M) / 2;// 1회전에서 돌려야하는 사각형의 개수 4/2 = 2 , 5/2 = 2
for (int i = 0; i < R; i++) {//회전수만큼 반복
rotate(s);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
System.out.print(arr[i][j] + " ");//회전 결과 출력
}
System.out.println();
}
sc.close();
}//main
public static void rotate(int s) {
for (int i = 0; i < s; i++) {
int dir = 0;//우 아 좌 상
int sy = i; //rotate 시작위치 행
int sx = i; //rotate 시작위치 열
int value = arr[sy][sx]; //4행4열 시작지점==> arr[0][0] , arr[1][1]
//8행8열 시작지점==> arr[0][0] , arr[1][1] , arr[2][2] , arr[3][3]
//int value == int temp
while (dir < 4) {//dir=0,1,2,3
int ny = sy + dy[dir];//ny = 0, 0, 0
int nx = sx + dx[dir];//nx = 1, 2, 3
if (ny >= i && nx >= i && ny < N - i && nx < M - i) {//배열의 범위를 넘어섰다면, 바깥 로테이션 범위를 넘어섰다면
arr[sy][sx] = arr[ny][nx]; //값 시프트
sy = ny; //이동
sx = nx; //이동
} else {
dir++;
}
}
arr[i + 1][i] = value;
}
}
} | UTF-8 | Java | 2,341 | java | Main_BJ_16926_배열돌리기1.java | Java | [] | null | [] | package problem210210;
import java.util.Scanner;
public class Main_BJ_16926_배열돌리기1 {
static int N, M, R;
static int[] dy = { 0, 1, 0, -1 };//행인덱스
static int[] dx = { 1, 0, -1, 0 };//열인덱스
//우 아 좌 상
static int[][] arr;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//배열의 크기 N*M
N = sc.nextInt(); // 행크기
M = sc.nextInt(); // 열크기
R = sc.nextInt(); // 회전 수
arr = new int[N][M];
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
arr[i][j] = sc.nextInt();//배열 숫자 입력
}
}
int s = Math.min(N, M) / 2;// 1회전에서 돌려야하는 사각형의 개수 4/2 = 2 , 5/2 = 2
for (int i = 0; i < R; i++) {//회전수만큼 반복
rotate(s);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
System.out.print(arr[i][j] + " ");//회전 결과 출력
}
System.out.println();
}
sc.close();
}//main
public static void rotate(int s) {
for (int i = 0; i < s; i++) {
int dir = 0;//우 아 좌 상
int sy = i; //rotate 시작위치 행
int sx = i; //rotate 시작위치 열
int value = arr[sy][sx]; //4행4열 시작지점==> arr[0][0] , arr[1][1]
//8행8열 시작지점==> arr[0][0] , arr[1][1] , arr[2][2] , arr[3][3]
//int value == int temp
while (dir < 4) {//dir=0,1,2,3
int ny = sy + dy[dir];//ny = 0, 0, 0
int nx = sx + dx[dir];//nx = 1, 2, 3
if (ny >= i && nx >= i && ny < N - i && nx < M - i) {//배열의 범위를 넘어섰다면, 바깥 로테이션 범위를 넘어섰다면
arr[sy][sx] = arr[ny][nx]; //값 시프트
sy = ny; //이동
sx = nx; //이동
} else {
dir++;
}
}
arr[i + 1][i] = value;
}
}
} | 2,341 | 0.345437 | 0.315337 | 70 | 28.914286 | 22.19829 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.9 | false | false | 0 |
c6562de510a1f46e7f2288f858c947ede21c6c65 | 30,657,476,585,977 | 85341c39db37e127a1eed49169e632fa7e3cfb9f | /src/com/ums/buildings/IBA.java | ad8c293ee213385a30e56225c1773053d36f258d | [] | no_license | sami-abdul511/UMS | https://github.com/sami-abdul511/UMS | d5f93239e8c77c5ccc0768d26653a81113d24031 | 86af80968966a41e4dccb6760af13fc4d556ffb6 | refs/heads/master | 2021-06-14T18:58:22.250000 | 2017-02-11T12:57:39 | 2017-02-11T12:57:39 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ums.buildings;
import com.ums.entities.Dean;
import com.ums.entities.Teacher;
import com.ums.event.Event;
import com.ums.lists.CourseList;
import com.ums.lists.StudentList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class IBA extends Department {
public static Dean dean;
public static ArrayList<Teacher> teacherList;
public static StudentList studentList;
public static CourseList courseList;
public static Event event;
static {
dean = new Dean(AdminBlock.employeeList.employees.get(1).getID(), AdminBlock.employeeList.employees.get(1).getName(),
AdminBlock.employeeList.employees.get(1).getQualification(), AdminBlock.employeeList.employees.get(1).getDepartment(),
AdminBlock.employeeList.employees.get(1).getPassword(), AdminBlock.employeeList.employees.get(1).getSalary(),
AdminBlock.employeeList.employees.get(1).getAttendance(), AdminBlock.employeeList.employees.get(1).getPort());
teacherList = new ArrayList<Teacher>();
studentList = new StudentList();
courseList = new CourseList();
event = new Event();
}
public IBA() {
super("bd300", "IBA", teacherList.size(), studentList.students.size(), courseList.courses.size(),
2, new String[2], 70000000);
fetchTeachers();
fetchStudents();
fetchCourses();
numOfTeachers = teacherList.size();
numOfStudents = studentList.students.size();
numOfCourses = courseList.courses.size();
this.fields[0] = "BBA";
this.fields[1] = "BS (Computer Science)";
}
private static void fetchTeachers() {
for (int i = 0; i < AdminBlock.teacherList.size(); i++) {
if (AdminBlock.teacherList.get(i).getDepartment().equals("IBA"))
IBA.teacherList.add((Teacher) AdminBlock.employeeList.employees.get(i));
}
}
private static void fetchStudents() {
for (int i = 0; i < AdminBlock.studentList.students.size(); i++) {
if (AdminBlock.studentList.students.get(i).getDepartment().equals("IBA"))
IBA.studentList.students.add(AdminBlock.studentList.students.get(i));
}
}
private static void fetchCourses() {
for (int i = 0; i < AdminBlock.courseList.courses.size(); i++) {
if (AdminBlock.courseList.courses.get(i).getDepartment().equals("IBA"))
IBA.courseList.courses.add(AdminBlock.courseList.courses.get(i));
}
}
public static void fetchAll() {
fetchTeachers();
fetchStudents();
fetchCourses();
}
public static void setEvent(String name, int year, int month, int date, int hour, int minutes) {
IBA.event.setEvent(name, year, month, date, hour, minutes);
}
public static void teacherSort() {
IBATeacherNameSort sort = new IBATeacherNameSort();
Collections.sort(teacherList, sort);
}
}
class IBATeacherNameSort implements Comparator<Teacher> {
@Override
public int compare(Teacher o1, Teacher o2) {
return o1.getName().compareTo(o2.getName());
}
}
| UTF-8 | Java | 3,305 | java | IBA.java | Java | [] | null | [] | package com.ums.buildings;
import com.ums.entities.Dean;
import com.ums.entities.Teacher;
import com.ums.event.Event;
import com.ums.lists.CourseList;
import com.ums.lists.StudentList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class IBA extends Department {
public static Dean dean;
public static ArrayList<Teacher> teacherList;
public static StudentList studentList;
public static CourseList courseList;
public static Event event;
static {
dean = new Dean(AdminBlock.employeeList.employees.get(1).getID(), AdminBlock.employeeList.employees.get(1).getName(),
AdminBlock.employeeList.employees.get(1).getQualification(), AdminBlock.employeeList.employees.get(1).getDepartment(),
AdminBlock.employeeList.employees.get(1).getPassword(), AdminBlock.employeeList.employees.get(1).getSalary(),
AdminBlock.employeeList.employees.get(1).getAttendance(), AdminBlock.employeeList.employees.get(1).getPort());
teacherList = new ArrayList<Teacher>();
studentList = new StudentList();
courseList = new CourseList();
event = new Event();
}
public IBA() {
super("bd300", "IBA", teacherList.size(), studentList.students.size(), courseList.courses.size(),
2, new String[2], 70000000);
fetchTeachers();
fetchStudents();
fetchCourses();
numOfTeachers = teacherList.size();
numOfStudents = studentList.students.size();
numOfCourses = courseList.courses.size();
this.fields[0] = "BBA";
this.fields[1] = "BS (Computer Science)";
}
private static void fetchTeachers() {
for (int i = 0; i < AdminBlock.teacherList.size(); i++) {
if (AdminBlock.teacherList.get(i).getDepartment().equals("IBA"))
IBA.teacherList.add((Teacher) AdminBlock.employeeList.employees.get(i));
}
}
private static void fetchStudents() {
for (int i = 0; i < AdminBlock.studentList.students.size(); i++) {
if (AdminBlock.studentList.students.get(i).getDepartment().equals("IBA"))
IBA.studentList.students.add(AdminBlock.studentList.students.get(i));
}
}
private static void fetchCourses() {
for (int i = 0; i < AdminBlock.courseList.courses.size(); i++) {
if (AdminBlock.courseList.courses.get(i).getDepartment().equals("IBA"))
IBA.courseList.courses.add(AdminBlock.courseList.courses.get(i));
}
}
public static void fetchAll() {
fetchTeachers();
fetchStudents();
fetchCourses();
}
public static void setEvent(String name, int year, int month, int date, int hour, int minutes) {
IBA.event.setEvent(name, year, month, date, hour, minutes);
}
public static void teacherSort() {
IBATeacherNameSort sort = new IBATeacherNameSort();
Collections.sort(teacherList, sort);
}
}
class IBATeacherNameSort implements Comparator<Teacher> {
@Override
public int compare(Teacher o1, Teacher o2) {
return o1.getName().compareTo(o2.getName());
}
}
| 3,305 | 0.632375 | 0.623298 | 95 | 32.789474 | 33.305569 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.736842 | false | false | 0 |
ba284b1e416be4693eb416ba79ed196c7e40c9da | 21,096,879,390,129 | b08f1485d0c2c18e57134d0d3d56220fdff3cc5e | /ClimateCore/src/main/java/com/icip/core/repository/ClimateImpactRepository.java | 696cf32402b307c3f1565a1c0c02f55524ca1d35 | [] | no_license | bithu30/myRepo | https://github.com/bithu30/myRepo | 250c9383d31c296a9e116032aebf4ce947d1964e | 64485bb10327ed3a84b3c15200b1dd6a90117a8e | refs/heads/master | 2022-10-21T16:26:45.997000 | 2018-05-31T02:51:31 | 2018-05-31T02:51:31 | 41,030,617 | 5 | 18 | null | false | 2022-10-05T07:40:41 | 2015-08-19T11:43:00 | 2020-09-09T06:47:31 | 2018-05-31T02:52:01 | 1,235,720 | 5 | 14 | 1 | Jupyter Notebook | false | false | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.icip.core.repository;
import com.icip.core.icipproject.ClimateImpact;
import com.icip.core.icipproject.ClimatePreventiveMeasure;
import java.util.List;
/**
*
* @author icipmac
*/
public interface ClimateImpactRepository {
ClimateImpact findClimateImpactById(int id);
ClimateImpact createClimateImpact(ClimateImpact impact);
ClimateImpact updateClimateImpact(ClimateImpact impact);
ClimatePreventiveMeasure addClimatePreventiveMeasure(int climateImpactid, ClimatePreventiveMeasure preventiveMeasure);
List<ClimateImpact> findAllClimateImpacts();
void deleteClimateImpact(int id);
}
| UTF-8 | Java | 807 | java | ClimateImpactRepository.java | Java | [
{
"context": "Measure;\nimport java.util.List;\n\n/**\n *\n * @author icipmac\n */\npublic interface ClimateImpactReposito",
"end": 368,
"score": 0.8864181041717529,
"start": 368,
"tag": "USERNAME",
"value": ""
},
{
"context": "easure;\nimport java.util.List;\n\n/**\n *\n * @author icipmac\n */\npublic interface ClimateImpactRepository {\n ",
"end": 376,
"score": 0.856486976146698,
"start": 369,
"tag": "USERNAME",
"value": "icipmac"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.icip.core.repository;
import com.icip.core.icipproject.ClimateImpact;
import com.icip.core.icipproject.ClimatePreventiveMeasure;
import java.util.List;
/**
*
* @author icipmac
*/
public interface ClimateImpactRepository {
ClimateImpact findClimateImpactById(int id);
ClimateImpact createClimateImpact(ClimateImpact impact);
ClimateImpact updateClimateImpact(ClimateImpact impact);
ClimatePreventiveMeasure addClimatePreventiveMeasure(int climateImpactid, ClimatePreventiveMeasure preventiveMeasure);
List<ClimateImpact> findAllClimateImpacts();
void deleteClimateImpact(int id);
}
| 807 | 0.798017 | 0.798017 | 23 | 34.086956 | 30.657879 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.608696 | false | false | 0 |
c896022da4623f9c2cc5425489f4f396a36743b3 | 773,094,150,066 | 823c10563c5fe55deaa3a360ec94bc9b1ba8e2c1 | /src/main/java/de/m1well/spring/webapp/sample/service/UserDetailsServiceImpl.java | 671383a6911a5a7afe268d2618436afb61220ecc | [
"MIT"
] | permissive | MrSkip/spring_hibernate_sample_webapp | https://github.com/MrSkip/spring_hibernate_sample_webapp | 49794296a46652d90212cddd51e80c41b8c0d5c9 | a95a6cbe7e23ac10e7f3766d8fc2e91680496ee4 | refs/heads/master | 2021-07-18T19:50:06.583000 | 2017-10-24T19:05:59 | 2017-10-24T19:10:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.m1well.spring.webapp.sample.service;
import de.m1well.spring.webapp.sample.model.AppAuthority;
import de.m1well.spring.webapp.sample.model.AppUser;
import de.m1well.spring.webapp.sample.repository.AppUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashSet;
import java.util.Set;
/**
* author: Michael Wellner<br/>
* date: 24.10.17<br/>
*/
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private AppUserRepository appUserRepository;
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
AppUser appUser = appUserRepository.findByUsername(username);
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
for (AppAuthority appAuthority : appUser.getAppAuthorities()){
grantedAuthorities.add(new SimpleGrantedAuthority(appAuthority.getName()));
}
return new User(appUser.getUsername(), appUser.getPassword(), grantedAuthorities);
}
} | UTF-8 | Java | 1,566 | java | UserDetailsServiceImpl.java | Java | [
{
"context": "til.HashSet;\nimport java.util.Set;\n\n/**\n * author: Michael Wellner<br/>\n * date: 24.10.17<br/>\n */\npublic class User",
"end": 848,
"score": 0.9996561408042908,
"start": 833,
"tag": "NAME",
"value": "Michael Wellner"
}
] | null | [] | package de.m1well.spring.webapp.sample.service;
import de.m1well.spring.webapp.sample.model.AppAuthority;
import de.m1well.spring.webapp.sample.model.AppUser;
import de.m1well.spring.webapp.sample.repository.AppUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashSet;
import java.util.Set;
/**
* author: <NAME><br/>
* date: 24.10.17<br/>
*/
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private AppUserRepository appUserRepository;
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
AppUser appUser = appUserRepository.findByUsername(username);
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
for (AppAuthority appAuthority : appUser.getAppAuthorities()){
grantedAuthorities.add(new SimpleGrantedAuthority(appAuthority.getName()));
}
return new User(appUser.getUsername(), appUser.getPassword(), grantedAuthorities);
}
} | 1,557 | 0.797573 | 0.791188 | 39 | 39.179485 | 31.241714 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false | 0 |
68f82a03dadc0fb59dda1df81e6e1f41ba98dbe5 | 31,001,073,986,815 | 0ebbb6df021aab34da2f6017072bc4d54e0a2ebd | /src/main/java/interview/bytedance/Main1.java | c35acf32babd964e1cf3e64dd109dcb2f5b87e3a | [] | no_license | genggengyuhuai/myStudy | https://github.com/genggengyuhuai/myStudy | 0d428611e44193e1f31a551b33dd7c7df723821f | 4f144bb665fec4ec7b95ec56100f8017b82f1bd7 | refs/heads/master | 2021-06-20T19:34:49.129000 | 2021-05-02T13:39:28 | 2021-05-02T13:39:28 | 217,287,024 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interview.bytedance;
/**
* @author lihaoyu
* @date 2/25/2020 3:58 PM
*/
public class Main1 {
private static volatile Integer anInt = 0;
static class A implements Runnable{
@Override
public void run() {
for (int i = 0; i < 1000000; i++) {
anInt++;
}
}
}
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(new A());
Thread t2 = new Thread(new A());
t1.start();t2.start();
t1.join();t2.join();
System.out.println(anInt);
}
}
| UTF-8 | Java | 604 | java | Main1.java | Java | [
{
"context": "package interview.bytedance;\n\n/**\n * @author lihaoyu\n * @date 2/25/2020 3:58 PM\n */\npublic class Main1",
"end": 52,
"score": 0.9881471991539001,
"start": 45,
"tag": "USERNAME",
"value": "lihaoyu"
}
] | null | [] | package interview.bytedance;
/**
* @author lihaoyu
* @date 2/25/2020 3:58 PM
*/
public class Main1 {
private static volatile Integer anInt = 0;
static class A implements Runnable{
@Override
public void run() {
for (int i = 0; i < 1000000; i++) {
anInt++;
}
}
}
public static void main(String[] args) throws InterruptedException {
Thread t1 = new Thread(new A());
Thread t2 = new Thread(new A());
t1.start();t2.start();
t1.join();t2.join();
System.out.println(anInt);
}
}
| 604 | 0.533113 | 0.490066 | 29 | 19.827587 | 18.351114 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413793 | false | false | 0 |
6b004c360257e579753d163ef70da84f25a9dfc3 | 32,753,420,624,752 | e1007306ea694e9540682a60d6f80ebeb1512027 | /family-web/src/main/java/com/family/web/UserController.java | 78d77fd30ad0104e54572c15a85ea908ffe1b1e2 | [] | no_license | honeyleo/family-parent | https://github.com/honeyleo/family-parent | e2ef8bff4c8346c6388339e9f6ab15ce70d2f332 | 492b032d8179e954adcddfabbb406079d1404ef0 | refs/heads/master | 2021-01-11T22:06:12.957000 | 2018-05-10T14:28:21 | 2018-05-10T14:28:21 | 78,924,585 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.family.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.family.common.model.ContributionRank;
import com.family.common.model.Phone;
import com.family.common.model.UserContributionRecord;
import com.family.common.model.UserDetail;
import com.family.common.model.UserDetailDTO;
import com.family.common.model.UserNewsFavor;
import com.family.common.service.CommentService;
import com.family.common.service.UserContributionService;
import com.family.common.service.UserDetailService;
import com.family.common.service.UserService;
import com.family.model.CurrentUser;
import com.family.service.UserFriendService;
import com.family.service.UserProxyService;
import com.family.service.VerifyCodeService;
import cn.lfy.base.model.User;
import cn.lfy.common.filehandler.ResourceIdentifier;
import cn.lfy.common.filehandler.ResourceManager;
import cn.lfy.common.framework.exception.ApplicationException;
import cn.lfy.common.framework.exception.ErrorCode;
import cn.lfy.common.model.Message;
import cn.lfy.common.utils.MessageDigestUtil;
import cn.lfy.common.utils.UUIDUtil;
import cn.lfy.common.utils.Validators;
import cn.lfy.common.web.BaseController;
@Controller
@RequestMapping("/app/user")
public class UserController extends BaseController {
@Value("${fileserver.image.url}")
private String imageUrl;
@Autowired
private UserProxyService userProxyService;
@Autowired
private ResourceManager resourceManager;
@Autowired
private UserService userService;
@Autowired
private UserDetailService userDetailService;
@Autowired
private VerifyCodeService verifyCodeService;
@RequestMapping("/me")
@ResponseBody
public Object me(CurrentUser user, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/me");
Map<String, Object> data = new HashMap<String, Object>();
data.put("basic", user);
UserDetail mine = userProxyService.getUserDetail(user.getId());
if(StringUtils.isNotBlank(mine.getAvatar())) {
mine.setAvatar(imageUrl + mine.getAvatar());
}
data.put("mine", mine);
return builder.data(data).build();
}
@RequestMapping("/avatar")
@ResponseBody
public Object avatar(CurrentUser user, MultipartFile file, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/avatar");
try {
// ResourceIdentifier dest = resourceManager.processResource("avatar_image", file.getBytes(), fileName);
ResourceIdentifier dest = handleFile("avatar_image", file, resourceManager);
builder.put("avatar", dest.getUrl());
if(dest != null) {
userDetailService.updateAvatar(user.getId(), dest.getRelativePath());
}
} catch (Exception e) {
throw new ApplicationException(ErrorCode.SERVER_ERROR);
}
return builder.build();
}
@RequestMapping("/update_my")
@ResponseBody
public Object updateMy(CurrentUser user, UserDetail userDetail, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_my");
userDetailService.updateMy(user.getId(), userDetail);
return builder.build();
}
@RequestMapping("/update_my_info")
@ResponseBody
public Object updateMyInfo(CurrentUser user, UserDetail userDetail, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_my_info");
userDetailService.updateMy(user.getId(), userDetail);
return builder.build();
}
@RequestMapping("/update_phones")
@ResponseBody
public Object updatePhones(CurrentUser user, String phones, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_phones");
List<Phone> list = userDetailService.updatePhones(user.getId(), phones);
JSONObject data = new JSONObject();
data.put("phones", list);
builder.data(data);
return builder.build();
}
@Autowired
private UserFriendService userFriendService;
@RequestMapping("/detail/{user_id}")
@ResponseBody
public Object detail(CurrentUser currentUser, @PathVariable("user_id") long userId, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/detail/" + userId);
UserDetailDTO userDetailDTO = userDetailService.getUserDetailDTO(userId);
if(userDetailDTO != null) {
userDetailDTO.setIsFriend(userFriendService.isFriend(currentUser.getId(), userId));
}
builder.data(userDetailDTO);
return builder.build();
}
@RequestMapping("/getUserDetail/{username}")
@ResponseBody
public Object getUserDetail(CurrentUser currentUser, @PathVariable("username") String username, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/getUserDetail/" + username);
UserDetailDTO userDetailDTO = userProxyService.getUserDetailDTO(username);
if(userDetailDTO != null) {
userDetailDTO.setIsFriend(userFriendService.isFriend(currentUser.getId(), userDetailDTO.getId()));
}
builder.data(userDetailDTO);
return builder.build();
}
@Autowired
private CommentService commentService;
@RequestMapping("/news/favor")
@ResponseBody
public Object newsFavor(CurrentUser currentUser,
@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "limit", defaultValue = "10") int limit,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/news/favor");
List<UserNewsFavor> list = commentService.getUserNewsFavorList(currentUser.getId(), start, limit);
boolean more = isMore(list, limit);
builder.putData("more", more);
builder.putData("list", list);
return builder.build();
}
@Autowired
private UserContributionService userContributionService;
@RequestMapping("/contributions")
@ResponseBody
public Object contributions(CurrentUser currentUser,
@RequestParam(value = "type", defaultValue = "0") int type,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/contributions");
List<UserContributionRecord> userContributionRecordList = userContributionService.getUserContributionRecordList(currentUser.getId(), type);
builder.putData("list", userContributionRecordList);
return builder.build();
}
@RequestMapping("/update_pwd")
@ResponseBody
public Object updatePwd(CurrentUser currentUser,
@RequestParam(value = "new_password") String new_password,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_pwd");
if (StringUtils.isNotBlank(new_password)) {// 判断password是否为空
User user = userService.findById(currentUser.getId());
Validators.isFalse(user == null, ErrorCode.VALUE_NOT_EXIST, "用户不存在");
String salt = UUIDUtil.salt();
String cNewPassword = MessageDigestUtil.getSHA256(new_password + salt);
User tmp = new User();
tmp.setId(user.getId());
tmp.setPassword(cNewPassword);
tmp.setSalt(salt);
userService.updateByIdSelective(tmp);
}
return builder.build();
}
@RequestMapping("/change_phone")
@ResponseBody
public Object updatePhone(CurrentUser currentUser,
@RequestParam(value = "phone") String phone,
@RequestParam(value = "verifyCode") String verifyCode,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/change_phone");
if (StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(verifyCode)) {// 判断password是否为空
User user = userService.findById(currentUser.getId());
Validators.isFalse(user == null, ErrorCode.VALUE_NOT_EXIST, "用户不存在");
verifyCodeService.verifyCodeAndDel("CHANGE_PHONE", phone, verifyCode);
User tmp = new User();
tmp.setId(user.getId());
tmp.setPhone(phone);
tmp.setUsername(phone);
userService.updateByIdSelective(tmp);
}
return builder.build();
}
@RequestMapping("/rank")
@ResponseBody
public Object rank(CurrentUser currentUser,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/rank");
ContributionRank contributionRank = userDetailService.getContributionRank(currentUser.getId());
builder.data(contributionRank);
return builder.build();
}
}
| UTF-8 | Java | 8,841 | java | UserController.java | Java | [
{
"context": ".setId(user.getId());\n tmp.setPassword(cNewPassword);\n tmp.setSalt(salt);\n user",
"end": 7447,
"score": 0.9983516335487366,
"start": 7435,
"tag": "PASSWORD",
"value": "cNewPassword"
}
] | null | [] | package com.family.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.family.common.model.ContributionRank;
import com.family.common.model.Phone;
import com.family.common.model.UserContributionRecord;
import com.family.common.model.UserDetail;
import com.family.common.model.UserDetailDTO;
import com.family.common.model.UserNewsFavor;
import com.family.common.service.CommentService;
import com.family.common.service.UserContributionService;
import com.family.common.service.UserDetailService;
import com.family.common.service.UserService;
import com.family.model.CurrentUser;
import com.family.service.UserFriendService;
import com.family.service.UserProxyService;
import com.family.service.VerifyCodeService;
import cn.lfy.base.model.User;
import cn.lfy.common.filehandler.ResourceIdentifier;
import cn.lfy.common.filehandler.ResourceManager;
import cn.lfy.common.framework.exception.ApplicationException;
import cn.lfy.common.framework.exception.ErrorCode;
import cn.lfy.common.model.Message;
import cn.lfy.common.utils.MessageDigestUtil;
import cn.lfy.common.utils.UUIDUtil;
import cn.lfy.common.utils.Validators;
import cn.lfy.common.web.BaseController;
@Controller
@RequestMapping("/app/user")
public class UserController extends BaseController {
@Value("${fileserver.image.url}")
private String imageUrl;
@Autowired
private UserProxyService userProxyService;
@Autowired
private ResourceManager resourceManager;
@Autowired
private UserService userService;
@Autowired
private UserDetailService userDetailService;
@Autowired
private VerifyCodeService verifyCodeService;
@RequestMapping("/me")
@ResponseBody
public Object me(CurrentUser user, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/me");
Map<String, Object> data = new HashMap<String, Object>();
data.put("basic", user);
UserDetail mine = userProxyService.getUserDetail(user.getId());
if(StringUtils.isNotBlank(mine.getAvatar())) {
mine.setAvatar(imageUrl + mine.getAvatar());
}
data.put("mine", mine);
return builder.data(data).build();
}
@RequestMapping("/avatar")
@ResponseBody
public Object avatar(CurrentUser user, MultipartFile file, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/avatar");
try {
// ResourceIdentifier dest = resourceManager.processResource("avatar_image", file.getBytes(), fileName);
ResourceIdentifier dest = handleFile("avatar_image", file, resourceManager);
builder.put("avatar", dest.getUrl());
if(dest != null) {
userDetailService.updateAvatar(user.getId(), dest.getRelativePath());
}
} catch (Exception e) {
throw new ApplicationException(ErrorCode.SERVER_ERROR);
}
return builder.build();
}
@RequestMapping("/update_my")
@ResponseBody
public Object updateMy(CurrentUser user, UserDetail userDetail, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_my");
userDetailService.updateMy(user.getId(), userDetail);
return builder.build();
}
@RequestMapping("/update_my_info")
@ResponseBody
public Object updateMyInfo(CurrentUser user, UserDetail userDetail, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_my_info");
userDetailService.updateMy(user.getId(), userDetail);
return builder.build();
}
@RequestMapping("/update_phones")
@ResponseBody
public Object updatePhones(CurrentUser user, String phones, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_phones");
List<Phone> list = userDetailService.updatePhones(user.getId(), phones);
JSONObject data = new JSONObject();
data.put("phones", list);
builder.data(data);
return builder.build();
}
@Autowired
private UserFriendService userFriendService;
@RequestMapping("/detail/{user_id}")
@ResponseBody
public Object detail(CurrentUser currentUser, @PathVariable("user_id") long userId, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/detail/" + userId);
UserDetailDTO userDetailDTO = userDetailService.getUserDetailDTO(userId);
if(userDetailDTO != null) {
userDetailDTO.setIsFriend(userFriendService.isFriend(currentUser.getId(), userId));
}
builder.data(userDetailDTO);
return builder.build();
}
@RequestMapping("/getUserDetail/{username}")
@ResponseBody
public Object getUserDetail(CurrentUser currentUser, @PathVariable("username") String username, HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/getUserDetail/" + username);
UserDetailDTO userDetailDTO = userProxyService.getUserDetailDTO(username);
if(userDetailDTO != null) {
userDetailDTO.setIsFriend(userFriendService.isFriend(currentUser.getId(), userDetailDTO.getId()));
}
builder.data(userDetailDTO);
return builder.build();
}
@Autowired
private CommentService commentService;
@RequestMapping("/news/favor")
@ResponseBody
public Object newsFavor(CurrentUser currentUser,
@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "limit", defaultValue = "10") int limit,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/news/favor");
List<UserNewsFavor> list = commentService.getUserNewsFavorList(currentUser.getId(), start, limit);
boolean more = isMore(list, limit);
builder.putData("more", more);
builder.putData("list", list);
return builder.build();
}
@Autowired
private UserContributionService userContributionService;
@RequestMapping("/contributions")
@ResponseBody
public Object contributions(CurrentUser currentUser,
@RequestParam(value = "type", defaultValue = "0") int type,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/contributions");
List<UserContributionRecord> userContributionRecordList = userContributionService.getUserContributionRecordList(currentUser.getId(), type);
builder.putData("list", userContributionRecordList);
return builder.build();
}
@RequestMapping("/update_pwd")
@ResponseBody
public Object updatePwd(CurrentUser currentUser,
@RequestParam(value = "new_password") String new_password,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/update_pwd");
if (StringUtils.isNotBlank(new_password)) {// 判断password是否为空
User user = userService.findById(currentUser.getId());
Validators.isFalse(user == null, ErrorCode.VALUE_NOT_EXIST, "用户不存在");
String salt = UUIDUtil.salt();
String cNewPassword = MessageDigestUtil.getSHA256(new_password + salt);
User tmp = new User();
tmp.setId(user.getId());
tmp.setPassword(<PASSWORD>);
tmp.setSalt(salt);
userService.updateByIdSelective(tmp);
}
return builder.build();
}
@RequestMapping("/change_phone")
@ResponseBody
public Object updatePhone(CurrentUser currentUser,
@RequestParam(value = "phone") String phone,
@RequestParam(value = "verifyCode") String verifyCode,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/change_phone");
if (StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(verifyCode)) {// 判断password是否为空
User user = userService.findById(currentUser.getId());
Validators.isFalse(user == null, ErrorCode.VALUE_NOT_EXIST, "用户不存在");
verifyCodeService.verifyCodeAndDel("CHANGE_PHONE", phone, verifyCode);
User tmp = new User();
tmp.setId(user.getId());
tmp.setPhone(phone);
tmp.setUsername(phone);
userService.updateByIdSelective(tmp);
}
return builder.build();
}
@RequestMapping("/rank")
@ResponseBody
public Object rank(CurrentUser currentUser,
HttpServletRequest request) {
Message.Builder builder = Message.newBuilder("/app/user/rank");
ContributionRank contributionRank = userDetailService.getContributionRank(currentUser.getId());
builder.data(contributionRank);
return builder.build();
}
}
| 8,839 | 0.75844 | 0.757645 | 237 | 36.118145 | 28.09708 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.919831 | false | false | 0 |
272a57012f8196d9e21eab3e2a67daf14269ce8f | 9,139,690,434,968 | 8b1727e4877dbdb4fb9461e30657c83cd50158e2 | /src/Lesson19/TaskCashRegister/Paidable.java | 01eabfd5a5ca69a67ec0589c3c6f6ab1d1cd2087 | [] | no_license | RLegun/JavaCoreProject | https://github.com/RLegun/JavaCoreProject | 97ee60d9986caf74758c834da71bed225a6ec252 | 85732d321c63c3a06816277238f64f425b8dd117 | refs/heads/master | 2021-08-30T07:14:03.932000 | 2017-12-08T19:21:54 | 2017-12-08T19:21:54 | 108,164,999 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Lesson19.TaskCashRegister;
public interface Paidable {
int executePay();
}
| UTF-8 | Java | 88 | java | Paidable.java | Java | [] | null | [] | package Lesson19.TaskCashRegister;
public interface Paidable {
int executePay();
}
| 88 | 0.761364 | 0.738636 | 5 | 16.6 | 13.778244 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 0 |
91ece7522196cce551e9c1c03915928b88ef2b68 | 23,055,384,467,795 | 690775609332be3c79c46aed095a14b6c3d73bbc | /src/heap/NextSmallerElement.java | 50f35748cef057be101e7c0ec615f2a40496ca82 | [] | no_license | Cdora1/NewRepository | https://github.com/Cdora1/NewRepository | 91492f29b650bd4dc5f261ef8b3465b1b4605122 | 547316f42f886ea221af8c4bbeae2572323a8a61 | refs/heads/master | 2023-06-03T10:34:45.866000 | 2021-06-22T17:41:37 | 2021-06-22T17:41:37 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package heap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
public class NextSmallerElement {
public static List<Integer> countSmaller(int[] arr) {
Stack<Integer> s = new Stack<Integer>();
HashMap<Integer, Integer> mp = new HashMap<Integer, Integer>();
int n = arr.length - 1;
s.push(arr[0]);
for (int i = 1; i < n; i++) {
if (s.empty()) {
s.push(arr[i]);
continue;
}
while (s.empty() == false && s.peek() > arr[i]) {
mp.put(s.peek(), arr[i]);
s.pop();
}
s.push(arr[i]);
}
while (s.empty() == false) {
mp.put(s.peek(), -1);
s.pop();
}
List ls = new ArrayList();
for (int i = 0; i < n; i++)
ls.add(mp.get(arr[i]));
return ls;
}
public static void main(String[] args) {
int arr[] = { 11, 13, 21, 3 };
System.out.println(NextSmallerElement.countSmaller(arr));
}
}
| UTF-8 | Java | 928 | java | NextSmallerElement.java | Java | [] | null | [] | package heap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
public class NextSmallerElement {
public static List<Integer> countSmaller(int[] arr) {
Stack<Integer> s = new Stack<Integer>();
HashMap<Integer, Integer> mp = new HashMap<Integer, Integer>();
int n = arr.length - 1;
s.push(arr[0]);
for (int i = 1; i < n; i++) {
if (s.empty()) {
s.push(arr[i]);
continue;
}
while (s.empty() == false && s.peek() > arr[i]) {
mp.put(s.peek(), arr[i]);
s.pop();
}
s.push(arr[i]);
}
while (s.empty() == false) {
mp.put(s.peek(), -1);
s.pop();
}
List ls = new ArrayList();
for (int i = 0; i < n; i++)
ls.add(mp.get(arr[i]));
return ls;
}
public static void main(String[] args) {
int arr[] = { 11, 13, 21, 3 };
System.out.println(NextSmallerElement.countSmaller(arr));
}
}
| 928 | 0.588362 | 0.575431 | 50 | 17.559999 | 17.29874 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.06 | false | false | 0 |
377e1c053f7b9d68f831343523234798e78fe89b | 23,055,384,466,065 | 989395cbbabd9c67e9b0a099dfb95976b3f5f20e | /app/src/main/java/com/example/homework_2/MainActivity.java | 5763658b8dcc651f2579ca007b57039c43cc362f | [] | no_license | BerembaevaAki/homework_2 | https://github.com/BerembaevaAki/homework_2 | ed58aba819aabe41201f60d91ac2c1f1204e5629 | 64570ef20b88b53c0454061bd6269defb043047b | refs/heads/master | 2022-02-16T16:15:51.445000 | 2019-07-29T13:35:30 | 2019-07-29T13:35:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.homework_2;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.text.TextUtilsCompat;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.example.homework_2.R;
public class MainActivity extends AppCompatActivity {
Button button;
TextView textView;
EditText editText;
Boolean isShow = true;
String a;
String b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text_view);
button = findViewById(R.id.button);
editText = findViewById(R.id.edit_text);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (a == null) {
a = editText.getText().toString();
textView.setText(a);
}else if (b == null){
b = editText.getText().toString();
textView.setText(b);
}else if (isShow) {
textView.setText(a);
isShow = false;
} else {
textView.setText(b);
isShow = true;
}
}
});
}
}
| UTF-8 | Java | 1,510 | java | MainActivity.java | Java | [] | null | [] | package com.example.homework_2;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.text.TextUtilsCompat;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.example.homework_2.R;
public class MainActivity extends AppCompatActivity {
Button button;
TextView textView;
EditText editText;
Boolean isShow = true;
String a;
String b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text_view);
button = findViewById(R.id.button);
editText = findViewById(R.id.edit_text);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (a == null) {
a = editText.getText().toString();
textView.setText(a);
}else if (b == null){
b = editText.getText().toString();
textView.setText(b);
}else if (isShow) {
textView.setText(a);
isShow = false;
} else {
textView.setText(b);
isShow = true;
}
}
});
}
}
| 1,510 | 0.599338 | 0.598013 | 59 | 24.576271 | 17.975693 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.542373 | false | false | 0 |
83a7edf182d60bc7b81210344bebf8b8c939d800 | 10,316,511,485,519 | 76184a0c82158dc73e4b541b6fb7bec3e9b369e0 | /manager/src/main/java/com/reign/manager/service/script/ScriptService.java | a091c3a14acba2d9ecaec73f08ad6468eb79c970 | [] | no_license | jgteng/reign | https://github.com/jgteng/reign | b564f7819f2356692eda12b94fc9e421b50d5934 | fc678c0293af7a3bb4a12b2cf950d048c4edf513 | refs/heads/master | 2021-01-21T13:56:53.430000 | 2016-05-23T08:43:42 | 2016-05-23T08:43:42 | 49,260,159 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.reign.manager.service.script;
import com.reign.domain.script.Script;
import java.io.File;
import java.util.List;
/**
* Created by ji on 15-12-10.
*/
public interface ScriptService {
public byte[] getFile(String... args) throws Exception;
public boolean saveFile(File paramFile) throws Exception;
List<Script> listScript(Script script) throws Exception;
}
| UTF-8 | Java | 386 | java | ScriptService.java | Java | [
{
"context": "io.File;\nimport java.util.List;\n\n/**\n * Created by ji on 15-12-10.\n */\npublic interface ScriptService {",
"end": 148,
"score": 0.9710032939910889,
"start": 146,
"tag": "USERNAME",
"value": "ji"
}
] | null | [] | package com.reign.manager.service.script;
import com.reign.domain.script.Script;
import java.io.File;
import java.util.List;
/**
* Created by ji on 15-12-10.
*/
public interface ScriptService {
public byte[] getFile(String... args) throws Exception;
public boolean saveFile(File paramFile) throws Exception;
List<Script> listScript(Script script) throws Exception;
}
| 386 | 0.740933 | 0.725389 | 17 | 21.705883 | 22.603395 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 0 |
77cbc79df813ef6592a405a18e5c41d07e9952fc | 12,610,024,011,340 | 185e6515ce3921d2230056b941353accbce7d95c | /strategy-pattern/src/main/java/cn/onlon/design/strategy/pattern/context/Context.java | f9150032cfcc3da7b5954aed907c03a56e9ca787 | [] | no_license | guoqingcun/Design-pattern | https://github.com/guoqingcun/Design-pattern | cd495e2a1539fddde4782dc5faf669e0a148e336 | 22e460a098b8c16a02b52701d9b040e486c7d55a | refs/heads/master | 2021-10-23T05:39:16.098000 | 2021-10-20T07:44:18 | 2021-10-20T07:44:18 | 178,579,391 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* All rights Reserved, Designed By www.onlon.cn
* @Title: Context.java
* @Package cn.onlon.design.strategy.pattern.context
* @Description: TODO(用一句话描述该文件做什么)
* @author: 郭清存
* @date: 2019年4月5日 上午11:12:14
* @version V1.0
* @Copyright: 2019 www.onlon.cn Inc. All rights reserved.
*/
package cn.onlon.design.strategy.pattern.context;
import cn.onlon.design.strategy.pattern.strategy.Istrategy;
/**
* @ClassName: Context
* @Description:TODO(策略的上下文)
* @author: 郭清存
* @date: 2019年4月5日 上午11:12:14
*
* @Copyright: 2019 www.onlon.cn Inc. All rights reserved.
* 注意:本内容仅限于公益交流,禁止外泄以及用于其他的商业目
*/
public class Context {
Istrategy strategy;
public Context(Istrategy strategy) {
this.strategy = strategy;
}
public void oprate() {
strategy.fight();
}
}
| UTF-8 | Java | 949 | java | Context.java | Java | [
{
"context": "Description: TODO(用一句话描述该文件做什么) \n * @author: 郭清存 \n * @date: 2019年4月5日 上午11:12:14 \n * @vers",
"end": 196,
"score": 0.9998157620429993,
"start": 193,
"tag": "NAME",
"value": "郭清存"
},
{
"context": "xt \n * @Description:TODO(策略的上下文) \n * @author: 郭清存 \n * @date: 2019年4月5日 上午11:12:14 \n * \n * @",
"end": 515,
"score": 0.9998123645782471,
"start": 512,
"tag": "NAME",
"value": "郭清存"
}
] | null | [] | /**
* All rights Reserved, Designed By www.onlon.cn
* @Title: Context.java
* @Package cn.onlon.design.strategy.pattern.context
* @Description: TODO(用一句话描述该文件做什么)
* @author: 郭清存
* @date: 2019年4月5日 上午11:12:14
* @version V1.0
* @Copyright: 2019 www.onlon.cn Inc. All rights reserved.
*/
package cn.onlon.design.strategy.pattern.context;
import cn.onlon.design.strategy.pattern.strategy.Istrategy;
/**
* @ClassName: Context
* @Description:TODO(策略的上下文)
* @author: 郭清存
* @date: 2019年4月5日 上午11:12:14
*
* @Copyright: 2019 www.onlon.cn Inc. All rights reserved.
* 注意:本内容仅限于公益交流,禁止外泄以及用于其他的商业目
*/
public class Context {
Istrategy strategy;
public Context(Istrategy strategy) {
this.strategy = strategy;
}
public void oprate() {
strategy.fight();
}
}
| 949 | 0.664242 | 0.62303 | 35 | 22.571428 | 19.149466 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.485714 | false | false | 0 |
c4a691cc59e4889e21b66f3f20a62b8b4029add0 | 24,558,623,035,040 | 8c2b32d6dee645beef1159330d7b14f2ca026093 | /gelato/src/main/java/gelato/leet1/sumNumbers.java | 20bc3c63dfdc54656b008088e22b6cd7f3b7afbe | [] | no_license | jinszh/gelato | https://github.com/jinszh/gelato | 9243c0bb4b28894cda24d493220abf273a48e6f5 | 74b3b8cb0440b2b150fbc8c3a1b8a1e0842d389b | refs/heads/master | 2022-12-23T14:12:16.820000 | 2021-08-05T08:55:17 | 2021-08-05T08:55:17 | 154,602,479 | 0 | 0 | null | false | 2022-12-16T04:49:13 | 2018-10-25T03:07:45 | 2021-08-05T08:55:25 | 2022-12-16T04:49:10 | 1,207 | 0 | 0 | 4 | Java | false | false | package gelato.leet1;
import gelato.model.TreeNode;
//129
public class sumNumbers {
int sum = 0;
public int sumNumbers(TreeNode root) {
dfs(root, 0);
return sum;
}
private void dfs(TreeNode root, int v){
if(root == null) return;
if(root.left == null && root.right == null){
sum += v * 10 + root.val;
}else {
dfs(root.left, v * 10 + root.val);
dfs(root.right, v * 10 + root.val);
}
}
}
| UTF-8 | Java | 492 | java | sumNumbers.java | Java | [] | null | [] | package gelato.leet1;
import gelato.model.TreeNode;
//129
public class sumNumbers {
int sum = 0;
public int sumNumbers(TreeNode root) {
dfs(root, 0);
return sum;
}
private void dfs(TreeNode root, int v){
if(root == null) return;
if(root.left == null && root.right == null){
sum += v * 10 + root.val;
}else {
dfs(root.left, v * 10 + root.val);
dfs(root.right, v * 10 + root.val);
}
}
}
| 492 | 0.518293 | 0.493902 | 22 | 21.363636 | 16.977379 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.590909 | false | false | 0 |
0bc3f20b3ab52b7c41640b72f3246c26202ed2e3 | 15,530,601,780,486 | 156188dab883f0141dc97306182e65614d2c13a4 | /src/twitterHTTP/IpTest2.java | 8b2512dbc627277853c253827c989b8da9a1d29b | [] | no_license | qifeili/TwitterAgricultureCrawler | https://github.com/qifeili/TwitterAgricultureCrawler | 872cc9f4f5072f920a6de1520ca2e5d85343bc9a | 0859bb245fcea404cec9fcf636978271ca3470bd | refs/heads/master | 2020-12-02T17:46:02.620000 | 2017-07-06T11:55:07 | 2017-07-06T11:55:07 | 96,423,334 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package twitterHTTP;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class IpTest2 {
public static void main(String[] args) {
Pattern p = Pattern.compile("(http://|ftp://|https://|www){0,1}[^\u4e00-\u9fa5\\s]*?\\.(com|net|cn|me|tw|fr){0,1}(\\S)+(\\/)(\\S)+" );
Matcher m = p.matcher(""+
"Mass shootings list. Reagan - 11 Bush Sr - 12 Clinton - 23 Bush Jr - 16 Obama - 162 #SanB.erna/dino"
);
if(m.find()){
System.out.println(m.groupCount());
System.out.println(m.group());
}
/*
m = p.matcher("http://zh.wikipedia.org:80/wiki/Special:Search?search=tielu&go=Go");
if(m.find()){
System.out.println(m.group());
} */
}
}
| UTF-8 | Java | 947 | java | IpTest2.java | Java | [] | null | [] | package twitterHTTP;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class IpTest2 {
public static void main(String[] args) {
Pattern p = Pattern.compile("(http://|ftp://|https://|www){0,1}[^\u4e00-\u9fa5\\s]*?\\.(com|net|cn|me|tw|fr){0,1}(\\S)+(\\/)(\\S)+" );
Matcher m = p.matcher(""+
"Mass shootings list. Reagan - 11 Bush Sr - 12 Clinton - 23 Bush Jr - 16 Obama - 162 #SanB.erna/dino"
);
if(m.find()){
System.out.println(m.groupCount());
System.out.println(m.group());
}
/*
m = p.matcher("http://zh.wikipedia.org:80/wiki/Special:Search?search=tielu&go=Go");
if(m.find()){
System.out.println(m.group());
} */
}
}
| 947 | 0.441394 | 0.417107 | 31 | 28.483871 | 33.192371 | 145 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.774194 | false | false | 0 |
269b0c540c9ae4af16777a5226147871a25b7dce | 25,288,767,472,834 | 51d4db297594e24de46c1efaf4f0430891f3f6c1 | /src/adapterpattern/Duck.java | 95522073e8c1973edb77f9429d11420d7c5cd1e0 | [] | no_license | sciencefl/Design-Patterns-master | https://github.com/sciencefl/Design-Patterns-master | 5c0150649ac9eb26c249ce91b9a30cb8a0cc7c57 | 456f7e6f14f25d22d309115afea49080740b6667 | refs/heads/master | 2021-07-13T10:34:19.429000 | 2020-05-26T05:56:14 | 2020-05-26T05:56:14 | 146,556,444 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package adapterpattern;
public interface Duck {
public void fly();
public void quack();
}
| UTF-8 | Java | 102 | java | Duck.java | Java | [] | null | [] | package adapterpattern;
public interface Duck {
public void fly();
public void quack();
}
| 102 | 0.666667 | 0.666667 | 7 | 12.571428 | 10.648369 | 23 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 0 |
b143bb0eb7d6280e20887c612b5c5ba681416e29 | 32,469,952,798,681 | 82d9cf1a6d7e04f496862c8e6e46d07f2f40221e | /CodingBookExcercises/src/test/java/Chapter1/question1_1/DuplicateCheckerTest.java | 6126cdbe13598c49080a372809de69c9ab206a3f | [] | no_license | cjrgraham/CodingBookExcercises | https://github.com/cjrgraham/CodingBookExcercises | ec5b10ecf6fb1a427782541fa591494787007b84 | f4a19f6e8d8acfacaeaa2817b5454ef4109ebeef | refs/heads/master | 2020-05-17T20:49:31.093000 | 2019-05-11T15:31:19 | 2019-05-11T15:31:19 | 181,973,767 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Chapter1.question1_1;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
class DuplicateCheckerTest {
@Mock
private CharFrequencyRecorder frequencyRecorder;
@InjectMocks
private DuplicateChecker duplicateChecker;
@BeforeEach
void setUp() throws Exception {
for(char characterOfAlphabet = 'a'; characterOfAlphabet <='z'; characterOfAlphabet ++ )
{
/* Has to be lenient because all letters
* of alphabet get mocked for each test
* but not neccessarily used. Otherwise
* mocking code would be much longer
*
*/
Mockito.lenient()
.doReturn(1,2)
.when(frequencyRecorder)
.getOccurences(characterOfAlphabet);
}
for(char characterOfAlphabet = 'A'; characterOfAlphabet <='Z'; characterOfAlphabet ++ )
{
Mockito.lenient()
.doReturn(1,2)
.when(frequencyRecorder)
.getOccurences(characterOfAlphabet);
}
}
@Test
void hasDuplicateLetters() {
boolean hasDuplicate;
String testString = "abcddefg";
hasDuplicate = duplicateChecker.checkForDuplicates(testString);
assertTrue(hasDuplicate);
}
@Test
void lacksDuplicateLetters() {
boolean hasDuplicate;
String testString = "abcdDefg";
hasDuplicate = duplicateChecker.checkForDuplicates(testString);
assertFalse(hasDuplicate);
}
}
| UTF-8 | Java | 1,684 | java | DuplicateCheckerTest.java | Java | [] | null | [] | package Chapter1.question1_1;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
class DuplicateCheckerTest {
@Mock
private CharFrequencyRecorder frequencyRecorder;
@InjectMocks
private DuplicateChecker duplicateChecker;
@BeforeEach
void setUp() throws Exception {
for(char characterOfAlphabet = 'a'; characterOfAlphabet <='z'; characterOfAlphabet ++ )
{
/* Has to be lenient because all letters
* of alphabet get mocked for each test
* but not neccessarily used. Otherwise
* mocking code would be much longer
*
*/
Mockito.lenient()
.doReturn(1,2)
.when(frequencyRecorder)
.getOccurences(characterOfAlphabet);
}
for(char characterOfAlphabet = 'A'; characterOfAlphabet <='Z'; characterOfAlphabet ++ )
{
Mockito.lenient()
.doReturn(1,2)
.when(frequencyRecorder)
.getOccurences(characterOfAlphabet);
}
}
@Test
void hasDuplicateLetters() {
boolean hasDuplicate;
String testString = "abcddefg";
hasDuplicate = duplicateChecker.checkForDuplicates(testString);
assertTrue(hasDuplicate);
}
@Test
void lacksDuplicateLetters() {
boolean hasDuplicate;
String testString = "abcdDefg";
hasDuplicate = duplicateChecker.checkForDuplicates(testString);
assertFalse(hasDuplicate);
}
}
| 1,684 | 0.699525 | 0.695368 | 63 | 24.730158 | 21.10759 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.809524 | false | false | 0 |
fb9b64c64ee45fd5ad46c1c07922fd794885aac5 | 32,469,952,800,059 | c840c7a2e20671f1be41cd626b86ca1c7e88bc65 | /Boblio/Ouvrage.java | ef3b91617b1368b80d2919715679a1d1e1d4107d | [] | no_license | mwone472/javaL3 | https://github.com/mwone472/javaL3 | 69c0ab110fdb40672c0bdb4c483914f4dd8f3fab | fcb4c0b9b002b5be840a87bd68048e0a244a951e | refs/heads/master | 2023-04-18T14:47:13.071000 | 2021-05-01T17:45:01 | 2021-05-01T17:45:01 | 340,361,228 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.ArrayList;
public class Ouvrage {
private int ouvrage_id;
private String nom_ouvrage;
private int number_interne;
private ArrayList<Auteur> list_author = new ArrayList<Auteur>();
public Ouvrage(int number_interne, String nom_ouvrage, int ouvrage_id) {
this.number_interne = number_interne;
this.nom_ouvrage = nom_ouvrage;
this.ouvrage_id = ouvrage_id;
}
public ArrayList<Auteur> getList_author() {
return this.list_author;
}
public void add(ArrayList<Auteur> authors) {
for (Auteur auteur : authors) {
this.getList_author().add(auteur);
}
}
public void listAuthor() {
for (Auteur auteur : this.list_author) {
System.out.println(auteur.getAuthor_name());
}
}
public String getNom_ouvrage() {
return nom_ouvrage;
}
} | UTF-8 | Java | 889 | java | Ouvrage.java | Java | [] | null | [] | import java.util.ArrayList;
public class Ouvrage {
private int ouvrage_id;
private String nom_ouvrage;
private int number_interne;
private ArrayList<Auteur> list_author = new ArrayList<Auteur>();
public Ouvrage(int number_interne, String nom_ouvrage, int ouvrage_id) {
this.number_interne = number_interne;
this.nom_ouvrage = nom_ouvrage;
this.ouvrage_id = ouvrage_id;
}
public ArrayList<Auteur> getList_author() {
return this.list_author;
}
public void add(ArrayList<Auteur> authors) {
for (Auteur auteur : authors) {
this.getList_author().add(auteur);
}
}
public void listAuthor() {
for (Auteur auteur : this.list_author) {
System.out.println(auteur.getAuthor_name());
}
}
public String getNom_ouvrage() {
return nom_ouvrage;
}
} | 889 | 0.619798 | 0.619798 | 34 | 25.17647 | 21.320345 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 0 |
d89eff5b1ac7509905d90ecb5fbebdbdb7baa348 | 8,160,437,908,600 | dbba3ecb618104a8122d179d523ca84258a1697e | /src/com/wickedgaminguk/ExplosiveSmite/ExplosiveSmite.java | 6b216872ffc867fc39ac29e41d0529ad75716d4b | [] | no_license | WickedGamingUK/Explosive-Smite | https://github.com/WickedGamingUK/Explosive-Smite | 8492e222449c176d7092565c3e5676e31a8c3f4f | d2d677131b10ed83099391cde34156fded1cb841 | refs/heads/master | 2016-09-15T23:04:08.097000 | 2013-12-01T09:15:06 | 2013-12-01T09:15:06 | 9,880,349 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.wickedgaminguk.ExplosiveSmite;
import com.wickedgaminguk.ExplosiveSmite.Commands.*;
import java.io.IOException;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.logging.Level;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class ExplosiveSmite extends JavaPlugin {
public static ExplosiveSmite plugin = null;
public static String pluginName;
public static String pluginVersion;
public static String pluginAuthor;
File configFile;
FileConfiguration config;
@Override
public void onEnable() {
plugin = this;
configFile = new File(plugin.getDataFolder(), "config.yml");
PluginDescriptionFile pdf = plugin.getDescription();
pluginName = pdf.getName();
pluginVersion = pdf.getVersion();
pluginAuthor = pdf.getAuthors().get(0);
if(!new File(plugin.getDataFolder(), "config.yml").isFile()) {
this.saveDefaultConfig();
ES_Util.logger.log(Level.INFO, "{0} version {1} configuration file saved.", new Object[]{pluginName, pluginVersion});
}
YamlConfiguration.loadConfiguration(configFile);
ES_Util.logger.log(Level.INFO, "{0} version {1} by {2} is enabled", new Object[]{pluginName, pluginVersion, pluginAuthor});
try {
MCstats metrics = new MCstats(this);
metrics.start();
}
catch (IOException e) {
ES_Util.logger.log(Level.SEVERE, "{0} Plugin Metrics have failed to submit the statistics to McStats!", pluginName);
}
plugin.getCommand("esmite").setExecutor(new Command_esmite(plugin));
plugin.getCommand("explosivesmite").setExecutor(new Command_explosivesmite(plugin));
plugin.getCommand("mong").setExecutor(new Command_mong(plugin));
plugin.getCommand("catapult").setExecutor(new Command_catapult(plugin));
}
@Override
public void onDisable() {
ES_Util.logger.log(Level.INFO, "{0} version {1} by {2} is disabled", new Object[]{pluginName, pluginVersion, pluginAuthor});
}
public static String getPluginName() {
return pluginName;
}
public static String getPluginVersion() {
return pluginVersion;
}
public static String getPluginAuthor() {
return pluginAuthor;
}
} | UTF-8 | Java | 2,489 | java | ExplosiveSmite.java | Java | [] | null | [] |
package com.wickedgaminguk.ExplosiveSmite;
import com.wickedgaminguk.ExplosiveSmite.Commands.*;
import java.io.IOException;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.logging.Level;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class ExplosiveSmite extends JavaPlugin {
public static ExplosiveSmite plugin = null;
public static String pluginName;
public static String pluginVersion;
public static String pluginAuthor;
File configFile;
FileConfiguration config;
@Override
public void onEnable() {
plugin = this;
configFile = new File(plugin.getDataFolder(), "config.yml");
PluginDescriptionFile pdf = plugin.getDescription();
pluginName = pdf.getName();
pluginVersion = pdf.getVersion();
pluginAuthor = pdf.getAuthors().get(0);
if(!new File(plugin.getDataFolder(), "config.yml").isFile()) {
this.saveDefaultConfig();
ES_Util.logger.log(Level.INFO, "{0} version {1} configuration file saved.", new Object[]{pluginName, pluginVersion});
}
YamlConfiguration.loadConfiguration(configFile);
ES_Util.logger.log(Level.INFO, "{0} version {1} by {2} is enabled", new Object[]{pluginName, pluginVersion, pluginAuthor});
try {
MCstats metrics = new MCstats(this);
metrics.start();
}
catch (IOException e) {
ES_Util.logger.log(Level.SEVERE, "{0} Plugin Metrics have failed to submit the statistics to McStats!", pluginName);
}
plugin.getCommand("esmite").setExecutor(new Command_esmite(plugin));
plugin.getCommand("explosivesmite").setExecutor(new Command_explosivesmite(plugin));
plugin.getCommand("mong").setExecutor(new Command_mong(plugin));
plugin.getCommand("catapult").setExecutor(new Command_catapult(plugin));
}
@Override
public void onDisable() {
ES_Util.logger.log(Level.INFO, "{0} version {1} by {2} is disabled", new Object[]{pluginName, pluginVersion, pluginAuthor});
}
public static String getPluginName() {
return pluginName;
}
public static String getPluginVersion() {
return pluginVersion;
}
public static String getPluginAuthor() {
return pluginAuthor;
}
} | 2,489 | 0.668943 | 0.664926 | 70 | 34.557144 | 32.558796 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.728571 | false | false | 0 |
2f4d3787da0b72077a16fec752d53139604c2635 | 3,539,053,062,042 | 8a1d15ff941033dece30d949f9ae9936eb15abd9 | /spring-boot-security/src/main/java/com/frozen/springbootsecurity/po/UserRole.java | cd833ef1ae1f8198db91ffb2d6a65ee0bcf0dd15 | [] | no_license | jdfrozen/J-frozen | https://github.com/jdfrozen/J-frozen | 5488b7401e1d31263b429580bfc61066e14f0166 | bcdd1b37d0ba6e160c0d29d4d3aeb7a93f73ec63 | refs/heads/master | 2022-12-11T18:05:36.386000 | 2021-01-29T07:29:43 | 2021-01-29T07:29:43 | 160,789,767 | 1 | 0 | null | false | 2022-11-21T22:37:13 | 2018-12-07T07:45:59 | 2021-01-29T07:30:34 | 2022-11-21T22:37:13 | 22,000 | 1 | 0 | 20 | Java | false | false | package com.frozen.springbootsecurity.po;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class UserRole {
private Long id;
private Long userId;
private Long roleId;
private Date createTime;
private Date updateTime;
}
| UTF-8 | Java | 287 | java | UserRole.java | Java | [] | null | [] | package com.frozen.springbootsecurity.po;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class UserRole {
private Long id;
private Long userId;
private Long roleId;
private Date createTime;
private Date updateTime;
}
| 287 | 0.731707 | 0.731707 | 20 | 13.35 | 12.740781 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45 | false | false | 0 |
3c4e192cf30910b5fa93e3e8b3228bf788ef1897 | 13,400,298,002,494 | be5acab16b4e50c97e1a2cc3a420c103480dbcc8 | /src/java/controller/StudentController11.java | 8fb80757c0ca73d50d3133833ce81b4df7d433a6 | [] | no_license | san6695/bv | https://github.com/san6695/bv | 41fb29f9d40daea303a924a655e3d803f53d983c | 0e4ab2109adde76c662716ba4ddb13ebf92975f0 | refs/heads/master | 2020-03-14T21:39:33.803000 | 2018-05-02T05:33:38 | 2018-05-02T05:33:38 | 131,801,719 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controller;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import entity.Major;
import entity.Mailer;
import entity.Student;
import entity.User;
import java.io.File;
import javax.mail.internet.MimeMessage;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@Transactional
@Controller
@RequestMapping("/thanhtich")
public class StudentController11 {
@Autowired
SessionFactory factory;
@Autowired
ServletContext context;
@Autowired
JavaMailSender mailer;
@RequestMapping("student")
public String quaylai(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "student";
}
@RequestMapping("list")
public String index1(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping()
public String index(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "student";
}
@RequestMapping("sendmail")
public String send(ModelMap model, @RequestParam("from") String from,
@RequestParam("to") String to,
@RequestParam("subject") String subject,
@RequestParam("body") String body) {
try {
// Tạo mail
MimeMessage mail = mailer.createMimeMessage();
// Sử dụng lớp trợ giúp
MimeMessageHelper helper = new MimeMessageHelper(mail);
helper.setFrom(from, from);
helper.setTo(to);
helper.setReplyTo(from, from);
helper.setSubject(subject);
helper.setText(body, true);
// Gửi mail
mailer.send(mail);
model.addAttribute("message", "Gửi email thành công !");
} catch (Exception ex) {
model.addAttribute("message", "Gửi email thất bại !");
}
return "sendmail";
}
@RequestMapping("form2/{id}")
public String edit2(ModelMap model, @PathVariable("id") Integer id) {
Session session = factory.getCurrentSession();
Student student = (Student) session.get(Student.class, id);
model.addAttribute("student", student);
model.addAttribute("students", getStudents());
return "mailer/form2";
}
@RequestMapping(params="btnCapNhat")
public String capnhat(ModelMap model, @ModelAttribute("student") Student student,HttpServletRequest request,@RequestParam ("txtimg") String img ) {
Session session = factory.openSession();
Transaction t = session.beginTransaction();
double mark = Double.parseDouble(request.getParameter("txtTru"));
double kyluat = Double.parseDouble(request.getParameter("txtKyluat"));
String image = request.getParameter("txtimg");
try{
student.setMark(mark);
student.setPhoto(image);
student.setKyluat(kyluat);
if(student.getMark() > 10){
model.addAttribute("message", "Điểm không được lớn hơn 10");
}
session.update(student);
t.commit();
model.addAttribute("message", "Cập nhật thành công !");
}
catch (Exception e) {
t.rollback();
model.addAttribute("message", "Cập nhật thất bại !");
}
finally {
session.close();
}
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping(params="btnKhen")
public String khen(ModelMap model, @ModelAttribute("student") Student student,HttpServletRequest request,@RequestParam ("txtimg") String img ) {
Session session = factory.openSession();
Transaction t = session.beginTransaction();
double mark = Double.parseDouble(request.getParameter("txtCong"));
double thanhtich = Double.parseDouble(request.getParameter("txtThanhtich"));
String image = request.getParameter("txtimg");
try{
student.setMark(mark);
student.setPhoto(image);
student.setThanhtich(thanhtich);
if(student.getMark() > 10){
model.addAttribute("message", "Điểm không được lớn hơn 10");
}
session.update(student);
t.commit();
model.addAttribute("message", "Cập nhật thành công !");
}
catch (Exception e) {
t.rollback();
model.addAttribute("message", "Cập nhật thất bại !");
}
finally {
session.close();
}
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping("{id}")
public String edit(ModelMap model, @PathVariable("id") Integer id) {
Session session = factory.getCurrentSession();
Student student = (Student) session.get(Student.class, id);
model.addAttribute("student", student);
model.addAttribute("students", getStudents());
return "thanhtich";
}
@SuppressWarnings("unchecked")
public List<Student> getStudents() {
Session session = factory.getCurrentSession();
String hql = "FROM Student";
Query query = session.createQuery(hql);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudents() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudentsLT() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o where o.major = 'MUL' order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudentMAR() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o where o.major = 'MAR' order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@ModelAttribute("majors")
@SuppressWarnings("unchecked")
public List<Major> getMajors() {
Session session = factory.getCurrentSession();
String hql = "FROM Major";
Query query = session.createQuery(hql);
List<Major> list = query.list();
return list;
}
}
| UTF-8 | Java | 7,883 | java | StudentController11.java | Java | [] | null | [] | package controller;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import entity.Major;
import entity.Mailer;
import entity.Student;
import entity.User;
import java.io.File;
import javax.mail.internet.MimeMessage;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@Transactional
@Controller
@RequestMapping("/thanhtich")
public class StudentController11 {
@Autowired
SessionFactory factory;
@Autowired
ServletContext context;
@Autowired
JavaMailSender mailer;
@RequestMapping("student")
public String quaylai(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "student";
}
@RequestMapping("list")
public String index1(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping()
public String index(ModelMap model) {
model.addAttribute("student", new Student());
model.addAttribute("students", getStudents());
return "student";
}
@RequestMapping("sendmail")
public String send(ModelMap model, @RequestParam("from") String from,
@RequestParam("to") String to,
@RequestParam("subject") String subject,
@RequestParam("body") String body) {
try {
// Tạo mail
MimeMessage mail = mailer.createMimeMessage();
// Sử dụng lớp trợ giúp
MimeMessageHelper helper = new MimeMessageHelper(mail);
helper.setFrom(from, from);
helper.setTo(to);
helper.setReplyTo(from, from);
helper.setSubject(subject);
helper.setText(body, true);
// Gửi mail
mailer.send(mail);
model.addAttribute("message", "Gửi email thành công !");
} catch (Exception ex) {
model.addAttribute("message", "Gửi email thất bại !");
}
return "sendmail";
}
@RequestMapping("form2/{id}")
public String edit2(ModelMap model, @PathVariable("id") Integer id) {
Session session = factory.getCurrentSession();
Student student = (Student) session.get(Student.class, id);
model.addAttribute("student", student);
model.addAttribute("students", getStudents());
return "mailer/form2";
}
@RequestMapping(params="btnCapNhat")
public String capnhat(ModelMap model, @ModelAttribute("student") Student student,HttpServletRequest request,@RequestParam ("txtimg") String img ) {
Session session = factory.openSession();
Transaction t = session.beginTransaction();
double mark = Double.parseDouble(request.getParameter("txtTru"));
double kyluat = Double.parseDouble(request.getParameter("txtKyluat"));
String image = request.getParameter("txtimg");
try{
student.setMark(mark);
student.setPhoto(image);
student.setKyluat(kyluat);
if(student.getMark() > 10){
model.addAttribute("message", "Điểm không được lớn hơn 10");
}
session.update(student);
t.commit();
model.addAttribute("message", "Cập nhật thành công !");
}
catch (Exception e) {
t.rollback();
model.addAttribute("message", "Cập nhật thất bại !");
}
finally {
session.close();
}
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping(params="btnKhen")
public String khen(ModelMap model, @ModelAttribute("student") Student student,HttpServletRequest request,@RequestParam ("txtimg") String img ) {
Session session = factory.openSession();
Transaction t = session.beginTransaction();
double mark = Double.parseDouble(request.getParameter("txtCong"));
double thanhtich = Double.parseDouble(request.getParameter("txtThanhtich"));
String image = request.getParameter("txtimg");
try{
student.setMark(mark);
student.setPhoto(image);
student.setThanhtich(thanhtich);
if(student.getMark() > 10){
model.addAttribute("message", "Điểm không được lớn hơn 10");
}
session.update(student);
t.commit();
model.addAttribute("message", "Cập nhật thành công !");
}
catch (Exception e) {
t.rollback();
model.addAttribute("message", "Cập nhật thất bại !");
}
finally {
session.close();
}
model.addAttribute("students", getStudents());
return "thanhtich";
}
@RequestMapping("{id}")
public String edit(ModelMap model, @PathVariable("id") Integer id) {
Session session = factory.getCurrentSession();
Student student = (Student) session.get(Student.class, id);
model.addAttribute("student", student);
model.addAttribute("students", getStudents());
return "thanhtich";
}
@SuppressWarnings("unchecked")
public List<Student> getStudents() {
Session session = factory.getCurrentSession();
String hql = "FROM Student";
Query query = session.createQuery(hql);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudents() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudentsLT() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o where o.major = 'MUL' order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@SuppressWarnings("unchecked")
public List<Student> getTopStudentMAR() {
Session session = factory.getCurrentSession();
Query query = session.createQuery("from Student as o where o.major = 'MAR' order by o.mark desc");
query.setFirstResult(0);
query.setMaxResults(6);
List<Student> list = query.list();
return list;
}
@ModelAttribute("majors")
@SuppressWarnings("unchecked")
public List<Major> getMajors() {
Session session = factory.getCurrentSession();
String hql = "FROM Major";
Query query = session.createQuery(hql);
List<Major> list = query.list();
return list;
}
}
| 7,883 | 0.636748 | 0.634187 | 232 | 32.663792 | 24.80265 | 148 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.422414 | false | false | 0 |
4579294adf0e071a64d36132ba82bc37c1819c83 | 23,837,068,531,609 | 7ea185fa90710fcf5edd8f770ee5683a8a721b39 | /src/main/java/pe/com/fingerprint/persistence/LaptopMapper.java | 81a2151ad4ab74af758aa3c88217fd9f14edab7f | [] | no_license | jmoics/MidFinger | https://github.com/jmoics/MidFinger | 51d3666cccf90759da1713913566b1b5882f9b0b | 70e9f63e5d9ac1cdb821ce2ba99b8651ac2b53fd | refs/heads/master | 2017-05-05T08:25:19.442000 | 2017-03-10T20:45:41 | 2017-03-10T20:45:41 | 59,431,421 | 0 | 0 | null | false | 2016-08-16T22:02:39 | 2016-05-22T19:55:25 | 2016-05-23T07:15:18 | 2016-08-16T22:02:38 | 29,389 | 0 | 0 | 0 | Java | null | null | package pe.com.fingerprint.persistence;
import java.util.List;
import pe.com.fingerprint.model.Laptops;
import pe.com.fingerprint.model.LaptopsMove;
/**
* @author Jorge
*
*/
public interface LaptopMapper
{
/**
* @param _laptop for filters.
* @return List of Laptops
*/
List<Laptops> getLaptops(Laptops _laptop);
/**
* @param _laptop for filters.
* @return Laptop object
*/
Laptops getLaptop4Id(Laptops _laptop);
/**
* @param _laptop for filters.
* @return Laptop objects.
*/
Laptops getLaptop4Serial(Laptops _laptop);
/**
* @param _laptop new Laptop object.
*/
void insertLaptop(Laptops _laptop);
/**
* @param _laptop Laptop object to update.
*/
void updateLaptop(Laptops _laptop);
/**
* @param _laptop Laptop object to update.
*/
void updateStore4Laptop(Laptops _laptop);
/**
* @param _laptop
* @return
*/
boolean deleteLaptop(Laptops _laptop);
/**
* @param _laptop new LaptopsMove object.
*/
void insertMovimientoLaptop(LaptopsMove _laptop);
}
| UTF-8 | Java | 1,123 | java | LaptopMapper.java | Java | [
{
"context": "com.fingerprint.model.LaptopsMove;\n\n/**\n * @author Jorge\n *\n */\npublic interface LaptopMapper\n{\n /*",
"end": 168,
"score": 0.9009392857551575,
"start": 167,
"tag": "NAME",
"value": "J"
},
{
"context": "m.fingerprint.model.LaptopsMove;\n\n/**\n * @author Jorge\n *\n */\npublic interface LaptopMapper\n{\n /**\n ",
"end": 172,
"score": 0.57561194896698,
"start": 168,
"tag": "USERNAME",
"value": "orge"
}
] | null | [] | package pe.com.fingerprint.persistence;
import java.util.List;
import pe.com.fingerprint.model.Laptops;
import pe.com.fingerprint.model.LaptopsMove;
/**
* @author Jorge
*
*/
public interface LaptopMapper
{
/**
* @param _laptop for filters.
* @return List of Laptops
*/
List<Laptops> getLaptops(Laptops _laptop);
/**
* @param _laptop for filters.
* @return Laptop object
*/
Laptops getLaptop4Id(Laptops _laptop);
/**
* @param _laptop for filters.
* @return Laptop objects.
*/
Laptops getLaptop4Serial(Laptops _laptop);
/**
* @param _laptop new Laptop object.
*/
void insertLaptop(Laptops _laptop);
/**
* @param _laptop Laptop object to update.
*/
void updateLaptop(Laptops _laptop);
/**
* @param _laptop Laptop object to update.
*/
void updateStore4Laptop(Laptops _laptop);
/**
* @param _laptop
* @return
*/
boolean deleteLaptop(Laptops _laptop);
/**
* @param _laptop new LaptopsMove object.
*/
void insertMovimientoLaptop(LaptopsMove _laptop);
}
| 1,123 | 0.611754 | 0.609083 | 57 | 18.701754 | 17.617739 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.210526 | false | false | 0 |
3f240124c2bdc07ed9f9f0cfee9e8404e07db332 | 15,272,903,743,419 | 7966fc91a740ef937c22063b890ec900f0c5ad07 | /Selenium/Webdriver_API/Common.java | b33434f66211f4203cec029b87ce095665a1fc81 | [] | no_license | ThuanLan/WEBDRIVER_API_13_THUANNT5 | https://github.com/ThuanLan/WEBDRIVER_API_13_THUANNT5 | 4fc34c57560c1b19e3bbec7d76e32bec97d47889 | c6b17764bbdc9644af57ef080d09f13c238f64f8 | refs/heads/master | 2020-12-23T12:42:20.233000 | 2020-02-05T08:11:05 | 2020-02-05T08:11:05 | 237,156,229 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Webdriver_API;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
public class Common {
WebDriver driver;
JavascriptExecutor js;
public void goToURL(String urlpage) throws Exception {
// Truy cập vào trang web
driver.get(urlpage);
Thread.sleep(3000);
}
public void newFFDriver() {
// Khởi tạo FF driver
System.setProperty("webdriver.geckodriver.driver", ".\\Libraries\\geckodriver.exe");
driver = new FirefoxDriver();
//FirefoxProfile profile = new FirefoxProfile();
// profile.setPreference("dom.webnotifications.enabled", false);
// driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public void newChromeDriver() {
// Khởi tạo Chrome driver
String projectPath = System.getProperty("user.dir");
System.setProperty("webdriver.chrome.driver", projectPath + "\\Libraries\\chromedriver.exe");
driver = new ChromeDriver();
System.out.println(driver.toString());
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public WebElement findByElement(By locator) {
return driver.findElement(locator);
}
public WebElement find(String xpathLocator) {
return driver.findElement(By.xpath(xpathLocator));
}
public WebElement findCss(String cssSelector) {
return driver.findElement(By.cssSelector(cssSelector));
}
// Check displayed Element
public boolean isElementDisplay(String xpath) {
return find(xpath).isDisplayed();
}
// Check selected Element
public boolean isElementSelected(WebDriver driver, String yourLocator) {
try {
WebElement locator;
locator = driver.findElement(By.xpath(yourLocator));
return locator.isSelected();
} catch (NoSuchElementException e) {
return false;
}
}
// Random number
public int randomNumber() {
Random rand = new Random();
return rand.nextInt(100000);
}
// Get Text by JS function
public String getTextByJS(String locator) {
return (String) js.executeScript("return document.querySelector('" + locator + "').text");
}
// Verify text by JS function
public boolean verifyTextInnerText(String textExpected) {
String textActual = (String) js
.executeScript("return document.documentElement.innerText.match('" + textExpected + "')[0]");
System.out.println("Text Actual = " + textActual);
return textActual.equals(textExpected);
}
// Switch to child windows (only 2 windows)
public String switchToChildWindowByID(String parent) {
Set<String> allWindows = driver.getWindowHandles();
System.out.println("Count of windows: " + allWindows.size());
for (String runWindows : allWindows) {
if (!runWindows.equals(parent)) {
driver.switchTo().window(runWindows);
System.out.println(driver.getTitle());
}
}
return driver.getTitle();
}
// Switch to child window (greater than 2 windows and title of the page are
// unique)
public void switchToWindowByTitle(String title) {
Set<String> allWindows = driver.getWindowHandles();
for (String runWindows : allWindows) {
driver.switchTo().window(runWindows);
String curentWin = driver.getTitle();
if (curentWin.equals(title)) {
break;
}
}
}
// Close all windows without parent window
public boolean closeAllWindowsWithoutParent(String parentWindow) {
Set<String> allWindows = driver.getWindowHandles();
for (String runWindows : allWindows) {
if (!runWindows.equals(parentWindow)) {
driver.switchTo().window(runWindows);
driver.close();
}
}
driver.switchTo().window(parentWindow);
if (driver.getWindowHandles().size() == 1)
return true;
else
return false;
}
}
| UTF-8 | Java | 4,319 | java | Common.java | Java | [] | null | [] | package Webdriver_API;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
public class Common {
WebDriver driver;
JavascriptExecutor js;
public void goToURL(String urlpage) throws Exception {
// Truy cập vào trang web
driver.get(urlpage);
Thread.sleep(3000);
}
public void newFFDriver() {
// Khởi tạo FF driver
System.setProperty("webdriver.geckodriver.driver", ".\\Libraries\\geckodriver.exe");
driver = new FirefoxDriver();
//FirefoxProfile profile = new FirefoxProfile();
// profile.setPreference("dom.webnotifications.enabled", false);
// driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public void newChromeDriver() {
// Khởi tạo Chrome driver
String projectPath = System.getProperty("user.dir");
System.setProperty("webdriver.chrome.driver", projectPath + "\\Libraries\\chromedriver.exe");
driver = new ChromeDriver();
System.out.println(driver.toString());
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public WebElement findByElement(By locator) {
return driver.findElement(locator);
}
public WebElement find(String xpathLocator) {
return driver.findElement(By.xpath(xpathLocator));
}
public WebElement findCss(String cssSelector) {
return driver.findElement(By.cssSelector(cssSelector));
}
// Check displayed Element
public boolean isElementDisplay(String xpath) {
return find(xpath).isDisplayed();
}
// Check selected Element
public boolean isElementSelected(WebDriver driver, String yourLocator) {
try {
WebElement locator;
locator = driver.findElement(By.xpath(yourLocator));
return locator.isSelected();
} catch (NoSuchElementException e) {
return false;
}
}
// Random number
public int randomNumber() {
Random rand = new Random();
return rand.nextInt(100000);
}
// Get Text by JS function
public String getTextByJS(String locator) {
return (String) js.executeScript("return document.querySelector('" + locator + "').text");
}
// Verify text by JS function
public boolean verifyTextInnerText(String textExpected) {
String textActual = (String) js
.executeScript("return document.documentElement.innerText.match('" + textExpected + "')[0]");
System.out.println("Text Actual = " + textActual);
return textActual.equals(textExpected);
}
// Switch to child windows (only 2 windows)
public String switchToChildWindowByID(String parent) {
Set<String> allWindows = driver.getWindowHandles();
System.out.println("Count of windows: " + allWindows.size());
for (String runWindows : allWindows) {
if (!runWindows.equals(parent)) {
driver.switchTo().window(runWindows);
System.out.println(driver.getTitle());
}
}
return driver.getTitle();
}
// Switch to child window (greater than 2 windows and title of the page are
// unique)
public void switchToWindowByTitle(String title) {
Set<String> allWindows = driver.getWindowHandles();
for (String runWindows : allWindows) {
driver.switchTo().window(runWindows);
String curentWin = driver.getTitle();
if (curentWin.equals(title)) {
break;
}
}
}
// Close all windows without parent window
public boolean closeAllWindowsWithoutParent(String parentWindow) {
Set<String> allWindows = driver.getWindowHandles();
for (String runWindows : allWindows) {
if (!runWindows.equals(parentWindow)) {
driver.switchTo().window(runWindows);
driver.close();
}
}
driver.switchTo().window(parentWindow);
if (driver.getWindowHandles().size() == 1)
return true;
else
return false;
}
}
| 4,319 | 0.711931 | 0.707753 | 138 | 29.217392 | 23.494291 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.913043 | false | false | 0 |
003d7929e5899f51f3752b7b79190194bec9ad45 | 6,975,026,907,685 | 1473db8b5ee8f40d0d2f2ebc0bc437994c561291 | /app/src/main/java/com/gameaholix/coinops/shopping/viewModel/ShoppingListViewModelFactory.java | 7ada8af13d358fc43fa28e1ec8702476a45874af | [] | no_license | mkillewald/GwG2018_Capstone | https://github.com/mkillewald/GwG2018_Capstone | 37583d32fef27e69c513202c9e4eaf151d2ad915 | 91ccc23034269ddf1df1ad4204eea72d8496e5e1 | refs/heads/master | 2020-03-26T10:30:09.354000 | 2019-01-02T17:49:32 | 2019-01-02T17:49:32 | 144,800,666 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gameaholix.coinops.shopping.viewModel;
import android.arch.lifecycle.ViewModel;
import android.arch.lifecycle.ViewModelProvider;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public class ShoppingListViewModelFactory implements ViewModelProvider.Factory {
private String mGameId;
public ShoppingListViewModelFactory(@Nullable String gameId) {
mGameId = gameId;
}
@Override
@NonNull
@SuppressWarnings("unchecked")
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new ShoppingListViewModel(mGameId);
}
} | UTF-8 | Java | 638 | java | ShoppingListViewModelFactory.java | Java | [] | null | [] | package com.gameaholix.coinops.shopping.viewModel;
import android.arch.lifecycle.ViewModel;
import android.arch.lifecycle.ViewModelProvider;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public class ShoppingListViewModelFactory implements ViewModelProvider.Factory {
private String mGameId;
public ShoppingListViewModelFactory(@Nullable String gameId) {
mGameId = gameId;
}
@Override
@NonNull
@SuppressWarnings("unchecked")
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new ShoppingListViewModel(mGameId);
}
} | 638 | 0.76489 | 0.76489 | 21 | 29.428572 | 25.546543 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.380952 | false | false | 0 |
b8bb017ad8d267be9476c3deea791cbf5372d46e | 22,711,787,111,916 | 88c28deb4cf497e1b17664173712e1620ccb8492 | /app/src/main/java/parkesfamily/co/uk/lotterychecker/database/Table_Players.java | 4fae5b21aad486d02a2425fb3c89466bca44dfe5 | [] | no_license | gavp1979/LottoBingo | https://github.com/gavp1979/LottoBingo | 4a07dfaba3210315c85832e382a87364f637286b | 29f3d423f2707de1ecc5a7c8f0a5afe2cc4807df | refs/heads/master | 2020-06-08T07:27:41.822000 | 2015-02-27T17:13:22 | 2015-02-27T17:13:22 | 29,087,864 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package parkesfamily.co.uk.lotterychecker.database;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
/**
* Created by Gav on 09/01/2015.
*/
public class Table_Players
{
// Database table
public static final String TABLE_PLAYERS = "players";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_NUMBER_1 = "number1";
public static final String COLUMN_NUMBER_2 = "number2";
public static final String COLUMN_NUMBER_3 = "number3";
public static final String COLUMN_NUMBER_4 = "number4";
public static final String COLUMN_NUMBER_5 = "number5";
public static final String COLUMN_NUMBER_6 = "number6";
// Database creation SQL statement
private static final String DATABASE_CREATE = "create table "
+ TABLE_PLAYERS
+ "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_NAME + " text not null, "
+ COLUMN_NUMBER_1 + " integer not null,"
+ COLUMN_NUMBER_2 + " integer not null,"
+ COLUMN_NUMBER_3 + " integer not null,"
+ COLUMN_NUMBER_4 + " integer not null,"
+ COLUMN_NUMBER_5 + " integer not null,"
+ COLUMN_NUMBER_6 + " integer not null"
+ ");";
public static void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
addDefaults(database);
}
public static void onUpgrade(SQLiteDatabase database, int oldVersion,
int newVersion) {
Log.w(Table_Players.class.getName(), "Upgrading database from version "
+ oldVersion + " to " + newVersion
+ ", which will destroy all old data");
database.execSQL("DROP TABLE IF EXISTS " + TABLE_PLAYERS);
onCreate(database);
}
private static void addDefaults(SQLiteDatabase db)
{
ContentValues values = new ContentValues();
values.put(COLUMN_NAME, "Gav Parkes");
values.put(COLUMN_NUMBER_1, 7);
values.put(COLUMN_NUMBER_2, 14);
values.put(COLUMN_NUMBER_3, 35);
values.put(COLUMN_NUMBER_4, 30);
values.put(COLUMN_NUMBER_5, 33);
values.put(COLUMN_NUMBER_6, 44);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Broady");
values.put(COLUMN_NUMBER_1, 5);
values.put(COLUMN_NUMBER_2, 7);
values.put(COLUMN_NUMBER_3, 10);
values.put(COLUMN_NUMBER_4, 20);
values.put(COLUMN_NUMBER_5, 38);
values.put(COLUMN_NUMBER_6, 47);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Lee Rawson");
values.put(COLUMN_NUMBER_1, 1);
values.put(COLUMN_NUMBER_2, 5);
values.put(COLUMN_NUMBER_3, 11);
values.put(COLUMN_NUMBER_4, 14);
values.put(COLUMN_NUMBER_5, 22);
values.put(COLUMN_NUMBER_6, 23);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Gazzo");
values.put(COLUMN_NUMBER_1, 9);
values.put(COLUMN_NUMBER_2, 18);
values.put(COLUMN_NUMBER_3, 24);
values.put(COLUMN_NUMBER_4, 34);
values.put(COLUMN_NUMBER_5, 40);
values.put(COLUMN_NUMBER_6, 48);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Adam Rawson");
values.put(COLUMN_NUMBER_1, 9);
values.put(COLUMN_NUMBER_2, 10);
values.put(COLUMN_NUMBER_3, 17);
values.put(COLUMN_NUMBER_4, 18);
values.put(COLUMN_NUMBER_5, 32);
values.put(COLUMN_NUMBER_6, 34);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Streety");
values.put(COLUMN_NUMBER_1, 2);
values.put(COLUMN_NUMBER_2, 15);
values.put(COLUMN_NUMBER_3, 22);
values.put(COLUMN_NUMBER_4, 36);
values.put(COLUMN_NUMBER_5, 40);
values.put(COLUMN_NUMBER_6, 44);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "John W");
values.put(COLUMN_NUMBER_1, 1);
values.put(COLUMN_NUMBER_2, 6);
values.put(COLUMN_NUMBER_3, 8);
values.put(COLUMN_NUMBER_4, 14);
values.put(COLUMN_NUMBER_5, 22);
values.put(COLUMN_NUMBER_6, 24);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Grimmy");
values.put(COLUMN_NUMBER_1, 8);
values.put(COLUMN_NUMBER_2, 14);
values.put(COLUMN_NUMBER_3, 15);
values.put(COLUMN_NUMBER_4, 23);
values.put(COLUMN_NUMBER_5, 32);
values.put(COLUMN_NUMBER_6, 48);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Martin");
values.put(COLUMN_NUMBER_1, 4);
values.put(COLUMN_NUMBER_2, 7);
values.put(COLUMN_NUMBER_3, 12);
values.put(COLUMN_NUMBER_4, 17);
values.put(COLUMN_NUMBER_5, 20);
values.put(COLUMN_NUMBER_6, 26);
db.insert(TABLE_PLAYERS, null, values);
}
}
| UTF-8 | Java | 5,097 | java | Table_Players.java | Java | [
{
"context": "abase;\nimport android.util.Log;\n\n/**\n * Created by Gav on 09/01/2015.\n */\npublic class Table_Players\n{\n ",
"end": 185,
"score": 0.9992601871490479,
"start": 182,
"tag": "NAME",
"value": "Gav"
},
{
"context": "ontentValues();\n\n values.put(COLUMN_NAME, \"Gav Parkes\");\n values.put(COLUMN_NUMBER_1, 7);\n ",
"end": 2092,
"score": 0.9995319247245789,
"start": 2082,
"tag": "NAME",
"value": "Gav Parkes"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Broady\");\n values.put(COLUMN_NUMBER_1, 5);\n ",
"end": 2429,
"score": 0.9996411800384521,
"start": 2423,
"tag": "NAME",
"value": "Broady"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Lee Rawson\");\n values.put(COLUMN_NUMBER_1, 1);\n ",
"end": 2769,
"score": 0.9993782043457031,
"start": 2759,
"tag": "NAME",
"value": "Lee Rawson"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Gazzo\");\n values.put(COLUMN_NUMBER_1, 9);\n ",
"end": 3104,
"score": 0.9996800422668457,
"start": 3099,
"tag": "NAME",
"value": "Gazzo"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Adam Rawson\");\n values.put(COLUMN_NUMBER_1, 9);\n ",
"end": 3446,
"score": 0.9993903636932373,
"start": 3435,
"tag": "NAME",
"value": "Adam Rawson"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Streety\");\n values.put(COLUMN_NUMBER_1, 2);\n ",
"end": 3784,
"score": 0.9996182918548584,
"start": 3777,
"tag": "NAME",
"value": "Streety"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"John W\");\n values.put(COLUMN_NUMBER_1, 1);\n ",
"end": 4121,
"score": 0.9995821714401245,
"start": 4115,
"tag": "NAME",
"value": "John W"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Grimmy\");\n values.put(COLUMN_NUMBER_1, 8);\n ",
"end": 4456,
"score": 0.9996354579925537,
"start": 4450,
"tag": "NAME",
"value": "Grimmy"
},
{
"context": " null, values);\n\n values.put(COLUMN_NAME, \"Martin\");\n values.put(COLUMN_NUMBER_1, 4);\n ",
"end": 4793,
"score": 0.9996031522750854,
"start": 4787,
"tag": "NAME",
"value": "Martin"
}
] | null | [] | package parkesfamily.co.uk.lotterychecker.database;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
/**
* Created by Gav on 09/01/2015.
*/
public class Table_Players
{
// Database table
public static final String TABLE_PLAYERS = "players";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_NUMBER_1 = "number1";
public static final String COLUMN_NUMBER_2 = "number2";
public static final String COLUMN_NUMBER_3 = "number3";
public static final String COLUMN_NUMBER_4 = "number4";
public static final String COLUMN_NUMBER_5 = "number5";
public static final String COLUMN_NUMBER_6 = "number6";
// Database creation SQL statement
private static final String DATABASE_CREATE = "create table "
+ TABLE_PLAYERS
+ "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_NAME + " text not null, "
+ COLUMN_NUMBER_1 + " integer not null,"
+ COLUMN_NUMBER_2 + " integer not null,"
+ COLUMN_NUMBER_3 + " integer not null,"
+ COLUMN_NUMBER_4 + " integer not null,"
+ COLUMN_NUMBER_5 + " integer not null,"
+ COLUMN_NUMBER_6 + " integer not null"
+ ");";
public static void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
addDefaults(database);
}
public static void onUpgrade(SQLiteDatabase database, int oldVersion,
int newVersion) {
Log.w(Table_Players.class.getName(), "Upgrading database from version "
+ oldVersion + " to " + newVersion
+ ", which will destroy all old data");
database.execSQL("DROP TABLE IF EXISTS " + TABLE_PLAYERS);
onCreate(database);
}
private static void addDefaults(SQLiteDatabase db)
{
ContentValues values = new ContentValues();
values.put(COLUMN_NAME, "<NAME>");
values.put(COLUMN_NUMBER_1, 7);
values.put(COLUMN_NUMBER_2, 14);
values.put(COLUMN_NUMBER_3, 35);
values.put(COLUMN_NUMBER_4, 30);
values.put(COLUMN_NUMBER_5, 33);
values.put(COLUMN_NUMBER_6, 44);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Broady");
values.put(COLUMN_NUMBER_1, 5);
values.put(COLUMN_NUMBER_2, 7);
values.put(COLUMN_NUMBER_3, 10);
values.put(COLUMN_NUMBER_4, 20);
values.put(COLUMN_NUMBER_5, 38);
values.put(COLUMN_NUMBER_6, 47);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "<NAME>");
values.put(COLUMN_NUMBER_1, 1);
values.put(COLUMN_NUMBER_2, 5);
values.put(COLUMN_NUMBER_3, 11);
values.put(COLUMN_NUMBER_4, 14);
values.put(COLUMN_NUMBER_5, 22);
values.put(COLUMN_NUMBER_6, 23);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Gazzo");
values.put(COLUMN_NUMBER_1, 9);
values.put(COLUMN_NUMBER_2, 18);
values.put(COLUMN_NUMBER_3, 24);
values.put(COLUMN_NUMBER_4, 34);
values.put(COLUMN_NUMBER_5, 40);
values.put(COLUMN_NUMBER_6, 48);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "<NAME>");
values.put(COLUMN_NUMBER_1, 9);
values.put(COLUMN_NUMBER_2, 10);
values.put(COLUMN_NUMBER_3, 17);
values.put(COLUMN_NUMBER_4, 18);
values.put(COLUMN_NUMBER_5, 32);
values.put(COLUMN_NUMBER_6, 34);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Streety");
values.put(COLUMN_NUMBER_1, 2);
values.put(COLUMN_NUMBER_2, 15);
values.put(COLUMN_NUMBER_3, 22);
values.put(COLUMN_NUMBER_4, 36);
values.put(COLUMN_NUMBER_5, 40);
values.put(COLUMN_NUMBER_6, 44);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "<NAME>");
values.put(COLUMN_NUMBER_1, 1);
values.put(COLUMN_NUMBER_2, 6);
values.put(COLUMN_NUMBER_3, 8);
values.put(COLUMN_NUMBER_4, 14);
values.put(COLUMN_NUMBER_5, 22);
values.put(COLUMN_NUMBER_6, 24);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Grimmy");
values.put(COLUMN_NUMBER_1, 8);
values.put(COLUMN_NUMBER_2, 14);
values.put(COLUMN_NUMBER_3, 15);
values.put(COLUMN_NUMBER_4, 23);
values.put(COLUMN_NUMBER_5, 32);
values.put(COLUMN_NUMBER_6, 48);
db.insert(TABLE_PLAYERS, null, values);
values.put(COLUMN_NAME, "Martin");
values.put(COLUMN_NUMBER_1, 4);
values.put(COLUMN_NUMBER_2, 7);
values.put(COLUMN_NUMBER_3, 12);
values.put(COLUMN_NUMBER_4, 17);
values.put(COLUMN_NUMBER_5, 20);
values.put(COLUMN_NUMBER_6, 26);
db.insert(TABLE_PLAYERS, null, values);
}
}
| 5,084 | 0.602904 | 0.568766 | 138 | 35.934784 | 18.60544 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.34058 | false | false | 0 |
88ee9e30ff3821d2957d5e9cec17eba0bd8cd2b0 | 20,358,145,042,329 | 79f0702d546fbeef22f206a1f0ee71db133dba87 | /LabExam/fibrec.java | ba17b747117cd5812bb1a4e707e073545860b1a0 | [] | no_license | raghavddps2/LabExam-Prep | https://github.com/raghavddps2/LabExam-Prep | f19763f5e31f3c1b863c292f8f49275d6c879b9b | edddd13a4f5de0a0614f502796290a7c3ab6cf30 | refs/heads/master | 2021-11-13T21:13:29.762000 | 2021-11-13T09:09:59 | 2021-11-13T09:09:59 | 153,180,278 | 3 | 4 | null | false | 2021-11-13T09:09:59 | 2018-10-15T20:54:21 | 2021-06-02T16:03:48 | 2021-11-13T09:09:59 | 355 | 0 | 2 | 1 | C | false | false | import java.util.Scanner;
class fibrec{
static int fib(int n){
if(n == 0){
return 0;
}
else if(n == 1){
return 1;
}
else{
return (fib(n-1)+fib(n-2));
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
System.out.println("-----------------------------------");
System.out.print("Enter the number of terms you want:\t");
n = sc.nextInt();
int i=0;
System.out.print("The fibonacci series is: \t");
while(i<n){
System.out.print(fib(i)+" ");
i++;
}
System.out.println("\n-----------------------------------");
}
} | UTF-8 | Java | 782 | java | fibrec.java | Java | [] | null | [] | import java.util.Scanner;
class fibrec{
static int fib(int n){
if(n == 0){
return 0;
}
else if(n == 1){
return 1;
}
else{
return (fib(n-1)+fib(n-2));
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
System.out.println("-----------------------------------");
System.out.print("Enter the number of terms you want:\t");
n = sc.nextInt();
int i=0;
System.out.print("The fibonacci series is: \t");
while(i<n){
System.out.print(fib(i)+" ");
i++;
}
System.out.println("\n-----------------------------------");
}
} | 782 | 0.392583 | 0.383632 | 31 | 23.290323 | 19.813963 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.451613 | false | false | 0 |
c53fc128cb3d7f4b35b782564b9b0f01d2348389 | 20,358,145,043,460 | 7d80233093398f7d7c121d888fc5575270939162 | /src/test/java/com/oxande/vinci/util/VinciUtilsTest.java | d8acf6f02ee70330c6a9e6e0f40268b76cb30b19 | [
"Apache-2.0"
] | permissive | hybridhyper/vinci | https://github.com/hybridhyper/vinci | 85693a572339b5f9d97a23e08f9b973b14377c36 | d864f22bc10551062900ce345834358863de2a1c | refs/heads/master | 2020-09-04T14:07:30.364000 | 2017-11-09T07:10:31 | 2017-11-09T07:10:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.oxande.vinci.util;
import org.junit.Assert;
import org.junit.Test;
/**
* Test of the VinciUtils library
*/
public class VinciUtilsTest {
@Test public void toJavaTest() {
Assert.assertEquals("\"zozo\"", VinciUtils.toJava("zozo"));
Assert.assertEquals("\"It's a \\t tabulation.\"", VinciUtils.toJava("It's a \t tabulation."));
Assert.assertEquals("\"le th\\u00e9 \\u00e0 la coriandre\"", VinciUtils.toJava("le thé à la coriandre"));
Assert.assertEquals("\"Victor \\net Zola\"", VinciUtils.toJava("Victor \net Zola"));
}
@Test public void quoteTest() {
Assert.assertEquals("\"zozo\"", VinciUtils.toJava("zozo"));
Assert.assertEquals("\"le thé à la coriandre\"", VinciUtils.quote("le thé à la coriandre"));
}
}
| UTF-8 | Java | 817 | java | VinciUtilsTest.java | Java | [
{
"context": " la coriandre\"));\r\n Assert.assertEquals(\"\\\"Victor \\\\net Zola\\\"\", VinciUtils.toJava(\"Victor \\net Zol",
"end": 527,
"score": 0.9965391755104065,
"start": 521,
"tag": "NAME",
"value": "Victor"
},
{
"context": "ndre\"));\r\n Assert.assertEquals(\"\\\"Victor \\\\net Zola\\\"\", VinciUtils.toJava(\"Victor \\net Zola\"));\r\n ",
"end": 538,
"score": 0.8889769911766052,
"start": 530,
"tag": "NAME",
"value": "net Zola"
},
{
"context": "quals(\"\\\"Victor \\\\net Zola\\\"\", VinciUtils.toJava(\"Victor \\net Zola\"));\r\n }\r\n\r\n @Test public void quo",
"end": 568,
"score": 0.9963371753692627,
"start": 562,
"tag": "NAME",
"value": "Victor"
},
{
"context": "\"Victor \\\\net Zola\\\"\", VinciUtils.toJava(\"Victor \\net Zola\"));\r\n }\r\n\r\n @Test public void quoteTest() {",
"end": 578,
"score": 0.8495791554450989,
"start": 570,
"tag": "NAME",
"value": "net Zola"
}
] | null | [] | package com.oxande.vinci.util;
import org.junit.Assert;
import org.junit.Test;
/**
* Test of the VinciUtils library
*/
public class VinciUtilsTest {
@Test public void toJavaTest() {
Assert.assertEquals("\"zozo\"", VinciUtils.toJava("zozo"));
Assert.assertEquals("\"It's a \\t tabulation.\"", VinciUtils.toJava("It's a \t tabulation."));
Assert.assertEquals("\"le th\\u00e9 \\u00e0 la coriandre\"", VinciUtils.toJava("le thé à la coriandre"));
Assert.assertEquals("\"Victor \\<NAME>\"", VinciUtils.toJava("Victor \<NAME>"));
}
@Test public void quoteTest() {
Assert.assertEquals("\"zozo\"", VinciUtils.toJava("zozo"));
Assert.assertEquals("\"le thé à la coriandre\"", VinciUtils.quote("le thé à la coriandre"));
}
}
| 813 | 0.631319 | 0.623921 | 22 | 34.863636 | 37.145042 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.681818 | false | false | 0 |
7b85a06983952a86bd301ca6e18e7c9f6e05b4b9 | 12,446,815,268,365 | 38a175cd7515c9147fd2e890743cd89f8412fda2 | /SGSI - MAGERIT/app/src/main/java/es/udc/fic/sgsi_magerit/AddEditThreat/IdentifyThreatFragment.java | c5ed942247f11189378536652c8baeb930c646a5 | [] | no_license | rubenbperez/SGSI-MAGERIT | https://github.com/rubenbperez/SGSI-MAGERIT | 1265b83dcb2c57552ba39bc257670ffd50495279 | 9e92ca7533f6bb6128b55c415fe23e6f1bfa1ce4 | refs/heads/master | 2020-05-21T15:01:16.745000 | 2017-09-22T00:26:35 | 2017-09-22T00:26:35 | 61,615,930 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package es.udc.fic.sgsi_magerit.AddEditThreat;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import es.udc.fic.sgsi_magerit.Model.Asset.AssetAssetType;
import es.udc.fic.sgsi_magerit.Model.ModelService.ModelService;
import es.udc.fic.sgsi_magerit.Model.ModelService.ModelServiceImpl;
import es.udc.fic.sgsi_magerit.Model.Threat.ThreatDTO;
import es.udc.fic.sgsi_magerit.R;
import es.udc.fic.sgsi_magerit.Util.GlobalConstants;
public class IdentifyThreatFragment extends Fragment {
private Long idProyecto;
private Long idListaTipoAmenazaRecibido;
private Long idTipoAmenazaRecibido;
private Spinner spinner;
private ArrayAdapter<CharSequence> spinnerAdapter;
private ListView lstOpcionesDesastresNaturales;
private Integer itemCheckedDesastresNaturales = null;
private ListView lstOpcionesOrigenIndustrial;
private Integer itemCheckedOrigenIndustrial = null;
private ListView lstOpcionesErroresFallos;
private Integer itemCheckedErroresFallos = null;
private ListView lstOpcionesAtaquesDeliberados;
private Integer itemCheckedAtaquesDeliberados = null;
private ListView lstOpcionesEdicion;
private List<String> listaAmenazasDesastresNaturales;
private List<String> listaAmenazasOrigenIndustrial;
private List<String> listaAmenazasErroresFallos;
private List<String> listaAmenazasAtaquesDeliberados;
private List<String> listaEdicion;
ModelService service;
protected List<String> getListaAmenazasDesastresNaturales() {
return listaAmenazasDesastresNaturales;
}
protected List<String> getListaAmenazasOrigenIndustrial() {
return listaAmenazasOrigenIndustrial;
}
protected List<String> getListaAmenazasErroresFallos() {
return listaAmenazasErroresFallos;
}
protected List<String> getListaAmenazasAtaquesDeliberados() {
return listaAmenazasAtaquesDeliberados;
}
public IdentifyThreatFragment() {
}
public static IdentifyThreatFragment newInstance() {
IdentifyThreatFragment fragment = new IdentifyThreatFragment();
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_identify_threat, container, false);
service = new ModelServiceImpl(this.getActivity(), GlobalConstants.DATABASE_NAME,1);
Bundle args = getArguments();
if(args != null){
this.idProyecto = args.getLong("idProyecto");
this.idListaTipoAmenazaRecibido = args.getLong("idListaTipoAmenaza", GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA);
this.idTipoAmenazaRecibido = args.getLong("idTipoAmenaza", GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA);
//EN caso de ser una edición, existe una lista extra donde se muestran las amenazas.
}
// Añadimos el Spinner
spinner = (Spinner) view.findViewById(R.id.spnMySpinner);
spinnerAdapter = ArrayAdapter.createFromResource(getContext(), R.array.Sizing_spinner_Threats,
android.R.layout.simple_spinner_item);
if (idListaTipoAmenazaRecibido != GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA
&& idListaTipoAmenazaRecibido != GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA) {
listaEdicion = new ArrayList<>();
switch(idListaTipoAmenazaRecibido.intValue()) {
case 0:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES[idTipoAmenazaRecibido.intValue()]);
break;
case 1:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL[idTipoAmenazaRecibido.intValue()]);
break;
case 2:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS[idTipoAmenazaRecibido.intValue()]);
break;
case 3:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS[idTipoAmenazaRecibido.intValue()]);
break;
}
lstOpcionesEdicion = (ListView) view.findViewById(R.id.ListEdicion);
lstOpcionesEdicion.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
ArrayAdapter<String> lstEdicion = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaEdicion){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text = (TextView) view.findViewById(android.R.id.text1);
text.setTextColor(getResources().getColor(R.color.threat));
return view;
}
};;
lstOpcionesEdicion.setAdapter(lstEdicion);
lstOpcionesEdicion.setItemChecked(0,true);
return view;
}
List<ThreatDTO> listaAmenazasCreadas = service.obtenerAmenazas(idProyecto);
listaAmenazasDesastresNaturales = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES));
listaAmenazasOrigenIndustrial = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL));
listaAmenazasErroresFallos = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS));
listaAmenazasAtaquesDeliberados = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS));
String codeName = null;
for (ThreatDTO threat : listaAmenazasCreadas) {
switch (threat.getIdListaTipo().intValue()) {
case 0:
codeName = GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES[threat.getIdTipo().intValue()];
listaAmenazasDesastresNaturales.remove(listaAmenazasDesastresNaturales.indexOf(codeName));
break;
case 1:
codeName = GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL[threat.getIdTipo().intValue()];
listaAmenazasOrigenIndustrial.remove(listaAmenazasOrigenIndustrial.indexOf(codeName));
break;
case 2:
codeName = GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS[threat.getIdTipo().intValue()];
listaAmenazasErroresFallos.remove(listaAmenazasErroresFallos.indexOf(codeName));
break;
case 3:
codeName = GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS[threat.getIdTipo().intValue()];
listaAmenazasAtaquesDeliberados.remove(listaAmenazasAtaquesDeliberados.indexOf(codeName));
break;
}
}
// Lista de Desastres Naturales
lstOpcionesDesastresNaturales = (ListView) view.findViewById(R.id.ListDesastresNaturales);
ArrayAdapter<String> lstDesastresNaturales = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasDesastresNaturales);
lstOpcionesDesastresNaturales.setAdapter(lstDesastresNaturales);
// Lista de Origen Industrial
lstOpcionesOrigenIndustrial = (ListView) view.findViewById(R.id.ListOrigenIndustrial);
ArrayAdapter<String> lstOrigenIndustrial = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasOrigenIndustrial);
lstOpcionesOrigenIndustrial.setAdapter(lstOrigenIndustrial);
// Lista de Errores y Fallos no intencionados
lstOpcionesErroresFallos = (ListView) view.findViewById(R.id.ListErroresFallos);
ArrayAdapter<String> lstErroresFallos = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasErroresFallos);
lstOpcionesErroresFallos.setAdapter(lstErroresFallos);
// Lista de Ataques deliberados
lstOpcionesAtaquesDeliberados = (ListView) view.findViewById(R.id.ListAtaquesDeliberados);
final ArrayAdapter<String> lstAtaquesDeliberados = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasAtaquesDeliberados);
lstOpcionesAtaquesDeliberados.setAdapter(lstAtaquesDeliberados);
// Si estaba seleccionado el item lo deseleccionamos (limpiamos)
//al seleccionar un elemento. Limpiamos las otras listas
lstOpcionesDesastresNaturales.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedDesastresNaturales != null && position == itemCheckedDesastresNaturales) {
lstOpcionesDesastresNaturales.setItemChecked(position, false);
itemCheckedDesastresNaturales = null;
} else
itemCheckedDesastresNaturales = position;
}
});
lstOpcionesOrigenIndustrial.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedOrigenIndustrial!= null && position == itemCheckedOrigenIndustrial) {
lstOpcionesOrigenIndustrial.setItemChecked(position, false);
itemCheckedOrigenIndustrial = null;
} else
itemCheckedOrigenIndustrial = position;
}
});
lstOpcionesErroresFallos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedErroresFallos != null && position == itemCheckedErroresFallos) {
lstOpcionesErroresFallos.setItemChecked(position, false);
itemCheckedErroresFallos = null;
} else
itemCheckedErroresFallos = position;
}
});
lstOpcionesAtaquesDeliberados.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
if (itemCheckedAtaquesDeliberados != null && position == itemCheckedAtaquesDeliberados) {
lstOpcionesAtaquesDeliberados.setItemChecked(position, false);
itemCheckedAtaquesDeliberados = null;
} else
itemCheckedAtaquesDeliberados = position;
}
});
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter((SpinnerAdapter) spinnerAdapter);
spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
android.view.View v, int position, long id) {
ocultarListasMostrarLista(position);
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
return view;
}
private void ocultarListasMostrarLista(int valor) {
if (valor == 0)
lstOpcionesDesastresNaturales.setVisibility(View.VISIBLE);
else
lstOpcionesDesastresNaturales.setVisibility(View.GONE);
if (valor == 1)
lstOpcionesOrigenIndustrial.setVisibility(View.VISIBLE);
else
lstOpcionesOrigenIndustrial.setVisibility(View.GONE);
if (valor == 2)
lstOpcionesErroresFallos.setVisibility(View.VISIBLE);
else
lstOpcionesErroresFallos.setVisibility(View.GONE);
if (valor == 3)
lstOpcionesAtaquesDeliberados.setVisibility(View.VISIBLE);
else
lstOpcionesAtaquesDeliberados.setVisibility(View.GONE);
}
}
| UTF-8 | Java | 14,298 | java | IdentifyThreatFragment.java | Java | [] | null | [] | package es.udc.fic.sgsi_magerit.AddEditThreat;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import es.udc.fic.sgsi_magerit.Model.Asset.AssetAssetType;
import es.udc.fic.sgsi_magerit.Model.ModelService.ModelService;
import es.udc.fic.sgsi_magerit.Model.ModelService.ModelServiceImpl;
import es.udc.fic.sgsi_magerit.Model.Threat.ThreatDTO;
import es.udc.fic.sgsi_magerit.R;
import es.udc.fic.sgsi_magerit.Util.GlobalConstants;
public class IdentifyThreatFragment extends Fragment {
private Long idProyecto;
private Long idListaTipoAmenazaRecibido;
private Long idTipoAmenazaRecibido;
private Spinner spinner;
private ArrayAdapter<CharSequence> spinnerAdapter;
private ListView lstOpcionesDesastresNaturales;
private Integer itemCheckedDesastresNaturales = null;
private ListView lstOpcionesOrigenIndustrial;
private Integer itemCheckedOrigenIndustrial = null;
private ListView lstOpcionesErroresFallos;
private Integer itemCheckedErroresFallos = null;
private ListView lstOpcionesAtaquesDeliberados;
private Integer itemCheckedAtaquesDeliberados = null;
private ListView lstOpcionesEdicion;
private List<String> listaAmenazasDesastresNaturales;
private List<String> listaAmenazasOrigenIndustrial;
private List<String> listaAmenazasErroresFallos;
private List<String> listaAmenazasAtaquesDeliberados;
private List<String> listaEdicion;
ModelService service;
protected List<String> getListaAmenazasDesastresNaturales() {
return listaAmenazasDesastresNaturales;
}
protected List<String> getListaAmenazasOrigenIndustrial() {
return listaAmenazasOrigenIndustrial;
}
protected List<String> getListaAmenazasErroresFallos() {
return listaAmenazasErroresFallos;
}
protected List<String> getListaAmenazasAtaquesDeliberados() {
return listaAmenazasAtaquesDeliberados;
}
public IdentifyThreatFragment() {
}
public static IdentifyThreatFragment newInstance() {
IdentifyThreatFragment fragment = new IdentifyThreatFragment();
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_identify_threat, container, false);
service = new ModelServiceImpl(this.getActivity(), GlobalConstants.DATABASE_NAME,1);
Bundle args = getArguments();
if(args != null){
this.idProyecto = args.getLong("idProyecto");
this.idListaTipoAmenazaRecibido = args.getLong("idListaTipoAmenaza", GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA);
this.idTipoAmenazaRecibido = args.getLong("idTipoAmenaza", GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA);
//EN caso de ser una edición, existe una lista extra donde se muestran las amenazas.
}
// Añadimos el Spinner
spinner = (Spinner) view.findViewById(R.id.spnMySpinner);
spinnerAdapter = ArrayAdapter.createFromResource(getContext(), R.array.Sizing_spinner_Threats,
android.R.layout.simple_spinner_item);
if (idListaTipoAmenazaRecibido != GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA
&& idListaTipoAmenazaRecibido != GlobalConstants.NULL_ID_LISTA_TIPO_AMENAZA) {
listaEdicion = new ArrayList<>();
switch(idListaTipoAmenazaRecibido.intValue()) {
case 0:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES[idTipoAmenazaRecibido.intValue()]);
break;
case 1:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL[idTipoAmenazaRecibido.intValue()]);
break;
case 2:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS[idTipoAmenazaRecibido.intValue()]);
break;
case 3:
listaEdicion.add(GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS[idTipoAmenazaRecibido.intValue()]);
break;
}
lstOpcionesEdicion = (ListView) view.findViewById(R.id.ListEdicion);
lstOpcionesEdicion.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
ArrayAdapter<String> lstEdicion = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaEdicion){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text = (TextView) view.findViewById(android.R.id.text1);
text.setTextColor(getResources().getColor(R.color.threat));
return view;
}
};;
lstOpcionesEdicion.setAdapter(lstEdicion);
lstOpcionesEdicion.setItemChecked(0,true);
return view;
}
List<ThreatDTO> listaAmenazasCreadas = service.obtenerAmenazas(idProyecto);
listaAmenazasDesastresNaturales = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES));
listaAmenazasOrigenIndustrial = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL));
listaAmenazasErroresFallos = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS));
listaAmenazasAtaquesDeliberados = new LinkedList<String>(Arrays.asList(GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS));
String codeName = null;
for (ThreatDTO threat : listaAmenazasCreadas) {
switch (threat.getIdListaTipo().intValue()) {
case 0:
codeName = GlobalConstants.AMENAZAS_TIPO_DESASTRES_NATURALES[threat.getIdTipo().intValue()];
listaAmenazasDesastresNaturales.remove(listaAmenazasDesastresNaturales.indexOf(codeName));
break;
case 1:
codeName = GlobalConstants.AMENAZAS_TIPO_ORIGEN_INDUSTRIAL[threat.getIdTipo().intValue()];
listaAmenazasOrigenIndustrial.remove(listaAmenazasOrigenIndustrial.indexOf(codeName));
break;
case 2:
codeName = GlobalConstants.AMENAZAS_TIPO_ERRORES_FALLOS_NO_INTENCIONADOS[threat.getIdTipo().intValue()];
listaAmenazasErroresFallos.remove(listaAmenazasErroresFallos.indexOf(codeName));
break;
case 3:
codeName = GlobalConstants.AMENAZAS_TIPO_ATAQUES_DELIBERADOS[threat.getIdTipo().intValue()];
listaAmenazasAtaquesDeliberados.remove(listaAmenazasAtaquesDeliberados.indexOf(codeName));
break;
}
}
// Lista de Desastres Naturales
lstOpcionesDesastresNaturales = (ListView) view.findViewById(R.id.ListDesastresNaturales);
ArrayAdapter<String> lstDesastresNaturales = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasDesastresNaturales);
lstOpcionesDesastresNaturales.setAdapter(lstDesastresNaturales);
// Lista de Origen Industrial
lstOpcionesOrigenIndustrial = (ListView) view.findViewById(R.id.ListOrigenIndustrial);
ArrayAdapter<String> lstOrigenIndustrial = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasOrigenIndustrial);
lstOpcionesOrigenIndustrial.setAdapter(lstOrigenIndustrial);
// Lista de Errores y Fallos no intencionados
lstOpcionesErroresFallos = (ListView) view.findViewById(R.id.ListErroresFallos);
ArrayAdapter<String> lstErroresFallos = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasErroresFallos);
lstOpcionesErroresFallos.setAdapter(lstErroresFallos);
// Lista de Ataques deliberados
lstOpcionesAtaquesDeliberados = (ListView) view.findViewById(R.id.ListAtaquesDeliberados);
final ArrayAdapter<String> lstAtaquesDeliberados = new ArrayAdapter<String>(this.getContext(),
android.R.layout.simple_list_item_single_choice, listaAmenazasAtaquesDeliberados);
lstOpcionesAtaquesDeliberados.setAdapter(lstAtaquesDeliberados);
// Si estaba seleccionado el item lo deseleccionamos (limpiamos)
//al seleccionar un elemento. Limpiamos las otras listas
lstOpcionesDesastresNaturales.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedDesastresNaturales != null && position == itemCheckedDesastresNaturales) {
lstOpcionesDesastresNaturales.setItemChecked(position, false);
itemCheckedDesastresNaturales = null;
} else
itemCheckedDesastresNaturales = position;
}
});
lstOpcionesOrigenIndustrial.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedOrigenIndustrial!= null && position == itemCheckedOrigenIndustrial) {
lstOpcionesOrigenIndustrial.setItemChecked(position, false);
itemCheckedOrigenIndustrial = null;
} else
itemCheckedOrigenIndustrial = position;
}
});
lstOpcionesErroresFallos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesAtaquesDeliberados.clearChoices();
itemCheckedAtaquesDeliberados = null;
if (itemCheckedErroresFallos != null && position == itemCheckedErroresFallos) {
lstOpcionesErroresFallos.setItemChecked(position, false);
itemCheckedErroresFallos = null;
} else
itemCheckedErroresFallos = position;
}
});
lstOpcionesAtaquesDeliberados.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lstOpcionesDesastresNaturales.clearChoices();
itemCheckedDesastresNaturales = null;
lstOpcionesOrigenIndustrial.clearChoices();
itemCheckedOrigenIndustrial = null;
lstOpcionesErroresFallos.clearChoices();
itemCheckedErroresFallos = null;
if (itemCheckedAtaquesDeliberados != null && position == itemCheckedAtaquesDeliberados) {
lstOpcionesAtaquesDeliberados.setItemChecked(position, false);
itemCheckedAtaquesDeliberados = null;
} else
itemCheckedAtaquesDeliberados = position;
}
});
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter((SpinnerAdapter) spinnerAdapter);
spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
android.view.View v, int position, long id) {
ocultarListasMostrarLista(position);
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
return view;
}
private void ocultarListasMostrarLista(int valor) {
if (valor == 0)
lstOpcionesDesastresNaturales.setVisibility(View.VISIBLE);
else
lstOpcionesDesastresNaturales.setVisibility(View.GONE);
if (valor == 1)
lstOpcionesOrigenIndustrial.setVisibility(View.VISIBLE);
else
lstOpcionesOrigenIndustrial.setVisibility(View.GONE);
if (valor == 2)
lstOpcionesErroresFallos.setVisibility(View.VISIBLE);
else
lstOpcionesErroresFallos.setVisibility(View.GONE);
if (valor == 3)
lstOpcionesAtaquesDeliberados.setVisibility(View.VISIBLE);
else
lstOpcionesAtaquesDeliberados.setVisibility(View.GONE);
}
}
| 14,298 | 0.669558 | 0.668439 | 308 | 45.415585 | 35.295361 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.675325 | false | false | 0 |
9aea327cafc34015894aff2b70b1387e8a57b6ce | 13,537,736,981,326 | f6f89e6e84493ab1fa25c246fa22bdf9e68ff5a5 | /chain-parsers-common/src/main/java/com/cloudera/parserchains/parsers/RenameFieldParser.java | 4b718a9e2ae0b5ab5be55c12e2ca44d9d5986e66 | [] | no_license | nickwallen/chain-parsers | https://github.com/nickwallen/chain-parsers | 4ce59bcc858869b1ac2a485aa327465925953f66 | 9bf87368deeb330fb7ef683e8447c4e02797e877 | refs/heads/master | 2020-12-19T19:13:52.602000 | 2020-02-04T20:19:55 | 2020-02-04T20:19:55 | 235,825,652 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.cloudera.parserchains.parsers;
import com.cloudera.parserchains.core.ConfigName;
import com.cloudera.parserchains.core.ConfigValue;
import com.cloudera.parserchains.core.FieldName;
import com.cloudera.parserchains.core.Message;
import com.cloudera.parserchains.core.MessageParser;
import com.cloudera.parserchains.core.Parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A parser that can rename message fields.
*/
@MessageParser(name="Rename Field(s)", description="Renames a message field.")
public class RenameFieldParser implements Parser {
// TODO how to communicate the necessary config values to the UI??
static final String CONFIG_FROM_KEY = "from";
static final String CONFIG_TO_KEY = "to";
static ConfigName renameConfig = ConfigName.of("rename", true);
private Map<FieldName, FieldName> fieldsToRename;
public RenameFieldParser() {
this.fieldsToRename = new HashMap<>();
}
/**
* Configure the parser to rename a field.
* @param from The original field name.
* @param to The new field name.
*/
public RenameFieldParser renameField(FieldName from, FieldName to) {
fieldsToRename.put(from, to);
return this;
}
Map<FieldName, FieldName> getFieldsToRename() {
return Collections.unmodifiableMap(fieldsToRename);
}
@Override
public Message parse(Message input) {
Message.Builder output = Message.builder()
.withFields(input);
fieldsToRename.forEach((from, to) -> output.renameField(from, to));
return output.build();
}
@Override
public List<FieldName> outputFields() {
return new ArrayList<>(fieldsToRename.keySet());
}
@Override
public List<ConfigName> validConfigurations() {
return Arrays.asList(renameConfig);
}
@Override
public void configure(ConfigName configName, List<ConfigValue> configValues) {
if(renameConfig.equals(configName)) {
FieldName from = null;
FieldName to = null;
for(ConfigValue value: configValues) {
if(CONFIG_FROM_KEY.equals(value.getKey())) {
from = FieldName.of(value.getValue());
} else if (CONFIG_TO_KEY.equals(value.getKey())) {
to = FieldName.of(value.getValue());
}
}
if(from == null) {
throw new IllegalArgumentException(String.format("Missing configuration value; key=%s", CONFIG_FROM_KEY));
} else if(to == null) {
throw new IllegalArgumentException(String.format("Missing configuration value; key=%s", CONFIG_TO_KEY));
} else {
renameField(from, to);
}
} else {
throw new IllegalArgumentException(String.format("Unexpected configuration; name=%s", configName));
}
}
}
| UTF-8 | Java | 3,025 | java | RenameFieldParser.java | Java | [] | null | [] | package com.cloudera.parserchains.parsers;
import com.cloudera.parserchains.core.ConfigName;
import com.cloudera.parserchains.core.ConfigValue;
import com.cloudera.parserchains.core.FieldName;
import com.cloudera.parserchains.core.Message;
import com.cloudera.parserchains.core.MessageParser;
import com.cloudera.parserchains.core.Parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A parser that can rename message fields.
*/
@MessageParser(name="Rename Field(s)", description="Renames a message field.")
public class RenameFieldParser implements Parser {
// TODO how to communicate the necessary config values to the UI??
static final String CONFIG_FROM_KEY = "from";
static final String CONFIG_TO_KEY = "to";
static ConfigName renameConfig = ConfigName.of("rename", true);
private Map<FieldName, FieldName> fieldsToRename;
public RenameFieldParser() {
this.fieldsToRename = new HashMap<>();
}
/**
* Configure the parser to rename a field.
* @param from The original field name.
* @param to The new field name.
*/
public RenameFieldParser renameField(FieldName from, FieldName to) {
fieldsToRename.put(from, to);
return this;
}
Map<FieldName, FieldName> getFieldsToRename() {
return Collections.unmodifiableMap(fieldsToRename);
}
@Override
public Message parse(Message input) {
Message.Builder output = Message.builder()
.withFields(input);
fieldsToRename.forEach((from, to) -> output.renameField(from, to));
return output.build();
}
@Override
public List<FieldName> outputFields() {
return new ArrayList<>(fieldsToRename.keySet());
}
@Override
public List<ConfigName> validConfigurations() {
return Arrays.asList(renameConfig);
}
@Override
public void configure(ConfigName configName, List<ConfigValue> configValues) {
if(renameConfig.equals(configName)) {
FieldName from = null;
FieldName to = null;
for(ConfigValue value: configValues) {
if(CONFIG_FROM_KEY.equals(value.getKey())) {
from = FieldName.of(value.getValue());
} else if (CONFIG_TO_KEY.equals(value.getKey())) {
to = FieldName.of(value.getValue());
}
}
if(from == null) {
throw new IllegalArgumentException(String.format("Missing configuration value; key=%s", CONFIG_FROM_KEY));
} else if(to == null) {
throw new IllegalArgumentException(String.format("Missing configuration value; key=%s", CONFIG_TO_KEY));
} else {
renameField(from, to);
}
} else {
throw new IllegalArgumentException(String.format("Unexpected configuration; name=%s", configName));
}
}
}
| 3,025 | 0.648595 | 0.648595 | 89 | 32.988766 | 27.622046 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.561798 | false | false | 0 |
66b4262269b25756c0b97e7231d1fa0be6e51b96 | 13,537,736,980,345 | 995d36aa315aa40600b5bbeb61db928d6c084c54 | /Projects/BuildMyDay/src/buildmyday/Board.java | c0dcd1b100f9cefe7286a41af3c940353702e6ec | [] | no_license | Dimonai/Java-Projects | https://github.com/Dimonai/Java-Projects | 56a89f9d6f6a9d51699cd33db99e9f99f7f58624 | da6f3048313d9df5fc00eb830adcf0b5d128d857 | refs/heads/master | 2015-08-14T02:00:38.985000 | 2015-06-08T17:07:40 | 2015-06-08T17:07:40 | 25,299,778 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package buildmyday;
import java.util.ArrayList;
public class Board {
/**
* Instance variables
*/
public ArrayList<Column> columnGroup;
private String title;
private int id;
private static int currentBoard;
/**
* Class variables
*/
public static int indexcount = 0;
/**
* Constructors
*/
public Board(String title, int id){
columnGroup = new ArrayList();
this.setTitle(title);
this.setID(id);
indexcount++;
}
public Board(int id){
this("Board "+id, id);
}
public Board(){
this("No Title", indexcount);
}
/**
* Gets & Sets
*/
public String getTitle(){
return title;
}
public void setTitle(String title){
this.title = title;
}
public int getID(){
return id;
}
public void setID(int id){
if(id > -1){
this.id = id;
}
}
/**
* Instance Methods
*/
public void addColumns(int colqtd, int linqtd, int board_id){
int i = 0;
for(i = 0; i < colqtd; i++){
columnGroup.add(new Column(i, board_id));
}
i = 0;
for(Column column : columnGroup){
if(column.getTitle().equals("No Col Title")){
column.AddLines(linqtd, i, board_id);
}
i++;
}
}
/**
* Class methods
*/
public static int getCurrentBoard(){
return currentBoard;
}
public static void setCurrentBoard(int val, ArrayList<Board> boardGroup){
if(val <= boardGroup.size()){
currentBoard = val;
}
}
public static void decrementIndexCount(){
--indexcount;
}
public static int getNumbIndexCount(){
return indexcount;
}
}
| UTF-8 | Java | 2,006 | java | Board.java | Java | [] | null | [] | package buildmyday;
import java.util.ArrayList;
public class Board {
/**
* Instance variables
*/
public ArrayList<Column> columnGroup;
private String title;
private int id;
private static int currentBoard;
/**
* Class variables
*/
public static int indexcount = 0;
/**
* Constructors
*/
public Board(String title, int id){
columnGroup = new ArrayList();
this.setTitle(title);
this.setID(id);
indexcount++;
}
public Board(int id){
this("Board "+id, id);
}
public Board(){
this("No Title", indexcount);
}
/**
* Gets & Sets
*/
public String getTitle(){
return title;
}
public void setTitle(String title){
this.title = title;
}
public int getID(){
return id;
}
public void setID(int id){
if(id > -1){
this.id = id;
}
}
/**
* Instance Methods
*/
public void addColumns(int colqtd, int linqtd, int board_id){
int i = 0;
for(i = 0; i < colqtd; i++){
columnGroup.add(new Column(i, board_id));
}
i = 0;
for(Column column : columnGroup){
if(column.getTitle().equals("No Col Title")){
column.AddLines(linqtd, i, board_id);
}
i++;
}
}
/**
* Class methods
*/
public static int getCurrentBoard(){
return currentBoard;
}
public static void setCurrentBoard(int val, ArrayList<Board> boardGroup){
if(val <= boardGroup.size()){
currentBoard = val;
}
}
public static void decrementIndexCount(){
--indexcount;
}
public static int getNumbIndexCount(){
return indexcount;
}
}
| 2,006 | 0.473579 | 0.471087 | 98 | 18.469387 | 15.838602 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.377551 | false | false | 0 |
a30ce557c169ac42949e9e2ea7885599110142e5 | 29,583,734,736,917 | eddefcc32891b30ce2cab143aee5f4bca92f8d06 | /src/main/java/cn/ntboy/mhttpd/Host.java | 43316ebde5a4c9072e262a8debaffce89c8b2382 | [] | no_license | jianse/mhttpd-java | https://github.com/jianse/mhttpd-java | be5b8cfba1d9609f450688743a2ec5a3f1923017 | 50731827fe4c5097694488599dc4edcb39e89a5e | refs/heads/master | 2022-01-17T03:31:35.655000 | 2022-01-10T12:30:46 | 2022-01-10T12:30:46 | 215,227,424 | 0 | 0 | null | false | 2022-01-10T12:30:47 | 2019-10-15T06:49:33 | 2021-12-16T10:37:06 | 2022-01-10T12:30:46 | 293 | 0 | 0 | 0 | Java | false | false | package cn.ntboy.mhttpd;
public interface Host {
}
| UTF-8 | Java | 52 | java | Host.java | Java | [] | null | [] | package cn.ntboy.mhttpd;
public interface Host {
}
| 52 | 0.75 | 0.75 | 4 | 12 | 11.510864 | 24 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 0 |
67645d615b5c75520e37f165aff1cf1edccb8855 | 29,360,396,484,419 | d04f52ec0772455289e2a428bb06d34824a4eead | /Project 03_Parital_Completed/Client/src/main/java/Client.java | e203b2c471aadea53040fb3957bc2903c322e35b | [] | no_license | JGuo99/CS342 | https://github.com/JGuo99/CS342 | 5d0a9fd69fc10c0e93853ea63d41ab6af5b2aedb | 0921ba99e5bb0ed587ad8699c7090c212cd5cd19 | refs/heads/master | 2022-04-09T12:45:37.789000 | 2020-02-13T21:08:08 | 2020-02-13T21:08:08 | 214,037,811 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.Socket;
import java.util.function.Consumer;
public class Client extends Thread {
Socket socketC;
ObjectOutputStream out;
ObjectInputStream in;
private Consumer<Serializable> callback;
Client(Consumer<Serializable> call) {
callback = call;
}
public void run() {
try {
socketC = new Socket("127.0.0.1", 1234); //Change this later
out = new ObjectOutputStream(socketC.getOutputStream());
in = new ObjectInputStream(socketC.getInputStream());
socketC.setTcpNoDelay(true);
}catch (Exception e){
System.out.println("ERROR: Stream did not open!");
}
while(true) {
try {
String m = in.readObject().toString();
callback.accept(m);
}catch (Exception e) {
System.out.println("ERROR: Did not get message!");
}
}
}
public void send(String data) {
try {
out.writeObject(data);
}catch (IOException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 1,243 | java | Client.java | Java | [
{
"context": "{\n try {\n socketC = new Socket(\"127.0.0.1\", 1234); //Change this later\n out = ne",
"end": 500,
"score": 0.9997671842575073,
"start": 491,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
}
] | null | [] | import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.Socket;
import java.util.function.Consumer;
public class Client extends Thread {
Socket socketC;
ObjectOutputStream out;
ObjectInputStream in;
private Consumer<Serializable> callback;
Client(Consumer<Serializable> call) {
callback = call;
}
public void run() {
try {
socketC = new Socket("127.0.0.1", 1234); //Change this later
out = new ObjectOutputStream(socketC.getOutputStream());
in = new ObjectInputStream(socketC.getInputStream());
socketC.setTcpNoDelay(true);
}catch (Exception e){
System.out.println("ERROR: Stream did not open!");
}
while(true) {
try {
String m = in.readObject().toString();
callback.accept(m);
}catch (Exception e) {
System.out.println("ERROR: Did not get message!");
}
}
}
public void send(String data) {
try {
out.writeObject(data);
}catch (IOException e) {
e.printStackTrace();
}
}
}
| 1,243 | 0.580048 | 0.572003 | 46 | 26.02174 | 19.810503 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478261 | false | false | 0 |
79b76701049d39f3a9215c13c6ab20bc18006ef2 | 22,660,247,480,723 | afeeb03cb213ef49998b46712cce374d02307b0d | /src/main/java/com/ibx/projects/smartschools/SmartWebSchoolsApplication.java | 0995c99e20341942f620c3345f0d46c0bbdf2a53 | [] | no_license | santoshMathologic/SmartWebSchools | https://github.com/santoshMathologic/SmartWebSchools | 6c5125a60a97a5c9303590fbdf086dcfe666f05a | 47a38f6cbf40d4ad3bdbe170d388598a0606d741 | refs/heads/master | 2020-07-20T19:02:27.022000 | 2016-11-26T09:55:38 | 2016-11-26T09:55:38 | 66,153,878 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ibx.projects.smartschools;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "com.ibx.projects.smartschools","com.ibx.project.smartschools.service","com.ibx.project.smartschools.dao","com.ibx.projects.smartschools.controllers","com.ibx.project.smartschools.serviceimpl","com.ibx.project.smartschools.daoimpl"})
@Configuration
@EnableAutoConfiguration
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaRepositories(basePackages={"com.ibx.projects.smartschools.repositories"})
public class SmartWebSchoolsApplication {
public static void main(String[] args) {
SpringApplication.run(SmartWebSchoolsApplication.class, args);
}
}
| UTF-8 | Java | 1,142 | java | SmartWebSchoolsApplication.java | Java | [] | null | [] | package com.ibx.projects.smartschools;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "com.ibx.projects.smartschools","com.ibx.project.smartschools.service","com.ibx.project.smartschools.dao","com.ibx.projects.smartschools.controllers","com.ibx.project.smartschools.serviceimpl","com.ibx.project.smartschools.daoimpl"})
@Configuration
@EnableAutoConfiguration
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaRepositories(basePackages={"com.ibx.projects.smartschools.repositories"})
public class SmartWebSchoolsApplication {
public static void main(String[] args) {
SpringApplication.run(SmartWebSchoolsApplication.class, args);
}
}
| 1,142 | 0.827496 | 0.827496 | 26 | 41.923077 | 53.172379 | 265 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.884615 | false | false | 0 |
3be4b2206d663572028a1695f12a6acb929e61e0 | 10,574,209,540,682 | 613088788468bb1077876f08f22233c8d74584cb | /generic-rts/src/main/java/pl/rembol/jme3/rts/input/state/Command.java | 405814f8d89caf39d5c1f129e6579693eef8c4db | [] | no_license | RemboL/world | https://github.com/RemboL/world | c2f91f5acf47b8b50a31ef3e8d4acad1d71d2d62 | df04dfb9821f5713c9efd52aef0e432c8733734c | refs/heads/master | 2021-01-17T06:57:55.098000 | 2017-06-25T06:32:08 | 2017-06-25T06:32:08 | 45,726,299 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.rembol.jme3.rts.input.state;
public class Command {
private ActionButtonPosition position;
private String iconName;
private int keyInput;
public Command(ActionButtonPosition position, String iconName,
int keyInput) {
this.position = position;
this.iconName = iconName;
this.keyInput = keyInput;
}
public int getPositionX() {
return position.getX();
}
public int getPositionY() {
return position.getY();
}
public String getIconName() {
return iconName;
}
public int getKey() {
return keyInput;
}
}
| UTF-8 | Java | 642 | java | Command.java | Java | [] | null | [] | package pl.rembol.jme3.rts.input.state;
public class Command {
private ActionButtonPosition position;
private String iconName;
private int keyInput;
public Command(ActionButtonPosition position, String iconName,
int keyInput) {
this.position = position;
this.iconName = iconName;
this.keyInput = keyInput;
}
public int getPositionX() {
return position.getX();
}
public int getPositionY() {
return position.getY();
}
public String getIconName() {
return iconName;
}
public int getKey() {
return keyInput;
}
}
| 642 | 0.613707 | 0.61215 | 31 | 19.709677 | 16.800909 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.419355 | false | false | 0 |
f0c5848725245da54a82cfa243d7edcb3f955620 | 8,881,992,401,209 | e682fa3667adce9277ecdedb40d4d01a785b3912 | /internal/fischer/mangf/A141609.java | a71adc51c0b1232a76464a827ee81dbb5e5cffa2 | [
"Apache-2.0"
] | permissive | gfis/joeis-lite | https://github.com/gfis/joeis-lite | 859158cb8fc3608febf39ba71ab5e72360b32cb4 | 7185a0b62d54735dc3d43d8fb5be677734f99101 | refs/heads/master | 2023-08-31T00:23:51.216000 | 2023-08-29T21:11:31 | 2023-08-29T21:11:31 | 179,938,034 | 4 | 1 | Apache-2.0 | false | 2022-06-25T22:47:19 | 2019-04-07T08:35:01 | 2022-03-26T06:04:12 | 2022-06-25T22:47:18 | 8,156 | 3 | 0 | 1 | Roff | false | false | package irvine.oeis.a141;
// generated by patch_offset.pl at 2022-08-27 22:36
import irvine.math.z.Z;
import irvine.oeis.recur.ConstantOrderRecurrence;
/**
* A141609 a(n)=(a(n - 1)*a(n - 2) + a(n - 1)^2)/a(n - 3).
* @author Georg Fischer
*/
public class A141609 extends ConstantOrderRecurrence {
/** Construct the sequence */
public A141609() {
super(1, 3, 0, 1, 1, 1);
}
@Override
protected Z compute(final int n) {
return a(n - 1).multiply(a(n - 2)).add(a(n - 1).square()).divide(a(n - 3));
}
}
| UTF-8 | Java | 524 | java | A141609.java | Java | [
{
"context": "n - 1)*a(n - 2) + a(n - 1)^2)/a(n - 3).\n * @author Georg Fischer\n */\npublic class A141609 extends ConstantOrderRec",
"end": 241,
"score": 0.9998546838760376,
"start": 228,
"tag": "NAME",
"value": "Georg Fischer"
}
] | null | [] | package irvine.oeis.a141;
// generated by patch_offset.pl at 2022-08-27 22:36
import irvine.math.z.Z;
import irvine.oeis.recur.ConstantOrderRecurrence;
/**
* A141609 a(n)=(a(n - 1)*a(n - 2) + a(n - 1)^2)/a(n - 3).
* @author <NAME>
*/
public class A141609 extends ConstantOrderRecurrence {
/** Construct the sequence */
public A141609() {
super(1, 3, 0, 1, 1, 1);
}
@Override
protected Z compute(final int n) {
return a(n - 1).multiply(a(n - 2)).add(a(n - 1).square()).divide(a(n - 3));
}
}
| 517 | 0.625954 | 0.534351 | 22 | 22.818182 | 22.760883 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false | 0 |
4e015100a74f4c968fabed15b86e6be67ae15348 | 32,762,010,590,767 | ccea1dcad485acb2347718f0695b919df06b2b3e | /WEB-INF/classes/gov/noaa/pfel/erddap/util/ThreadedWorkManager.java | d79e627de649b6f1e9dc301f49dee6984fdeafbf | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] | permissive | BobSimons/erddap | https://github.com/BobSimons/erddap | 82a825e8dab0f1a620cea31d53d46ab6e7fc00c2 | 4956f2180dd54a82c906f5b9e120a00699dba728 | refs/heads/master | 2023-04-29T03:20:58.867000 | 2023-04-28T20:46:14 | 2023-04-28T20:46:14 | 4,228,540 | 60 | 56 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gov.noaa.pfel.erddap.util;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
public class ThreadedWorkManager<T> {
ExecutorService executorService = null;
List<FutureTask<T>> taskList = new ArrayList<>();
WorkConsumer<T> processor;
int completed = 0;
public ThreadedWorkManager (int nThreads, WorkConsumer<T> processResult) {
if (nThreads > 1) {
executorService = Executors.newFixedThreadPool(nThreads);
}
processor = processResult;
}
public void addTask(Callable<T> callable) throws Exception, Throwable {
// If we're threaded add the work to the thread.
if (executorService != null) {
FutureTask<T> task = new FutureTask<T>(callable);
taskList.add(task);
if (executorService != null) {
executorService.submit(task);
}
} else {
// No threading here, just do the work and process it.
processor.accept(callable.call());
}
}
public boolean hasNext() {
return taskList.size() > completed;
}
public T getNextTaskResult() throws InterruptedException, ExecutionException {
//get results table from a futureTask
//Put null in that position in futureTasks so it can be gc'd after this method
FutureTask<T> task = taskList.set(completed++, null);
return task.get();
}
public void finishedEnqueing() {
if (executorService != null) {
executorService.shutdown();
}
}
public void forceShutdown() {
if (executorService != null) {
executorService.shutdownNow();
}
}
public void processResults() throws InterruptedException, ExecutionException, Throwable {
while(hasNext()) {
processor.accept(getNextTaskResult());
}
}
}
| UTF-8 | Java | 2,119 | java | ThreadedWorkManager.java | Java | [] | null | [] | package gov.noaa.pfel.erddap.util;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
public class ThreadedWorkManager<T> {
ExecutorService executorService = null;
List<FutureTask<T>> taskList = new ArrayList<>();
WorkConsumer<T> processor;
int completed = 0;
public ThreadedWorkManager (int nThreads, WorkConsumer<T> processResult) {
if (nThreads > 1) {
executorService = Executors.newFixedThreadPool(nThreads);
}
processor = processResult;
}
public void addTask(Callable<T> callable) throws Exception, Throwable {
// If we're threaded add the work to the thread.
if (executorService != null) {
FutureTask<T> task = new FutureTask<T>(callable);
taskList.add(task);
if (executorService != null) {
executorService.submit(task);
}
} else {
// No threading here, just do the work and process it.
processor.accept(callable.call());
}
}
public boolean hasNext() {
return taskList.size() > completed;
}
public T getNextTaskResult() throws InterruptedException, ExecutionException {
//get results table from a futureTask
//Put null in that position in futureTasks so it can be gc'd after this method
FutureTask<T> task = taskList.set(completed++, null);
return task.get();
}
public void finishedEnqueing() {
if (executorService != null) {
executorService.shutdown();
}
}
public void forceShutdown() {
if (executorService != null) {
executorService.shutdownNow();
}
}
public void processResults() throws InterruptedException, ExecutionException, Throwable {
while(hasNext()) {
processor.accept(getNextTaskResult());
}
}
}
| 2,119 | 0.628127 | 0.627183 | 67 | 30.626865 | 23.884571 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.462687 | false | false | 0 |
9bdeb766bdcd3b0cbac8c8bcff57e80cec091e50 | 103,079,265,157 | 39624cc96a19e9691bd8291d10586c75e9d36b5e | /Week10/Empty.java | 7d5a840604da3b332ab604b21c351cf414de6e9c | [] | no_license | madanalogy/CS2030 | https://github.com/madanalogy/CS2030 | d1fced0f52ac3b5acd0e6a5bbcca48cf9b61f255 | 46f15abd44610c7193f6b64267853e01bc54c2b2 | refs/heads/master | 2021-10-09T20:36:41.857000 | 2019-01-03T10:21:09 | 2019-01-03T10:21:09 | 163,957,516 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cs2030.mystream;
public class Empty<T> extends Ahmed<T> {
public Empty () {}
public boolean isEmpty() {
return true;
}
}
| UTF-8 | Java | 155 | java | Empty.java | Java | [] | null | [] | package cs2030.mystream;
public class Empty<T> extends Ahmed<T> {
public Empty () {}
public boolean isEmpty() {
return true;
}
}
| 155 | 0.593548 | 0.567742 | 9 | 16.222221 | 13.472423 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 0 |
3c7358587edbbbf151ac73cfb982c44db537c9a2 | 103,079,263,338 | fde3a87f64a099a0a8d1110c18753c6c8c317353 | /src/main/java/com/daniel/coupons/enums/Category.java | 7e7ecfbad77820363c217ebea9910b4c9aaca4d1 | [] | no_license | danielkariti/CouponsProject-Backend | https://github.com/danielkariti/CouponsProject-Backend | 968482dbc5b9b1dab72932bb548f60177691dda0 | 26eda7c80e3d618bb13ed7941242a240ec175668 | refs/heads/master | 2023-07-21T10:31:01.067000 | 2021-08-26T16:04:43 | 2021-08-26T16:04:43 | 393,361,689 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.daniel.coupons.enums;
public enum Category {
FOOD("Food"),
ELECTRICITY("Electricity"),
VACATION("Vacation"),
FASHION("Fashion"),
ENTERTAINMENT("Entertainment"),
SPORTS("Sports"),
HEALTH("Health");
private String category;
Category(String category){
this.category = category;
}
public String getCategory() {
return this.category;
}
}
| UTF-8 | Java | 376 | java | Category.java | Java | [] | null | [] | package com.daniel.coupons.enums;
public enum Category {
FOOD("Food"),
ELECTRICITY("Electricity"),
VACATION("Vacation"),
FASHION("Fashion"),
ENTERTAINMENT("Entertainment"),
SPORTS("Sports"),
HEALTH("Health");
private String category;
Category(String category){
this.category = category;
}
public String getCategory() {
return this.category;
}
}
| 376 | 0.691489 | 0.691489 | 24 | 14.583333 | 12.13094 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.375 | false | false | 0 |
8c43c2c276b6aaea4fd82a05e318cf0c30938e14 | 2,843,268,399,470 | 5b32de09bc3ccade4c88623862b9aa0afd351e68 | /server/src/main/java/com/provectus/formula/alexis/DAO/ConfigurationDAO.java | 195803ad2e92b2c3a89685b759dbc382bb23cfe0 | [] | no_license | pkoptilin/alexis-server | https://github.com/pkoptilin/alexis-server | c12bbf2535f9f5171049e728c8d4fe51ab46b2ae | d0ab37c1a662d9a8eec528a1076f81461abc2ab4 | refs/heads/master | 2020-04-08T13:31:44.379000 | 2019-01-14T21:32:37 | 2019-01-14T21:32:37 | 159,394,836 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.provectus.formula.alexis.DAO;
import com.provectus.formula.alexis.models.ConfigurationReturn;
import java.util.Optional;
public interface ConfigurationDAO {
ConfigurationReturn getConfigurationByUserId(Long userId);
Optional<ConfigurationReturn> getConfigurationByAlexaId(String alexaId);
void updateConfiguration(ConfigurationReturn configurationReturn, Long userId);
}
| UTF-8 | Java | 398 | java | ConfigurationDAO.java | Java | [] | null | [] | package com.provectus.formula.alexis.DAO;
import com.provectus.formula.alexis.models.ConfigurationReturn;
import java.util.Optional;
public interface ConfigurationDAO {
ConfigurationReturn getConfigurationByUserId(Long userId);
Optional<ConfigurationReturn> getConfigurationByAlexaId(String alexaId);
void updateConfiguration(ConfigurationReturn configurationReturn, Long userId);
}
| 398 | 0.836683 | 0.836683 | 11 | 35.18182 | 30.815634 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 0 |
96ac2624b25ef02d2031fe0ea6e7938b2406c732 | 2,843,268,399,666 | e90a4882492a69b27d4bf7322149eb444c104da5 | /sos1/src/main/java/g28/sos1/problems/graphs/criteria/PathCriterion.java | 2a408b41a947f337779c2144b4c16b98054b6781 | [] | no_license | michael-borkowski/sos-g28 | https://github.com/michael-borkowski/sos-g28 | 5740550a29435a72220b52b32fb3aeb9e89afad1 | 81485ad51009debadb7e4c2d1f5f3b3b803416bb | refs/heads/master | 2021-08-23T05:36:33.746000 | 2017-12-03T17:38:14 | 2017-12-03T17:38:14 | 112,948,883 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package g28.sos1.problems.graphs.criteria;
import g28.sos1.problems.graphs.DirectedGraph;
import g28.sos1.problems.graphs.Edge;
import g28.sos1.problems.graphs.Path;
import java.util.Comparator;
import java.util.List;
public abstract class PathCriterion implements Comparator<Path> {
public PathCriterion() {
}
public abstract void init(DirectedGraph graph);
public abstract Double rateEdge(Edge edge, long pheromones);
public abstract double ratePath(Path temporaryPath);
public Path getBestPath(List<Path> paths) {
return paths.stream().sorted(this).findFirst().orElse(null);
}
@Override
public int compare(Path o1, Path o2) {
return -Double.compare(ratePath(o1), ratePath(o2));
}
}
| UTF-8 | Java | 749 | java | PathCriterion.java | Java | [] | null | [] | package g28.sos1.problems.graphs.criteria;
import g28.sos1.problems.graphs.DirectedGraph;
import g28.sos1.problems.graphs.Edge;
import g28.sos1.problems.graphs.Path;
import java.util.Comparator;
import java.util.List;
public abstract class PathCriterion implements Comparator<Path> {
public PathCriterion() {
}
public abstract void init(DirectedGraph graph);
public abstract Double rateEdge(Edge edge, long pheromones);
public abstract double ratePath(Path temporaryPath);
public Path getBestPath(List<Path> paths) {
return paths.stream().sorted(this).findFirst().orElse(null);
}
@Override
public int compare(Path o1, Path o2) {
return -Double.compare(ratePath(o1), ratePath(o2));
}
}
| 749 | 0.727637 | 0.706275 | 28 | 25.75 | 24.264355 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 0 |
668cbe9faea91f46947f97f0945e2e12230347e9 | 6,571,300,007,354 | e760cd8ffc85c6402549f094e279a2400356d328 | /chapter_003/part_005/src/main/java/ru/abelov/chat/package-info.java | fbc27e877c5a27ec4be4e94a163655a537649155 | [
"Apache-2.0"
] | permissive | xcyde/Java-A-to-Z | https://github.com/xcyde/Java-A-to-Z | aca7b425fcc29472e5142d2792bf462f721a6dcd | a06701b96293ecee0f7aa1d79dd50a028c5af89c | refs/heads/master | 2020-12-02T01:11:19.934000 | 2018-08-15T09:47:02 | 2018-08-15T09:47:02 | 67,689,699 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Package for chapter_003/part_005.
* @author Aleksandr Belov
* @since 05.12.2016
*/
package ru.abelov.chat; | UTF-8 | Java | 116 | java | package-info.java | Java | [
{
"context": "**\n * Package for chapter_003/part_005.\n * @author Aleksandr Belov\n * @since 05.12.2016\n */\npackage ru.abelov.chat;",
"end": 67,
"score": 0.9998776316642761,
"start": 52,
"tag": "NAME",
"value": "Aleksandr Belov"
}
] | null | [] | /**
* Package for chapter_003/part_005.
* @author <NAME>
* @since 05.12.2016
*/
package ru.abelov.chat; | 107 | 0.681035 | 0.560345 | 6 | 18.5 | 12.010412 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 0 |
5b810ff54bca42c4dd23b98283ca940d8e721e29 | 13,159,779,848,329 | 867eca343c02a6a0823022cec5efb81eecd9c1f6 | /LivrOnTime/src/main/java/controleur/CdeSuppression.java | e49c24984f12cff31b5ba127705aba3bf6c72e19 | [] | no_license | lsordillon/LivrOnTime | https://github.com/lsordillon/LivrOnTime | 19d995b426e9ad9e81d99a937c2565ca6dbd51b5 | a945ce4a24aea8d7959be6069a59ceb048f7a31e | refs/heads/master | 2021-08-08T17:32:24.518000 | 2017-11-10T19:11:40 | 2017-11-10T19:11:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controleur;
import LivrOnTime.Main;
import modele.Intersection;
import modele.Livraison;
import modele.Plan;
import modele.Tournee;
/**
* La classe CdeSuppression implemente l interface Commande pour la suppression
* d une livraison dans la tournee. Elle stocke la livraison supprimee et sa
* position.
*
* @author Matthieu
*
*/
public class CdeSuppression implements Commande {
private Plan plan;
private Intersection intersection;
private int index;
private Tournee tournee;
private Livraison livraison;
/**
* Constructeur de la classe CdeSuppression
*
* @param plan
* @param intersection
* @param tournee
* @param livraison
* @param index
*/
public CdeSuppression(Plan plan, Intersection intersection, Tournee tournee, Livraison livraison, int index) {
super();
this.plan = plan;
this.intersection = intersection;
this.tournee = tournee;
this.index = index;
this.livraison = livraison;
}
@Override
public void undoCde() {
Main.aController.getDemandeLiv().getLivraisons().add(livraison);
try {
tournee.AjouterLivraison(plan, intersection, livraison, index);
} catch (Exception e) {
System.err.println("Le undo de la suppression bug!");
}
}
@Override
public void redoCde() {
Main.aController.getDemandeLiv().getLivraisons().remove(livraison);
try {
index = (tournee.SupprimerLivraison(plan, intersection, livraison)).getKey();
} catch (Exception e) {
System.err.println("Le redo de la suppression bug!");
}
}
}
| UTF-8 | Java | 1,569 | java | CdeSuppression.java | Java | [
{
"context": "son supprimee et sa\r\n * position.\r\n * \r\n * @author Matthieu\r\n *\r\n */\r\npublic class CdeSuppression implements ",
"end": 352,
"score": 0.9997345805168152,
"start": 344,
"tag": "NAME",
"value": "Matthieu"
}
] | null | [] | package controleur;
import LivrOnTime.Main;
import modele.Intersection;
import modele.Livraison;
import modele.Plan;
import modele.Tournee;
/**
* La classe CdeSuppression implemente l interface Commande pour la suppression
* d une livraison dans la tournee. Elle stocke la livraison supprimee et sa
* position.
*
* @author Matthieu
*
*/
public class CdeSuppression implements Commande {
private Plan plan;
private Intersection intersection;
private int index;
private Tournee tournee;
private Livraison livraison;
/**
* Constructeur de la classe CdeSuppression
*
* @param plan
* @param intersection
* @param tournee
* @param livraison
* @param index
*/
public CdeSuppression(Plan plan, Intersection intersection, Tournee tournee, Livraison livraison, int index) {
super();
this.plan = plan;
this.intersection = intersection;
this.tournee = tournee;
this.index = index;
this.livraison = livraison;
}
@Override
public void undoCde() {
Main.aController.getDemandeLiv().getLivraisons().add(livraison);
try {
tournee.AjouterLivraison(plan, intersection, livraison, index);
} catch (Exception e) {
System.err.println("Le undo de la suppression bug!");
}
}
@Override
public void redoCde() {
Main.aController.getDemandeLiv().getLivraisons().remove(livraison);
try {
index = (tournee.SupprimerLivraison(plan, intersection, livraison)).getKey();
} catch (Exception e) {
System.err.println("Le redo de la suppression bug!");
}
}
}
| 1,569 | 0.697259 | 0.697259 | 63 | 22.904762 | 24.189539 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.492064 | false | false | 0 |
706d598f7b4fe54697b2bf68ef1c3596042167e3 | 32,255,204,409,115 | e68afb67412b86d838a268664129e1daa66d3ce4 | /Core/src/main/java/gg/hound/core/commands/user/ReportCommand.java | d569cb6ab99af2735ad6c80002ad975bd72ea762 | [] | no_license | edutf8/development-projects-2020 | https://github.com/edutf8/development-projects-2020 | a1481b10e8958a1041500e6ed3c567958da92849 | 2aead4b149b97f6f81f122341450f1bc49c4391c | refs/heads/master | 2022-11-20T19:02:34.513000 | 2020-07-16T19:19:14 | 2020-07-16T19:19:14 | 280,238,480 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gg.hound.core.commands.user;
import gg.hound.core.CorePlugin;
import gg.hound.core.punishments.PunishmentData;
import gg.hound.core.punishments.Reason;
import gg.hound.core.tasks.PlayerCooldownTask;
import gg.hound.core.user.CoreUser;
import gg.hound.core.user.UserManager;
import gg.hound.core.util.ItemBuilder;
import gg.hound.core.util.Report;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class ReportCommand implements CommandExecutor {
private final CorePlugin corePlugin;
private final UserManager userManager;
private final PlayerCooldownTask playerCooldownTask;
private final Inventory inventory;
private final PunishmentData punishmentData;
public ReportCommand(CorePlugin corePlugin, UserManager userManager, PlayerCooldownTask playerCooldownTask, PunishmentData punishmentData) {
this.corePlugin = corePlugin;
this.userManager = userManager;
this.playerCooldownTask = playerCooldownTask;
this.punishmentData = punishmentData;
inventory = Bukkit.createInventory(null, 54, ChatColor.GREEN + "Report");
setup();
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] arguments) {
if (!(commandSender instanceof Player)) {
commandSender.sendMessage(corePlugin.getPrefix() + "You must be a player to execute this command");
return true;
}
if (arguments.length != 1) {
commandSender.sendMessage(corePlugin.getPrefix() + "Usage: /report <user>");
return true;
}
Player player = (Player) commandSender;
CoreUser coreUser = userManager.getUser(player.getUniqueId());
if (coreUser == null)
return true;
if (playerCooldownTask.hasReportCooldown(coreUser)) {
commandSender.sendMessage(corePlugin.getPrefix() + "Please wait before attempting to report a player again");
return true;
}
Player target = Bukkit.getPlayer(arguments[0]);
if (target == null) {
player.sendMessage(corePlugin.getPrefix() + "This player is not online");
return true;
}
player.openInventory(inventory);
if (!player.hasPermission("perms.staff"))
playerCooldownTask.addReportCooldown(coreUser);
punishmentData.addReport(player.getUniqueId(), new Report(arguments[0], player.getName()));
return true;
}
private void setup() {
ItemStack blank = new ItemBuilder(Material.STAINED_GLASS_PANE).setName(" ").setAmount(1).setDurability((short) 14).toItemStack();
for (int i = 0; i < inventory.getSize() - 1; i++) {
inventory.setItem(i, blank);
}
int start = 10;
for (Reason reason : punishmentData.getReportReasons().values()) {
if (start == 17 || start == 26 || start == 38 || start == 47) {
start = start + 2;
}
inventory.setItem(start, reason.getItemStack());
start++;
}
ItemStack cancel = new ItemBuilder(Material.REDSTONE_BLOCK).setName("Cancel").toItemStack();
inventory.setItem(53, cancel);
}
}
| UTF-8 | Java | 3,504 | java | ReportCommand.java | Java | [] | null | [] | package gg.hound.core.commands.user;
import gg.hound.core.CorePlugin;
import gg.hound.core.punishments.PunishmentData;
import gg.hound.core.punishments.Reason;
import gg.hound.core.tasks.PlayerCooldownTask;
import gg.hound.core.user.CoreUser;
import gg.hound.core.user.UserManager;
import gg.hound.core.util.ItemBuilder;
import gg.hound.core.util.Report;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class ReportCommand implements CommandExecutor {
private final CorePlugin corePlugin;
private final UserManager userManager;
private final PlayerCooldownTask playerCooldownTask;
private final Inventory inventory;
private final PunishmentData punishmentData;
public ReportCommand(CorePlugin corePlugin, UserManager userManager, PlayerCooldownTask playerCooldownTask, PunishmentData punishmentData) {
this.corePlugin = corePlugin;
this.userManager = userManager;
this.playerCooldownTask = playerCooldownTask;
this.punishmentData = punishmentData;
inventory = Bukkit.createInventory(null, 54, ChatColor.GREEN + "Report");
setup();
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] arguments) {
if (!(commandSender instanceof Player)) {
commandSender.sendMessage(corePlugin.getPrefix() + "You must be a player to execute this command");
return true;
}
if (arguments.length != 1) {
commandSender.sendMessage(corePlugin.getPrefix() + "Usage: /report <user>");
return true;
}
Player player = (Player) commandSender;
CoreUser coreUser = userManager.getUser(player.getUniqueId());
if (coreUser == null)
return true;
if (playerCooldownTask.hasReportCooldown(coreUser)) {
commandSender.sendMessage(corePlugin.getPrefix() + "Please wait before attempting to report a player again");
return true;
}
Player target = Bukkit.getPlayer(arguments[0]);
if (target == null) {
player.sendMessage(corePlugin.getPrefix() + "This player is not online");
return true;
}
player.openInventory(inventory);
if (!player.hasPermission("perms.staff"))
playerCooldownTask.addReportCooldown(coreUser);
punishmentData.addReport(player.getUniqueId(), new Report(arguments[0], player.getName()));
return true;
}
private void setup() {
ItemStack blank = new ItemBuilder(Material.STAINED_GLASS_PANE).setName(" ").setAmount(1).setDurability((short) 14).toItemStack();
for (int i = 0; i < inventory.getSize() - 1; i++) {
inventory.setItem(i, blank);
}
int start = 10;
for (Reason reason : punishmentData.getReportReasons().values()) {
if (start == 17 || start == 26 || start == 38 || start == 47) {
start = start + 2;
}
inventory.setItem(start, reason.getItemStack());
start++;
}
ItemStack cancel = new ItemBuilder(Material.REDSTONE_BLOCK).setName("Cancel").toItemStack();
inventory.setItem(53, cancel);
}
}
| 3,504 | 0.67266 | 0.666096 | 100 | 34.040001 | 32.291462 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.74 | false | false | 0 |
0b553ddedaa66af44fb9c600b843f8e6fc87e11a | 20,358,145,054,316 | 600d556afe9b8075c1d40f6da3d9046c3f5b9159 | /java-example-tools/src/test/java/com/gyq/pattern/proxy/jdkdynamicproxy/JdkDynamicProxyTest.java | 3e956774fba6e51f4ba556442a8e310ab3315d06 | [] | no_license | gaoyaqiu/java-example | https://github.com/gaoyaqiu/java-example | 5d5040ea10da28cee215bef564abf791133ce865 | 04aecf2fe7032ceb08be0d37beffa06a8bd98deb | refs/heads/master | 2022-11-15T01:09:51.728000 | 2020-07-09T13:32:06 | 2020-07-09T13:32:06 | 116,021,924 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gyq.pattern.proxy.jdkdynamicproxy;
import com.gyq.pattern.proxy.Person;
import com.gyq.pattern.proxy.staticproxy.LiSi;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Proxy;
/**
* @author gaoyaqiu
* @date 2018/6/20
*/
public class JdkDynamicProxyTest {
@Before
public void init() {
// System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
}
@Test
public void test() throws IOException {
Person person = (Person) Proxy.newProxyInstance(Person.class.getClassLoader(), new Class[]{Person.class}, new AgencyProxy(new LiSi()));
person.findHourse();
// 查看代理之后的类名
System.out.println(person.getClass());
// 获取字节码
// byte[] data = ProxyGenerator.generateProxyClass("$Proxy4", new Class[]{Person.class});
// 输出到class文件
// FileOutputStream os = new FileOutputStream("/Users/gaoyaqiu/Downloads/bak/test/$Proxy4.class");
// os.write(data);
// os.close();
// 用反编译软件查看class文件
}
}
| UTF-8 | Java | 1,139 | java | JdkDynamicProxyTest.java | Java | [
{
"context": "n;\nimport java.lang.reflect.Proxy;\n\n/**\n * @author gaoyaqiu\n * @date 2018/6/20\n */\npublic class JdkDynamicPro",
"end": 265,
"score": 0.998914897441864,
"start": 257,
"tag": "USERNAME",
"value": "gaoyaqiu"
}
] | null | [] | package com.gyq.pattern.proxy.jdkdynamicproxy;
import com.gyq.pattern.proxy.Person;
import com.gyq.pattern.proxy.staticproxy.LiSi;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Proxy;
/**
* @author gaoyaqiu
* @date 2018/6/20
*/
public class JdkDynamicProxyTest {
@Before
public void init() {
// System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
}
@Test
public void test() throws IOException {
Person person = (Person) Proxy.newProxyInstance(Person.class.getClassLoader(), new Class[]{Person.class}, new AgencyProxy(new LiSi()));
person.findHourse();
// 查看代理之后的类名
System.out.println(person.getClass());
// 获取字节码
// byte[] data = ProxyGenerator.generateProxyClass("$Proxy4", new Class[]{Person.class});
// 输出到class文件
// FileOutputStream os = new FileOutputStream("/Users/gaoyaqiu/Downloads/bak/test/$Proxy4.class");
// os.write(data);
// os.close();
// 用反编译软件查看class文件
}
}
| 1,139 | 0.661425 | 0.653099 | 40 | 26.025 | 31.540836 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.475 | false | false | 0 |
3b4bf2624522cb427d2f8c7641ec59e4ff75cfb0 | 32,444,183,002,288 | 6ec8669591eeeba59865ed233a3ba4a8be355f3c | /src/Movie.java | 5c9a13bad9e4ba58bd23626593d534ee577e0fa7 | [] | no_license | knobelman/StateMachine | https://github.com/knobelman/StateMachine | d06873de028fecc6d8e5538d444eea4cbcf77013 | af2ab0d5f74881542c0df03b1e1875aef7d2f18b | refs/heads/master | 2020-05-29T23:38:36.674000 | 2019-06-01T17:11:04 | 2019-06-01T17:11:04 | 189,441,423 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Random;
public class Movie {
private int size;
private int length;
Random rand = new Random();
public Movie(int size) {
this.size = size;//GB
this.length = rand.nextInt(120);//Minutes
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public String toString() {
return "Movie{" +
"Size=" + size +
", Length=" + length +
'}';
}
}
| UTF-8 | Java | 712 | java | Movie.java | Java | [] | null | [] | import java.util.Random;
public class Movie {
private int size;
private int length;
Random rand = new Random();
public Movie(int size) {
this.size = size;//GB
this.length = rand.nextInt(120);//Minutes
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public String toString() {
return "Movie{" +
"Size=" + size +
", Length=" + length +
'}';
}
}
| 712 | 0.481742 | 0.477528 | 37 | 17.243244 | 13.950502 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.324324 | false | false | 0 |
2a72a6ba57e7bc4b124d9b9fd2b3ffd1c6dcc324 | 13,589,276,552,584 | 21bcd1da03415fec0a4f3fa7287f250df1d14051 | /sources/com/google/android/gms/measurement/internal/C5235e1.java | dd99cd81acea1453fc3cde306331231696a80b5e | [] | no_license | lestseeandtest/Delivery | https://github.com/lestseeandtest/Delivery | 9a5cc96bd6bd2316a535271ec9ca3865080c3ec8 | bc3fae8f30804a2520e6699df92c2e6a4a0a7cfc | refs/heads/master | 2022-04-24T12:14:22.396000 | 2020-04-25T21:50:29 | 2020-04-25T21:50:29 | 258,875,870 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.google.android.gms.measurement.internal;
import com.google.android.gms.internal.measurement.C4745eb;
/* renamed from: com.google.android.gms.measurement.internal.e1 */
/* compiled from: com.google.android.gms:play-services-measurement-impl@@17.1.0 */
final /* synthetic */ class C5235e1 implements C5466z2 {
/* renamed from: a */
static final C5466z2 f14968a = new C5235e1();
private C5235e1() {
}
/* renamed from: a */
public final Object mo21140a() {
return Boolean.valueOf(C4745eb.m20055d());
}
}
| UTF-8 | Java | 553 | java | C5235e1.java | Java | [] | null | [] | package com.google.android.gms.measurement.internal;
import com.google.android.gms.internal.measurement.C4745eb;
/* renamed from: com.google.android.gms.measurement.internal.e1 */
/* compiled from: com.google.android.gms:play-services-measurement-impl@@17.1.0 */
final /* synthetic */ class C5235e1 implements C5466z2 {
/* renamed from: a */
static final C5466z2 f14968a = new C5235e1();
private C5235e1() {
}
/* renamed from: a */
public final Object mo21140a() {
return Boolean.valueOf(C4745eb.m20055d());
}
}
| 553 | 0.694394 | 0.598553 | 19 | 28.105263 | 26.576393 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.210526 | false | false | 0 |
0d730f02ae20f61f9b23f7b4a722358788f0830a | 24,962,349,924,622 | cf48449596dec78380a8bab3465ed7c0610353e6 | /src/test/java/name/sugawara/hiroshi/math/function/integer/FactorialFunctionTest.java | 00bb53b9b75ce584a9afa40f18cfdf8efbd5b8a6 | [] | no_license | Sughir/MathLibrary | https://github.com/Sughir/MathLibrary | 50171b2d7b39483980a5af7ff0b8cf0e33328d6b | 223a431d9e8412578fbaa9e4d9f2bd41be22e8fe | refs/heads/master | 2021-07-14T08:40:10.992000 | 2017-10-18T17:01:35 | 2017-10-18T17:01:35 | 107,275,140 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Created Date : 2007/02/01 15:45:19
*/
package name.sugawara.hiroshi.math.function.integer;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import java.math.BigInteger;
import org.junit.Before;
import org.junit.Test;
/**
* @author Hiroshi Sugawara
* @version $Id$ Created Date : 2007/02/01 15:45:19
*/
public class FactorialFunctionTest {
/**
* @since 2010/06/11 3:02:39
*/
private FactorialFunction f;
/**
* @since 2010/06/11 3:02:37
*/
private FactorialFunction f2;
/**
* @throws java.lang.Exception
* @since 2007/02/01 15:45:19
*/
@Before
public void setUp() throws Exception {
this.f = new FactorialFunction();
this.f2 = new FactorialFunction();
}
/**
* Test method for
* {@link name.sugawara.hiroshi.math.function.integer.FactorialFunction#factorial(java.math.BigInteger, java.math.BigInteger)}
* .
*/
@Test
public final void testFactorial() {
assertNotNull(this.f);
assertNotNull(this.f2);
assertNotSame(this.f, this.f2);
}
/**
* Test method for
* {@link name.sugawara.hiroshi.math.function.integer.FactorialFunction#getDependentVariable(java.math.BigInteger, java.math.BigInteger)}
* .
*/
@Test
public final void testGetDependentVariable() {
BigInteger result = null;
BigInteger test = BigInteger.ONE;
assertTrue(this.f.getDependentVariable(BigInteger.valueOf(0), BigInteger.valueOf(0)).compareTo(
BigInteger.ONE) == 0);
assertTrue(this.f.getDependentVariable(BigInteger.valueOf(1), BigInteger.valueOf(0)).compareTo(
BigInteger.ONE) == 0);
for (int i = 0; i < 10; i++) {
test = BigInteger.valueOf(i);
for (int j = 0; j < 10; j++) {
result = this.f.getDependentVariable(BigInteger.valueOf(i), BigInteger.valueOf(j));
System.out.printf("%2d^(%2d) = %8d ", Integer.valueOf(i), Integer.valueOf(j), result);
if (test.intValue() < j) {
assertTrue(result.compareTo(BigInteger.ZERO) == 0);
}
}
System.out.println();
}
}
}
| UTF-8 | Java | 2,218 | java | FactorialFunctionTest.java | Java | [
{
"context": "Before;\r\nimport org.junit.Test;\r\n\r\n/**\r\n * @author Hiroshi Sugawara\r\n * @version $Id$ Created Date : 2007/02/01 15:45",
"end": 361,
"score": 0.9998874664306641,
"start": 345,
"tag": "NAME",
"value": "Hiroshi Sugawara"
}
] | null | [] | /**
* Created Date : 2007/02/01 15:45:19
*/
package name.sugawara.hiroshi.math.function.integer;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import java.math.BigInteger;
import org.junit.Before;
import org.junit.Test;
/**
* @author <NAME>
* @version $Id$ Created Date : 2007/02/01 15:45:19
*/
public class FactorialFunctionTest {
/**
* @since 2010/06/11 3:02:39
*/
private FactorialFunction f;
/**
* @since 2010/06/11 3:02:37
*/
private FactorialFunction f2;
/**
* @throws java.lang.Exception
* @since 2007/02/01 15:45:19
*/
@Before
public void setUp() throws Exception {
this.f = new FactorialFunction();
this.f2 = new FactorialFunction();
}
/**
* Test method for
* {@link name.sugawara.hiroshi.math.function.integer.FactorialFunction#factorial(java.math.BigInteger, java.math.BigInteger)}
* .
*/
@Test
public final void testFactorial() {
assertNotNull(this.f);
assertNotNull(this.f2);
assertNotSame(this.f, this.f2);
}
/**
* Test method for
* {@link name.sugawara.hiroshi.math.function.integer.FactorialFunction#getDependentVariable(java.math.BigInteger, java.math.BigInteger)}
* .
*/
@Test
public final void testGetDependentVariable() {
BigInteger result = null;
BigInteger test = BigInteger.ONE;
assertTrue(this.f.getDependentVariable(BigInteger.valueOf(0), BigInteger.valueOf(0)).compareTo(
BigInteger.ONE) == 0);
assertTrue(this.f.getDependentVariable(BigInteger.valueOf(1), BigInteger.valueOf(0)).compareTo(
BigInteger.ONE) == 0);
for (int i = 0; i < 10; i++) {
test = BigInteger.valueOf(i);
for (int j = 0; j < 10; j++) {
result = this.f.getDependentVariable(BigInteger.valueOf(i), BigInteger.valueOf(j));
System.out.printf("%2d^(%2d) = %8d ", Integer.valueOf(i), Integer.valueOf(j), result);
if (test.intValue() < j) {
assertTrue(result.compareTo(BigInteger.ZERO) == 0);
}
}
System.out.println();
}
}
}
| 2,208 | 0.63505 | 0.595303 | 81 | 25.333334 | 28.968267 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 0 |
3e686c289f3e47686071b8f4d11c1a2fcb2741dd | 28,767,691,001,942 | 91d1d05c0e63ac509f2a490d2409b7dbf6450055 | /springcloud-consumer-ribbon/src/main/java/com/qiqi/springcloudconsumerribbon/service/HelloService.java | 374a3c670418a10be36bfe3f35e611b6c8e72e62 | [] | no_license | swiperqi/springcloud | https://github.com/swiperqi/springcloud | 735435fd69c6177a74533a7af75675594742a38d | 71ec13d5bea4cbdbdb5bd4a0bc2b7874be8e0ae4 | refs/heads/master | 2022-11-05T17:19:23.806000 | 2020-05-17T13:29:47 | 2020-05-17T13:29:47 | 263,044,703 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.qiqi.springcloudconsumerribbon.service;
/**
* @author qiqi
* @date 2020-05-12
*/
public interface HelloService {
String hello(String name);
String helloFeign(String name);
}
| UTF-8 | Java | 200 | java | HelloService.java | Java | [
{
"context": "springcloudconsumerribbon.service;\n\n/**\n * @author qiqi\n * @date 2020-05-12\n */\n\npublic interface HelloSe",
"end": 72,
"score": 0.9967113137245178,
"start": 68,
"tag": "USERNAME",
"value": "qiqi"
}
] | null | [] | package com.qiqi.springcloudconsumerribbon.service;
/**
* @author qiqi
* @date 2020-05-12
*/
public interface HelloService {
String hello(String name);
String helloFeign(String name);
}
| 200 | 0.71 | 0.67 | 12 | 15.666667 | 16.699966 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 0 |
52895e79af3324320d564e687debc19ff12f7ea5 | 11,227,044,523,736 | 592c7e7d7dcd7139b718c0e790ccfc45463ce204 | /src/main/java/arrayparameters/Test.java | 610421f59a238ebcb33eb39a3809e9df021b7455 | [] | no_license | SivakumarRevuri/SpringCore | https://github.com/SivakumarRevuri/SpringCore | da35570d0d4151fd30ff832f233ce851eda0fda6 | 8e2284109e283fb3c47e7bbb68873c6d907d9194 | refs/heads/master | 2021-06-27T12:29:20.683000 | 2019-06-04T13:02:49 | 2019-06-04T13:02:49 | 158,075,032 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package arrayparameters;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("resources/array.xml");
Fruits fruits = (Fruits)context.getBean("fruit");
String[] fruitNames = fruits.getFruitName();
for (String string : fruitNames) {
System.out.println(string);
}
}
}
| UTF-8 | Java | 488 | java | Test.java | Java | [] | null | [] | package arrayparameters;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("resources/array.xml");
Fruits fruits = (Fruits)context.getBean("fruit");
String[] fruitNames = fruits.getFruitName();
for (String string : fruitNames) {
System.out.println(string);
}
}
}
| 488 | 0.772541 | 0.772541 | 16 | 29.5 | 27.631504 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.375 | false | false | 0 |
f1bc112e63607d367d21ba31e948a35a0bf28c8e | 6,442,450,944,183 | b6dc874a12fd4d80366e43b998456210bcdb5462 | /core/model/src/test/java/org/eclipse/rdf4j/model/impl/SimpleLiteralTest.java | cddb3577307bfade1934086fec4bd268012bc997 | [
"MIT",
"BSD-3-Clause",
"CPL-1.0",
"JSON",
"Apache-2.0",
"EPL-1.0",
"MPL-1.1",
"Apache-1.1",
"LicenseRef-scancode-generic-export-compliance"
] | permissive | seralf/rdf4j | https://github.com/seralf/rdf4j | b0e8da6bbfbb12ffbf39e9c0847097337c642621 | 17c1b12aa083f5513fb29975dcf10db9d50f892b | refs/heads/master | 2020-12-02T19:35:40.109000 | 2020-08-11T08:51:30 | 2020-08-11T08:51:30 | 96,359,265 | 1 | 0 | BSD-3-Clause | true | 2020-08-17T13:34:23 | 2017-07-05T20:37:45 | 2020-04-15T15:00:58 | 2020-08-17T13:33:14 | 31,813 | 0 | 0 | 1 | Java | false | false | /*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*******************************************************************************/
package org.eclipse.rdf4j.model.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.XSD;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link SimpleLiteral}.
*
* @author Peter Ansell
*/
public class SimpleLiteralTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link SimpleLiteral#hashCode()} and {@link SimpleLiteral#equals(Object)}.
*/
@Test
public final void testHashCodeEquals() throws Exception {
/*
* The base contract for Object.hashCode is simply that it returns the same value for two objects for which
* equals() returns true. Note that the inverse does not hold: there is no absolute guarantee that hashCode will
* return different values for objects whose equals is _not_ true. Also note that the Literal interface
* explicitly specifies that the hashCode method returns a value based on the Literal's label only. Datatype and
* language tag are _not_ included in hashcode calculation. See issue
* https://github.com/eclipse/rdf4j/issues/668.
*/
// plain literals
SimpleLiteral lit1 = new SimpleLiteral("a");
SimpleLiteral lit2 = new SimpleLiteral("a");
assertEquals(lit1, lit2);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit1.hashCode(), lit2.hashCode());
// datatyped literals
SimpleLiteral lit3 = new SimpleLiteral("10.0", XSD.DECIMAL);
SimpleLiteral lit4 = new SimpleLiteral("10.0", XSD.DECIMAL);
assertEquals(lit3, lit4);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit3.hashCode(), lit4.hashCode());
// language-tagged literals
SimpleLiteral lit5 = new SimpleLiteral("duck", "en");
SimpleLiteral lit6 = new SimpleLiteral("duck", "en");
assertEquals(lit5, lit6);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit5.hashCode(), lit6.hashCode());
SimpleLiteral lit1en = new SimpleLiteral("a", "en");
assertFalse(lit1.equals(lit1en));
SimpleLiteral lit1dt = new SimpleLiteral("a", XSD.DECIMAL);
assertFalse(lit1.equals(lit1dt));
// language tags case sensitivity
SimpleLiteral lit7 = new SimpleLiteral("duck", "EN");
assertEquals(lit5, lit7);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit5.hashCode(), lit7.hashCode());
}
@Test
public final void testStringLiteralEqualsHashCode() {
// in RDF 1.1, there is no distinction between plain and string-typed literals.
SimpleLiteral lit1 = new SimpleLiteral("a");
SimpleLiteral lit2 = new SimpleLiteral("a", XSD.STRING);
assertEquals(lit1, lit2);
assertEquals(lit1.hashCode(), lit2.hashCode());
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringNull() throws Exception {
thrown.expect(NullPointerException.class);
new SimpleLiteral(null);
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringEmpty() throws Exception {
Literal test = new SimpleLiteral("");
assertEquals("", test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringLong() throws Exception {
StringBuilder testBuilder = new StringBuilder(1000000);
for (int i = 0; i < 1000000; i++) {
testBuilder.append(Integer.toHexString(i % 16));
}
Literal test = new SimpleLiteral(testBuilder.toString());
assertEquals(testBuilder.toString(), test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringNullNull() throws Exception {
String label = null;
String language = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringEmptyNull() throws Exception {
String label = "";
String language = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringNullEmpty() throws Exception {
String label = null;
String language = "";
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringEmptyEmpty() throws Exception {
String label = "";
String language = "";
thrown.expect(IllegalArgumentException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullNull() throws Exception {
String label = null;
IRI datatype = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullString() throws Exception {
String label = null;
IRI datatype = XSD.STRING;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullLangString() throws Exception {
String label = null;
IRI datatype = RDF.LANGSTRING;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRIEmptyNull() throws Exception {
String label = "";
IRI datatype = null;
Literal test = new SimpleLiteral(label, datatype);
assertEquals("", test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRIEmptyLangString() throws Exception {
String label = "";
IRI datatype = RDF.LANGSTRING;
thrown.expect(IllegalArgumentException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setLabel(java.lang.String)}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetLabel() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getLabel()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetLabel() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setLanguage(java.lang.String)}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetLanguage() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getLanguage()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetLanguage() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setDatatype(org.eclipse.rdf4j.model.IRI)} .
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetDatatype() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getDatatype()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetDatatype() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#toString()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testToString() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#stringValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testStringValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#booleanValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testBooleanValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#byteValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testByteValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#shortValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testShortValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#intValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testIntValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#longValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testLongValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#floatValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testFloatValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#doubleValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testDoubleValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#integerValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testIntegerValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#decimalValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testDecimalValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#calendarValue()} .
*/
@Ignore("TODO: Implement me!")
@Test
public final void testCalendarValue() throws Exception {
fail("Not yet implemented"); // TODO
}
}
| UTF-8 | Java | 12,495 | java | SimpleLiteralTest.java | Java | [
{
"context": "\n * Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.\n * All rights reserved. This program",
"end": 136,
"score": 0.9930561780929565,
"start": 131,
"tag": "NAME",
"value": "Aduna"
},
{
"context": "nit tests for {@link SimpleLiteral}.\n *\n * @author Peter Ansell\n */\npublic class SimpleLiteralTest {\n\n\t@Rule\n\tpub",
"end": 1062,
"score": 0.9997051358222961,
"start": 1050,
"tag": "NAME",
"value": "Peter Ansell"
},
{
"context": "de calculation. See issue\n\t\t * https://github.com/eclipse/rdf4j/issues/668.\n\t\t */\n\n\t\t// plain literals\n\t\tSi",
"end": 2087,
"score": 0.998977780342102,
"start": 2080,
"tag": "USERNAME",
"value": "eclipse"
}
] | null | [] | /*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*******************************************************************************/
package org.eclipse.rdf4j.model.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.XSD;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link SimpleLiteral}.
*
* @author <NAME>
*/
public class SimpleLiteralTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link SimpleLiteral#hashCode()} and {@link SimpleLiteral#equals(Object)}.
*/
@Test
public final void testHashCodeEquals() throws Exception {
/*
* The base contract for Object.hashCode is simply that it returns the same value for two objects for which
* equals() returns true. Note that the inverse does not hold: there is no absolute guarantee that hashCode will
* return different values for objects whose equals is _not_ true. Also note that the Literal interface
* explicitly specifies that the hashCode method returns a value based on the Literal's label only. Datatype and
* language tag are _not_ included in hashcode calculation. See issue
* https://github.com/eclipse/rdf4j/issues/668.
*/
// plain literals
SimpleLiteral lit1 = new SimpleLiteral("a");
SimpleLiteral lit2 = new SimpleLiteral("a");
assertEquals(lit1, lit2);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit1.hashCode(), lit2.hashCode());
// datatyped literals
SimpleLiteral lit3 = new SimpleLiteral("10.0", XSD.DECIMAL);
SimpleLiteral lit4 = new SimpleLiteral("10.0", XSD.DECIMAL);
assertEquals(lit3, lit4);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit3.hashCode(), lit4.hashCode());
// language-tagged literals
SimpleLiteral lit5 = new SimpleLiteral("duck", "en");
SimpleLiteral lit6 = new SimpleLiteral("duck", "en");
assertEquals(lit5, lit6);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit5.hashCode(), lit6.hashCode());
SimpleLiteral lit1en = new SimpleLiteral("a", "en");
assertFalse(lit1.equals(lit1en));
SimpleLiteral lit1dt = new SimpleLiteral("a", XSD.DECIMAL);
assertFalse(lit1.equals(lit1dt));
// language tags case sensitivity
SimpleLiteral lit7 = new SimpleLiteral("duck", "EN");
assertEquals(lit5, lit7);
assertEquals("hashCode() should return identical values for literals for which equals() is true",
lit5.hashCode(), lit7.hashCode());
}
@Test
public final void testStringLiteralEqualsHashCode() {
// in RDF 1.1, there is no distinction between plain and string-typed literals.
SimpleLiteral lit1 = new SimpleLiteral("a");
SimpleLiteral lit2 = new SimpleLiteral("a", XSD.STRING);
assertEquals(lit1, lit2);
assertEquals(lit1.hashCode(), lit2.hashCode());
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringNull() throws Exception {
thrown.expect(NullPointerException.class);
new SimpleLiteral(null);
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringEmpty() throws Exception {
Literal test = new SimpleLiteral("");
assertEquals("", test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringLong() throws Exception {
StringBuilder testBuilder = new StringBuilder(1000000);
for (int i = 0; i < 1000000; i++) {
testBuilder.append(Integer.toHexString(i % 16));
}
Literal test = new SimpleLiteral(testBuilder.toString());
assertEquals(testBuilder.toString(), test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringNullNull() throws Exception {
String label = null;
String language = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringEmptyNull() throws Exception {
String label = "";
String language = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringNullEmpty() throws Exception {
String label = null;
String language = "";
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, java.lang.String)} .
*/
@Test
public final void testStringStringEmptyEmpty() throws Exception {
String label = "";
String language = "";
thrown.expect(IllegalArgumentException.class);
new SimpleLiteral(label, language);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullNull() throws Exception {
String label = null;
IRI datatype = null;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullString() throws Exception {
String label = null;
IRI datatype = XSD.STRING;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRINullLangString() throws Exception {
String label = null;
IRI datatype = RDF.LANGSTRING;
thrown.expect(NullPointerException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRIEmptyNull() throws Exception {
String label = "";
IRI datatype = null;
Literal test = new SimpleLiteral(label, datatype);
assertEquals("", test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XSD.STRING, test.getDatatype());
}
/**
* Test method for
* {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String, org.eclipse.rdf4j.model.IRI)} .
*/
@Test
public final void testStringIRIEmptyLangString() throws Exception {
String label = "";
IRI datatype = RDF.LANGSTRING;
thrown.expect(IllegalArgumentException.class);
new SimpleLiteral(label, datatype);
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setLabel(java.lang.String)}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetLabel() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getLabel()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetLabel() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setLanguage(java.lang.String)}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetLanguage() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getLanguage()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetLanguage() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#setDatatype(org.eclipse.rdf4j.model.IRI)} .
*/
@Ignore("TODO: Implement me!")
@Test
public final void testSetDatatype() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#getDatatype()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testGetDatatype() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#toString()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testToString() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#stringValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testStringValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#booleanValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testBooleanValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#byteValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testByteValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#shortValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testShortValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#intValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testIntValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#longValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testLongValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#floatValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testFloatValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#doubleValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testDoubleValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#integerValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testIntegerValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#decimalValue()}.
*/
@Ignore("TODO: Implement me!")
@Test
public final void testDecimalValue() throws Exception {
fail("Not yet implemented"); // TODO
}
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#calendarValue()} .
*/
@Ignore("TODO: Implement me!")
@Test
public final void testCalendarValue() throws Exception {
fail("Not yet implemented"); // TODO
}
}
| 12,489 | 0.704922 | 0.695798 | 427 | 28.262295 | 30.505676 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.444965 | false | false | 0 |
a4b23ec20744201e6e209c098d3b83fa53f211cd | 5,360,119,254,372 | 03a57dd6bbe6373b0c883182c5a73b1e0b6a7c1d | /app/src/main/java/posidenpalace/com/test6/RecycleAdapter.java | 5954cbc24bb6035b303d6807508675dc1530b01e | [] | no_license | Willus08/Test6 | https://github.com/Willus08/Test6 | a8ee87f59f0e96873eb08423035760fb9a065c25 | d648a254f6f6239ed7a201533423982eb9be205d | refs/heads/master | 2021-01-01T19:48:12.730000 | 2017-07-30T16:11:03 | 2017-07-30T16:11:03 | 98,689,452 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package posidenpalace.com.test6;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.ViewHolder> {
List<MoviesList> moviesList = new ArrayList<>();
public RecycleAdapter(List<MoviesList> temp) {
this.moviesList = temp;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final MoviesList temp = moviesList.get(position);
holder.title.setText("Title: "+temp.getTitle());
holder.language.setText("Language: "+temp.getLanguage());
Glide.with(holder.itemView.getContext()).load(temp.getPosterPath()).into(holder.picture);
holder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "Passing: "+ temp.getTitle(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(v.getContext(), Details.class);
Bundle bundle = new Bundle();
bundle.putParcelable("movie" , temp);
intent.putExtras(bundle);
v.getContext().startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return moviesList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView language;
ImageView picture;
FrameLayout container;
public ViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.tvTitle);
language = (TextView) itemView.findViewById(R.id.tvLanguage);
picture = (ImageView) itemView.findViewById(R.id.ivPicture);
container = (FrameLayout) itemView.findViewById(R.id.flContainer);
}
}
}
| UTF-8 | Java | 2,468 | java | RecycleAdapter.java | Java | [] | null | [] | package posidenpalace.com.test6;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.ViewHolder> {
List<MoviesList> moviesList = new ArrayList<>();
public RecycleAdapter(List<MoviesList> temp) {
this.moviesList = temp;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final MoviesList temp = moviesList.get(position);
holder.title.setText("Title: "+temp.getTitle());
holder.language.setText("Language: "+temp.getLanguage());
Glide.with(holder.itemView.getContext()).load(temp.getPosterPath()).into(holder.picture);
holder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "Passing: "+ temp.getTitle(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(v.getContext(), Details.class);
Bundle bundle = new Bundle();
bundle.putParcelable("movie" , temp);
intent.putExtras(bundle);
v.getContext().startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return moviesList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView language;
ImageView picture;
FrameLayout container;
public ViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.tvTitle);
language = (TextView) itemView.findViewById(R.id.tvLanguage);
picture = (ImageView) itemView.findViewById(R.id.ivPicture);
container = (FrameLayout) itemView.findViewById(R.id.flContainer);
}
}
}
| 2,468 | 0.666532 | 0.665721 | 75 | 31.906666 | 27.908028 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.626667 | false | false | 0 |
672784c86379799ecfc3a79b84c438386ac9d2e3 | 26,637,387,172,410 | 90d7b98e0149c9db52ba7af998e3f56847440d53 | /src/main/java/com/oversea/common/enums/UserType.java | 65f4482e7b8c4d71da0ec1dd533d395d6fc8244b | [] | no_license | tzwdbd/common | https://github.com/tzwdbd/common | ce80bcb7fabd42e484fe421ef2ef5dadc0e32f03 | 32adb67f068d3a7263399c9aacd7c1c3aec9b1b3 | refs/heads/master | 2020-02-19T16:53:25.218000 | 2018-03-23T04:54:27 | 2018-03-23T04:54:27 | 126,921,662 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.oversea.common.enums;
import com.oversea.common.util.StringUtil;
public enum UserType {
MOBILE("mobile", "手机"),
TAOBAO("tb", "淘宝"),
WECHAT("wechat", "微信"),
APPWECHAT("appwechat", "app微信"),
DUMMY("dummy", "刷单小号"),
JIAZB("jiazb", "家政帮"),
ZHONGDA("zhongda", "中大对接平台","partnerType"),
SOUGOU("sougou", "搜狗","partnerType"),
FANLI("fanli", "返利网","partnerType")
;
private String value;
private String name;
private String type;
UserType(String value,String name){
this.value = value;
this.name = name;
}
UserType(String value,String name,String type){
this.value = value;
this.name = name;
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static UserType getUserTypeByValue(String value){
if(StringUtil.isBlank(value)){
return null;
}
for(UserType ut: UserType.values()) {
if(value.equals(ut.getValue())) {
return ut;
}
}
return null;
}
}
| UTF-8 | Java | 1,379 | java | UserType.java | Java | [] | null | [] | package com.oversea.common.enums;
import com.oversea.common.util.StringUtil;
public enum UserType {
MOBILE("mobile", "手机"),
TAOBAO("tb", "淘宝"),
WECHAT("wechat", "微信"),
APPWECHAT("appwechat", "app微信"),
DUMMY("dummy", "刷单小号"),
JIAZB("jiazb", "家政帮"),
ZHONGDA("zhongda", "中大对接平台","partnerType"),
SOUGOU("sougou", "搜狗","partnerType"),
FANLI("fanli", "返利网","partnerType")
;
private String value;
private String name;
private String type;
UserType(String value,String name){
this.value = value;
this.name = name;
}
UserType(String value,String name,String type){
this.value = value;
this.name = name;
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static UserType getUserTypeByValue(String value){
if(StringUtil.isBlank(value)){
return null;
}
for(UserType ut: UserType.values()) {
if(value.equals(ut.getValue())) {
return ut;
}
}
return null;
}
}
| 1,379 | 0.599096 | 0.599096 | 68 | 18.514706 | 15.109884 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.235294 | false | false | 0 |
ed82cba6784d60fbd53562df04463897878b6704 | 4,423,816,380,488 | 35a067635ab631c482a4bd6d30f45460a4f1c8e4 | /src/main/java/cs444/group9/AST/Node/Statement/StatementNode.java | cbb0545e17e5f0db2053e68fc2d8c0d3071dddb3 | [] | no_license | acgatea/Java-compiler | https://github.com/acgatea/Java-compiler | ddee20a857eeb09f4612af64c937d80552f6a319 | 9dd8cf79c614d964084ba36ba7a0a494cb9ec411 | refs/heads/main | 2023-08-29T10:57:38.318000 | 2021-10-16T23:35:27 | 2021-10-16T23:35:27 | 417,942,736 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*******************************************************************************
* StatementNode.java
*
* A module implementing the Statement node for the AST.
* ****************************************************************************/
package cs444.group9.AST.Node.Statement;
import cs444.group9.AST.Node.ASTNode;
import cs444.group9.AST.Visitor.iVisitor;
import cs444.group9.Parser.Node;
public class StatementNode extends ASTNode {
NoTrailingStmtNode _notrailingstmt;
IfStmtNode _ifstmt;
WhileStmtNode _whilestmt;
ForStmtNode _forstmt;
/*******************************************************************************
* StatementNode constructor
* time : O(1)
* *****************************************************************************/
public StatementNode(Node parseTreeNode) {
super(parseTreeNode);
} // StatementNode()
/*******************************************************************************
* Printer for ASTNode
* time : O(|AST|)
* *****************************************************************************/
@Override
public void print() {
if(_notrailingstmt != null) _notrailingstmt.print();
else if(_ifstmt != null) _ifstmt.print();
else if(_whilestmt != null) _whilestmt.print();
else if(_forstmt != null) _forstmt.print();
else throw new Error();
} // print()
/*******************************************************************************
* Visitor acceptor
* time : O(1)
* *****************************************************************************/
@Override
public void accept(iVisitor visitor) throws iVisitor.ASTException {
visitor.visit(this);
} // accept()
/*******************************************************************************
* Accessor methods
* *****************************************************************************/
public NoTrailingStmtNode NoTrailingStmt(){
return _notrailingstmt;
}
public IfStmtNode IfStmt(){
return _ifstmt;
}
public WhileStmtNode WhileStmt(){
return _whilestmt;
}
public ForStmtNode ForStmt(){
return _forstmt;
}
public void NoTrailingStmt(NoTrailingStmtNode notrailingstmt){ _notrailingstmt = notrailingstmt; }
public void IfStmt(IfStmtNode ifstmt){ _ifstmt = ifstmt; }
public void WhileStmt(WhileStmtNode whilestmt){ _whilestmt = whilestmt; }
public void ForStmt(ForStmtNode forstmt){ _forstmt = forstmt; }
} // class StatementNode
| UTF-8 | Java | 2,665 | java | StatementNode.java | Java | [] | null | [] | /*******************************************************************************
* StatementNode.java
*
* A module implementing the Statement node for the AST.
* ****************************************************************************/
package cs444.group9.AST.Node.Statement;
import cs444.group9.AST.Node.ASTNode;
import cs444.group9.AST.Visitor.iVisitor;
import cs444.group9.Parser.Node;
public class StatementNode extends ASTNode {
NoTrailingStmtNode _notrailingstmt;
IfStmtNode _ifstmt;
WhileStmtNode _whilestmt;
ForStmtNode _forstmt;
/*******************************************************************************
* StatementNode constructor
* time : O(1)
* *****************************************************************************/
public StatementNode(Node parseTreeNode) {
super(parseTreeNode);
} // StatementNode()
/*******************************************************************************
* Printer for ASTNode
* time : O(|AST|)
* *****************************************************************************/
@Override
public void print() {
if(_notrailingstmt != null) _notrailingstmt.print();
else if(_ifstmt != null) _ifstmt.print();
else if(_whilestmt != null) _whilestmt.print();
else if(_forstmt != null) _forstmt.print();
else throw new Error();
} // print()
/*******************************************************************************
* Visitor acceptor
* time : O(1)
* *****************************************************************************/
@Override
public void accept(iVisitor visitor) throws iVisitor.ASTException {
visitor.visit(this);
} // accept()
/*******************************************************************************
* Accessor methods
* *****************************************************************************/
public NoTrailingStmtNode NoTrailingStmt(){
return _notrailingstmt;
}
public IfStmtNode IfStmt(){
return _ifstmt;
}
public WhileStmtNode WhileStmt(){
return _whilestmt;
}
public ForStmtNode ForStmt(){
return _forstmt;
}
public void NoTrailingStmt(NoTrailingStmtNode notrailingstmt){ _notrailingstmt = notrailingstmt; }
public void IfStmt(IfStmtNode ifstmt){ _ifstmt = ifstmt; }
public void WhileStmt(WhileStmtNode whilestmt){ _whilestmt = whilestmt; }
public void ForStmt(ForStmtNode forstmt){ _forstmt = forstmt; }
} // class StatementNode
| 2,665 | 0.434522 | 0.427767 | 70 | 36.042858 | 28.08428 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false | 0 |
8159445b196967ff18dfd1bd71a376a041fc8853 | 4,423,816,378,570 | 5560d106128da015ce7c365cf07e1ffc9cf311ca | /src/java8/features/example1/Community.java | d21b0e2b23957e4bb6c1569c32e46b313d139c89 | [] | no_license | hanysourcecode/Java8-Features | https://github.com/hanysourcecode/Java8-Features | fed60ade5dead732c99789106bb1befc835cf27e | 7317bda58e79b8fa2154b30fe647a80ef2dfb66e | refs/heads/master | 2023-03-15T15:26:59.894000 | 2015-07-06T08:51:46 | 2015-07-06T08:51:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java8.features.example1;
import java.util.Collections;
import java.util.List;
/**
*
* @author Hany.Ahmed
*/
public class Community implements CommunityInt {
/**
* Print All Male/Female members
* @param members List of members
* @param gender Gender: Male/Female
*/
@Override
public void printMembersByGender(List<Member> members, Member.Gender gender) {
for(Member member : members) {
if(member.getGender() == gender) {
System.out.println(member);
}
}
}
/**
* Print all adult members (above 20 years)
* @param members List of members
*/
@Override
public void printAdultMembers(List<Member> members) {
for(Member member : members) {
if(member.getAge() > 20) {
System.out.println(member);
}
}
}
/**
* Print Max age
* @param members List of members
*/
@Override
public void printMaxAge(List<Member> members) {
int max = 0;
for(Member member : members) {
if(member.getAge() > max) {
max = member.getAge();
}
}
System.out.println("Max age " + max);
}
/**
* Print all members sorted by Name
* @param members List of members
*/
@Override
public void printMembersSortedByName(List<Member> members) {
Collections.sort(members);
for(Member member : members) {
System.out.println(member);
}
}
}
| UTF-8 | Java | 1,769 | java | Community.java | Java | [
{
"context": "ections;\nimport java.util.List;\n\n/**\n *\n * @author Hany.Ahmed\n */\npublic class Community implements CommunityIn",
"end": 302,
"score": 0.9998656511306763,
"start": 292,
"tag": "NAME",
"value": "Hany.Ahmed"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java8.features.example1;
import java.util.Collections;
import java.util.List;
/**
*
* @author Hany.Ahmed
*/
public class Community implements CommunityInt {
/**
* Print All Male/Female members
* @param members List of members
* @param gender Gender: Male/Female
*/
@Override
public void printMembersByGender(List<Member> members, Member.Gender gender) {
for(Member member : members) {
if(member.getGender() == gender) {
System.out.println(member);
}
}
}
/**
* Print all adult members (above 20 years)
* @param members List of members
*/
@Override
public void printAdultMembers(List<Member> members) {
for(Member member : members) {
if(member.getAge() > 20) {
System.out.println(member);
}
}
}
/**
* Print Max age
* @param members List of members
*/
@Override
public void printMaxAge(List<Member> members) {
int max = 0;
for(Member member : members) {
if(member.getAge() > max) {
max = member.getAge();
}
}
System.out.println("Max age " + max);
}
/**
* Print all members sorted by Name
* @param members List of members
*/
@Override
public void printMembersSortedByName(List<Member> members) {
Collections.sort(members);
for(Member member : members) {
System.out.println(member);
}
}
}
| 1,769 | 0.56303 | 0.559073 | 74 | 22.905405 | 20.085068 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.189189 | false | false | 0 |
b5c5cf25b11a77d4f6387dd87641d3b100b38ee8 | 4,887,672,847,481 | fc16c214e43c52ee71e39da2557c84dbfc3bab0d | /app/src/main/java/com/tanveer/qhunter/fragment/QRGenerateFragment.java | d9c04eff6e59b4879e31c19dcb346f804757ba60 | [] | no_license | DrawTechBD/qHunter | https://github.com/DrawTechBD/qHunter | 8e185bfc5110687a1c8b8c5be14eef3d22ccbc28 | 0e851467300e834af297d123c1fe74cce2e3fe2a | refs/heads/master | 2020-07-21T11:48:20.840000 | 2019-10-26T01:41:44 | 2019-10-26T01:41:44 | 206,855,042 | 0 | 1 | null | false | 2019-09-28T10:04:45 | 2019-09-06T18:46:32 | 2019-09-22T10:51:38 | 2019-09-28T10:04:45 | 225 | 0 | 1 | 2 | Java | false | false | package com.tanveer.qhunter.fragment;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.TypeFilter;
import com.google.android.libraries.places.widget.Autocomplete;
import com.google.android.libraries.places.widget.AutocompleteActivity;
import com.google.android.libraries.places.widget.AutocompleteSupportFragment;
import com.google.android.libraries.places.widget.listener.PlaceSelectionListener;
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.ValueEventListener;
import com.tanveer.qhunter.R;
import com.tanveer.qhunter.model.User;
import com.tanveer.qhunter.utills.CustomLoader;
import com.tanveer.qhunter.utills.WriteFile;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import de.hdodenhof.circleimageview.CircleImageView;
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import static com.tanveer.qhunter.utills.Constant.ADDRESS_KEY;
import static com.tanveer.qhunter.utills.Constant.AUTH;
import static com.tanveer.qhunter.utills.Constant.EMAIL_KEY;
import static com.tanveer.qhunter.utills.Constant.EmailValidate;
import static com.tanveer.qhunter.utills.Constant.MESSENGER_KEY;
import static com.tanveer.qhunter.utills.Constant.NAME_KEY;
import static com.tanveer.qhunter.utills.Constant.PHONE_KEY;
import static com.tanveer.qhunter.utills.Constant.USER_REFERENCE;
import static com.tanveer.qhunter.utills.Constant.setToast;
import static com.tanveer.qhunter.utills.Constant.sharePicture;
import static com.tanveer.qhunter.utills.ImageManipulation.TextToImageEncode;
public class QRGenerateFragment extends Fragment {
private boolean check;
private EditText nameView,phoneView,messengerView,emailView;
private TextView addressView, titleView;
private RelativeLayout pickerBtn;
private TextView geolocationView;
private CircleImageView imageView;
private Button informbtn;
private String location;
private Button generateBtn;
private Bitmap bitmap;
private ImageView iv;
private Handler handler;
private int PLACE_PICKER_REQUEST=1;
private String lat,lng;
private FusedLocationProviderClient client;
private static final int AUTOCOMPLETE_REQUEST_CODE=1;
private User user;
private String title, name, phone, email, messenger, address;
private RelativeLayout nameLayout, phoneLayout, emailLayout, messengerLayout, addressLayout;
public QRGenerateFragment(){
Log.i("QRGEN", "Null class called");
name = "";
phone = "";
email = "";
messenger = "";
address = "";
title = "QR Generate";
}
public QRGenerateFragment(JSONObject jsonObject){
Log.i("QRGEN", "json object class called");
try{
name = jsonObject.getString(NAME_KEY);
phone = jsonObject.getString(PHONE_KEY);
email = jsonObject.getString(EMAIL_KEY);
messenger = jsonObject.getString(MESSENGER_KEY);
address = jsonObject.getString(ADDRESS_KEY);
}catch (JSONException e){
e.printStackTrace();
}
}
public QRGenerateFragment(String action){
Log.i("QRGEN", "boolean class called");
check = true;
name = phone = email = messenger = address = "";
title = action;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@SuppressLint("MissingPermission")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mView=inflater.inflate(R.layout.fragment_qr_generate,container,false);
Places.initialize(getActivity(),getResources().getString(R.string.api_key));
initialize(mView);
generateBtn.setOnClickListener(v -> {
generate();
});
return mView;
}
public void saveUserData(User user){
String UID= AUTH.getUid();
USER_REFERENCE.child(UID).setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(getActivity(), "User Information saved!", Toast.LENGTH_SHORT).show();
}
}
});
}
public void fragmentLoad(Fragment fragment, String tag){
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.profile_container, fragment, tag)
.addToBackStack(null)
.commit();
}
public void generate(){
name = nameView.getText().toString();
phone = phoneView.getText().toString();
email = emailView.getText().toString();
address = addressView.getText().toString();
messenger = messengerView.getText().toString();
if(name.isEmpty()){
nameView.setError("Name is required");
nameView.requestFocus();
return;
}
if(phone.isEmpty() && email.isEmpty()){
emailView.setError("Either phone or email is required");
emailView.requestFocus();
return;
}
if(!email.isEmpty() && !EmailValidate(email)){
emailView.setError("Invalid email address");
emailView.requestFocus();
return;
}
ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("QR is Generating...");
progressDialog.setCancelable(false);
// progressDialog.show();
CustomLoader.showDialog(getActivity());
// start the time consuming task in a new thread
Thread thread = new Thread() {
public void run () {
// this is the time consuming task (like, network call, database call)
try{
final String scanResult = "{'name':'"+name+"', 'phone': '"+phone+"', 'email': '"+email+"', 'address': '"+address+"', 'messenger': '"+messenger+"'}";
bitmap = TextToImageEncode(getActivity(), scanResult);
} catch (Exception e){
e.printStackTrace();
}
// Now we are on a different thread than UI thread
// and we would like to update our UI, as this task is completed
handler.post(new Runnable() {
@Override
public void run() {
// Update your UI or do any Post job after the time consuming task
CustomLoader.dismissDialog();
iv.setImageBitmap(bitmap);
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogView = inflater.inflate(R.layout.qr_view, null);
ImageView qrView=dialogView.findViewById(R.id.dialog_imageview);
Button saveBtn=dialogView.findViewById(R.id.save_btn);
Button shareBtn=dialogView.findViewById(R.id.share_btn);
user = new User(name, phone, email, messenger, address);
if(check){
saveUserData(user);
}
qrView.setImageBitmap(bitmap);
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WriteFile.saveQR(getActivity(),bitmap,name);
}
});
shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sharePicture(getActivity(), bitmap);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if(check){
fragmentLoad(new UserFragment(true), "user");
}
}
});
builder.create().show();
// remember to dismiss the progress dialog on UI thread
progressDialog.dismiss();
}
});
}
};
thread.start();
}
public void initialize(View mView){
handler = new Handler();
titleView = mView.findViewById(R.id.title);
titleView.setText(title);
nameView=mView.findViewById(R.id.name_view);
phoneView=mView.findViewById(R.id.phone_view);
emailView= mView.findViewById(R.id.email_view);
addressView=mView.findViewById(R.id.address_view);
messengerView=mView.findViewById(R.id.messenger_view);
iv = mView.findViewById(R.id.profie_image_view);
nameView.setFocusable(true);
nameLayout = mView.findViewById(R.id.name_layout);
phoneLayout = mView.findViewById(R.id.phone_layout);
emailLayout = mView.findViewById(R.id.email_layout);
messengerLayout = mView.findViewById(R.id.messenger_layout);
addressLayout = mView.findViewById(R.id.address_layout);
generateBtn = mView.findViewById(R.id.generateBtn);
if(title.equals("Update")){
readUser();
}
// pickerBtn=mView.findViewById(R.id.address_layout);
if(!name.isEmpty()){
nameView.setText(name);
}
if(!phone.isEmpty()){
phoneView.setText(phone);
}
if(!email.isEmpty()){
emailView.setText(email);
}
if(!messenger.isEmpty()){
messengerView.setText(messenger);
}
if(!address.isEmpty()){
addressView.setText(address);
}
addressLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sentIntent();
}
});
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
public void readUser(){
String UID=AUTH.getUid();
USER_REFERENCE.child(UID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
Toast.makeText(getActivity(), "Fetching Data!", Toast.LENGTH_SHORT).show();
User user = dataSnapshot.getValue(User.class);
name = user.getName();
phone = user.getPhone();
email = user.getEmail();
address = user.getAddress();
messenger = user.getMessenger();
if (!name.equals("")) {
nameView.setText(name);
}
if (!phone.equals("")) {
phoneView.setText(phone);
}
if (!email.equals("")) {
emailView.setText(email);
}
if (!messenger.equals("")){
messengerView.setText(messenger);
}
if (!address.equals("")) {
addressView.setText(address);
}
titleView.setText(title);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void sentIntent(){
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
Intent intent = new Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields)
.setCountry("BD")
.setTypeFilter(TypeFilter.ADDRESS)
.build(getActivity());
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = Autocomplete.getPlaceFromIntent(data);
addressView.setText(place.getName());
location=place.getName();
Log.i("Place", "Place: " + place.getName() + ", " + place.getId());
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
Status status = Autocomplete.getStatusFromIntent(data);
Log.i("ERROR", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
}
}
| UTF-8 | Java | 14,782 | java | QRGenerateFragment.java | Java | [] | null | [] | package com.tanveer.qhunter.fragment;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.TypeFilter;
import com.google.android.libraries.places.widget.Autocomplete;
import com.google.android.libraries.places.widget.AutocompleteActivity;
import com.google.android.libraries.places.widget.AutocompleteSupportFragment;
import com.google.android.libraries.places.widget.listener.PlaceSelectionListener;
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.ValueEventListener;
import com.tanveer.qhunter.R;
import com.tanveer.qhunter.model.User;
import com.tanveer.qhunter.utills.CustomLoader;
import com.tanveer.qhunter.utills.WriteFile;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import de.hdodenhof.circleimageview.CircleImageView;
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import static com.tanveer.qhunter.utills.Constant.ADDRESS_KEY;
import static com.tanveer.qhunter.utills.Constant.AUTH;
import static com.tanveer.qhunter.utills.Constant.EMAIL_KEY;
import static com.tanveer.qhunter.utills.Constant.EmailValidate;
import static com.tanveer.qhunter.utills.Constant.MESSENGER_KEY;
import static com.tanveer.qhunter.utills.Constant.NAME_KEY;
import static com.tanveer.qhunter.utills.Constant.PHONE_KEY;
import static com.tanveer.qhunter.utills.Constant.USER_REFERENCE;
import static com.tanveer.qhunter.utills.Constant.setToast;
import static com.tanveer.qhunter.utills.Constant.sharePicture;
import static com.tanveer.qhunter.utills.ImageManipulation.TextToImageEncode;
public class QRGenerateFragment extends Fragment {
private boolean check;
private EditText nameView,phoneView,messengerView,emailView;
private TextView addressView, titleView;
private RelativeLayout pickerBtn;
private TextView geolocationView;
private CircleImageView imageView;
private Button informbtn;
private String location;
private Button generateBtn;
private Bitmap bitmap;
private ImageView iv;
private Handler handler;
private int PLACE_PICKER_REQUEST=1;
private String lat,lng;
private FusedLocationProviderClient client;
private static final int AUTOCOMPLETE_REQUEST_CODE=1;
private User user;
private String title, name, phone, email, messenger, address;
private RelativeLayout nameLayout, phoneLayout, emailLayout, messengerLayout, addressLayout;
public QRGenerateFragment(){
Log.i("QRGEN", "Null class called");
name = "";
phone = "";
email = "";
messenger = "";
address = "";
title = "QR Generate";
}
public QRGenerateFragment(JSONObject jsonObject){
Log.i("QRGEN", "json object class called");
try{
name = jsonObject.getString(NAME_KEY);
phone = jsonObject.getString(PHONE_KEY);
email = jsonObject.getString(EMAIL_KEY);
messenger = jsonObject.getString(MESSENGER_KEY);
address = jsonObject.getString(ADDRESS_KEY);
}catch (JSONException e){
e.printStackTrace();
}
}
public QRGenerateFragment(String action){
Log.i("QRGEN", "boolean class called");
check = true;
name = phone = email = messenger = address = "";
title = action;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@SuppressLint("MissingPermission")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mView=inflater.inflate(R.layout.fragment_qr_generate,container,false);
Places.initialize(getActivity(),getResources().getString(R.string.api_key));
initialize(mView);
generateBtn.setOnClickListener(v -> {
generate();
});
return mView;
}
public void saveUserData(User user){
String UID= AUTH.getUid();
USER_REFERENCE.child(UID).setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(getActivity(), "User Information saved!", Toast.LENGTH_SHORT).show();
}
}
});
}
public void fragmentLoad(Fragment fragment, String tag){
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.profile_container, fragment, tag)
.addToBackStack(null)
.commit();
}
public void generate(){
name = nameView.getText().toString();
phone = phoneView.getText().toString();
email = emailView.getText().toString();
address = addressView.getText().toString();
messenger = messengerView.getText().toString();
if(name.isEmpty()){
nameView.setError("Name is required");
nameView.requestFocus();
return;
}
if(phone.isEmpty() && email.isEmpty()){
emailView.setError("Either phone or email is required");
emailView.requestFocus();
return;
}
if(!email.isEmpty() && !EmailValidate(email)){
emailView.setError("Invalid email address");
emailView.requestFocus();
return;
}
ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("QR is Generating...");
progressDialog.setCancelable(false);
// progressDialog.show();
CustomLoader.showDialog(getActivity());
// start the time consuming task in a new thread
Thread thread = new Thread() {
public void run () {
// this is the time consuming task (like, network call, database call)
try{
final String scanResult = "{'name':'"+name+"', 'phone': '"+phone+"', 'email': '"+email+"', 'address': '"+address+"', 'messenger': '"+messenger+"'}";
bitmap = TextToImageEncode(getActivity(), scanResult);
} catch (Exception e){
e.printStackTrace();
}
// Now we are on a different thread than UI thread
// and we would like to update our UI, as this task is completed
handler.post(new Runnable() {
@Override
public void run() {
// Update your UI or do any Post job after the time consuming task
CustomLoader.dismissDialog();
iv.setImageBitmap(bitmap);
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogView = inflater.inflate(R.layout.qr_view, null);
ImageView qrView=dialogView.findViewById(R.id.dialog_imageview);
Button saveBtn=dialogView.findViewById(R.id.save_btn);
Button shareBtn=dialogView.findViewById(R.id.share_btn);
user = new User(name, phone, email, messenger, address);
if(check){
saveUserData(user);
}
qrView.setImageBitmap(bitmap);
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WriteFile.saveQR(getActivity(),bitmap,name);
}
});
shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sharePicture(getActivity(), bitmap);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if(check){
fragmentLoad(new UserFragment(true), "user");
}
}
});
builder.create().show();
// remember to dismiss the progress dialog on UI thread
progressDialog.dismiss();
}
});
}
};
thread.start();
}
public void initialize(View mView){
handler = new Handler();
titleView = mView.findViewById(R.id.title);
titleView.setText(title);
nameView=mView.findViewById(R.id.name_view);
phoneView=mView.findViewById(R.id.phone_view);
emailView= mView.findViewById(R.id.email_view);
addressView=mView.findViewById(R.id.address_view);
messengerView=mView.findViewById(R.id.messenger_view);
iv = mView.findViewById(R.id.profie_image_view);
nameView.setFocusable(true);
nameLayout = mView.findViewById(R.id.name_layout);
phoneLayout = mView.findViewById(R.id.phone_layout);
emailLayout = mView.findViewById(R.id.email_layout);
messengerLayout = mView.findViewById(R.id.messenger_layout);
addressLayout = mView.findViewById(R.id.address_layout);
generateBtn = mView.findViewById(R.id.generateBtn);
if(title.equals("Update")){
readUser();
}
// pickerBtn=mView.findViewById(R.id.address_layout);
if(!name.isEmpty()){
nameView.setText(name);
}
if(!phone.isEmpty()){
phoneView.setText(phone);
}
if(!email.isEmpty()){
emailView.setText(email);
}
if(!messenger.isEmpty()){
messengerView.setText(messenger);
}
if(!address.isEmpty()){
addressView.setText(address);
}
addressLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sentIntent();
}
});
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
public void readUser(){
String UID=AUTH.getUid();
USER_REFERENCE.child(UID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
Toast.makeText(getActivity(), "Fetching Data!", Toast.LENGTH_SHORT).show();
User user = dataSnapshot.getValue(User.class);
name = user.getName();
phone = user.getPhone();
email = user.getEmail();
address = user.getAddress();
messenger = user.getMessenger();
if (!name.equals("")) {
nameView.setText(name);
}
if (!phone.equals("")) {
phoneView.setText(phone);
}
if (!email.equals("")) {
emailView.setText(email);
}
if (!messenger.equals("")){
messengerView.setText(messenger);
}
if (!address.equals("")) {
addressView.setText(address);
}
titleView.setText(title);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void sentIntent(){
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
Intent intent = new Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields)
.setCountry("BD")
.setTypeFilter(TypeFilter.ADDRESS)
.build(getActivity());
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = Autocomplete.getPlaceFromIntent(data);
addressView.setText(place.getName());
location=place.getName();
Log.i("Place", "Place: " + place.getName() + ", " + place.getId());
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
Status status = Autocomplete.getStatusFromIntent(data);
Log.i("ERROR", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
}
}
| 14,782 | 0.599513 | 0.599378 | 392 | 36.709183 | 26.186577 | 168 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.663265 | false | false | 0 |
60eb1ac074c10c8e326a8803a7c518f82525841d | 19,688,130,115,794 | bdf94d3aa8f037934b1e13ac7fdc60338139654f | /Assembler.java | 9fb75821a15653cc8a27c4c2434b53c40d3c82e3 | [] | no_license | ANIKET7419/MINI-ASSEMBLER | https://github.com/ANIKET7419/MINI-ASSEMBLER | 97e2cd1be2fae4a77cb5b4ca89e20de0e6cab0c3 | 3dacb15b3d696286397d3bad94630c30703c071b | refs/heads/main | 2023-01-12T11:39:57.672000 | 2020-11-14T06:48:38 | 2020-11-14T06:48:38 | 312,045,016 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Assembler;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.ArrayList;
/**
*
* PROJECT NAME --- DUMMY ASSEMBLER
* <br>
* DEVELOPER --- ANIKET
* <br>
* COURSE -- BSC ( HONS ) COMPUTER SCIENCE LAST YEAR
* <br>
* COLLEGE --- DYAL SINGH COLLEGE ( DELHI UNIVERSITY )
* <br>
* COLLEGE ROLL-NUMBER -- 18/94026
*<br>
* <br>
* FOR THIS ASSEMBLER :
* <br>
* LANGUAGE RULES -:
* <br>
* 1. IT IS WHITESPACE SENSITIVE
* <br>
* 2. IT IS ALSO CASE SENSITIVE
* <br>
* 3. FOR INSTRUCTIONS SET PREFER MOT.txt
* <br>
* 4. IT SUPPORTS ERROR HANDLING LIKE LITERAL SIZE , SYMBOL NOT DEFINED , DESTINATION ILLEGAL , ILLEGAL INSTRUCTION , ALL TYPE SYNTAX ERROR
*<br>
*
*
*<br>
* INSTRUCTION -:
* <br>
* JDK MUST GREATER OR EQAUL TO 14.0.1
* <br>
* MUST DOWNLOAD REQUIRED CLASS FOR @NotNull ANNOTATION
*<br>
* <br>
* <br>
* EMAIL -:
* <br>
* aniketranag123@gmail.com
* <br>
* aniketranag1234@gmail.com
*<br>
* <br>
*
*/
public class Assembler {
static ArrayList<ArrayList<String>> section_table = new ArrayList<>();
static ArrayList<ArrayList<String>> symbol_table = new ArrayList<>();
static String file = "";
static int location_counter = 0;
static String lines[];
static FileOutputStream outputStream;
static final String output_file_name="/root/IdeaProjects/src/output.out";
public static void main(String[] args) throws Exception {
FileReader reader = new FileReader("/root/IdeaProjects/src/sourcecode.asm");
for (; ; ) {
int c = reader.read();
if (c != -1)
file += (char) c;
else
break;
}
lines = file.split("\n");
firstPass();
if (section_table.size() >= 1)
section_table.get(section_table.size() - 1).add(1, location_counter + "");// TO ADD THE SIZE ENTRY OF LAST SECTION USED IN ASSEMBLY PROGRAM
System.out.println("First Pass Successfully Done ");
System.out.println("-------------SECTION TABLE ------------");
System.out.println("Name\t Size");
for (ArrayList<String> list : section_table)
System.out.println(list.get(0) + "\t\t\t" + list.get(1));
System.out.println("-------------SYMBOL TABLE ------------");
System.out.println("Name\tSize\tType\tOffset");
for (ArrayList<String> list : symbol_table)
System.out.println(list.get(0) + "\t\t" + list.get(1) + "\t\t" + list.get(2) + "\t\t" + list.get(3));
outputStream=new FileOutputStream(output_file_name);
ArrayList<String> A =new ArrayList<>();
A.add(0,"A");
A.add(1,"DD");
A.add(2,"REGISTER");
A.add(3,"11");
ArrayList<String> B =new ArrayList<>();
B.add(0,"B");
B.add(1,"DD");
B.add(2,"REGISTER");
B.add(3,"12");
ArrayList<String> C =new ArrayList<>();
C.add(0,"C");
C.add(1,"DD");
C.add(2,"REGISTER");
C.add(3,"13");
ArrayList<String> D =new ArrayList<>();
D.add(0,"D");
D.add(1,"DD");
D.add(2,"REGISTER");
D.add(3,"14");
symbol_table.add(A);
symbol_table.add(B);
symbol_table.add(C);
symbol_table.add(D);
secondPass();
System.out.println("Second Pass Successfully Done .. Output File "+output_file_name+" is generated ");
}
static int value(@NotNull String temp) {
if (temp.equals("DD"))
return 4;
else if (temp.equals("DW"))
return 2;
else
return 1;
}
static void addLabel(OutputStream outputStream,String label_name,int current_locationcounter,int line_number) throws Exception
{
String location_cou;
for(int i=0;i<symbol_table.size();i++)
{
if (symbol_table.get(i).get(0).equals(label_name))
{
if (symbol_table.get(i).get(2).equals("Label"))
{
location_cou=symbol_table.get(i).get(3);
int offset=Integer.parseInt(location_cou);
int result=offset-current_locationcounter;
String hex_=Integer.toHexString(result);
outputStream.write(hex_.getBytes());
outputStream.write('\n');
return;
}
}
}
System.out.println("Label is not found at line # "+(line_number+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
static void firstPass () {
for (int i = 0; i < lines.length; i++) {
String current = lines[i];
current = current.trim();
String words[] = current.split(" ");
if (words.length == 0)
continue;
if (words[0].charAt(0) == '.') {
if (words[0].equals(".CODE")) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, "CODE");
temp.add(1, "0");
if (section_table.size() >= 1)
(section_table.get(section_table.size() - 1)).add(1, "" + location_counter);
section_table.add(temp);
location_counter = 0;
} else if (words[0].equals(".DATA")) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, "DATA");
temp.add(1, "0");
if (section_table.size() >= 1)
(section_table.get(section_table.size() - 1)).add(1, "" + location_counter);
section_table.add(temp);
location_counter = 0;
} else {
System.out.println("There is a syntax error at line : " + (i + 1));
System.exit(100);
}
} else {
if (words.length >= 2) {
if (words[1].equals("DD") || words[1].equals("DW") || words[1].equals("DB")) {
if (section_table.size() == 0) {
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
} else {
if (!section_table.get(section_table.size() - 1).get(0).equals("DATA")) // BECAUSE WE CAN ONLY DEFINE ANY ID. ONLY IN DATA SECTION
{
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
}
}
if (words.length >=3) // BCZ TO DEFINE A VARIABLE INSTRUCTION SIZE MUST BE GREATER THAN 2 LIKE ( ANIKET DD 10 )
{
if (!search(words[0])) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, words[0]);
temp.add(1, words[1]);
temp.add(2, "Variable");
temp.add(3, location_counter + "");
symbol_table.add(temp);
location_counter = location_counter + (value(words[1]) * (words.length - 2));
}
else
{
System.out.println("ERROR : SYMBOL IS ALREADY DEFINE AT LINE # "+(i+1));
System.exit(100);
}
} else {
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
}
}
else if (words[1].equals(":"))
{
try
{
Integer.parseInt(words[0]);
System.out.println("Label can not be literal at line # "+(i+1));
System.exit(100);
}
catch (Exception e)
{
if (!search(words[0])) {
ArrayList<String> list = new ArrayList<>();
list.add(0, words[0]);
list.add(1, " ");
list.add(2, "Label");
list.add(3, location_counter + "");
symbol_table.add(list);
}
else
{
System.out.println("ERROR : LABEL IS ALREADY DEFINED AT LINE # "+(i+1));
System.exit(100);
}
}
}
else {
switch (words[0]) {
case "MOV" -> {
if (words.length == 4) {
if (!words[2].equals(",")) {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
} else {
location_counter = location_counter + 9;
}
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "ADD", "INC", "SUB" -> {
if (words.length == 2) {
location_counter += 5;
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "END" -> {
return;
}
case "CMP" -> {
if (words.length == 4) {
if (words[2].charAt(0)!=',')
{
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
location_counter += 9;
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "JMP"->
{
if (words.length!=2)
{
System.out.println("There is syntax error at line #"+(i+1));
System.exit(100);
}
else
{
location_counter+=5;
}
}
default -> {
System.out.println("There is some error at line :" + (i + 1));
System.exit(100);
}
}
}
}
else
{
System.out.println("There is some error at line # "+(i+1));
System.exit(100);
}
}
}
}
static boolean search(String name)
{
for(ArrayList<String> te:symbol_table)
{
if (te.get(0).equals(name))
return true;
}
return false;
}
static void writeNumber(String number,String size,OutputStream outputStream,int line_number) throws Exception
{
int value = Integer.parseInt(number);
String hexvalue = Integer.toHexString(value);
if (hexvalue.length()>value(size)*2)
{
System.out.println("ERROR : NUMBER IS BIGGER , LINE # "+(line_number+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
for (int i2 = hexvalue.length(); i2 < value(size) *2; i2++)
hexvalue = "0" + hexvalue;
outputStream.write(hexvalue.getBytes());
}
static void deleteFile(String name, @NotNull OutputStream outputStream) throws Exception
{
outputStream.close();
File file=new File(name);
boolean isdeleted=file.delete();
System.out.println(isdeleted?"File is deleted Successfully ":"ERROR : FILE IS NOT DELETED ...");
}
static String getLocationCounter(String name)
{
String lc="NF"; //NF FOR NOT FOUND
for(int i=0;i<symbol_table.size();i++)
{
if (symbol_table.get(i).get(0).equals(name))
{
lc= symbol_table.get(i).get(3);
break;
}
}
if (!lc.equals("NF"))
{
String hex=Integer.toHexString(Integer.parseInt(lc));
for (int i=hex.length();i<8;i++)
hex="0"+hex;
return hex;
}
return lc;
}
static String getOpcode(@NotNull String ins)
{
switch (ins)
{
case "ADD" -> {
return "7B";
}
case "SUB" -> {
return "8C";
}
case "MOV" ->{
return "8A";
}
case "CMP" ->
{
return "5E";
}
case "INC" ->
{
return "9D";
}
case "JMP" ->
{
return "6E";
}
default ->
{
return "NF"; //NOT FOUND Note : it will never occur just to avoid compile time error ( bcz return type is not void so compiler has to make sure every condition must return some string ) i added default case
}
}
}
static void secondPass() throws Exception {
for(int i=0;i<lines.length;i++)
{
String current=lines[i];
current=current.trim();
String words[]=current.split(" ");
if (words.length==0)
continue;
if (words[0].charAt(0)=='.')
{
if (words[0].equals(".CODE") || words[0].equals(".DATA"))
{
location_counter=0;
}
}
else
{
if (words.length>=2)
{
if (words[1].equals("DD")||words[1].equals("DW")||words[1].equals("DB"))
{
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
for(int i1=2;i1<words.length;i1++)
{
try {
writeNumber(words[i1],words[1],outputStream,i1);
}
catch (Exception exp)
{
System.out.println("Error : DATA MUST BE LITERAL , LINE NUMBER "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
outputStream.write('\n');
location_counter=location_counter+(value(words[1])*(words.length-2));
}
else if (!words[1].equals(":")){
switch (words[0]) {
case "MOV" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("MOV").getBytes());
if (!search(words[1]))
{
try{
Integer.parseInt(words[1]);
System.out.println("ERROR : Destination can never be literal , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
catch (Exception ep)
{
System.out.println("ERROR : Symbol is not found , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
}
if (!search(words[3]))
{
try
{
writeNumber(words[3],"DD",outputStream,i);
outputStream.write('\n');
}
catch (Exception ep)
{
System.out.println("ERROR : SYMBOL IS NOT FOUND , LINE : "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
else
{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
location_counter = location_counter + 9;
}
case "ADD", "INC", "SUB" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode(words[0]).getBytes());
try{
writeNumber(words[1],"DD",outputStream,i);
if (words[0].equals("INC"))
{
System.out.println("In INC instruction operand can never le literal at line : "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
catch (Exception ep)
{
if (!search(words[1]))
{
System.out.println("ERROR : Symbol is not found , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
outputStream.write('\n');
}
}
location_counter += 5;
}
case "END" -> {
return;
}
case "JMP" ->
{
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("JMP").getBytes());
addLabel(outputStream,words[1],location_counter,i);
location_counter+=5;
}
case "CMP" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("CMP").getBytes());
boolean first_second=true;
try
{
int val1= Integer.parseInt(words[1]);
String hex=Integer.toHexString(val1);
for(int i1=hex.length();i1<8;i1++)
hex="0"+hex;
outputStream.write(hex.getBytes());
first_second=false;
int val2= Integer.parseInt(words[3]);
String hex2=Integer.toHexString(val2);
for(int i1=hex2.length();i1<8;i1++)
hex2="0"+hex2;
outputStream.write(hex2.getBytes());
outputStream.write('\n');
}
catch (Exception e)
{
if (first_second) {
if (!search(words[1])) {
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
}
try
{
String hex2=Integer.toHexString(Integer.parseInt(words[2]));
for(int i1=hex2.length();i1<8;i1++)
hex2="0"+hex2;
outputStream.write(hex2.getBytes());
outputStream.write('\n');
}
catch (Exception ep)
{
if (!search(words[3]))
{
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
}
}
else
{
if (!search(words[3]))
{
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
}
}
location_counter += 9;
}
}
}
}
}
}
}
}
| UTF-8 | Java | 26,652 | java | Assembler.java | Java | [
{
"context": " NAME --- DUMMY ASSEMBLER\n * <br>\n * DEVELOPER --- ANIKET\n * <br>\n * COURSE -- BSC ( HONS ) COMPUTER SCIENC",
"end": 187,
"score": 0.9997043609619141,
"start": 181,
"tag": "NAME",
"value": "ANIKET"
},
{
"context": " COMPUTER SCIENCE LAST YEAR\n * <br>\n * COLLEGE --- DYAL SINGH COLLEGE ( DELHI UNIVERSITY )\n * <br>\n * COLLEGE R",
"end": 282,
"score": 0.7830951809883118,
"start": 272,
"tag": "NAME",
"value": "DYAL SINGH"
},
{
"context": " <br>\n * <br>\n * EMAIL -:\n * <br>\n * aniketranag123@gmail.com\n * <br>\n * aniketranag1234@gmail.com\n *<br>\n * ",
"end": 959,
"score": 0.9999142289161682,
"start": 935,
"tag": "EMAIL",
"value": "aniketranag123@gmail.com"
},
{
"context": "\n * <br>\n * aniketranag123@gmail.com\n * <br>\n * aniketranag1234@gmail.com\n *<br>\n * <br>\n *\n */\n\n\n\npublic class Assembl",
"end": 997,
"score": 0.9999179840087891,
"start": 972,
"tag": "EMAIL",
"value": "aniketranag1234@gmail.com"
}
] | null | [] |
package Assembler;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.ArrayList;
/**
*
* PROJECT NAME --- DUMMY ASSEMBLER
* <br>
* DEVELOPER --- ANIKET
* <br>
* COURSE -- BSC ( HONS ) COMPUTER SCIENCE LAST YEAR
* <br>
* COLLEGE --- <NAME> COLLEGE ( DELHI UNIVERSITY )
* <br>
* COLLEGE ROLL-NUMBER -- 18/94026
*<br>
* <br>
* FOR THIS ASSEMBLER :
* <br>
* LANGUAGE RULES -:
* <br>
* 1. IT IS WHITESPACE SENSITIVE
* <br>
* 2. IT IS ALSO CASE SENSITIVE
* <br>
* 3. FOR INSTRUCTIONS SET PREFER MOT.txt
* <br>
* 4. IT SUPPORTS ERROR HANDLING LIKE LITERAL SIZE , SYMBOL NOT DEFINED , DESTINATION ILLEGAL , ILLEGAL INSTRUCTION , ALL TYPE SYNTAX ERROR
*<br>
*
*
*<br>
* INSTRUCTION -:
* <br>
* JDK MUST GREATER OR EQAUL TO 14.0.1
* <br>
* MUST DOWNLOAD REQUIRED CLASS FOR @NotNull ANNOTATION
*<br>
* <br>
* <br>
* EMAIL -:
* <br>
* <EMAIL>
* <br>
* <EMAIL>
*<br>
* <br>
*
*/
public class Assembler {
static ArrayList<ArrayList<String>> section_table = new ArrayList<>();
static ArrayList<ArrayList<String>> symbol_table = new ArrayList<>();
static String file = "";
static int location_counter = 0;
static String lines[];
static FileOutputStream outputStream;
static final String output_file_name="/root/IdeaProjects/src/output.out";
public static void main(String[] args) throws Exception {
FileReader reader = new FileReader("/root/IdeaProjects/src/sourcecode.asm");
for (; ; ) {
int c = reader.read();
if (c != -1)
file += (char) c;
else
break;
}
lines = file.split("\n");
firstPass();
if (section_table.size() >= 1)
section_table.get(section_table.size() - 1).add(1, location_counter + "");// TO ADD THE SIZE ENTRY OF LAST SECTION USED IN ASSEMBLY PROGRAM
System.out.println("First Pass Successfully Done ");
System.out.println("-------------SECTION TABLE ------------");
System.out.println("Name\t Size");
for (ArrayList<String> list : section_table)
System.out.println(list.get(0) + "\t\t\t" + list.get(1));
System.out.println("-------------SYMBOL TABLE ------------");
System.out.println("Name\tSize\tType\tOffset");
for (ArrayList<String> list : symbol_table)
System.out.println(list.get(0) + "\t\t" + list.get(1) + "\t\t" + list.get(2) + "\t\t" + list.get(3));
outputStream=new FileOutputStream(output_file_name);
ArrayList<String> A =new ArrayList<>();
A.add(0,"A");
A.add(1,"DD");
A.add(2,"REGISTER");
A.add(3,"11");
ArrayList<String> B =new ArrayList<>();
B.add(0,"B");
B.add(1,"DD");
B.add(2,"REGISTER");
B.add(3,"12");
ArrayList<String> C =new ArrayList<>();
C.add(0,"C");
C.add(1,"DD");
C.add(2,"REGISTER");
C.add(3,"13");
ArrayList<String> D =new ArrayList<>();
D.add(0,"D");
D.add(1,"DD");
D.add(2,"REGISTER");
D.add(3,"14");
symbol_table.add(A);
symbol_table.add(B);
symbol_table.add(C);
symbol_table.add(D);
secondPass();
System.out.println("Second Pass Successfully Done .. Output File "+output_file_name+" is generated ");
}
static int value(@NotNull String temp) {
if (temp.equals("DD"))
return 4;
else if (temp.equals("DW"))
return 2;
else
return 1;
}
static void addLabel(OutputStream outputStream,String label_name,int current_locationcounter,int line_number) throws Exception
{
String location_cou;
for(int i=0;i<symbol_table.size();i++)
{
if (symbol_table.get(i).get(0).equals(label_name))
{
if (symbol_table.get(i).get(2).equals("Label"))
{
location_cou=symbol_table.get(i).get(3);
int offset=Integer.parseInt(location_cou);
int result=offset-current_locationcounter;
String hex_=Integer.toHexString(result);
outputStream.write(hex_.getBytes());
outputStream.write('\n');
return;
}
}
}
System.out.println("Label is not found at line # "+(line_number+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
static void firstPass () {
for (int i = 0; i < lines.length; i++) {
String current = lines[i];
current = current.trim();
String words[] = current.split(" ");
if (words.length == 0)
continue;
if (words[0].charAt(0) == '.') {
if (words[0].equals(".CODE")) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, "CODE");
temp.add(1, "0");
if (section_table.size() >= 1)
(section_table.get(section_table.size() - 1)).add(1, "" + location_counter);
section_table.add(temp);
location_counter = 0;
} else if (words[0].equals(".DATA")) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, "DATA");
temp.add(1, "0");
if (section_table.size() >= 1)
(section_table.get(section_table.size() - 1)).add(1, "" + location_counter);
section_table.add(temp);
location_counter = 0;
} else {
System.out.println("There is a syntax error at line : " + (i + 1));
System.exit(100);
}
} else {
if (words.length >= 2) {
if (words[1].equals("DD") || words[1].equals("DW") || words[1].equals("DB")) {
if (section_table.size() == 0) {
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
} else {
if (!section_table.get(section_table.size() - 1).get(0).equals("DATA")) // BECAUSE WE CAN ONLY DEFINE ANY ID. ONLY IN DATA SECTION
{
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
}
}
if (words.length >=3) // BCZ TO DEFINE A VARIABLE INSTRUCTION SIZE MUST BE GREATER THAN 2 LIKE ( ANIKET DD 10 )
{
if (!search(words[0])) {
ArrayList<String> temp = new ArrayList<>();
temp.add(0, words[0]);
temp.add(1, words[1]);
temp.add(2, "Variable");
temp.add(3, location_counter + "");
symbol_table.add(temp);
location_counter = location_counter + (value(words[1]) * (words.length - 2));
}
else
{
System.out.println("ERROR : SYMBOL IS ALREADY DEFINE AT LINE # "+(i+1));
System.exit(100);
}
} else {
System.out.println("There is syntax error at line : " + (i + 1));
System.exit(100);
}
}
else if (words[1].equals(":"))
{
try
{
Integer.parseInt(words[0]);
System.out.println("Label can not be literal at line # "+(i+1));
System.exit(100);
}
catch (Exception e)
{
if (!search(words[0])) {
ArrayList<String> list = new ArrayList<>();
list.add(0, words[0]);
list.add(1, " ");
list.add(2, "Label");
list.add(3, location_counter + "");
symbol_table.add(list);
}
else
{
System.out.println("ERROR : LABEL IS ALREADY DEFINED AT LINE # "+(i+1));
System.exit(100);
}
}
}
else {
switch (words[0]) {
case "MOV" -> {
if (words.length == 4) {
if (!words[2].equals(",")) {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
} else {
location_counter = location_counter + 9;
}
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "ADD", "INC", "SUB" -> {
if (words.length == 2) {
location_counter += 5;
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "END" -> {
return;
}
case "CMP" -> {
if (words.length == 4) {
if (words[2].charAt(0)!=',')
{
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
location_counter += 9;
} else {
System.out.println("There is some error at line : " + (i + 1));
System.exit(100);
}
}
case "JMP"->
{
if (words.length!=2)
{
System.out.println("There is syntax error at line #"+(i+1));
System.exit(100);
}
else
{
location_counter+=5;
}
}
default -> {
System.out.println("There is some error at line :" + (i + 1));
System.exit(100);
}
}
}
}
else
{
System.out.println("There is some error at line # "+(i+1));
System.exit(100);
}
}
}
}
static boolean search(String name)
{
for(ArrayList<String> te:symbol_table)
{
if (te.get(0).equals(name))
return true;
}
return false;
}
static void writeNumber(String number,String size,OutputStream outputStream,int line_number) throws Exception
{
int value = Integer.parseInt(number);
String hexvalue = Integer.toHexString(value);
if (hexvalue.length()>value(size)*2)
{
System.out.println("ERROR : NUMBER IS BIGGER , LINE # "+(line_number+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
for (int i2 = hexvalue.length(); i2 < value(size) *2; i2++)
hexvalue = "0" + hexvalue;
outputStream.write(hexvalue.getBytes());
}
static void deleteFile(String name, @NotNull OutputStream outputStream) throws Exception
{
outputStream.close();
File file=new File(name);
boolean isdeleted=file.delete();
System.out.println(isdeleted?"File is deleted Successfully ":"ERROR : FILE IS NOT DELETED ...");
}
static String getLocationCounter(String name)
{
String lc="NF"; //NF FOR NOT FOUND
for(int i=0;i<symbol_table.size();i++)
{
if (symbol_table.get(i).get(0).equals(name))
{
lc= symbol_table.get(i).get(3);
break;
}
}
if (!lc.equals("NF"))
{
String hex=Integer.toHexString(Integer.parseInt(lc));
for (int i=hex.length();i<8;i++)
hex="0"+hex;
return hex;
}
return lc;
}
static String getOpcode(@NotNull String ins)
{
switch (ins)
{
case "ADD" -> {
return "7B";
}
case "SUB" -> {
return "8C";
}
case "MOV" ->{
return "8A";
}
case "CMP" ->
{
return "5E";
}
case "INC" ->
{
return "9D";
}
case "JMP" ->
{
return "6E";
}
default ->
{
return "NF"; //NOT FOUND Note : it will never occur just to avoid compile time error ( bcz return type is not void so compiler has to make sure every condition must return some string ) i added default case
}
}
}
static void secondPass() throws Exception {
for(int i=0;i<lines.length;i++)
{
String current=lines[i];
current=current.trim();
String words[]=current.split(" ");
if (words.length==0)
continue;
if (words[0].charAt(0)=='.')
{
if (words[0].equals(".CODE") || words[0].equals(".DATA"))
{
location_counter=0;
}
}
else
{
if (words.length>=2)
{
if (words[1].equals("DD")||words[1].equals("DW")||words[1].equals("DB"))
{
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
for(int i1=2;i1<words.length;i1++)
{
try {
writeNumber(words[i1],words[1],outputStream,i1);
}
catch (Exception exp)
{
System.out.println("Error : DATA MUST BE LITERAL , LINE NUMBER "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
outputStream.write('\n');
location_counter=location_counter+(value(words[1])*(words.length-2));
}
else if (!words[1].equals(":")){
switch (words[0]) {
case "MOV" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("MOV").getBytes());
if (!search(words[1]))
{
try{
Integer.parseInt(words[1]);
System.out.println("ERROR : Destination can never be literal , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
catch (Exception ep)
{
System.out.println("ERROR : Symbol is not found , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
}
if (!search(words[3]))
{
try
{
writeNumber(words[3],"DD",outputStream,i);
outputStream.write('\n');
}
catch (Exception ep)
{
System.out.println("ERROR : SYMBOL IS NOT FOUND , LINE : "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
else
{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
location_counter = location_counter + 9;
}
case "ADD", "INC", "SUB" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode(words[0]).getBytes());
try{
writeNumber(words[1],"DD",outputStream,i);
if (words[0].equals("INC"))
{
System.out.println("In INC instruction operand can never le literal at line : "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
}
catch (Exception ep)
{
if (!search(words[1]))
{
System.out.println("ERROR : Symbol is not found , Line # "+(i+1));
deleteFile(output_file_name,outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
outputStream.write('\n');
}
}
location_counter += 5;
}
case "END" -> {
return;
}
case "JMP" ->
{
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("JMP").getBytes());
addLabel(outputStream,words[1],location_counter,i);
location_counter+=5;
}
case "CMP" -> {
writeNumber(""+location_counter,"DD",outputStream,i);
outputStream.write(' ');
outputStream.write(getOpcode("CMP").getBytes());
boolean first_second=true;
try
{
int val1= Integer.parseInt(words[1]);
String hex=Integer.toHexString(val1);
for(int i1=hex.length();i1<8;i1++)
hex="0"+hex;
outputStream.write(hex.getBytes());
first_second=false;
int val2= Integer.parseInt(words[3]);
String hex2=Integer.toHexString(val2);
for(int i1=hex2.length();i1<8;i1++)
hex2="0"+hex2;
outputStream.write(hex2.getBytes());
outputStream.write('\n');
}
catch (Exception e)
{
if (first_second) {
if (!search(words[1])) {
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[1]).getBytes());
}
try
{
String hex2=Integer.toHexString(Integer.parseInt(words[2]));
for(int i1=hex2.length();i1<8;i1++)
hex2="0"+hex2;
outputStream.write(hex2.getBytes());
outputStream.write('\n');
}
catch (Exception ep)
{
if (!search(words[3]))
{
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else
{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
}
}
else
{
if (!search(words[3]))
{
System.out.println("ERROR: SYMBOL IS NOT FOUND , LINE #" + (i + 1));
deleteFile(output_file_name, outputStream);
System.exit(100);
}
else{
outputStream.write(getLocationCounter(words[3]).getBytes());
outputStream.write('\n');
}
}
}
location_counter += 9;
}
}
}
}
}
}
}
}
| 26,613 | 0.338361 | 0.326279 | 668 | 38.892216 | 31.275248 | 229 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.552395 | false | false | 0 |
5c4d92ccdd42d13fb20cc11a870e53da4b205f9c | 850,403,526,268 | ed094297869d51695fc47104d6d17b5daf2d3ff2 | /src/main/java/com/example/contacto/MainActivity.java | a66b61280c78ca34a8b606d34b316105d22dc1e5 | [] | no_license | cperezimbert/contacto | https://github.com/cperezimbert/contacto | e53f38140683874328e28090cc651d74cd8f4711 | 1968f92afa0c807b2f366fa2361a09ea27190fc1 | refs/heads/main | 2023-01-08T21:29:31.020000 | 2020-11-02T15:35:29 | 2020-11-02T15:35:29 | 309,387,191 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.contacto;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private static final String TAG ="Contacto" ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate: Starting");
//Obtenemos una referencia a los controles de la interfaz
final EditText txtNombre = (EditText) findViewById(R.id.txtNombre);
final EditText txtEmail = (EditText) findViewById(R.id.txtEmail);
final EditText txtTelefono = (EditText) findViewById(R.id.txtTelefono);
final EditText txtMensaje = (EditText) findViewById(R.id.txtMensaje);
final DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker);
Button btnEnviar = (Button) findViewById(R.id.btnEnviar);
Button btnCancelar = (Button) findViewById(R.id.btnCancelar);
btnEnviar.setOnClickListener( (new View.OnClickListener(){
@Override
public void onClick (View v) {
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth() + 1;
int year = datePicker.getYear();
String date = day + "/" + month + "/" + year;
//controlamos ingresos
Boolean ingresoOK = true;
if(txtNombre.getText().toString().isEmpty()){
txtNombre.setError("Dato obligatorio!");
ingresoOK = false;
}
if(txtEmail.getText().toString().isEmpty()){
txtEmail.setError("Dato obligatorio!");
ingresoOK = false;
}
if(txtMensaje.getText().toString().isEmpty()){
txtMensaje.setError("Dato obligatorio!");
ingresoOK = false;
}
//Creamos el Intent
Intent intent =
new Intent(MainActivity. this ,
MostrarDatos.class);
//Creamos la información a pasar entre actividades
Bundle b = new Bundle();
b.putString( "Nombre" , txtNombre.getText().toString());
//Bundle c = new Bundle();
b.putString("Email" , txtEmail.getText().toString());
//Bundle d = new Bundle();
b.putString("Telefono", txtTelefono.getText().toString());
//Bundle e = new Bundle();
b.putString("Mensaje", txtMensaje.getText().toString());
b.putString("Fecha", date);
//Añadimos la información al intent
intent.putExtras(b);
intent.putExtras(b);
intent.putExtras(b);
intent.putExtras(b);
try {
if(ingresoOK== true){
//Iniciamos la nueva actividad
Toast.makeText(MainActivity.this, "Datos ingresados correctamente", Toast.LENGTH_LONG).show();
startActivity(intent);
}
}catch (Exception ex){
Log.e(TAG, "onClick: ERROR"+ ex.getMessage());
}
//Log.e(TAG, "onClick: error");
//Log.i(TAG, "onClick: info"+" "+txtNombre.getText()+" "+txtEmail.getText()+" "+txtMensaje);
}
}));
btnCancelar.setOnClickListener( new View.OnClickListener(){
//limpiamos el formulario
@Override
public void onClick (View v) {
txtNombre.setText(null);
txtEmail.setText(null);
txtTelefono.setText(null);
txtMensaje.setText(null);
}
});
Log.d(TAG, "onCreate: Finishing");
}
} | UTF-8 | Java | 4,306 | java | MainActivity.java | Java | [] | null | [] | package com.example.contacto;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private static final String TAG ="Contacto" ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate: Starting");
//Obtenemos una referencia a los controles de la interfaz
final EditText txtNombre = (EditText) findViewById(R.id.txtNombre);
final EditText txtEmail = (EditText) findViewById(R.id.txtEmail);
final EditText txtTelefono = (EditText) findViewById(R.id.txtTelefono);
final EditText txtMensaje = (EditText) findViewById(R.id.txtMensaje);
final DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker);
Button btnEnviar = (Button) findViewById(R.id.btnEnviar);
Button btnCancelar = (Button) findViewById(R.id.btnCancelar);
btnEnviar.setOnClickListener( (new View.OnClickListener(){
@Override
public void onClick (View v) {
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth() + 1;
int year = datePicker.getYear();
String date = day + "/" + month + "/" + year;
//controlamos ingresos
Boolean ingresoOK = true;
if(txtNombre.getText().toString().isEmpty()){
txtNombre.setError("Dato obligatorio!");
ingresoOK = false;
}
if(txtEmail.getText().toString().isEmpty()){
txtEmail.setError("Dato obligatorio!");
ingresoOK = false;
}
if(txtMensaje.getText().toString().isEmpty()){
txtMensaje.setError("Dato obligatorio!");
ingresoOK = false;
}
//Creamos el Intent
Intent intent =
new Intent(MainActivity. this ,
MostrarDatos.class);
//Creamos la información a pasar entre actividades
Bundle b = new Bundle();
b.putString( "Nombre" , txtNombre.getText().toString());
//Bundle c = new Bundle();
b.putString("Email" , txtEmail.getText().toString());
//Bundle d = new Bundle();
b.putString("Telefono", txtTelefono.getText().toString());
//Bundle e = new Bundle();
b.putString("Mensaje", txtMensaje.getText().toString());
b.putString("Fecha", date);
//Añadimos la información al intent
intent.putExtras(b);
intent.putExtras(b);
intent.putExtras(b);
intent.putExtras(b);
try {
if(ingresoOK== true){
//Iniciamos la nueva actividad
Toast.makeText(MainActivity.this, "Datos ingresados correctamente", Toast.LENGTH_LONG).show();
startActivity(intent);
}
}catch (Exception ex){
Log.e(TAG, "onClick: ERROR"+ ex.getMessage());
}
//Log.e(TAG, "onClick: error");
//Log.i(TAG, "onClick: info"+" "+txtNombre.getText()+" "+txtEmail.getText()+" "+txtMensaje);
}
}));
btnCancelar.setOnClickListener( new View.OnClickListener(){
//limpiamos el formulario
@Override
public void onClick (View v) {
txtNombre.setText(null);
txtEmail.setText(null);
txtTelefono.setText(null);
txtMensaje.setText(null);
}
});
Log.d(TAG, "onCreate: Finishing");
}
} | 4,306 | 0.53056 | 0.530328 | 106 | 38.613209 | 24.845018 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.669811 | false | false | 0 |
6a69163a5a7348a7389c428206d824d392dcdd53 | 77,309,414,681 | c19cc78880298eae676af0e1fc510884cba40b05 | /src/sim/net/overlay/dht/swarm/StreamEvent.java | f7aabc647d0a051b1715e2538fda98ab185510c4 | [
"BSD-2-Clause"
] | permissive | bramp/p2psim | https://github.com/bramp/p2psim | 40283349144147c8bbd43615c7776e90e271531c | b73a3576a55da19428c297e84bd4bdb3dcb32790 | refs/heads/master | 2023-05-03T16:32:06.793000 | 2013-04-18T21:15:00 | 2013-04-18T21:15:00 | 7,320,705 | 4 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Created on 04-May-2005
*/
package sim.net.overlay.dht.swarm;
import sim.events.Event;
import sim.events.EventException;
import sim.events.Events;
/**
* @author Andrew Brampton
*/
public class StreamEvent extends Event {
public int packetCount = 0;
public final SwarmPeer peer;
public final int OPlane;
public final int rate;
public final int duration;
/**
*
* @param peer The peer to send the stream
* @param OPlane The OPlane to send on
* @param rate The rate in bytes/second
* @param duration The duration of the stream
* @throws EventException
*/
public StreamEvent(SwarmPeer peer, int OPlane, int rate, int duration) {
this.peer = peer;
this.OPlane = OPlane;
this.rate = rate;
this.duration = duration;
}
/* (non-Javadoc)
* @see net.bramp.p2psim.events.Event#run()
*/
@Override
public void run() {
//Send a packet of this stream
peer.sendStreamPacket(OPlane, null, rate, packetCount++);
// Reschedule ourselfs
if ((Events.getTime() - time) < duration) {
Events.addFromNow(this, 1000);
}
}
@Override
public long getEstimatedRunTime() {
return duration;
}
}
| UTF-8 | Java | 1,192 | java | StreamEvent.java | Java | [
{
"context": "ion;\r\nimport sim.events.Events;\r\n\r\n/**\r\n * @author Andrew Brampton\r\n */\r\npublic class StreamEvent extends Event {\r\n\r",
"end": 195,
"score": 0.9998584985733032,
"start": 180,
"tag": "NAME",
"value": "Andrew Brampton"
}
] | null | [] | /*
* Created on 04-May-2005
*/
package sim.net.overlay.dht.swarm;
import sim.events.Event;
import sim.events.EventException;
import sim.events.Events;
/**
* @author <NAME>
*/
public class StreamEvent extends Event {
public int packetCount = 0;
public final SwarmPeer peer;
public final int OPlane;
public final int rate;
public final int duration;
/**
*
* @param peer The peer to send the stream
* @param OPlane The OPlane to send on
* @param rate The rate in bytes/second
* @param duration The duration of the stream
* @throws EventException
*/
public StreamEvent(SwarmPeer peer, int OPlane, int rate, int duration) {
this.peer = peer;
this.OPlane = OPlane;
this.rate = rate;
this.duration = duration;
}
/* (non-Javadoc)
* @see net.bramp.p2psim.events.Event#run()
*/
@Override
public void run() {
//Send a packet of this stream
peer.sendStreamPacket(OPlane, null, rate, packetCount++);
// Reschedule ourselfs
if ((Events.getTime() - time) < duration) {
Events.addFromNow(this, 1000);
}
}
@Override
public long getEstimatedRunTime() {
return duration;
}
}
| 1,183 | 0.658557 | 0.64849 | 57 | 18.912281 | 17.415743 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.22807 | false | false | 0 |
85a32c75468edd282383a63dadca3a1b5dec30b2 | 5,016,521,829,221 | e338f8d30e7c38d712b5c86adefcabde3b8ef249 | /Crawler/src/interfaces/HtmlDownloader.java | 4a908552ddb06487cd076db9a98ce862b78ff4fa | [] | no_license | MollyHe5/SeekMovies | https://github.com/MollyHe5/SeekMovies | 48054be95d8a4eb2e5e37a5009bd93ebe6ca193d | 9ffdbbfd8483ee0f9f4fe4797fe8c79fa90b3bcb | refs/heads/master | 2022-09-10T04:24:56.297000 | 2017-07-08T10:05:05 | 2017-07-08T10:05:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interfaces;
import java.io.IOException;
/**
* Created by douchengfeng on 2017/5/30.
* 用于下载html页面
*/
public interface HtmlDownloader {
/**
* 用于下载html页面
* @param url 页面的url
* @return html页面,以字符串的形式
*/
String getHtmlPage(String url) throws IOException;
/**
* 用于结束下载器
*/
void closeDownloader();
}
| UTF-8 | Java | 419 | java | HtmlDownloader.java | Java | [
{
"context": "s;\n\nimport java.io.IOException;\n\n/**\n * Created by douchengfeng on 2017/5/30.\n * 用于下载html页面\n */\npublic interface ",
"end": 80,
"score": 0.9991569519042969,
"start": 68,
"tag": "USERNAME",
"value": "douchengfeng"
}
] | null | [] | package interfaces;
import java.io.IOException;
/**
* Created by douchengfeng on 2017/5/30.
* 用于下载html页面
*/
public interface HtmlDownloader {
/**
* 用于下载html页面
* @param url 页面的url
* @return html页面,以字符串的形式
*/
String getHtmlPage(String url) throws IOException;
/**
* 用于结束下载器
*/
void closeDownloader();
}
| 419 | 0.622535 | 0.602817 | 23 | 14.434783 | 14.622276 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.173913 | false | false | 0 |
cfe8ccd7ad02ec87f9849c3c80af76bc830f4bc7 | 23,244,363,010,280 | 2a83693b029e72c9cf20f3209eec3133398bc8e8 | /Practice/src/com/practice/A.java | 37f2a09d243d3450002070d76124645586ba6865 | [] | no_license | kumarankit01/euler | https://github.com/kumarankit01/euler | 98a01449a69fe80a7c90a24916270405d4e1cfd3 | 40f9eee2c83b86779b4ccab1d79b668807bc2d3d | refs/heads/master | 2021-01-10T21:40:29.663000 | 2015-04-27T03:26:44 | 2015-04-27T03:26:44 | 34,643,970 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.practice;
class C{
{
System.out.println("C ins");
}
C(){
System.out.println("C const!!");
}
static{
System.out.println("C static");
}
}
class B extends C{
{
System.out.println("B ins");
}
static{
System.out.println("B static");
}
}
public class A extends B {
static{
System.out.println("A static");
}
{
System.out.println("A ins");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new B();
}
}
| UTF-8 | Java | 507 | java | A.java | Java | [] | null | [] | package com.practice;
class C{
{
System.out.println("C ins");
}
C(){
System.out.println("C const!!");
}
static{
System.out.println("C static");
}
}
class B extends C{
{
System.out.println("B ins");
}
static{
System.out.println("B static");
}
}
public class A extends B {
static{
System.out.println("A static");
}
{
System.out.println("A ins");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new B();
}
}
| 507 | 0.57002 | 0.57002 | 35 | 12.485714 | 13.641054 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.228571 | false | false | 0 |
a1e2c2d55530e901c8c6d772e1ac37084f3322cb | 2,534,030,706,931 | bd69275e097dacbf28cb7def0b02620cedabb17d | /queue-core/src/main/java/com/kingsoft/wps/mail/queue/KMQueueManager.java | 9a92b100f38b20d07f61f054081bcbe120048fb1 | [
"Apache-2.0"
] | permissive | wanghuading/KMQueue | https://github.com/wanghuading/KMQueue | 30c23982b7980e87eccb8a6b9612f6934dd413c5 | 424136867c8dfaaaf6306a3ae3493381f9c82486 | refs/heads/master | 2020-03-16T22:57:07.594000 | 2018-02-11T03:27:57 | 2018-02-11T03:28:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kingsoft.wps.mail.queue;
import com.kingsoft.wps.mail.exception.NestedException;
import com.kingsoft.wps.mail.queue.backup.BackupQueue;
import com.kingsoft.wps.mail.queue.backup.RedisBackupQueue;
import com.kingsoft.wps.mail.utils.Assert;
import com.kingsoft.wps.mail.utils.KMQUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.util.Pool;
import sun.misc.BASE64Encoder;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
/**
* Created by 刘春龙 on 2018/1/17.
* <p>
* 队列管理器,redis线程池的初始化,队列的初始化
*/
public class KMQueueManager extends KMQueueAdapter {
private final static Logger logger = Logger.getLogger(KMQueueManager.class.getName());
private Map<String, Object> queueMap = new ConcurrentHashMap<>();
/**
* 待创建的队列的名称集合
*/
private List<String> queues;
/**
* 任务的存活超时时间。单位:ms
* <p>
* 注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间
* <p>
* 该值只针对安全队列起作用
* <p>
* 不设置默认为 Long.MAX_VALUE
*/
private long aliveTimeout;
/**
* 构造方法私有化,防止外部调用
*/
private KMQueueManager() {
}
/**
* 根据名称获取任务队列
*
* @param name 队列名称
* @return 任务队列
*/
public TaskQueue getTaskQueue(String name) {
Object queue = this.queueMap.get(name);
if (queue != null && queue instanceof TaskQueue) {
return (TaskQueue) queue;
}
return null;
}
/**
* 获取任务存活超时时间。注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间。单位:ms
*
* @return
*/
public long getAliveTimeout() {
return this.aliveTimeout;
}
/**
* 初始化队列
*/
public void init() {
// 生成备份队列名称
backUpQueueName = KMQUtils.genBackUpQueueName(this.queues);
logger.info("Initializing the queues");
boolean hasSq = false;
for (String queue : this.queues) {
String[] qInfos = queue.trim().split(":");
String qName = qInfos[0].trim();// 队列名称
String qMode = null;// 队列模式
if (qInfos.length == 2) {
qMode = qInfos[1].trim();
}
if (qMode != null && !"".equals(qMode) && !qMode.equals(DEFAULT) && !qMode.equals(SAFE)) {
throw new NestedException("The current queue mode is invalid, the queue name:" + qName);
}
if (!"".equals(qName)) {
if (!queueMap.containsKey(qName)) {
if (qMode != null && qMode.equals(SAFE)) {
hasSq = true;// 标记存在安全队列
}
queueMap.put(qName, new RedisTaskQueue(this, qName, qMode));
logger.info("Creating a task queue:" + qName);
} else {
logger.info("The current queue already exists. Do not create the queue name repeatedly:" + qName);
}
} else {
throw new NestedException("The current queue name is empty!");
}
}
// 添加备份队列
if (hasSq) {
BackupQueue backupQueue = new RedisBackupQueue(this);
backupQueue.initQueue();
queueMap.put(backUpQueueName, backupQueue);
logger.info("Initializing backup queue");
}
}
/**
* 构建器,用于设置初始化参数,执行初始化操作
*/
public static class Builder {
/**
* redis连接方式:
* <ul>
* <li>default</li>
* <li>single</li>
* <li>sentinel</li>
* </ul>
*/
private final String REDIS_CONN_DEFAULT = "default";
private final String REDIS_CONN_SINGLE = "single";
private final String REDIS_CONN_SENTINEL = "sentinel";
private String REDIS_CONN_MODE;
/**
* redis连接池
*/
private Pool<Jedis> pool;
/**
* 待创建的队列的名称集合
*/
private List<String> queues;
/**
* redis host
*/
private String host;
/**
* redis port
*/
private int port;
/**
* 主从复制集
*/
private Set<String> sentinels;
/**
* 连接池最大分配的连接数
*/
private Integer poolMaxTotal;
/**
* 连接池的最大空闲连接数
*/
private Integer poolMaxIdle;
/**
* redis获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常,小于零:阻塞不确定的时间,默认-1
*/
private Long poolMaxWaitMillis;
/**
* 任务的存活超时时间。注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间。单位:ms
* <p>
* 该值只针对安全队列起作用
* <p>
* 不设置默认为 Long.MAX_VALUE
*/
private long aliveTimeout;
/**
* 创建Builder对象
* <p>
* 使用指定的redis连接池
*
* @param pool redis连接池
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(Pool<Jedis> pool, String... queues) {
Assert.notNull(pool, "Param pool can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.pool = pool;
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_DEFAULT;
}
/**
* 创建Builder对象
*
* @param host redis host
* @param port redis port
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(String host, int port, String... queues) {
Assert.notNull(host, "Param host can't null");
Assert.notNull(port, "Param port can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.host = host;
this.port = port;
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_SINGLE;
}
/**
* 创建Builder对象
* <p>
* 采用主从复制的方式创建redis连接池
*
* @param hostPort 逗号分隔的 host:port 列表
* @param isSentinel 是否是主从复制
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(String hostPort, boolean isSentinel, String... queues) {
Assert.isTrue(isSentinel, "Param isSentinel invalid");
Assert.notNull(hostPort, "Param hostPort can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.sentinels = new HashSet<>();
sentinels.addAll(Arrays.asList(hostPort.split(",")));
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_SENTINEL;
}
/**
* 设置redis连接池最大分配的连接数
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxTotal 连接池最大分配的连接数
* @return 返回Builder
*/
public Builder setMaxTotal(Integer poolMaxTotal) {
Assert.greaterThanEquals(poolMaxTotal, 0, "Param poolMaxTotal is negative");
this.poolMaxTotal = poolMaxTotal;
return this;
}
/**
* 设置redis连接池的最大空闲连接数
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxIdle 连接池的最大空闲连接数
* @return 返回Builder
*/
public Builder setMaxIdle(Integer poolMaxIdle) {
Assert.greaterThanEquals(poolMaxIdle, 0, "Param poolMaxIdle is negative");
this.poolMaxIdle = poolMaxIdle;
return this;
}
/**
* 设置redis获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),
* 如果超时就抛异常,小于零则阻塞不确定的时间,默认-1
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxWaitMillis 获取连接时的最大等待毫秒数
* @return 返回Builder
*/
public Builder setMaxWaitMillis(Long poolMaxWaitMillis) {
this.poolMaxWaitMillis = poolMaxWaitMillis;
return this;
}
/**
* 设置任务的存活超时时间,传0 则采用默认值: Long.MAX_VALUE
*
* @param aliveTimeout 任务的存活时间
* @return 返回Builder
*/
public Builder setAliveTimeout(long aliveTimeout) {
Assert.greaterThanEquals(aliveTimeout, 0, "Param aliveTimeout is negative");
if (aliveTimeout == 0) {
aliveTimeout = Long.MAX_VALUE;
}
this.aliveTimeout = aliveTimeout;
return this;
}
public KMQueueManager build() {
KMQueueManager queueManager = new KMQueueManager();
JedisPoolConfig jedisPoolConfig = null;
switch (REDIS_CONN_MODE) {
case REDIS_CONN_DEFAULT:
break;
case REDIS_CONN_SINGLE:
jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(this.poolMaxTotal);
jedisPoolConfig.setMaxIdle(this.poolMaxIdle);
jedisPoolConfig.setMaxWaitMillis(this.poolMaxWaitMillis);
this.pool = new JedisPool(jedisPoolConfig, host, port);
break;
case REDIS_CONN_SENTINEL:
jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(this.poolMaxTotal);
jedisPoolConfig.setMaxIdle(this.poolMaxIdle);
jedisPoolConfig.setMaxWaitMillis(this.poolMaxWaitMillis);
this.pool = new JedisSentinelPool("master", sentinels, jedisPoolConfig);
break;
}
queueManager.pool = this.pool;
queueManager.queues = this.queues;
queueManager.aliveTimeout = this.aliveTimeout;
return queueManager;
}
}
}
| UTF-8 | Java | 11,136 | java | KMQueueManager.java | Java | [
{
"context": "port java.util.logging.Logger;\n\n/**\n * Created by 刘春龙 on 2018/1/17.\n * <p>\n * 队列管理器,redis线程池的初始化,队列的初始化",
"end": 773,
"score": 0.9998226165771484,
"start": 770,
"tag": "NAME",
"value": "刘春龙"
}
] | null | [] | package com.kingsoft.wps.mail.queue;
import com.kingsoft.wps.mail.exception.NestedException;
import com.kingsoft.wps.mail.queue.backup.BackupQueue;
import com.kingsoft.wps.mail.queue.backup.RedisBackupQueue;
import com.kingsoft.wps.mail.utils.Assert;
import com.kingsoft.wps.mail.utils.KMQUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.util.Pool;
import sun.misc.BASE64Encoder;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
/**
* Created by 刘春龙 on 2018/1/17.
* <p>
* 队列管理器,redis线程池的初始化,队列的初始化
*/
public class KMQueueManager extends KMQueueAdapter {
private final static Logger logger = Logger.getLogger(KMQueueManager.class.getName());
private Map<String, Object> queueMap = new ConcurrentHashMap<>();
/**
* 待创建的队列的名称集合
*/
private List<String> queues;
/**
* 任务的存活超时时间。单位:ms
* <p>
* 注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间
* <p>
* 该值只针对安全队列起作用
* <p>
* 不设置默认为 Long.MAX_VALUE
*/
private long aliveTimeout;
/**
* 构造方法私有化,防止外部调用
*/
private KMQueueManager() {
}
/**
* 根据名称获取任务队列
*
* @param name 队列名称
* @return 任务队列
*/
public TaskQueue getTaskQueue(String name) {
Object queue = this.queueMap.get(name);
if (queue != null && queue instanceof TaskQueue) {
return (TaskQueue) queue;
}
return null;
}
/**
* 获取任务存活超时时间。注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间。单位:ms
*
* @return
*/
public long getAliveTimeout() {
return this.aliveTimeout;
}
/**
* 初始化队列
*/
public void init() {
// 生成备份队列名称
backUpQueueName = KMQUtils.genBackUpQueueName(this.queues);
logger.info("Initializing the queues");
boolean hasSq = false;
for (String queue : this.queues) {
String[] qInfos = queue.trim().split(":");
String qName = qInfos[0].trim();// 队列名称
String qMode = null;// 队列模式
if (qInfos.length == 2) {
qMode = qInfos[1].trim();
}
if (qMode != null && !"".equals(qMode) && !qMode.equals(DEFAULT) && !qMode.equals(SAFE)) {
throw new NestedException("The current queue mode is invalid, the queue name:" + qName);
}
if (!"".equals(qName)) {
if (!queueMap.containsKey(qName)) {
if (qMode != null && qMode.equals(SAFE)) {
hasSq = true;// 标记存在安全队列
}
queueMap.put(qName, new RedisTaskQueue(this, qName, qMode));
logger.info("Creating a task queue:" + qName);
} else {
logger.info("The current queue already exists. Do not create the queue name repeatedly:" + qName);
}
} else {
throw new NestedException("The current queue name is empty!");
}
}
// 添加备份队列
if (hasSq) {
BackupQueue backupQueue = new RedisBackupQueue(this);
backupQueue.initQueue();
queueMap.put(backUpQueueName, backupQueue);
logger.info("Initializing backup queue");
}
}
/**
* 构建器,用于设置初始化参数,执行初始化操作
*/
public static class Builder {
/**
* redis连接方式:
* <ul>
* <li>default</li>
* <li>single</li>
* <li>sentinel</li>
* </ul>
*/
private final String REDIS_CONN_DEFAULT = "default";
private final String REDIS_CONN_SINGLE = "single";
private final String REDIS_CONN_SENTINEL = "sentinel";
private String REDIS_CONN_MODE;
/**
* redis连接池
*/
private Pool<Jedis> pool;
/**
* 待创建的队列的名称集合
*/
private List<String> queues;
/**
* redis host
*/
private String host;
/**
* redis port
*/
private int port;
/**
* 主从复制集
*/
private Set<String> sentinels;
/**
* 连接池最大分配的连接数
*/
private Integer poolMaxTotal;
/**
* 连接池的最大空闲连接数
*/
private Integer poolMaxIdle;
/**
* redis获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常,小于零:阻塞不确定的时间,默认-1
*/
private Long poolMaxWaitMillis;
/**
* 任务的存活超时时间。注意,该时间是任务从创建({@code new Task(...)})到销毁的总时间。单位:ms
* <p>
* 该值只针对安全队列起作用
* <p>
* 不设置默认为 Long.MAX_VALUE
*/
private long aliveTimeout;
/**
* 创建Builder对象
* <p>
* 使用指定的redis连接池
*
* @param pool redis连接池
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(Pool<Jedis> pool, String... queues) {
Assert.notNull(pool, "Param pool can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.pool = pool;
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_DEFAULT;
}
/**
* 创建Builder对象
*
* @param host redis host
* @param port redis port
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(String host, int port, String... queues) {
Assert.notNull(host, "Param host can't null");
Assert.notNull(port, "Param port can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.host = host;
this.port = port;
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_SINGLE;
}
/**
* 创建Builder对象
* <p>
* 采用主从复制的方式创建redis连接池
*
* @param hostPort 逗号分隔的 host:port 列表
* @param isSentinel 是否是主从复制
* @param queues 所要创建的队列名称,可以传多个
*/
public Builder(String hostPort, boolean isSentinel, String... queues) {
Assert.isTrue(isSentinel, "Param isSentinel invalid");
Assert.notNull(hostPort, "Param hostPort can't null");
this.aliveTimeout = Long.MAX_VALUE;
this.sentinels = new HashSet<>();
sentinels.addAll(Arrays.asList(hostPort.split(",")));
this.queues = Arrays.asList(queues);
this.REDIS_CONN_MODE = this.REDIS_CONN_SENTINEL;
}
/**
* 设置redis连接池最大分配的连接数
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxTotal 连接池最大分配的连接数
* @return 返回Builder
*/
public Builder setMaxTotal(Integer poolMaxTotal) {
Assert.greaterThanEquals(poolMaxTotal, 0, "Param poolMaxTotal is negative");
this.poolMaxTotal = poolMaxTotal;
return this;
}
/**
* 设置redis连接池的最大空闲连接数
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxIdle 连接池的最大空闲连接数
* @return 返回Builder
*/
public Builder setMaxIdle(Integer poolMaxIdle) {
Assert.greaterThanEquals(poolMaxIdle, 0, "Param poolMaxIdle is negative");
this.poolMaxIdle = poolMaxIdle;
return this;
}
/**
* 设置redis获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),
* 如果超时就抛异常,小于零则阻塞不确定的时间,默认-1
* <p>
* 对使用{@link #Builder(Pool, String...)}构造的Builder不起作用
*
* @param poolMaxWaitMillis 获取连接时的最大等待毫秒数
* @return 返回Builder
*/
public Builder setMaxWaitMillis(Long poolMaxWaitMillis) {
this.poolMaxWaitMillis = poolMaxWaitMillis;
return this;
}
/**
* 设置任务的存活超时时间,传0 则采用默认值: Long.MAX_VALUE
*
* @param aliveTimeout 任务的存活时间
* @return 返回Builder
*/
public Builder setAliveTimeout(long aliveTimeout) {
Assert.greaterThanEquals(aliveTimeout, 0, "Param aliveTimeout is negative");
if (aliveTimeout == 0) {
aliveTimeout = Long.MAX_VALUE;
}
this.aliveTimeout = aliveTimeout;
return this;
}
public KMQueueManager build() {
KMQueueManager queueManager = new KMQueueManager();
JedisPoolConfig jedisPoolConfig = null;
switch (REDIS_CONN_MODE) {
case REDIS_CONN_DEFAULT:
break;
case REDIS_CONN_SINGLE:
jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(this.poolMaxTotal);
jedisPoolConfig.setMaxIdle(this.poolMaxIdle);
jedisPoolConfig.setMaxWaitMillis(this.poolMaxWaitMillis);
this.pool = new JedisPool(jedisPoolConfig, host, port);
break;
case REDIS_CONN_SENTINEL:
jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(this.poolMaxTotal);
jedisPoolConfig.setMaxIdle(this.poolMaxIdle);
jedisPoolConfig.setMaxWaitMillis(this.poolMaxWaitMillis);
this.pool = new JedisSentinelPool("master", sentinels, jedisPoolConfig);
break;
}
queueManager.pool = this.pool;
queueManager.queues = this.queues;
queueManager.aliveTimeout = this.aliveTimeout;
return queueManager;
}
}
}
| 11,136 | 0.546787 | 0.544867 | 334 | 28.628742 | 23.735189 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.407186 | false | false | 0 |
03813699d505d62118f2cdd4de908e97e05dbc63 | 20,633,022,913,756 | 0762537a6c04de8182978d6b345b853027c00b2c | /src/ca/hjalmionlabs/rendering/gui/toolbar/Toolbar.java | bc441a7f828c2e5c3e5a3290c10d95f70ee5dcfe | [] | no_license | Hjalmion-Labs/SandboxGame | https://github.com/Hjalmion-Labs/SandboxGame | def47fde750d1efa45dda0ed236e593580f20766 | 0a4285eba1a17c81e2d739aba44721edcc63eb9d | refs/heads/master | 2022-03-17T11:48:45.701000 | 2019-12-06T00:17:35 | 2019-12-06T00:17:35 | 111,003,956 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ca.hjalmionlabs.rendering.gui.toolbar;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import ca.hjalmionlabs.main.Game;
import ca.hjalmionlabs.world.tiles.Tile;
import ca.hjalmionlabs.world.tiles.TileType;
public class Toolbar
{
/** X-position of top left corner of the Toolbar */
private int x;
/** Y-position of the top left corner of the Toolbar */
private int y;
/** Width of the Toolbar */
private int width;
/** Height of the Toolbar */
private int height;
/** When using this value, make sure to use it in a loop like so: <br> boxX = x + (i * 50) + 3; */
private int boxX;
private int boxY;
private int boxWidth;
private int boxHeight;
private List<ToolbarBox> boxes = new ArrayList<ToolbarBox>();
private ToolbarBox box1 = new ToolbarBox(); // First Box on the Toolbar (furthest left)
private ToolbarBox box2 = new ToolbarBox();
private ToolbarBox box3 = new ToolbarBox();
private ToolbarBox box4 = new ToolbarBox();
private ToolbarBox box5 = new ToolbarBox();
private ToolbarBox box6 = new ToolbarBox();
private ToolbarBox box7 = new ToolbarBox();
private ToolbarBox box8 = new ToolbarBox();
private ToolbarBox box9 = new ToolbarBox();
private ToolbarBox box0 = new ToolbarBox(); // Last Box on the Toolbar (furthest right)
/**
* Constructor. Creates a new Toolbar and initializes the 9 ToolbarBoxes that it contains
*/
public Toolbar()
{
x = 250;
y = Game.HEIGHT - 103;
width = 501;
height = 51;
boxY = y + 2;
boxWidth = Tile.TILEWIDTH - 5;
boxHeight = Tile.TILEWIDTH - 5;
initialize();
}
/**
* Add the ToolbarBoxes to the Toolbar and set the Tiles of each accordingly
*/
private void initialize()
{
boxes.add(box1);
boxes.add(box2);
boxes.add(box3);
boxes.add(box4);
boxes.add(box5);
boxes.add(box6);
boxes.add(box7);
boxes.add(box8);
boxes.add(box9);
boxes.add(box0);
for(int i = 0; i < boxes.size(); i++)
{
assignTile(i);
}
}
/**
* Based on parameter <code>i</code> set the tile of the ToolbarBox to that TileType
* @param i
*/
private void assignTile(int i)
{
switch(i)
{
case 0:
boxes.get(0).setTile(TileType.DIRT);
break;
case 1:
boxes.get(1).setTile(TileType.GRASS);
break;
case 2:
boxes.get(2).setTile(TileType.STONE);
break;
case 3:
boxes.get(3).setTile(TileType.WATER);
break;
case 4:
boxes.get(4).setTile(TileType.LAVA);
break;
default:
boxes.get(i).setTile(TileType.NULL);
}
}
/**
* Get the current Tile that is active (has the yellow glow)
* @return
*/
public TileType getActiveTile()
{
for(ToolbarBox box : boxes)
{
if(box.isActive())
return box.getTile();
}
return TileType.NULL;
}
/**
* Returns List of all the ToolbarBoxes that this Toolbar contains
* @return List of ToolbarBoxes
*/
public List<ToolbarBox> getBoxes()
{
return boxes;
}
/**
* Any required updating goes here
*/
public void tick()
{
}
/**
* Draws the Toolbar with its ToolbarBoxes to the screen
* @param g
*/
public void render(java.awt.Graphics g)
{
g.setColor(Color.DARK_GRAY);
g.fillRect(x, y, width, height);
g.setColor(Color.BLACK);
// Draw a rectangle at this :
// x value, but make sure it is spaced out by 2 pixels from each box and the sides of the bar.
// y value, but make sure it is spaced out by 2 pixels from the top and bottom of the bar.
// width, which is just a smaller version of the Tile's Width.
// height, which is just a smaller versio of the Tile's Height.
// All of these combined space the boxes out
int i = 0;
box1.setX(x + (i++ * 50) + 3);
box1.setY(y + 2);
box1.setWidth(Tile.TILEWIDTH - 10);
box1.setHeight(Tile.TILEHEIGHT - 10);
box2.setX(x + (i++ * 50) + 3);
box2.setY(y + 2);
box2.setWidth(Tile.TILEWIDTH - 10);
box2.setHeight(Tile.TILEHEIGHT - 10);
box3.setX(x + (i++ * 50) + 3);
box3.setY(y + 2);
box3.setWidth(Tile.TILEWIDTH - 10);
box3.setHeight(Tile.TILEHEIGHT - 10);
box4.setX(x + (i++ * 50) + 3);
box4.setY(y + 2);
box4.setWidth(Tile.TILEWIDTH - 10);
box4.setHeight(Tile.TILEHEIGHT - 10);
box5.setX(x + (i++ * 50) + 3);
box5.setY(y + 2);
box5.setWidth(Tile.TILEWIDTH - 10);
box5.setHeight(Tile.TILEHEIGHT - 10);
box6.setX(x + (i++ * 50) + 3);
box6.setY(y + 2);
box6.setWidth(Tile.TILEWIDTH - 10);
box6.setHeight(Tile.TILEHEIGHT - 10);
box7.setX(x + (i++ * 50) + 3);
box7.setY(y + 2);
box7.setWidth(Tile.TILEWIDTH - 10);
box7.setHeight(Tile.TILEHEIGHT - 10);
box8.setX(x + (i++ * 50) + 3);
box8.setY(y + 2);
box8.setWidth(Tile.TILEWIDTH - 10);
box8.setHeight(Tile.TILEHEIGHT - 10);
box9.setX(x + (i++ * 50) + 3);
box9.setY(y + 2);
box9.setWidth(Tile.TILEWIDTH - 10);
box9.setHeight(Tile.TILEHEIGHT - 10);
box0.setX(x + (i++ * 50) + 3);
box0.setY(y + 2);
box0.setWidth(Tile.TILEWIDTH - 10);
box0.setHeight(Tile.TILEHEIGHT - 10);
/* Example of how to set the TileType of a ToolbarBox */
// ToolbarBox box1 = boxes.get(0);
// box1.setTile(TileType.DIRT);
for(ToolbarBox box : boxes) // Render all the ToolbarBoxes that are in the List of ToolbarBoxes
{
box.render(g);
}
}
/**
* Get a certain ToolbarBox
* @param index
* @return ToolbarBox at index <code>index</code>
*/
public ToolbarBox getBox(int index)
{
return boxes.get(index);
}
/**
* Get this Toolbar's X-value
* @return
*/
public int getX() {
return x;
}
/**
* Set this Toolbar's X-value
* @param x - x value to set the X-value to
*/
public void setX(int x) {
this.x = x;
}
/**
* Get this Toolbar's Y-value
* @return
*/
public int getY() {
return y;
}
/**
* Set this Toolbar's Y-value
* @param y - y value to set the Y-value to
*/
public void setY(int y) {
this.y = y;
}
/**
* Get the Toolbar's width
* @return
*/
public int getWidth() {
return width;
}
/**
* Set the width of the Toolbar
* @param width
*/
public void setWidth(int width) {
this.width = width;
}
/**
* Get the Toolbar's height
* @return
*/
public int getHeight() {
return height;
}
/**
* Set the height of the Toolbar
* @param height
*/
public void setHeight(int height) {
this.height = height;
}
public int getBoxX() {
return boxX;
}
public void setBoxX(int boxX) {
this.boxX = boxX;
}
public int getBoxY() {
return boxY;
}
public void setBoxY(int boxY) {
this.boxY = boxY;
}
public int getBoxWidth() {
return boxWidth;
}
public void setBoxWidth(int boxWidth) {
this.boxWidth = boxWidth;
}
public int getBoxHeight() {
return boxHeight;
}
public void setBoxHeight(int boxHeight) {
this.boxHeight = boxHeight;
}
}
| UTF-8 | Java | 6,765 | java | Toolbar.java | Java | [] | null | [] | package ca.hjalmionlabs.rendering.gui.toolbar;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import ca.hjalmionlabs.main.Game;
import ca.hjalmionlabs.world.tiles.Tile;
import ca.hjalmionlabs.world.tiles.TileType;
public class Toolbar
{
/** X-position of top left corner of the Toolbar */
private int x;
/** Y-position of the top left corner of the Toolbar */
private int y;
/** Width of the Toolbar */
private int width;
/** Height of the Toolbar */
private int height;
/** When using this value, make sure to use it in a loop like so: <br> boxX = x + (i * 50) + 3; */
private int boxX;
private int boxY;
private int boxWidth;
private int boxHeight;
private List<ToolbarBox> boxes = new ArrayList<ToolbarBox>();
private ToolbarBox box1 = new ToolbarBox(); // First Box on the Toolbar (furthest left)
private ToolbarBox box2 = new ToolbarBox();
private ToolbarBox box3 = new ToolbarBox();
private ToolbarBox box4 = new ToolbarBox();
private ToolbarBox box5 = new ToolbarBox();
private ToolbarBox box6 = new ToolbarBox();
private ToolbarBox box7 = new ToolbarBox();
private ToolbarBox box8 = new ToolbarBox();
private ToolbarBox box9 = new ToolbarBox();
private ToolbarBox box0 = new ToolbarBox(); // Last Box on the Toolbar (furthest right)
/**
* Constructor. Creates a new Toolbar and initializes the 9 ToolbarBoxes that it contains
*/
public Toolbar()
{
x = 250;
y = Game.HEIGHT - 103;
width = 501;
height = 51;
boxY = y + 2;
boxWidth = Tile.TILEWIDTH - 5;
boxHeight = Tile.TILEWIDTH - 5;
initialize();
}
/**
* Add the ToolbarBoxes to the Toolbar and set the Tiles of each accordingly
*/
private void initialize()
{
boxes.add(box1);
boxes.add(box2);
boxes.add(box3);
boxes.add(box4);
boxes.add(box5);
boxes.add(box6);
boxes.add(box7);
boxes.add(box8);
boxes.add(box9);
boxes.add(box0);
for(int i = 0; i < boxes.size(); i++)
{
assignTile(i);
}
}
/**
* Based on parameter <code>i</code> set the tile of the ToolbarBox to that TileType
* @param i
*/
private void assignTile(int i)
{
switch(i)
{
case 0:
boxes.get(0).setTile(TileType.DIRT);
break;
case 1:
boxes.get(1).setTile(TileType.GRASS);
break;
case 2:
boxes.get(2).setTile(TileType.STONE);
break;
case 3:
boxes.get(3).setTile(TileType.WATER);
break;
case 4:
boxes.get(4).setTile(TileType.LAVA);
break;
default:
boxes.get(i).setTile(TileType.NULL);
}
}
/**
* Get the current Tile that is active (has the yellow glow)
* @return
*/
public TileType getActiveTile()
{
for(ToolbarBox box : boxes)
{
if(box.isActive())
return box.getTile();
}
return TileType.NULL;
}
/**
* Returns List of all the ToolbarBoxes that this Toolbar contains
* @return List of ToolbarBoxes
*/
public List<ToolbarBox> getBoxes()
{
return boxes;
}
/**
* Any required updating goes here
*/
public void tick()
{
}
/**
* Draws the Toolbar with its ToolbarBoxes to the screen
* @param g
*/
public void render(java.awt.Graphics g)
{
g.setColor(Color.DARK_GRAY);
g.fillRect(x, y, width, height);
g.setColor(Color.BLACK);
// Draw a rectangle at this :
// x value, but make sure it is spaced out by 2 pixels from each box and the sides of the bar.
// y value, but make sure it is spaced out by 2 pixels from the top and bottom of the bar.
// width, which is just a smaller version of the Tile's Width.
// height, which is just a smaller versio of the Tile's Height.
// All of these combined space the boxes out
int i = 0;
box1.setX(x + (i++ * 50) + 3);
box1.setY(y + 2);
box1.setWidth(Tile.TILEWIDTH - 10);
box1.setHeight(Tile.TILEHEIGHT - 10);
box2.setX(x + (i++ * 50) + 3);
box2.setY(y + 2);
box2.setWidth(Tile.TILEWIDTH - 10);
box2.setHeight(Tile.TILEHEIGHT - 10);
box3.setX(x + (i++ * 50) + 3);
box3.setY(y + 2);
box3.setWidth(Tile.TILEWIDTH - 10);
box3.setHeight(Tile.TILEHEIGHT - 10);
box4.setX(x + (i++ * 50) + 3);
box4.setY(y + 2);
box4.setWidth(Tile.TILEWIDTH - 10);
box4.setHeight(Tile.TILEHEIGHT - 10);
box5.setX(x + (i++ * 50) + 3);
box5.setY(y + 2);
box5.setWidth(Tile.TILEWIDTH - 10);
box5.setHeight(Tile.TILEHEIGHT - 10);
box6.setX(x + (i++ * 50) + 3);
box6.setY(y + 2);
box6.setWidth(Tile.TILEWIDTH - 10);
box6.setHeight(Tile.TILEHEIGHT - 10);
box7.setX(x + (i++ * 50) + 3);
box7.setY(y + 2);
box7.setWidth(Tile.TILEWIDTH - 10);
box7.setHeight(Tile.TILEHEIGHT - 10);
box8.setX(x + (i++ * 50) + 3);
box8.setY(y + 2);
box8.setWidth(Tile.TILEWIDTH - 10);
box8.setHeight(Tile.TILEHEIGHT - 10);
box9.setX(x + (i++ * 50) + 3);
box9.setY(y + 2);
box9.setWidth(Tile.TILEWIDTH - 10);
box9.setHeight(Tile.TILEHEIGHT - 10);
box0.setX(x + (i++ * 50) + 3);
box0.setY(y + 2);
box0.setWidth(Tile.TILEWIDTH - 10);
box0.setHeight(Tile.TILEHEIGHT - 10);
/* Example of how to set the TileType of a ToolbarBox */
// ToolbarBox box1 = boxes.get(0);
// box1.setTile(TileType.DIRT);
for(ToolbarBox box : boxes) // Render all the ToolbarBoxes that are in the List of ToolbarBoxes
{
box.render(g);
}
}
/**
* Get a certain ToolbarBox
* @param index
* @return ToolbarBox at index <code>index</code>
*/
public ToolbarBox getBox(int index)
{
return boxes.get(index);
}
/**
* Get this Toolbar's X-value
* @return
*/
public int getX() {
return x;
}
/**
* Set this Toolbar's X-value
* @param x - x value to set the X-value to
*/
public void setX(int x) {
this.x = x;
}
/**
* Get this Toolbar's Y-value
* @return
*/
public int getY() {
return y;
}
/**
* Set this Toolbar's Y-value
* @param y - y value to set the Y-value to
*/
public void setY(int y) {
this.y = y;
}
/**
* Get the Toolbar's width
* @return
*/
public int getWidth() {
return width;
}
/**
* Set the width of the Toolbar
* @param width
*/
public void setWidth(int width) {
this.width = width;
}
/**
* Get the Toolbar's height
* @return
*/
public int getHeight() {
return height;
}
/**
* Set the height of the Toolbar
* @param height
*/
public void setHeight(int height) {
this.height = height;
}
public int getBoxX() {
return boxX;
}
public void setBoxX(int boxX) {
this.boxX = boxX;
}
public int getBoxY() {
return boxY;
}
public void setBoxY(int boxY) {
this.boxY = boxY;
}
public int getBoxWidth() {
return boxWidth;
}
public void setBoxWidth(int boxWidth) {
this.boxWidth = boxWidth;
}
public int getBoxHeight() {
return boxHeight;
}
public void setBoxHeight(int boxHeight) {
this.boxHeight = boxHeight;
}
}
| 6,765 | 0.637842 | 0.611973 | 325 | 19.815384 | 19.82686 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.864615 | false | false | 0 |
3f6ae358022fc364059da671000fddaca38c5bc5 | 28,664,611,760,065 | dd43915d036195d5925c5b49e1ede767b6eb82c7 | /Junit5Tutorial/src/test/java/TestInfoDemo.java | 2db69502188e3160fe6fb0ee7233cbf344d43619 | [] | no_license | cwray01/BigDataLearning | https://github.com/cwray01/BigDataLearning | 12a1f6368a61e5aeeb0963384d4cfc217c38f190 | 7738ca32e30bab141ed0e267bfb7870323ef9a5d | refs/heads/master | 2021-07-01T01:40:09.539000 | 2019-04-16T23:56:31 | 2019-04-16T23:56:31 | 114,504,107 | 2 | 0 | null | false | 2017-12-17T03:38:37 | 2017-12-17T02:31:08 | 2017-12-17T02:31:08 | 2017-12-17T03:38:37 | 0 | 0 | 0 | 0 | null | false | null | import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
/**
* [ParameterResolver] defines the API for test extensions
* that wish to dynamically resolve parameters at runtime.
* If a test constructor or a @Test @TestFactory, @BeforeEach, @AfterEach, @BeforeAll, of @AfterAll
* method accepts a parameter, the parameter must be resolved at runtime by a registered ParameterResolver
*/
/**
* [TestInfoParameterResolver] if a method parameter is of type TestInfo
* the TestInfoParameterResolver will supply an instance of TestInfo corresponding to the current test
* as the value for the parameter
*/
/**
* [TestInfo] acts as a drop-in replacement for the TestName rule from Junit4
* The following demonstrates how to have TestInfo injected into a test constructor,
* @BeforeEach method and @Test method
*/
@DisplayName("TestInfo Demo")
class TestInfoDemo {
TestInfoDemo(TestInfo testInfo){
assertEquals("TestInfo Demo", testInfo.getDisplayName());
}
@BeforeEach
void init(TestInfo testInfo){
String displayName = testInfo.getDisplayName();
assertTrue(displayName.equals("TEST 1") ||
displayName.equals("test2()"));
}
@Test
@DisplayName("TEST 1")
@Tag("my-tag")
void test1(TestInfo testInfo){
assertEquals("TEST 1", testInfo.getDisplayName());
assertTrue(testInfo.getTags().contains("my-tag"));
}
@Test
void test2(){
}
}
| UTF-8 | Java | 1,705 | java | TestInfoDemo.java | Java | [] | null | [] | import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
/**
* [ParameterResolver] defines the API for test extensions
* that wish to dynamically resolve parameters at runtime.
* If a test constructor or a @Test @TestFactory, @BeforeEach, @AfterEach, @BeforeAll, of @AfterAll
* method accepts a parameter, the parameter must be resolved at runtime by a registered ParameterResolver
*/
/**
* [TestInfoParameterResolver] if a method parameter is of type TestInfo
* the TestInfoParameterResolver will supply an instance of TestInfo corresponding to the current test
* as the value for the parameter
*/
/**
* [TestInfo] acts as a drop-in replacement for the TestName rule from Junit4
* The following demonstrates how to have TestInfo injected into a test constructor,
* @BeforeEach method and @Test method
*/
@DisplayName("TestInfo Demo")
class TestInfoDemo {
TestInfoDemo(TestInfo testInfo){
assertEquals("TestInfo Demo", testInfo.getDisplayName());
}
@BeforeEach
void init(TestInfo testInfo){
String displayName = testInfo.getDisplayName();
assertTrue(displayName.equals("TEST 1") ||
displayName.equals("test2()"));
}
@Test
@DisplayName("TEST 1")
@Tag("my-tag")
void test1(TestInfo testInfo){
assertEquals("TEST 1", testInfo.getDisplayName());
assertTrue(testInfo.getTags().contains("my-tag"));
}
@Test
void test2(){
}
}
| 1,705 | 0.719648 | 0.715542 | 56 | 29.446428 | 29.7453 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.392857 | false | false | 0 |
8316bc903be430268f19e50e90393cf4974691fe | 12,859,132,086,400 | 29b52f4d202b0e5b3e1b0a4b3130a4a7bbed0392 | /PrimerosPasos2018/src/practicasPropuestas/PrimeraPracticaPropuesta.java | d72d1baa6226a1a31a39a4210f32f44fb469f9b2 | [] | no_license | juanra1997/DI | https://github.com/juanra1997/DI | 80b5350a2f4210a583c444e9345a286d44efe650 | 656d97c147f1dc60d97f3efb5a9aebf80bd182bd | refs/heads/master | 2020-03-29T02:31:31.412000 | 2019-03-12T12:24:08 | 2019-03-12T12:24:08 | 149,441,261 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package practicasPropuestas;
import javax.swing.JFrame;
public class PrimeraPracticaPropuesta {
public static void main(String[] args) {
MiMarco marco=new MiMarco();
marco.setLocation(200,300);
}
}
class MiMarco extends JFrame{
private static final long serialVersionUID = 1L;
public MiMarco() {
iniciar();
}
public void iniciar() {
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Primera Practica Propuesta");
setSize(500,300);
}
}
| UTF-8 | Java | 499 | java | PrimeraPracticaPropuesta.java | Java | [] | null | [] | package practicasPropuestas;
import javax.swing.JFrame;
public class PrimeraPracticaPropuesta {
public static void main(String[] args) {
MiMarco marco=new MiMarco();
marco.setLocation(200,300);
}
}
class MiMarco extends JFrame{
private static final long serialVersionUID = 1L;
public MiMarco() {
iniciar();
}
public void iniciar() {
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Primera Practica Propuesta");
setSize(500,300);
}
}
| 499 | 0.719439 | 0.693387 | 30 | 15.6 | 16.58634 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.3 | false | false | 0 |
5a6f46414c471c2d332dbb63974cd764402e89e6 | 13,091,060,338,297 | f083b293c040290a06d79dd0fd3199f8ec94e78b | /My Java/src/com/pkg1/A4.java | f54b673b7bfd3cfbd9b0137042ee15dbe7547ab1 | [] | no_license | bhushanbpujar/Bhushan | https://github.com/bhushanbpujar/Bhushan | b5132b56d517679656ca22b16cabbb806ddfcfb3 | 53c74ab10e856ba9d57b94997e1f04ac987122e8 | refs/heads/master | 2022-12-22T16:31:16.622000 | 2022-12-09T07:12:54 | 2022-12-09T07:12:54 | 218,668,327 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pkg1;
public class A4 {
protected static int i=10;
protected int j=20;
public static void main(String[] args) {
System.out.println(A4.i);
A4 a=new A4();
System.out.println(a.j);
}
}
| UTF-8 | Java | 222 | java | A4.java | Java | [] | null | [] | package com.pkg1;
public class A4 {
protected static int i=10;
protected int j=20;
public static void main(String[] args) {
System.out.println(A4.i);
A4 a=new A4();
System.out.println(a.j);
}
}
| 222 | 0.621622 | 0.581081 | 15 | 12.8 | 12.812494 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.933333 | false | false | 0 |
953b8235ef65c8b479d7ba881747cb372e7d8a68 | 30,494,267,813,562 | 50f983d25984b3bc4751882a9e970e4678bd54fc | /src/main/java/by/qlab/energycenter/drivers/SerialChannel.java | 846d6aae66b961601efc96000ce20bc370aba93a | [] | no_license | freonby/energycenter | https://github.com/freonby/energycenter | c4f669a11e2dd0705246319f7d06d0c00a14b5fb | b2cd558d986e07c0a890cf9bcb2cf7d49783d2e9 | refs/heads/master | 2021-01-12T10:05:33.494000 | 2017-02-19T12:09:10 | 2017-02-19T12:09:10 | 76,357,049 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package by.qlab.energycenter.drivers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import by.qlab.energycenter.interfaces.Answer;
import by.qlab.energycenter.interfaces.Channel;
import by.qlab.energycenter.interfaces.Packet;
import jssc.SerialPort;
import jssc.SerialPortException;
public class SerialChannel implements Channel {
private static final Logger logger = LoggerFactory.getLogger(SerialChannel.class);
private SerialPort port;
private PortSet portset;
public SerialChannel(String portName, PortSet portset) {
super();
this.port = new SerialPort(portName);
this.portset = portset;
}
public PortSet getPortset() {
return portset;
}
public void setPortset(PortSet portset) {
this.portset = portset;
}
public SerialPort getPort() {
return port;
}
public void setPort(SerialPort port) {
this.port = port;
}
@Override
public void open() {
try {
port.openPort();
port.setParams(portset.getBaudrate(), portset.getDatabits(), portset.getStopbits(), portset.getParity());
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE | SerialPort.FLOWCONTROL_NONE);
} catch (SerialPortException e) {
logger.error("Opening serial port - failed");
}
}
@Override
public void close() {
try {
if (port != null)
port.closePort();
} catch (SerialPortException e) {
logger.error("Closing serial port - failed");
}
}
@Override
public Answer send(Packet packet) {
// TODO Auto-generated method stub
return null;
}
}
| UTF-8 | Java | 1,500 | java | SerialChannel.java | Java | [] | null | [] | package by.qlab.energycenter.drivers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import by.qlab.energycenter.interfaces.Answer;
import by.qlab.energycenter.interfaces.Channel;
import by.qlab.energycenter.interfaces.Packet;
import jssc.SerialPort;
import jssc.SerialPortException;
public class SerialChannel implements Channel {
private static final Logger logger = LoggerFactory.getLogger(SerialChannel.class);
private SerialPort port;
private PortSet portset;
public SerialChannel(String portName, PortSet portset) {
super();
this.port = new SerialPort(portName);
this.portset = portset;
}
public PortSet getPortset() {
return portset;
}
public void setPortset(PortSet portset) {
this.portset = portset;
}
public SerialPort getPort() {
return port;
}
public void setPort(SerialPort port) {
this.port = port;
}
@Override
public void open() {
try {
port.openPort();
port.setParams(portset.getBaudrate(), portset.getDatabits(), portset.getStopbits(), portset.getParity());
port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE | SerialPort.FLOWCONTROL_NONE);
} catch (SerialPortException e) {
logger.error("Opening serial port - failed");
}
}
@Override
public void close() {
try {
if (port != null)
port.closePort();
} catch (SerialPortException e) {
logger.error("Closing serial port - failed");
}
}
@Override
public Answer send(Packet packet) {
// TODO Auto-generated method stub
return null;
}
}
| 1,500 | 0.731333 | 0.73 | 71 | 20.12676 | 22.523809 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.464789 | false | false | 0 |
e4614cf66b3f433d29f4ebaf5f5cd52482b6eb27 | 26,448,408,646,232 | 190b57d66038ac57595c9523d444279ae88d18f7 | /Dentist/src/views/GlobalProcedureListView.java | f6178bd4a580aee7e056783552a4eaf03fa7a95e | [] | no_license | shane-tw/College | https://github.com/shane-tw/College | 43dcbdabcdfa25553692eae7b20a49915ca2f445 | 4635a378034db6bdfdea55824c8f2f457b60290d | refs/heads/master | 2022-12-25T03:30:36.864000 | 2020-10-04T17:49:03 | 2020-10-04T17:49:03 | 301,187,451 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package views;
import controllers.GlobalProcedureListController;
import controllers.ProcedureListController;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* Created by Shane on 19/03/2017.
*/
public class GlobalProcedureListView extends View<GlobalProcedureListController> {
private GeneralManagementView generalManagementView;
private VBox root;
private ScrollPane scrollPane;
private VBox proceduresVBox;
private HBox buttonsHBox;
private Button addProcedureBtn;
public GlobalProcedureListView(GeneralManagementView generalManagementView) {
this(new Stage(), generalManagementView);
}
public GlobalProcedureListView(Stage window, GeneralManagementView generalManagementView) {
super(window);
setGeneralManagementView(generalManagementView);
assignChildren();
assignController(new GlobalProcedureListController(this));
}
public GeneralManagementView getGeneralManagementView() {
return generalManagementView;
}
public void setGeneralManagementView(GeneralManagementView generalManagementView) {
this.generalManagementView = generalManagementView;
}
@Override
public VBox getRoot() {
return root;
}
public void setRoot(VBox root) {
this.root = root;
}
public ScrollPane getScrollPane() {
return scrollPane;
}
public void setScrollPane(ScrollPane scrollPane) {
this.scrollPane = scrollPane;
}
public VBox getProceduresVBox() {
return proceduresVBox;
}
public void setProceduresVBox(VBox proceduresVBox) {
this.proceduresVBox = proceduresVBox;
}
public HBox getButtonsHBox() {
return buttonsHBox;
}
public void setButtonsHBox(HBox buttonsHBox) {
this.buttonsHBox = buttonsHBox;
}
public Button getAddProcedureBtn() {
return addProcedureBtn;
}
public void setAddProcedureBtn(Button addProcedureBtn) {
this.addProcedureBtn = addProcedureBtn;
}
@Override
public void assignChildren() {
setRoot(new VBox());
getRoot().setMaxHeight(Double.POSITIVE_INFINITY);
getRoot().setSpacing(10);
getRoot().setPadding(new Insets(15));
setScrollPane(new ScrollPane());
getScrollPane().setFitToHeight(true);
getScrollPane().setFitToWidth(true);
VBox.setVgrow(getScrollPane(), Priority.ALWAYS);
getRoot().getChildren().add(getScrollPane());
setProceduresVBox(new VBox());
getProceduresVBox().setSpacing(10);
getProceduresVBox().setPadding(new Insets(15));
getScrollPane().setContent(getProceduresVBox());
setButtonsHBox(new HBox());
getButtonsHBox().setAlignment(Pos.TOP_RIGHT);
getRoot().getChildren().add(getButtonsHBox());
setAddProcedureBtn(new Button());
getAddProcedureBtn().setText("Add Procedure");
getAddProcedureBtn().setPrefWidth(120);
getButtonsHBox().getChildren().add(getAddProcedureBtn());
}
}
| UTF-8 | Java | 3,395 | java | GlobalProcedureListView.java | Java | [
{
"context": "\r\nimport javafx.stage.Stage;\r\n\r\n/**\r\n * Created by Shane on 19/03/2017.\r\n */\r\npublic class GlobalProcedure",
"end": 413,
"score": 0.9760239124298096,
"start": 408,
"tag": "USERNAME",
"value": "Shane"
}
] | null | [] | package views;
import controllers.GlobalProcedureListController;
import controllers.ProcedureListController;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* Created by Shane on 19/03/2017.
*/
public class GlobalProcedureListView extends View<GlobalProcedureListController> {
private GeneralManagementView generalManagementView;
private VBox root;
private ScrollPane scrollPane;
private VBox proceduresVBox;
private HBox buttonsHBox;
private Button addProcedureBtn;
public GlobalProcedureListView(GeneralManagementView generalManagementView) {
this(new Stage(), generalManagementView);
}
public GlobalProcedureListView(Stage window, GeneralManagementView generalManagementView) {
super(window);
setGeneralManagementView(generalManagementView);
assignChildren();
assignController(new GlobalProcedureListController(this));
}
public GeneralManagementView getGeneralManagementView() {
return generalManagementView;
}
public void setGeneralManagementView(GeneralManagementView generalManagementView) {
this.generalManagementView = generalManagementView;
}
@Override
public VBox getRoot() {
return root;
}
public void setRoot(VBox root) {
this.root = root;
}
public ScrollPane getScrollPane() {
return scrollPane;
}
public void setScrollPane(ScrollPane scrollPane) {
this.scrollPane = scrollPane;
}
public VBox getProceduresVBox() {
return proceduresVBox;
}
public void setProceduresVBox(VBox proceduresVBox) {
this.proceduresVBox = proceduresVBox;
}
public HBox getButtonsHBox() {
return buttonsHBox;
}
public void setButtonsHBox(HBox buttonsHBox) {
this.buttonsHBox = buttonsHBox;
}
public Button getAddProcedureBtn() {
return addProcedureBtn;
}
public void setAddProcedureBtn(Button addProcedureBtn) {
this.addProcedureBtn = addProcedureBtn;
}
@Override
public void assignChildren() {
setRoot(new VBox());
getRoot().setMaxHeight(Double.POSITIVE_INFINITY);
getRoot().setSpacing(10);
getRoot().setPadding(new Insets(15));
setScrollPane(new ScrollPane());
getScrollPane().setFitToHeight(true);
getScrollPane().setFitToWidth(true);
VBox.setVgrow(getScrollPane(), Priority.ALWAYS);
getRoot().getChildren().add(getScrollPane());
setProceduresVBox(new VBox());
getProceduresVBox().setSpacing(10);
getProceduresVBox().setPadding(new Insets(15));
getScrollPane().setContent(getProceduresVBox());
setButtonsHBox(new HBox());
getButtonsHBox().setAlignment(Pos.TOP_RIGHT);
getRoot().getChildren().add(getButtonsHBox());
setAddProcedureBtn(new Button());
getAddProcedureBtn().setText("Add Procedure");
getAddProcedureBtn().setPrefWidth(120);
getButtonsHBox().getChildren().add(getAddProcedureBtn());
}
}
| 3,395 | 0.677172 | 0.671576 | 113 | 28.044249 | 23.358835 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.504425 | false | false | 0 |
63cb1d723129dc9c5cfdfbe8cb2acc82ae140f2d | 17,171,279,252,116 | b6400c51e916328108fcc4cd417804c992cab322 | /src/com/dp/proxy/Proxy.java | 44acf7d26883dc31032bed144ba04d631c7fef80 | [] | no_license | PlumpMath/DesignPattern-242 | https://github.com/PlumpMath/DesignPattern-242 | 5f137eae641e053fd73a8da7af4e12b15600e9e9 | 0126e2b2f2d968b66d25085901e9b4780058d551 | refs/heads/master | 2021-01-20T09:36:25.680000 | 2017-03-21T07:16:10 | 2017-03-21T07:16:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dp.proxy;
public class Proxy implements IProxy{
IProxy worker = null;
public Proxy(IProxy p)
{
worker = p;
}
@Override
public void operation() {
// TODO Auto-generated method stub
System.out.println("before work...");
worker.operation();
System.out.println("after work...");
}
}
| UTF-8 | Java | 310 | java | Proxy.java | Java | [] | null | [] | package com.dp.proxy;
public class Proxy implements IProxy{
IProxy worker = null;
public Proxy(IProxy p)
{
worker = p;
}
@Override
public void operation() {
// TODO Auto-generated method stub
System.out.println("before work...");
worker.operation();
System.out.println("after work...");
}
}
| 310 | 0.677419 | 0.677419 | 17 | 17.235294 | 14.210723 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.352941 | false | false | 0 |
0039796b6f967031110e53ec7ada3bd5bfd4e979 | 23,210,003,272,293 | 0ffc6a422cbba3853467fc430902e1299c2f1a95 | /src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/PointersObject.java | 4f4741108dd98b4b5a95d7991073d772e68f72d1 | [
"MIT"
] | permissive | hpi-swa/graalsqueak | https://github.com/hpi-swa/graalsqueak | 93fdc00227093293bfb7876f0bde468eb24b2018 | a0f1de39da15d304958b89b326b8dad177344e44 | refs/heads/master | 2021-03-30T18:28:37.691000 | 2021-03-25T14:01:17 | 2021-03-25T15:10:03 | 111,902,034 | 93 | 7 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute
*
* Licensed under the MIT License.
*/
package de.hpi.swa.trufflesqueak.model;
import com.oracle.truffle.api.CompilerAsserts;
import de.hpi.swa.trufflesqueak.image.SqueakImageContext;
import de.hpi.swa.trufflesqueak.image.SqueakImageWriter;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayout;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.ASSOCIATION;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.BINDING;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.FORM;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.FRACTION;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.LINKED_LIST;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.POINT;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.PROCESS;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.SPECIAL_OBJECT;
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectReadNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectWriteNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.SqueakObjectIdentityNode;
import de.hpi.swa.trufflesqueak.util.ObjectGraphUtils.ObjectTracer;
public final class PointersObject extends AbstractPointersObject {
public PointersObject(final SqueakImageContext image) {
super(image); // for special PointersObjects only
}
public PointersObject(final SqueakImageContext image, final long hash, final ClassObject klass) {
super(image, hash, klass);
}
public PointersObject(final SqueakImageContext image, final ClassObject classObject, final ObjectLayout layout) {
super(image, classObject, layout);
}
public PointersObject(final SqueakImageContext image, final ClassObject classObject) {
super(image, classObject);
}
private PointersObject(final PointersObject original) {
super(original);
}
public static PointersObject newHandleWithHiddenObject(final SqueakImageContext image, final Object hiddenObject) {
final PointersObject handle = new PointersObject(image, image.pointClass);
handle.object2 = hiddenObject;
return handle;
}
public Object getHiddenObject() {
assert getSqueakClass().isPoint() && object2 != NilObject.SINGLETON : "Object not a handle with hidden object";
return object2;
}
public void setHiddenObject(final Object value) {
object2 = value;
}
@Override
protected void fillInVariablePart(final Object[] pointers, final int instSize) {
// No variable part to fill in
assert pointers.length == instSize : "Unexpected number of pointers found for " + this;
}
public void become(final PointersObject other) {
becomeLayout(other);
}
@Override
public int size() {
return instsize();
}
public boolean pointsTo(final SqueakObjectIdentityNode identityNode, final Object thang) {
return layoutValuesPointTo(identityNode, thang);
}
public boolean isEmptyList(final AbstractPointersObjectReadNode readNode) {
return readNode.execute(this, LINKED_LIST.FIRST_LINK) == NilObject.SINGLETON;
}
public boolean isDisplay(final SqueakImageContext image) {
return this == image.getSpecialObject(SPECIAL_OBJECT.THE_DISPLAY);
}
public boolean isPoint() {
return getSqueakClass().isPoint();
}
public int[] getFormBits(final AbstractPointersObjectReadNode readNode) {
return readNode.executeNative(this, FORM.BITS).getIntStorage();
}
public int getFormDepth(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.DEPTH);
}
public int getFormHeight(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.HEIGHT);
}
public PointersObject getFormOffset(final AbstractPointersObjectReadNode readNode) {
return readNode.executePointers(this, FORM.OFFSET);
}
public int getFormWidth(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.WIDTH);
}
public PointersObject removeFirstLinkOfList(final AbstractPointersObjectReadNode readNode, final AbstractPointersObjectWriteNode writeNode) {
// Remove the first process from the given linked list.
final PointersObject first = readNode.executePointers(this, LINKED_LIST.FIRST_LINK);
final Object last = readNode.execute(this, LINKED_LIST.LAST_LINK);
if (first == last) {
writeNode.executeNil(this, LINKED_LIST.FIRST_LINK);
writeNode.executeNil(this, LINKED_LIST.LAST_LINK);
} else {
writeNode.execute(this, LINKED_LIST.FIRST_LINK, readNode.execute(first, PROCESS.NEXT_LINK));
}
writeNode.executeNil(first, PROCESS.NEXT_LINK);
return first;
}
public PointersObject shallowCopy() {
return new PointersObject(this);
}
@Override
public void pointersBecomeOneWay(final Object[] from, final Object[] to) {
layoutValuesBecomeOneWay(from, to);
}
@Override
protected void traceVariablePart(final ObjectTracer tracer) {
// nothing to do
}
@Override
protected void traceVariablePart(final SqueakImageWriter writer) {
// nothing to do
}
@Override
protected void writeVariablePart(final SqueakImageWriter writer) {
// nothing to do
}
@Override
public String toString() {
CompilerAsserts.neverPartOfCompilation();
final AbstractPointersObjectReadNode readNode = AbstractPointersObjectReadNode.getUncached();
if (isPoint()) {
return readNode.execute(this, POINT.X) + "@" + readNode.execute(this, POINT.Y);
}
final String squeakClassName = getSqueakClass().getClassName();
if ("Fraction".equals(squeakClassName)) {
return readNode.execute(this, FRACTION.NUMERATOR) + " / " + readNode.execute(this, FRACTION.DENOMINATOR);
}
if ("Association".equals(squeakClassName)) {
return readNode.execute(this, ASSOCIATION.KEY) + " -> " + readNode.execute(this, ASSOCIATION.VALUE);
}
final ClassObject superclass = getSqueakClass().getSuperclassOrNull();
if (superclass != null && "Binding".equals(superclass.getClassName())) {
return readNode.execute(this, BINDING.KEY) + " => " + readNode.execute(this, BINDING.VALUE);
}
return super.toString();
}
}
| UTF-8 | Java | 6,667 | java | PointersObject.java | Java | [] | null | [] | /*
* Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute
*
* Licensed under the MIT License.
*/
package de.hpi.swa.trufflesqueak.model;
import com.oracle.truffle.api.CompilerAsserts;
import de.hpi.swa.trufflesqueak.image.SqueakImageContext;
import de.hpi.swa.trufflesqueak.image.SqueakImageWriter;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayout;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.ASSOCIATION;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.BINDING;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.FORM;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.FRACTION;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.LINKED_LIST;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.POINT;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.PROCESS;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.SPECIAL_OBJECT;
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectReadNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectWriteNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.SqueakObjectIdentityNode;
import de.hpi.swa.trufflesqueak.util.ObjectGraphUtils.ObjectTracer;
public final class PointersObject extends AbstractPointersObject {
public PointersObject(final SqueakImageContext image) {
super(image); // for special PointersObjects only
}
public PointersObject(final SqueakImageContext image, final long hash, final ClassObject klass) {
super(image, hash, klass);
}
public PointersObject(final SqueakImageContext image, final ClassObject classObject, final ObjectLayout layout) {
super(image, classObject, layout);
}
public PointersObject(final SqueakImageContext image, final ClassObject classObject) {
super(image, classObject);
}
private PointersObject(final PointersObject original) {
super(original);
}
public static PointersObject newHandleWithHiddenObject(final SqueakImageContext image, final Object hiddenObject) {
final PointersObject handle = new PointersObject(image, image.pointClass);
handle.object2 = hiddenObject;
return handle;
}
public Object getHiddenObject() {
assert getSqueakClass().isPoint() && object2 != NilObject.SINGLETON : "Object not a handle with hidden object";
return object2;
}
public void setHiddenObject(final Object value) {
object2 = value;
}
@Override
protected void fillInVariablePart(final Object[] pointers, final int instSize) {
// No variable part to fill in
assert pointers.length == instSize : "Unexpected number of pointers found for " + this;
}
public void become(final PointersObject other) {
becomeLayout(other);
}
@Override
public int size() {
return instsize();
}
public boolean pointsTo(final SqueakObjectIdentityNode identityNode, final Object thang) {
return layoutValuesPointTo(identityNode, thang);
}
public boolean isEmptyList(final AbstractPointersObjectReadNode readNode) {
return readNode.execute(this, LINKED_LIST.FIRST_LINK) == NilObject.SINGLETON;
}
public boolean isDisplay(final SqueakImageContext image) {
return this == image.getSpecialObject(SPECIAL_OBJECT.THE_DISPLAY);
}
public boolean isPoint() {
return getSqueakClass().isPoint();
}
public int[] getFormBits(final AbstractPointersObjectReadNode readNode) {
return readNode.executeNative(this, FORM.BITS).getIntStorage();
}
public int getFormDepth(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.DEPTH);
}
public int getFormHeight(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.HEIGHT);
}
public PointersObject getFormOffset(final AbstractPointersObjectReadNode readNode) {
return readNode.executePointers(this, FORM.OFFSET);
}
public int getFormWidth(final AbstractPointersObjectReadNode readNode) {
return readNode.executeInt(this, FORM.WIDTH);
}
public PointersObject removeFirstLinkOfList(final AbstractPointersObjectReadNode readNode, final AbstractPointersObjectWriteNode writeNode) {
// Remove the first process from the given linked list.
final PointersObject first = readNode.executePointers(this, LINKED_LIST.FIRST_LINK);
final Object last = readNode.execute(this, LINKED_LIST.LAST_LINK);
if (first == last) {
writeNode.executeNil(this, LINKED_LIST.FIRST_LINK);
writeNode.executeNil(this, LINKED_LIST.LAST_LINK);
} else {
writeNode.execute(this, LINKED_LIST.FIRST_LINK, readNode.execute(first, PROCESS.NEXT_LINK));
}
writeNode.executeNil(first, PROCESS.NEXT_LINK);
return first;
}
public PointersObject shallowCopy() {
return new PointersObject(this);
}
@Override
public void pointersBecomeOneWay(final Object[] from, final Object[] to) {
layoutValuesBecomeOneWay(from, to);
}
@Override
protected void traceVariablePart(final ObjectTracer tracer) {
// nothing to do
}
@Override
protected void traceVariablePart(final SqueakImageWriter writer) {
// nothing to do
}
@Override
protected void writeVariablePart(final SqueakImageWriter writer) {
// nothing to do
}
@Override
public String toString() {
CompilerAsserts.neverPartOfCompilation();
final AbstractPointersObjectReadNode readNode = AbstractPointersObjectReadNode.getUncached();
if (isPoint()) {
return readNode.execute(this, POINT.X) + "@" + readNode.execute(this, POINT.Y);
}
final String squeakClassName = getSqueakClass().getClassName();
if ("Fraction".equals(squeakClassName)) {
return readNode.execute(this, FRACTION.NUMERATOR) + " / " + readNode.execute(this, FRACTION.DENOMINATOR);
}
if ("Association".equals(squeakClassName)) {
return readNode.execute(this, ASSOCIATION.KEY) + " -> " + readNode.execute(this, ASSOCIATION.VALUE);
}
final ClassObject superclass = getSqueakClass().getSuperclassOrNull();
if (superclass != null && "Binding".equals(superclass.getClassName())) {
return readNode.execute(this, BINDING.KEY) + " => " + readNode.execute(this, BINDING.VALUE);
}
return super.toString();
}
}
| 6,667 | 0.717414 | 0.715614 | 172 | 37.761627 | 35.909061 | 145 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575581 | false | false | 0 |
20f99da06a5021c880ed450be14489bf7bfe782f | 14,104,672,609,979 | c16c84611ed327db16b2d4a0a498a1aa26adbb06 | /src/com/java/pojo/test2email.java | 826e26b03304150d8d81271ba22459cb15696a81 | [] | no_license | redKinge/git-spring02 | https://github.com/redKinge/git-spring02 | 315b92f9264468335070b8914ece3ea605af15ab | 01c029468d836d3be99238926575ce4a7493777b | refs/heads/master | 2023-05-06T02:25:30.501000 | 2021-05-29T01:41:57 | 2021-05-29T01:41:57 | 371,854,652 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.java.pojo;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.util.Properties;
/**
* description:描述
* author: 河发
* time: 23:00
*/
public class test2email {
}
| UTF-8 | Java | 258 | java | test2email.java | Java | [
{
"context": "util.Properties;\n\n/**\n * description:描述\n * author: 河发\n * time: 23:00\n */\npublic class test2email {\n\n\n\n\n",
"end": 198,
"score": 0.9747620224952698,
"start": 196,
"tag": "NAME",
"value": "河发"
}
] | null | [] | package com.java.pojo;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.util.Properties;
/**
* description:描述
* author: 河发
* time: 23:00
*/
public class test2email {
}
| 258 | 0.736 | 0.716 | 18 | 12.888889 | 13.851951 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.277778 | false | false | 0 |
4c3803dd4c724c4c648ff19444486d8459718762 | 17,368,847,812,709 | 6a29d312eef3b99ba08da4a89d93a37b53ffd11d | /src/mdc/strings/StringMethods.java | 7676086ca4ad9ddf4b71090782315cf1192af34c | [] | no_license | mpenapr/java-certification-1z0-808 | https://github.com/mpenapr/java-certification-1z0-808 | 3caee198821be04fb483d038c2593bbe9d2b76b2 | 72a0ad2c9044e7fb72b97ff09bc5fa10ae30cda7 | refs/heads/master | 2023-01-31T15:34:56.679000 | 2020-12-11T00:49:33 | 2020-12-11T00:49:33 | 302,190,842 | 0 | 0 | null | true | 2020-12-11T00:49:34 | 2020-10-08T00:12:19 | 2020-12-09T00:57:07 | 2020-12-11T00:49:33 | 282 | 0 | 0 | 0 | Java | false | false | package mdc.strings;
import java.util.Scanner;
public class StringMethods {
static int number;
public static void main(String[] args) {
// 0 1 2 3 4 5 6 7 8 9 10 ==> index is always length - 1
// J a v a i s f u n => length = 11
String str = "Java is fun";
// length
System.out.println("length = " + str.length()); // returns length = 11
//chat at
Scanner input = new Scanner(System.in);
System.out.print("Enter a number from 0 to 10 >> ");
number = input.nextInt();
if (number < 0 || number > 10){
System.out.println("Invalid entry again");
}else {
if (str.charAt(number) == ' ')
System.out.println("element at position " + number + " : empty space");
else
System.out.println("element at position " + number + " : " + str.charAt(number));
}
//System.out.println(str.charAt(2));
//System.out.println(str.charAt(6));
// index of
System.out.println(str.indexOf('a')); // where in the array is 'a'
System.out.println(str.indexOf('a', 2)); // character 'a' starting at position 2
System.out.println(str.indexOf("fun")); // returns 8 bc the fun starts at index 8
System.out.println(str.indexOf("f", 10)); // returns -1
System.out.println(str.indexOf('n')); // returns 10
System.out.println(str.indexOf("Java", 2)); // returns -1
System.out.println(str.indexOf("n", 10)); // returns 10
System.out.println(str.indexOf("Java", 0)); // returns 0
// substring
System.out.println(str.substring(6));
System.out.println(str.substring(0, 5)); // returns "Java " because the "ToIndex" value is NOT inclusive
System.out.println(str.substring(4, 4)); // returns an empty string when the fromIndex and toIndex are the same
System.out.println(str.substring(3, 3)); // returns an empty string when the fromIndex and toIndex are the same
//System.out.println(str.substring(14, 14)); // returns StringIndexOutOfBoundsException
//System.out.println(str.substring(4, 2)); // returns StringIndexOutOfBoundsException because the fromIndex value
// is bigger than the toIndex value
//System.out.println(str.substring(8, 14)); // returns StringIndexOutOfBoundsException because index 14 does not exist
// toLowerCase()
System.out.println("AbCd".toLowerCase()); // returns abcd
System.out.println(str.toUpperCase()); // JAVA IS FUN
//str.toUpperCase(); is completely ignored because the expression returns a new string
System.out.println(str); // this will print the original string "Java is fun"
String dog = "Lucky";
System.out.println("dog hash code = " + System.identityHashCode(dog));
//dog.toUpperCase(); will not do anything bc strings are immutable
dog = dog.toUpperCase();
System.out.println("dog hash code = " + System.identityHashCode(dog));
System.out.println(dog);
}
}
| UTF-8 | Java | 3,137 | java | StringMethods.java | Java | [] | null | [] | package mdc.strings;
import java.util.Scanner;
public class StringMethods {
static int number;
public static void main(String[] args) {
// 0 1 2 3 4 5 6 7 8 9 10 ==> index is always length - 1
// J a v a i s f u n => length = 11
String str = "Java is fun";
// length
System.out.println("length = " + str.length()); // returns length = 11
//chat at
Scanner input = new Scanner(System.in);
System.out.print("Enter a number from 0 to 10 >> ");
number = input.nextInt();
if (number < 0 || number > 10){
System.out.println("Invalid entry again");
}else {
if (str.charAt(number) == ' ')
System.out.println("element at position " + number + " : empty space");
else
System.out.println("element at position " + number + " : " + str.charAt(number));
}
//System.out.println(str.charAt(2));
//System.out.println(str.charAt(6));
// index of
System.out.println(str.indexOf('a')); // where in the array is 'a'
System.out.println(str.indexOf('a', 2)); // character 'a' starting at position 2
System.out.println(str.indexOf("fun")); // returns 8 bc the fun starts at index 8
System.out.println(str.indexOf("f", 10)); // returns -1
System.out.println(str.indexOf('n')); // returns 10
System.out.println(str.indexOf("Java", 2)); // returns -1
System.out.println(str.indexOf("n", 10)); // returns 10
System.out.println(str.indexOf("Java", 0)); // returns 0
// substring
System.out.println(str.substring(6));
System.out.println(str.substring(0, 5)); // returns "Java " because the "ToIndex" value is NOT inclusive
System.out.println(str.substring(4, 4)); // returns an empty string when the fromIndex and toIndex are the same
System.out.println(str.substring(3, 3)); // returns an empty string when the fromIndex and toIndex are the same
//System.out.println(str.substring(14, 14)); // returns StringIndexOutOfBoundsException
//System.out.println(str.substring(4, 2)); // returns StringIndexOutOfBoundsException because the fromIndex value
// is bigger than the toIndex value
//System.out.println(str.substring(8, 14)); // returns StringIndexOutOfBoundsException because index 14 does not exist
// toLowerCase()
System.out.println("AbCd".toLowerCase()); // returns abcd
System.out.println(str.toUpperCase()); // JAVA IS FUN
//str.toUpperCase(); is completely ignored because the expression returns a new string
System.out.println(str); // this will print the original string "Java is fun"
String dog = "Lucky";
System.out.println("dog hash code = " + System.identityHashCode(dog));
//dog.toUpperCase(); will not do anything bc strings are immutable
dog = dog.toUpperCase();
System.out.println("dog hash code = " + System.identityHashCode(dog));
System.out.println(dog);
}
}
| 3,137 | 0.605355 | 0.586229 | 67 | 45.820896 | 36.483456 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.761194 | false | false | 0 |
b2487c747fabe941be24f7ec6d1e848c0b520179 | 14,173,392,094,192 | ad828ffb2d5a3051b62ac758e06a9f172c4eb848 | /week3/src/test/java/ie/gmit/softwareeng/week3/ex1/Exercise1.java | 814d142ec30ebfd5fa8bc4b0e82eb79d6404fc94 | [] | no_license | eamonncollins/SoftwareEngAndTest | https://github.com/eamonncollins/SoftwareEngAndTest | d397df6f03077aa731c71107ebe27ba51e4bf05e | 5e9ba2cd98f0e311e664662de3605842c6a1f05f | refs/heads/master | 2020-05-03T04:34:55.252000 | 2019-03-29T15:28:07 | 2019-03-29T15:28:07 | 178,425,673 | 0 | 0 | null | true | 2019-03-29T14:59:01 | 2019-03-29T14:59:00 | 2019-03-06T22:08:05 | 2019-03-29T14:58:55 | 7,964 | 0 | 0 | 0 | null | false | null | package ie.gmit.softwareeng.week3.ex1;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class Exercise1 {
@Mock
DayOfTheWeek dayOfTheWeek;
@Test
public void testWeekday() {
when(dayOfTheWeek.getDay()).thenReturn("THURSDAY");
WeekendChecker weekendChecker = new WeekendChecker(dayOfTheWeek);
String isWeekend = weekendChecker.isWeekend();
assertEquals("It's not the weekend yet", isWeekend);
}
@Test
public void testWeekend() {
when(dayOfTheWeek.getDay()).thenReturn("SATURDAY");
WeekendChecker weekendChecker = new WeekendChecker(dayOfTheWeek);
String isWeekend = weekendChecker.isWeekend();
assertEquals("It's the weekend!", isWeekend);
}
}
| UTF-8 | Java | 952 | java | Exercise1.java | Java | [] | null | [] | package ie.gmit.softwareeng.week3.ex1;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class Exercise1 {
@Mock
DayOfTheWeek dayOfTheWeek;
@Test
public void testWeekday() {
when(dayOfTheWeek.getDay()).thenReturn("THURSDAY");
WeekendChecker weekendChecker = new WeekendChecker(dayOfTheWeek);
String isWeekend = weekendChecker.isWeekend();
assertEquals("It's not the weekend yet", isWeekend);
}
@Test
public void testWeekend() {
when(dayOfTheWeek.getDay()).thenReturn("SATURDAY");
WeekendChecker weekendChecker = new WeekendChecker(dayOfTheWeek);
String isWeekend = weekendChecker.isWeekend();
assertEquals("It's the weekend!", isWeekend);
}
}
| 952 | 0.713235 | 0.710084 | 36 | 25.444445 | 23.759727 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 0 |
fc1747ed033f568c1ac8e9cff7b86f32563471ee | 32,134,945,332,523 | df3699bf78aa480f28472b6b23b6634fcc366595 | /NCT/src/main/java/ie/cit/adf/domain/dao/JdbcVehicleRepository.java | 16c1697628e8fec99375823f16136eb6de9b3ace | [] | no_license | DeclanHurney/NCT | https://github.com/DeclanHurney/NCT | d25cbff30c9652b76c371f84cf5b58554055ac9e | 3e10a538ecc9340b51516a28181a7051c5495a6f | refs/heads/master | 2021-01-10T19:39:08.844000 | 2013-05-13T20:45:08 | 2013-05-13T20:45:08 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ie.cit.adf.domain.dao;
import ie.cit.adf.domain.Vehicle;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
public class JdbcVehicleRepository implements VehicleRepository{
private JdbcTemplate jdbcTemplate;
private VehicleMapper vehicleMapper = new VehicleMapper();
public JdbcVehicleRepository(DataSource dataSource){
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
public Vehicle findById(String vehicleId) {
return jdbcTemplate.queryForObject(
"SELECT VEHICLEID, VEHICLEMAKE, VEHICLEMODEL, VEHICLEREGISTRATION FROM VEHICLES " +
"WHERE VEHICLEID = ?", vehicleMapper, vehicleId);
}
@Override
public List<Vehicle> getAll() {
return jdbcTemplate.query(
"SELECT * FROM VEHICLES", vehicleMapper);
}
@Override
public void add(Vehicle vehicle) {
jdbcTemplate.update("INSERT INTO VEHICLES (VEHICLEID, VEHICLEMAKE,VEHICLEMODEL,VEHICLEREGISTRATION) VALUES(?,?,?,?)",
vehicle.getVehicleId(), vehicle.getVehicleMake(), vehicle.getVehicleModel(),
vehicle.getRegistration());
}
class VehicleMapper implements RowMapper<Vehicle>{
@Override
public Vehicle mapRow(ResultSet rs, int rowNum) throws SQLException {
Vehicle vehicle = new Vehicle(rs.getString("VEHICLEMAKE"), rs.getString("VEHICLEMODEL"));
vehicle.setRegistration(rs.getString("VEHICLEREGISTRATION"));
vehicle.setVehicleId(rs.getString("VEHICLEID"));
return vehicle;
}
}
}
| UTF-8 | Java | 1,568 | java | JdbcVehicleRepository.java | Java | [] | null | [] | package ie.cit.adf.domain.dao;
import ie.cit.adf.domain.Vehicle;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
public class JdbcVehicleRepository implements VehicleRepository{
private JdbcTemplate jdbcTemplate;
private VehicleMapper vehicleMapper = new VehicleMapper();
public JdbcVehicleRepository(DataSource dataSource){
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
public Vehicle findById(String vehicleId) {
return jdbcTemplate.queryForObject(
"SELECT VEHICLEID, VEHICLEMAKE, VEHICLEMODEL, VEHICLEREGISTRATION FROM VEHICLES " +
"WHERE VEHICLEID = ?", vehicleMapper, vehicleId);
}
@Override
public List<Vehicle> getAll() {
return jdbcTemplate.query(
"SELECT * FROM VEHICLES", vehicleMapper);
}
@Override
public void add(Vehicle vehicle) {
jdbcTemplate.update("INSERT INTO VEHICLES (VEHICLEID, VEHICLEMAKE,VEHICLEMODEL,VEHICLEREGISTRATION) VALUES(?,?,?,?)",
vehicle.getVehicleId(), vehicle.getVehicleMake(), vehicle.getVehicleModel(),
vehicle.getRegistration());
}
class VehicleMapper implements RowMapper<Vehicle>{
@Override
public Vehicle mapRow(ResultSet rs, int rowNum) throws SQLException {
Vehicle vehicle = new Vehicle(rs.getString("VEHICLEMAKE"), rs.getString("VEHICLEMODEL"));
vehicle.setRegistration(rs.getString("VEHICLEREGISTRATION"));
vehicle.setVehicleId(rs.getString("VEHICLEID"));
return vehicle;
}
}
}
| 1,568 | 0.770408 | 0.770408 | 50 | 30.360001 | 28.763004 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.96 | false | false | 0 |
632d54282060a6a206b45a15a029dffcd2b0a799 | 18,468,359,383,508 | e1d41991a9b8c9969c886300197ed6519dc92599 | /src/com/tfarm/board/controller/BoardController.java | 2c2375e02ba4b5e215ae5b1e4666e6c37d76a0a3 | [] | no_license | tmzmfldkqls/tfarm-2 | https://github.com/tmzmfldkqls/tfarm-2 | 3b9de93911e788a7c192ce659b2285396b85ead0 | 74c935ca95d22dace8e24ebce17d17c83e09c627 | refs/heads/master | 2021-05-11T18:07:01.556000 | 2018-01-31T09:45:43 | 2018-01-31T09:45:43 | 117,816,411 | 0 | 0 | null | true | 2018-01-17T09:45:08 | 2018-01-17T09:45:08 | 2018-01-17T09:42:09 | 2018-01-17T09:42:07 | 0 | 0 | 0 | 0 | null | false | null | package com.tfarm.board.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
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.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.tfarm.member.model.MemberDto;
import com.tfarm.admin.board.model.BoardListDto;
import com.tfarm.admin.board.service.BoardAdminService;
import com.tfarm.board.model.BoardDto;
import com.tfarm.board.model.ReboardDto;
import com.tfarm.board.service.BoardService;
import com.tfarm.common.service.CommonService;
import com.tfarm.util.BoardConstance;
import com.tfarm.util.PageNavigation;
@Controller
@RequestMapping("/board")
public class BoardController {
@Autowired
private BoardService boardService;
@Autowired
private BoardAdminService boardAdminService;
@Autowired
private CommonService commonService;
@RequestMapping("/boardmenu.tfarm")
public String boardMenu(HttpServletRequest request) {
List<BoardListDto> list = boardAdminService.boardMenu();
System.out.println("갯수 : " + list.size());
ServletContext context = request.getServletContext();
context.setAttribute("boardmenu", list);
return "redirect:/index.jsp";
}
@RequestMapping(value = "/list.tfarm", method = RequestMethod.GET)
public ModelAndView list(@RequestParam Map<String, String> map, HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
List<ReboardDto> list = boardService.listArticle(map);
map.put("listsize", BoardConstance.BOARD_LIST_SIZE + "");
PageNavigation navigation = commonService.makePageNavigation(map);
navigation.setRoot(request.getContextPath());
navigation.setBcode(Integer.parseInt(map.get("bcode")));
navigation.setKey(map.get("key"));
navigation.setWord(map.get("word"));
navigation.setNavigator();
mav.addObject("articlelist", list);
mav.addObject("navigator", navigation);
mav.addObject("querystring", map);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/list");
return mav;
}
@RequestMapping(value = "/write.tfarm", method = RequestMethod.GET)
public ModelAndView write(@RequestParam Map<String, String> map) {
ModelAndView mav = new ModelAndView();
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
mav.addObject("querystring", map);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/write");
return mav;
}
@RequestMapping(value = "/write.tfarm", method = RequestMethod.POST)
public ModelAndView write(ReboardDto reboardDto, @RequestParam Map<String, String> map, HttpSession session) {
ModelAndView mav = new ModelAndView();
int seq = commonService.getNextSeq();
reboardDto.setSeq(seq);
reboardDto.setId("admin");
reboardDto.setEmail("admin@tfarm.com");
int cnt = boardService.writeArticle(reboardDto);
System.out.println(cnt);
mav.addObject("querystring", map);
mav.addObject("seq", seq);
if (cnt != 0) {
mav.setViewName("/WEB-INF/notice/writeok");
} else {
mav.setViewName("/WEB-INF/notice/writefail");
}
return mav;
}
@RequestMapping(value="/view.tfarm", method=RequestMethod.GET)
public ModelAndView view(@RequestParam Map<String, String> map,
HttpSession session) {
ModelAndView mav = new ModelAndView();
// MemberDto memberDto = (MemberDto) session.getAttribute("userInfo");
// if(memberDto != null) {
int seq = Integer.parseInt(map.get("seq"));
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
System.out.println(category);
BoardDto boardDto = boardService.viewArticle(seq);
mav.addObject("querystring", map);
mav.addObject("article", boardDto);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/view");
// } else {
// mav.setViewName("/login/login");
// }
return mav;
}
}
| UTF-8 | Java | 4,341 | java | BoardController.java | Java | [
{
"context": ";\r\n\t\treboardDto.setSeq(seq);\r\n\t\treboardDto.setId(\"admin\");\r\n\t\treboardDto.setEmail(\"admin@tfarm.com\");\r\n\t\t",
"end": 3212,
"score": 0.9613637328147888,
"start": 3207,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "eboardDto.setId(\"admin\");\r\n\t\treboardDto.setEmail(\"admin@tfarm.com\");\r\n\t\tint cnt = boardService.writeArticle(reboard",
"end": 3255,
"score": 0.999927818775177,
"start": 3240,
"tag": "EMAIL",
"value": "admin@tfarm.com"
}
] | null | [] | package com.tfarm.board.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
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.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.tfarm.member.model.MemberDto;
import com.tfarm.admin.board.model.BoardListDto;
import com.tfarm.admin.board.service.BoardAdminService;
import com.tfarm.board.model.BoardDto;
import com.tfarm.board.model.ReboardDto;
import com.tfarm.board.service.BoardService;
import com.tfarm.common.service.CommonService;
import com.tfarm.util.BoardConstance;
import com.tfarm.util.PageNavigation;
@Controller
@RequestMapping("/board")
public class BoardController {
@Autowired
private BoardService boardService;
@Autowired
private BoardAdminService boardAdminService;
@Autowired
private CommonService commonService;
@RequestMapping("/boardmenu.tfarm")
public String boardMenu(HttpServletRequest request) {
List<BoardListDto> list = boardAdminService.boardMenu();
System.out.println("갯수 : " + list.size());
ServletContext context = request.getServletContext();
context.setAttribute("boardmenu", list);
return "redirect:/index.jsp";
}
@RequestMapping(value = "/list.tfarm", method = RequestMethod.GET)
public ModelAndView list(@RequestParam Map<String, String> map, HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
List<ReboardDto> list = boardService.listArticle(map);
map.put("listsize", BoardConstance.BOARD_LIST_SIZE + "");
PageNavigation navigation = commonService.makePageNavigation(map);
navigation.setRoot(request.getContextPath());
navigation.setBcode(Integer.parseInt(map.get("bcode")));
navigation.setKey(map.get("key"));
navigation.setWord(map.get("word"));
navigation.setNavigator();
mav.addObject("articlelist", list);
mav.addObject("navigator", navigation);
mav.addObject("querystring", map);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/list");
return mav;
}
@RequestMapping(value = "/write.tfarm", method = RequestMethod.GET)
public ModelAndView write(@RequestParam Map<String, String> map) {
ModelAndView mav = new ModelAndView();
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
mav.addObject("querystring", map);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/write");
return mav;
}
@RequestMapping(value = "/write.tfarm", method = RequestMethod.POST)
public ModelAndView write(ReboardDto reboardDto, @RequestParam Map<String, String> map, HttpSession session) {
ModelAndView mav = new ModelAndView();
int seq = commonService.getNextSeq();
reboardDto.setSeq(seq);
reboardDto.setId("admin");
reboardDto.setEmail("<EMAIL>");
int cnt = boardService.writeArticle(reboardDto);
System.out.println(cnt);
mav.addObject("querystring", map);
mav.addObject("seq", seq);
if (cnt != 0) {
mav.setViewName("/WEB-INF/notice/writeok");
} else {
mav.setViewName("/WEB-INF/notice/writefail");
}
return mav;
}
@RequestMapping(value="/view.tfarm", method=RequestMethod.GET)
public ModelAndView view(@RequestParam Map<String, String> map,
HttpSession session) {
ModelAndView mav = new ModelAndView();
// MemberDto memberDto = (MemberDto) session.getAttribute("userInfo");
// if(memberDto != null) {
int seq = Integer.parseInt(map.get("seq"));
String category = commonService.getCategory(Integer.parseInt(map.get("bcode")));
System.out.println(category);
BoardDto boardDto = boardService.viewArticle(seq);
mav.addObject("querystring", map);
mav.addObject("article", boardDto);
mav.addObject("category", category);
mav.setViewName("/WEB-INF/notice/view");
// } else {
// mav.setViewName("/login/login");
// }
return mav;
}
}
| 4,333 | 0.735993 | 0.735762 | 118 | 34.754238 | 23.543303 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.118644 | false | false | 0 |
409708f98e8db665ae3993c43ea15d45074cd4a7 | 14,766,097,612,828 | 782bc67db31e3326ec44cc4e6ed969d7a0afe552 | /demo/src/main/java/com/zzs/demo/controller/ActionResult.java | 18f500d78e40f8a8ea46fa4127d9e2f7fb0b01d9 | [] | no_license | jenson-zzs/Jenson_ING | https://github.com/jenson-zzs/Jenson_ING | 30277eb05ba940ce15d69ae97531ce7c41fc16c1 | e31443aec306223f302a9e154d48522b80f84631 | refs/heads/master | 2022-12-08T13:20:50.874000 | 2020-08-22T06:45:47 | 2020-08-22T06:45:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zzs.demo.controller;
import java.util.Map;
public class ActionResult {
private Boolean status;
private String msg;
private Map<String, Object> data;
public Boolean getStatus() {
return status;
}
public String getMsg() {
return msg;
}
public Map<String, Object> getData() {
return data;
}
public void setStatus(Boolean status) {
this.status = status;
}
public void setStatusAndMsg(Boolean status, String msg) {
this.status = status;
this.msg = msg;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public ActionResult() {
status = true;
msg = "Action success";
}
public ActionResult(Boolean status, String msg) {
this.status = status;
this.msg = msg;
}
}
| UTF-8 | Java | 778 | java | ActionResult.java | Java | [] | null | [] | package com.zzs.demo.controller;
import java.util.Map;
public class ActionResult {
private Boolean status;
private String msg;
private Map<String, Object> data;
public Boolean getStatus() {
return status;
}
public String getMsg() {
return msg;
}
public Map<String, Object> getData() {
return data;
}
public void setStatus(Boolean status) {
this.status = status;
}
public void setStatusAndMsg(Boolean status, String msg) {
this.status = status;
this.msg = msg;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public ActionResult() {
status = true;
msg = "Action success";
}
public ActionResult(Boolean status, String msg) {
this.status = status;
this.msg = msg;
}
}
| 778 | 0.651671 | 0.651671 | 40 | 17.450001 | 15.444983 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.65 | false | false | 0 |
ef0216eea1286cb3a53bcb67193937d2e8766707 | 26,903,675,146,988 | a4cf8f746d9920402f7f866affe80214541a405a | /src/main/java/BurrowsWheeler.java | 70b68986eea5a0f4eabd3cd84ad214b8b88aeebb | [] | no_license | Kamil-Krynicki/Princeton-algorithms-coursera | https://github.com/Kamil-Krynicki/Princeton-algorithms-coursera | a8b5e86339e85fb039c923a4ea0880d8a3db5f76 | d5950125b17763dedfef4d4d8838cc2e69b3bd93 | refs/heads/master | 2020-12-02T21:53:11.327000 | 2017-11-21T15:12:04 | 2017-11-21T15:12:04 | 67,534,760 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import edu.princeton.cs.algs4.BinaryStdIn;
import edu.princeton.cs.algs4.BinaryStdOut;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public class BurrowsWheeler {
// apply Burrows-Wheeler encoding, reading from standard input and writing to standard output
public static void encode() {
char[] input = BinaryStdIn.readString().toCharArray();
CircularSuffixArray csa = new CircularSuffixArray(String.valueOf(input));
char[] result = new char[input.length];
for (int i = 0; i < input.length; i++) {
if (csa.index(i) == 0) {
result[i] = input[input.length - 1];
BinaryStdOut.write(i);
} else {
result[i] = input[csa.index(i) - 1];
}
}
BinaryStdOut.write(new String(result));
BinaryStdOut.close();
}
// apply Burrows-Wheeler decoding, reading from standard input and writing to standard output
public static void decode() {
int first = BinaryStdIn.readInt();
char[] t = BinaryStdIn.readString().toCharArray();
char[] f = linearSort(t);
int[] next = generateNext(t, f);
int current = first;
for (int i = 0; i < next.length; i++) {
BinaryStdOut.write(f[current]);
current = next[current];
}
BinaryStdOut.close();
}
private static int[] generateNext(char[] t, char[] f) {
Map<Character, Deque<Integer>> positions = invertIndex(t);
int[] next = new int[t.length];
for (int i = 0; i < next.length; i++)
next[i] = positions.get(f[i]).pop();
return next;
}
private static Map<Character, Deque<Integer>> invertIndex(char[] t) {
Map<Character, Deque<Integer>> result = new HashMap<>();
for (int i = 0; i < t.length; i++) {
if (!result.containsKey(t[i]))
result.put(t[i], new LinkedList<>());
result.get(t[i]).addLast(i);
}
return result;
}
private static char[] linearSort(char[] input) {
int[] counts = counts(input);
char[] result = new char[input.length];
int letter = 0;
for (int i = 0; i < counts.length; i++)
while (counts[i]-- > 0)
result[letter++] = (char) i;
return result;
}
private static int[] counts(char[] input) {
int[] result = new int[2 << 8];
for (char c : input)
result[c]++;
return result;
}
// if args[0] is '-', apply Burrows-Wheeler encoding
// if args[0] is '+', apply Burrows-Wheeler decoding
public static void main(String[] args) {
if (args.length > 0) {
switch (args[0].charAt(0)) {
case '-':
encode();
break;
case '+':
decode();
break;
}
}
}
} | UTF-8 | Java | 3,009 | java | BurrowsWheeler.java | Java | [] | null | [] | import edu.princeton.cs.algs4.BinaryStdIn;
import edu.princeton.cs.algs4.BinaryStdOut;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public class BurrowsWheeler {
// apply Burrows-Wheeler encoding, reading from standard input and writing to standard output
public static void encode() {
char[] input = BinaryStdIn.readString().toCharArray();
CircularSuffixArray csa = new CircularSuffixArray(String.valueOf(input));
char[] result = new char[input.length];
for (int i = 0; i < input.length; i++) {
if (csa.index(i) == 0) {
result[i] = input[input.length - 1];
BinaryStdOut.write(i);
} else {
result[i] = input[csa.index(i) - 1];
}
}
BinaryStdOut.write(new String(result));
BinaryStdOut.close();
}
// apply Burrows-Wheeler decoding, reading from standard input and writing to standard output
public static void decode() {
int first = BinaryStdIn.readInt();
char[] t = BinaryStdIn.readString().toCharArray();
char[] f = linearSort(t);
int[] next = generateNext(t, f);
int current = first;
for (int i = 0; i < next.length; i++) {
BinaryStdOut.write(f[current]);
current = next[current];
}
BinaryStdOut.close();
}
private static int[] generateNext(char[] t, char[] f) {
Map<Character, Deque<Integer>> positions = invertIndex(t);
int[] next = new int[t.length];
for (int i = 0; i < next.length; i++)
next[i] = positions.get(f[i]).pop();
return next;
}
private static Map<Character, Deque<Integer>> invertIndex(char[] t) {
Map<Character, Deque<Integer>> result = new HashMap<>();
for (int i = 0; i < t.length; i++) {
if (!result.containsKey(t[i]))
result.put(t[i], new LinkedList<>());
result.get(t[i]).addLast(i);
}
return result;
}
private static char[] linearSort(char[] input) {
int[] counts = counts(input);
char[] result = new char[input.length];
int letter = 0;
for (int i = 0; i < counts.length; i++)
while (counts[i]-- > 0)
result[letter++] = (char) i;
return result;
}
private static int[] counts(char[] input) {
int[] result = new int[2 << 8];
for (char c : input)
result[c]++;
return result;
}
// if args[0] is '-', apply Burrows-Wheeler encoding
// if args[0] is '+', apply Burrows-Wheeler decoding
public static void main(String[] args) {
if (args.length > 0) {
switch (args[0].charAt(0)) {
case '-':
encode();
break;
case '+':
decode();
break;
}
}
}
} | 3,009 | 0.530076 | 0.523762 | 105 | 27.666666 | 22.875092 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.590476 | false | false | 0 |
43852df37e5a71b3a2ea4e779cd118b602c8e39a | 16,458,314,699,872 | eef14d12365c3afcd964def36d24df249ddb6b53 | /ex2APC2/src/ex2apc2/Xpto.java | 1ad6b97e3d41b1146aeaec14b7eeb98197f769b3 | [] | no_license | PatriciaDuarte/Java | https://github.com/PatriciaDuarte/Java | 78eeb17bc55e15862d60fd57032318407d9cb052 | 8e0ea2419ed7ff833ec6767b666b8277b5fd55ca | refs/heads/master | 2020-06-03T05:49:51.425000 | 2019-06-12T01:19:28 | 2019-06-12T01:19:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ex2apc2;
public class Xpto
{
//VARIAVEIS DE INSTANCIA
private int a;
private int b;
private int c;
//CONSTRUTOR
public Xpto()
{
a = 0;
b=0;
c=0;
}
public Xpto (int a, int b, int c)
{
seta(a);
setb(b);
setc(c);
}
public int geta()
{
return a;
}
public void seta(int a)
{
this.a = a;
}
public int getb()
{
return b;
}
public void setb(int b)
{
this.b = b;
}
public int getc()
{
return c;
}
public void setc(int c)
{
this.c = c;
}
//METODOS
public int produto()
{
return (a*b*c);
}
public int soma()
{
return (a+b+c);
}
} | UTF-8 | Java | 875 | java | Xpto.java | Java | [] | null | [] | package ex2apc2;
public class Xpto
{
//VARIAVEIS DE INSTANCIA
private int a;
private int b;
private int c;
//CONSTRUTOR
public Xpto()
{
a = 0;
b=0;
c=0;
}
public Xpto (int a, int b, int c)
{
seta(a);
setb(b);
setc(c);
}
public int geta()
{
return a;
}
public void seta(int a)
{
this.a = a;
}
public int getb()
{
return b;
}
public void setb(int b)
{
this.b = b;
}
public int getc()
{
return c;
}
public void setc(int c)
{
this.c = c;
}
//METODOS
public int produto()
{
return (a*b*c);
}
public int soma()
{
return (a+b+c);
}
} | 875 | 0.378286 | 0.372571 | 64 | 11.703125 | 8.6849 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 0 |
f7df21b84be60ffbdebe99ccd20c7fbe2015b414 | 6,408,091,229,022 | deb923683deac60d51ca204c4fc22f3aa57cd2d8 | /src/model/TipoTransaccion.java | 609abf235ca5d087f7663e33989cd550e6405398 | [] | no_license | mvargass/tiendita | https://github.com/mvargass/tiendita | 5aa987d39f598b717ee0b9111c714d76e79868dc | 6fdc08adcf10296ffe6883b00323633b5605f5bc | refs/heads/master | 2021-05-01T22:04:48.978000 | 2018-02-24T05:51:58 | 2018-02-24T05:51:58 | 120,985,499 | 0 | 0 | null | false | 2018-02-24T05:32:29 | 2018-02-10T04:54:23 | 2018-02-23T05:30:44 | 2018-02-24T05:32:29 | 21,594 | 0 | 0 | 0 | HTML | false | null | package model;
/**
*
* @author Mario
*/
public enum TipoTransaccion {
VENTA
,COMPRA;
}
| UTF-8 | Java | 109 | java | TipoTransaccion.java | Java | [
{
"context": "package model;\r\n\r\n/**\r\n *\r\n * @author Mario\r\n */\r\npublic enum TipoTransaccion {\r\n VENTA\r\n ",
"end": 43,
"score": 0.9995555877685547,
"start": 38,
"tag": "NAME",
"value": "Mario"
}
] | null | [] | package model;
/**
*
* @author Mario
*/
public enum TipoTransaccion {
VENTA
,COMPRA;
}
| 109 | 0.541284 | 0.541284 | 10 | 8.9 | 8.653901 | 29 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | false | false | 0 |
6c8c746476eea22791e28769222668237c701334 | 3,470,333,587,530 | a1c8c5f33fc3c7f79ae22b13d4b8cc454b8b1b8d | /src/main/java/demo/file/scanner/filescanner/FileScannerApplication.java | edb2f2745e7f2c612f2103d574ebb31a8bc80426 | [] | no_license | tinhtinhcd/file-scanner | https://github.com/tinhtinhcd/file-scanner | 457f3c3d9c68d5fc3772fda8842d6c9853646137 | 32c49446b6aea5ef47471d4a0a732681fc02f4d7 | refs/heads/main | 2023-04-03T11:02:15.947000 | 2021-04-02T02:16:24 | 2021-04-02T02:16:24 | 353,532,351 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package demo.file.scanner.filescanner;
import demo.file.scanner.filescanner.component.CommandHelper;
import demo.file.scanner.filescanner.component.Uploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.util.Scanner;
@SpringBootApplication
public class FileScannerApplication implements CommandLineRunner {
@Autowired
CommandHelper commandHelper;
@Autowired
Uploader uploader;
public static void main(String[] args) {
SpringApplication.run(FileScannerApplication.class, args);
}
/**
* application listen to the input from command line.
* if command start with exit or -e then terminate the application
* if command start with upload or -u then validate, lookup and upload.
* or else show the command helper.
*/
@Override
public void run(String... args) {
commandHelper.listCommand();
Scanner in = new Scanner(System.in);
while (in.hasNext()){
String s = in.nextLine();
if(s.equalsIgnoreCase("exit") || s.equals("-e"))
System.exit(0);
else if(s.startsWith("upload")||s.startsWith("Upload")||s.startsWith("-u")){
uploader.upload(s);
}
else {
System.out.printf("command not found: '" +s+ "'");
commandHelper.listCommand();
}
}
}
/**
* create bean for restTemplate that using by lookup and upload
* */
@Bean
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
return restTemplate;
}
}
| UTF-8 | Java | 2,019 | java | FileScannerApplication.java | Java | [] | null | [] | package demo.file.scanner.filescanner;
import demo.file.scanner.filescanner.component.CommandHelper;
import demo.file.scanner.filescanner.component.Uploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.util.Scanner;
@SpringBootApplication
public class FileScannerApplication implements CommandLineRunner {
@Autowired
CommandHelper commandHelper;
@Autowired
Uploader uploader;
public static void main(String[] args) {
SpringApplication.run(FileScannerApplication.class, args);
}
/**
* application listen to the input from command line.
* if command start with exit or -e then terminate the application
* if command start with upload or -u then validate, lookup and upload.
* or else show the command helper.
*/
@Override
public void run(String... args) {
commandHelper.listCommand();
Scanner in = new Scanner(System.in);
while (in.hasNext()){
String s = in.nextLine();
if(s.equalsIgnoreCase("exit") || s.equals("-e"))
System.exit(0);
else if(s.startsWith("upload")||s.startsWith("Upload")||s.startsWith("-u")){
uploader.upload(s);
}
else {
System.out.printf("command not found: '" +s+ "'");
commandHelper.listCommand();
}
}
}
/**
* create bean for restTemplate that using by lookup and upload
* */
@Bean
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
return restTemplate;
}
}
| 2,019 | 0.76424 | 0.762754 | 69 | 28.26087 | 26.732519 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.550725 | false | false | 0 |
5ce51f2c4cc397c4e060eab0612999234c9c4838 | 472,446,418,951 | cca9558c57c026914460794d1a6d98ffedc617d1 | /proto/src/main/java/jshdc/type/TemplateType.java | b9e6541e789947f5ad959ef96ca123d134960c1e | [] | no_license | yinghuihong/JSHDC_Platform | https://github.com/yinghuihong/JSHDC_Platform | 9dc0d2660b03e059864f2d581bff21bf30544f22 | c0b39f4950d9f229ed87adc6111905eebd316af6 | refs/heads/master | 2020-04-10T03:51:56.137000 | 2016-06-12T16:14:12 | 2016-06-12T16:14:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package jshdc.type;
/**
* 模板ID
* Created by yinghuihong on 16/2/23.
*/
public interface TemplateType {
/**
* 通用轮播模板
*/
String COMMON_CAROUSEL = "COMMON_CAROUSEL";
/**
* OTT模块 - 数量模糊的模板(搜索场景)
*/
String OTT_BLUR = "OTT_BLUR";
/**
* OTT模块 - 一行两列的模板
*/
String OTT_ONE_TWO = "OTT_ONE_TWO";
/**
* OTT模块 - 一行三列的模板
*/
String OTT_ONE_THREE = "OTT_ONE_THREE";
/**
* OTT模块 - 一行四列的模板
*/
String OTT_ONE_FOUR = "OTT_ONE_FOUR";
/**
* 应用模块 - 数量模糊的模板(搜索场景)
*/
String APP_BLUR = "APP_BLUR";
/**
* 应用模块 - 两行三列的模板
*/
String APP_TWO_THREE = "APP_TWO_THREE";
/**
* 应用模块 - 三行一列的模板
*/
String APP_THREE_ONE = "APP_THREE_ONE";
}
| UTF-8 | Java | 922 | java | TemplateType.java | Java | [
{
"context": "package jshdc.type;\n\n/**\n * 模板ID\n * Created by yinghuihong on 16/2/23.\n */\npublic interface TemplateType {\n ",
"end": 58,
"score": 0.9993690848350525,
"start": 47,
"tag": "USERNAME",
"value": "yinghuihong"
}
] | null | [] | package jshdc.type;
/**
* 模板ID
* Created by yinghuihong on 16/2/23.
*/
public interface TemplateType {
/**
* 通用轮播模板
*/
String COMMON_CAROUSEL = "COMMON_CAROUSEL";
/**
* OTT模块 - 数量模糊的模板(搜索场景)
*/
String OTT_BLUR = "OTT_BLUR";
/**
* OTT模块 - 一行两列的模板
*/
String OTT_ONE_TWO = "OTT_ONE_TWO";
/**
* OTT模块 - 一行三列的模板
*/
String OTT_ONE_THREE = "OTT_ONE_THREE";
/**
* OTT模块 - 一行四列的模板
*/
String OTT_ONE_FOUR = "OTT_ONE_FOUR";
/**
* 应用模块 - 数量模糊的模板(搜索场景)
*/
String APP_BLUR = "APP_BLUR";
/**
* 应用模块 - 两行三列的模板
*/
String APP_TWO_THREE = "APP_TWO_THREE";
/**
* 应用模块 - 三行一列的模板
*/
String APP_THREE_ONE = "APP_THREE_ONE";
}
| 922 | 0.50133 | 0.494681 | 41 | 17.341463 | 14.283898 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.219512 | false | false | 0 |
b00c033520d409e18b13d6612e51c1e040f52d0c | 7,438,883,420,981 | 65f727c611214622ef70f49e52ddf6feedaeee5c | /spring-boot/my-spring-boot/src/main/java/com/sxh/processors/MySimpleBeanPostProcessor.java | 0782dc28993f8d46a38b834e4d21633c39c01d83 | [] | no_license | JokerByrant/SpringBoot-Parent | https://github.com/JokerByrant/SpringBoot-Parent | 8563240c0aea27424517c4a4be4b352c2507ee7f | 77d40a9e688b70898f678c86bbc0e15a44b226cb | refs/heads/master | 2022-07-14T19:33:43.692000 | 2021-04-07T08:58:14 | 2021-04-07T08:58:14 | 248,183,862 | 0 | 0 | null | false | 2022-06-17T03:02:34 | 2020-03-18T09:06:39 | 2021-04-07T08:58:39 | 2022-06-17T03:02:34 | 253 | 0 | 0 | 2 | Java | false | false | package com.sxh.processors;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
/**
* @author sxh
* @date 2020/6/11
*/
public class MySimpleBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
System.out.println(beanName + " -> MySimpleBeanPostProcessor -> postProcessBeforeInitialization");
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println(beanName + " -> MySimpleBeanPostProcessor -> postProcessAfterInitialization");
return bean;
}
}
| UTF-8 | Java | 763 | java | MySimpleBeanPostProcessor.java | Java | [
{
"context": ".factory.config.BeanPostProcessor;\n\n/**\n * @author sxh\n * @date 2020/6/11\n */\npublic class MySimpleBeanP",
"end": 164,
"score": 0.9996185898780823,
"start": 161,
"tag": "USERNAME",
"value": "sxh"
}
] | null | [] | package com.sxh.processors;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
/**
* @author sxh
* @date 2020/6/11
*/
public class MySimpleBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
System.out.println(beanName + " -> MySimpleBeanPostProcessor -> postProcessBeforeInitialization");
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println(beanName + " -> MySimpleBeanPostProcessor -> postProcessAfterInitialization");
return bean;
}
}
| 763 | 0.754915 | 0.74574 | 22 | 33.68182 | 38.253208 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.409091 | false | false | 13 |
fa8babe971e5b2bebef405104566e555dbb3d33f | 19,731,079,778,197 | 7b1138660b7de20bcc40cd1ed95e7e85eee79e0f | /ERS/src/com/richard/game/graphics/Screen.java | 64e975171d4ff73ba0a34cc59c078bd1bb4aea03 | [] | no_license | PlasmaFlare/Game-Projects | https://github.com/PlasmaFlare/Game-Projects | 734dd1c81077af0435a7c64a22427415d11d6617 | c00b63f4f6b93a7478ea61da922a5e8df1d15e94 | refs/heads/master | 2016-09-06T11:34:08.849000 | 2016-03-02T03:17:48 | 2016-03-02T03:17:48 | 26,120,500 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.richard.game.graphics;
public class Screen {
public int width, height;
public int[] pixels;
public int xOffset, yOffset;
public Screen(int width, int height) {
this.width = width;
this.height = height;
pixels = new int[width * height];
}
public void renderSprite(Sprite sprite) {
int spriteHeight = sprite.getHeight();
int spriteWidth = sprite.getWidth();
for (int y = 0; y < spriteHeight; y++) {
int ya = y;
for (int x = 0; x < spriteWidth; x++) {
int xa = x;
// stops rendering the tile when the tile is off the screen
if (xa < 0 || xa >= width || ya < 0 || ya >= height)
continue;
if (xa < 0)
xa = 0;
int col = sprite.pixels[x + y * spriteWidth];
pixels[xa + ya * width] = col;
}
}
}
public void renderSprite(Sprite sprite, int x, int y) {
int spriteHeight = sprite.getHeight();
int spriteWidth = sprite.getWidth();
for (int y1 = 0; y1 < spriteHeight; y1++) {
int ya = y1 + y;
for (int x1 = 0; x1 < spriteWidth; x1++) {
int xa = x1 + x;
// stops rendering the tile when the tile is off the screen
if (xa < 0 || xa >= width || ya < 0 || ya >= height)
continue;
if (xa < 0)
xa = 0;
int col = sprite.pixels[x1 + y1 * spriteWidth];
if (col != sprite.getSheet().getTransparentColor())
pixels[xa + ya * width] = col;
}
}
}
public void clear() {
for (int i = 0; i < pixels.length; i++) {
pixels[i] = 0x1BB2E0;
}
}
// updates the offset of the original position of the map
public void setOffset(int xOffset, int yOffset) {
this.xOffset = xOffset;
this.yOffset = yOffset;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}
| UTF-8 | Java | 1,955 | java | Screen.java | Java | [] | null | [] | package com.richard.game.graphics;
public class Screen {
public int width, height;
public int[] pixels;
public int xOffset, yOffset;
public Screen(int width, int height) {
this.width = width;
this.height = height;
pixels = new int[width * height];
}
public void renderSprite(Sprite sprite) {
int spriteHeight = sprite.getHeight();
int spriteWidth = sprite.getWidth();
for (int y = 0; y < spriteHeight; y++) {
int ya = y;
for (int x = 0; x < spriteWidth; x++) {
int xa = x;
// stops rendering the tile when the tile is off the screen
if (xa < 0 || xa >= width || ya < 0 || ya >= height)
continue;
if (xa < 0)
xa = 0;
int col = sprite.pixels[x + y * spriteWidth];
pixels[xa + ya * width] = col;
}
}
}
public void renderSprite(Sprite sprite, int x, int y) {
int spriteHeight = sprite.getHeight();
int spriteWidth = sprite.getWidth();
for (int y1 = 0; y1 < spriteHeight; y1++) {
int ya = y1 + y;
for (int x1 = 0; x1 < spriteWidth; x1++) {
int xa = x1 + x;
// stops rendering the tile when the tile is off the screen
if (xa < 0 || xa >= width || ya < 0 || ya >= height)
continue;
if (xa < 0)
xa = 0;
int col = sprite.pixels[x1 + y1 * spriteWidth];
if (col != sprite.getSheet().getTransparentColor())
pixels[xa + ya * width] = col;
}
}
}
public void clear() {
for (int i = 0; i < pixels.length; i++) {
pixels[i] = 0x1BB2E0;
}
}
// updates the offset of the original position of the map
public void setOffset(int xOffset, int yOffset) {
this.xOffset = xOffset;
this.yOffset = yOffset;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}
| 1,955 | 0.57289 | 0.559079 | 92 | 19.25 | 19.200106 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.358696 | false | false | 13 |
3136762064b2d22ceabf9ae7e9f37d3ee6ff1e09 | 28,862,180,236,276 | 1f38c354083fbf39a2816cc42421b268be1f43f8 | /30 StringCleaner/StringRemover.java | dc0c6091b99070fba9e7cb6d69fdd85fa4b2628b | [] | no_license | AyushmaanAggarwal/AP-Computer-Science-A | https://github.com/AyushmaanAggarwal/AP-Computer-Science-A | c175bd5a121aa7c3a2157c9def1854641ab564ad | da37417470160c9dece2818d87d0dd551ff04e5e | refs/heads/master | 2023-04-23T10:23:53.478000 | 2021-05-19T22:05:15 | 2021-05-19T22:05:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class StringRemover {
private String remove;
private String sentence;
public StringRemover( String sen, String rem )
{
sentence = sen;
remove = rem;
System.out.println(sen+" - String to remove R-M");
}
public void removeStrings()
{
int loc = sentence.indexOf(remove);
while(loc!=-1){
if (loc>1){
sentence = sentence.substring(0,loc-1)+sentence.substring(loc+remove.length());
} else {
sentence = sentence.substring(loc+remove.length());
}
loc = sentence.indexOf(remove);
}
}
public String toString()
{
return sentence;
}
}
| UTF-8 | Java | 683 | java | StringRemover.java | Java | [] | null | [] | public class StringRemover {
private String remove;
private String sentence;
public StringRemover( String sen, String rem )
{
sentence = sen;
remove = rem;
System.out.println(sen+" - String to remove R-M");
}
public void removeStrings()
{
int loc = sentence.indexOf(remove);
while(loc!=-1){
if (loc>1){
sentence = sentence.substring(0,loc-1)+sentence.substring(loc+remove.length());
} else {
sentence = sentence.substring(loc+remove.length());
}
loc = sentence.indexOf(remove);
}
}
public String toString()
{
return sentence;
}
}
| 683 | 0.56369 | 0.557833 | 29 | 22.551723 | 22.730181 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.793103 | false | false | 13 |
361e530fe10c41b20ec60ce5d7493787097a6532 | 2,757,369,074,562 | c5c54923f72d975c24c96eb647feb675511adb45 | /src/Testcases/Loginapplication.java | 4b02ab26f0e50b2453d7d35420fbe4fb21baffed | [] | no_license | diessjack/PageObject | https://github.com/diessjack/PageObject | 75d08839c4415f87fb4f9e2b01ae74fadbd3aa20 | 47bab2368fdcf9e7215b9f483130369207799b0c | refs/heads/master | 2021-08-19T10:17:01.214000 | 2017-11-25T20:45:36 | 2017-11-25T20:45:36 | 112,033,409 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package Testcases;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import objectrepository.eBayHomepage;
import objectrepository.eBayLoginpage;
/**
* @author HAOSHU FENG
* @version 1.0
* @since Oct 23, 2017 8:18:45 PM
*/
public class Loginapplication {
private static Logger log = LogManager.getLogger(Loginapplication.class.getName());
/**
* @param args
*/
@BeforeClass
public void testBegin(){
if (log.isDebugEnabled()) {
log.debug("entering testBegin()");
}
log.info("Login Test Begin");
if (log.isDebugEnabled()) {
log.debug("exiting testBegin()");
}
}
@Test
public void Login(){
if (log.isDebugEnabled()) {
log.debug("entering Login()");
}
System.setProperty("webdriver.chrome.driver","D://selenium/chromedriver_win32/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=");
eBayLoginpage rd = new eBayLoginpage(driver);
rd.Emailid().sendKeys("fenghaoshu@gamil.com");
log.info("SendEmailID success");
rd.password().sendKeys("1a4830b");
log.info("SendPassword success");
rd.submit().click();
log.info("clicked login button");
rd.home().click();
log.info("clicked icon back to homepage");
eBayHomepage hp = new eBayHomepage(driver);
hp.text().sendKeys("apple");
log.info("text apple Done.");
hp.search().click();
log.info("search for apple Done.");
driver.close();
log.info("Test finish closed chrome.");
if (log.isDebugEnabled()) {
log.debug("exiting Login()");
}
}
}
| UTF-8 | Java | 1,759 | java | Loginapplication.java | Java | [
{
"context": "rt objectrepository.eBayLoginpage;\n\n/**\n * @author HAOSHU FENG\n * @version 1.0\n * @since Oct 23, 2017 8:18:45 PM",
"end": 385,
"score": 0.9997803568840027,
"start": 374,
"tag": "NAME",
"value": "HAOSHU FENG"
},
{
"context": "w eBayLoginpage(driver);\n\t\trd.Emailid().sendKeys(\"fenghaoshu@gamil.com\");\n\t\tlog.info(\"SendEmailID success\");\n\t\trd.passwo",
"end": 1205,
"score": 0.9995769262313843,
"start": 1185,
"tag": "EMAIL",
"value": "fenghaoshu@gamil.com"
},
{
"context": "\"SendEmailID success\");\n\t\trd.password().sendKeys(\"1a4830b\");\n\t\tlog.info(\"SendPassword success\");\n\t\trd.submi",
"end": 1277,
"score": 0.9994479417800903,
"start": 1270,
"tag": "PASSWORD",
"value": "1a4830b"
}
] | null | [] | /**
*
*/
package Testcases;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import objectrepository.eBayHomepage;
import objectrepository.eBayLoginpage;
/**
* @author <NAME>
* @version 1.0
* @since Oct 23, 2017 8:18:45 PM
*/
public class Loginapplication {
private static Logger log = LogManager.getLogger(Loginapplication.class.getName());
/**
* @param args
*/
@BeforeClass
public void testBegin(){
if (log.isDebugEnabled()) {
log.debug("entering testBegin()");
}
log.info("Login Test Begin");
if (log.isDebugEnabled()) {
log.debug("exiting testBegin()");
}
}
@Test
public void Login(){
if (log.isDebugEnabled()) {
log.debug("entering Login()");
}
System.setProperty("webdriver.chrome.driver","D://selenium/chromedriver_win32/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=");
eBayLoginpage rd = new eBayLoginpage(driver);
rd.Emailid().sendKeys("<EMAIL>");
log.info("SendEmailID success");
rd.password().sendKeys("<PASSWORD>");
log.info("SendPassword success");
rd.submit().click();
log.info("clicked login button");
rd.home().click();
log.info("clicked icon back to homepage");
eBayHomepage hp = new eBayHomepage(driver);
hp.text().sendKeys("apple");
log.info("text apple Done.");
hp.search().click();
log.info("search for apple Done.");
driver.close();
log.info("Test finish closed chrome.");
if (log.isDebugEnabled()) {
log.debug("exiting Login()");
}
}
}
| 1,744 | 0.694144 | 0.681637 | 70 | 24.128571 | 20.323751 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.785714 | false | false | 13 |
83e56a810ef3c94a80086c2a97f02afc1ba2b618 | 11,407,433,146,557 | 1252e9cee395e637caa6ac223e4e2c4663dfff7a | /src/main/java/com/m2i/tp/service/ServiceClientImpl.java | 339017afe511afe03f0b18e7ae456b0189ad8cbd | [] | no_license | pascalgillot/appliSpring | https://github.com/pascalgillot/appliSpring | 7dabff0d377d8f87fb56f71d5f84841f21cce8b3 | e9f25ad4e25686258573b38d9d3a3d671c512e22 | refs/heads/master | 2020-04-17T08:39:31.532000 | 2019-01-18T15:01:05 | 2019-01-18T15:01:05 | 166,420,511 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.m2i.tp.service;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.m2i.tp.dao.DaoClient;
import com.m2i.tp.dao.DaoCompte;
import com.m2i.tp.entity.Client;
import com.m2i.tp.entity.Compte;
@Service
@Transactional
public class ServiceClientImpl implements ServiceClient {
@Autowired
private DaoClient daoClient; //dao vers lequel déléguer
@Autowired
private DaoCompte daoCompte; //dao vers lequel déléguer
@Override
public Client rechercherClientById(Long numero) {
return daoClient.findClientByNumero(numero);
}
@Override
public void saveOrUpdateClient(Client cli) {
if(cli.getNumero()==null) {
daoClient.createClient(cli);
}else
daoClient.createClient(cli);
}
@Override
public void ajouterComptePourClient(long numCliExistant,long numCptExistant) {
Client cli = daoClient.findClientByNumero(numCliExistant);
Compte cpt = daoCompte.findCompteByNumero(numCptExistant);
cli.getComptes().add(cpt); //cpt relié à cli en mémoire
daoClient.updateClient(cli);
}
public static void loadNowInMemoryLazyCollection(Collection col) {
col.size(); //en appelant .size() sur une collection JPA/Hib en mode lazy
//ça provoque un parcours de la collection pour connaître la taille
//et ca déclenche immédiatement une remontée des objets des tables vers le mémoire
}
@Override
public List<Compte> rechercherComptesDuClient(Long numero) {
Client cli = daoClient.findClientByNumero(numero);
List<Compte> listeCompte = cli.getComptes();
loadNowInMemoryLazyCollection(listeCompte);
return listeCompte;
}
}
| UTF-8 | Java | 1,770 | java | ServiceClientImpl.java | Java | [] | null | [] | package com.m2i.tp.service;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.m2i.tp.dao.DaoClient;
import com.m2i.tp.dao.DaoCompte;
import com.m2i.tp.entity.Client;
import com.m2i.tp.entity.Compte;
@Service
@Transactional
public class ServiceClientImpl implements ServiceClient {
@Autowired
private DaoClient daoClient; //dao vers lequel déléguer
@Autowired
private DaoCompte daoCompte; //dao vers lequel déléguer
@Override
public Client rechercherClientById(Long numero) {
return daoClient.findClientByNumero(numero);
}
@Override
public void saveOrUpdateClient(Client cli) {
if(cli.getNumero()==null) {
daoClient.createClient(cli);
}else
daoClient.createClient(cli);
}
@Override
public void ajouterComptePourClient(long numCliExistant,long numCptExistant) {
Client cli = daoClient.findClientByNumero(numCliExistant);
Compte cpt = daoCompte.findCompteByNumero(numCptExistant);
cli.getComptes().add(cpt); //cpt relié à cli en mémoire
daoClient.updateClient(cli);
}
public static void loadNowInMemoryLazyCollection(Collection col) {
col.size(); //en appelant .size() sur une collection JPA/Hib en mode lazy
//ça provoque un parcours de la collection pour connaître la taille
//et ca déclenche immédiatement une remontée des objets des tables vers le mémoire
}
@Override
public List<Compte> rechercherComptesDuClient(Long numero) {
Client cli = daoClient.findClientByNumero(numero);
List<Compte> listeCompte = cli.getComptes();
loadNowInMemoryLazyCollection(listeCompte);
return listeCompte;
}
}
| 1,770 | 0.782015 | 0.779169 | 64 | 26.453125 | 25.597809 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.296875 | false | false | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.