blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f12c027e47f4b253b4a9cf843a8b7c0b6d91d9f5 | 204ff5a7cfd6325c9733479c5837ebb2e21d31d9 | /classpath/src/java/lang/ProcessBuilder.java | f01ac11b617c7b8997bc082d0bdbff2d268544ba | [] | no_license | yang123vc/jfvm | f2a7726b5df3993d52da58720054b3e2fe6fdec8 | c6ec82fb68f44e733d795374fdb2989399568c1e | refs/heads/master | 2020-07-16T13:27:10.502379 | 2016-12-08T13:11:53 | 2016-12-08T13:11:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 229 | java | package java.lang;
/** ProcessBuilder
*
* @author pquiring
*/
public class ProcessBuilder {
public ProcessBuilder(String cmd[]) {
//TODO
}
public Process start() {
//TODO
return null;
}
}
| [
"pquiring@gmail.com"
] | pquiring@gmail.com |
88b2a88b536be63defbdbe48c12c8fa25a3ba246 | beae909ca2cda99138c0fcd7387bd55cdcba0db2 | /src/Databases/MyAccessTest.java | 35c90a1eea7c57f91f37c83d4ab99e91b756f85c | [] | no_license | vijaykumarsaurav/core-java-practice | 5df9b8378b83b751fe35c3636f0734f8888694ba | 39057005622561d35eef5bb572f07c93f6056f85 | refs/heads/master | 2020-03-28T09:34:11.040798 | 2018-09-09T16:30:34 | 2018-09-09T16:30:34 | 148,043,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java | package Databases;
import java.sql.*;
import javax.swing.*;
abstract class Access
{
public static Connection con = null;
private static String userName = "root";
private static String password = "";
private static String dataBase = "vijay";
private static String url = "jdbc:odbc:dk" + dataBase;
public static void openConnection()
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
con=DriverManager.getConnection("jdbc:odbc:access"+dataBase);
}
catch (Exception e){
JOptionPane.showMessageDialog(null,"driver not load :"+e);
}
}
public static void closeConnection(){
try{ con.close();
}
catch (Exception e){
}
}
}
class MyAccessTest
{
public static void main(String arr[])
{
Access.openConnection();
//String query="Create table login1(name varchar(20),pass varchar(20))";
String q = "select * from login";
try{
//Access.con.createStatement().executeUpdate(query);
ResultSet rs= Access.con.createStatement().executeQuery(q);
while(rs.next())
{
System.out.println(rs.getString(0));
System.out.println(rs.getString(1));
}
JOptionPane.showMessageDialog(null,"Sucessesfulll", "good............", 1);
}
catch(Exception e){JOptionPane.showMessageDialog(null, e, "Error............", 1);}
}
}
| [
"vijaykumarsaurav@gmail.com"
] | vijaykumarsaurav@gmail.com |
c9546e3fb3e9d5d53a0b09c2c540f3e2ed01977b | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/4/4_7455a0815a27b046d028b7944ec9f0088885aef5/CBackend/4_7455a0815a27b046d028b7944ec9f0088885aef5_CBackend_s.java | ce84fd87ad4ece8d7144ea70db18608f5258f2dd | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 10,783 | java | /*
* Copyright (c) 2012, IETR/INSA of Rennes
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the IETR/INSA of Rennes nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package net.sf.orcc.backends.c;
import static net.sf.orcc.OrccLaunchConstants.NO_LIBRARY_EXPORT;
import static net.sf.orcc.backends.BackendsConstants.ADDITIONAL_TRANSFOS;
import static net.sf.orcc.backends.BackendsConstants.GENETIC_ALGORITHM;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.orcc.backends.AbstractBackend;
import net.sf.orcc.backends.c.transform.CBroadcastAdder;
import net.sf.orcc.backends.transform.CastAdder;
import net.sf.orcc.backends.transform.DeadVariableRemoval;
import net.sf.orcc.backends.transform.DivisionSubstitution;
import net.sf.orcc.backends.transform.EmptyBlockRemover;
import net.sf.orcc.backends.transform.Inliner;
import net.sf.orcc.backends.transform.InstPhiTransformation;
import net.sf.orcc.backends.transform.InstTernaryAdder;
import net.sf.orcc.backends.transform.ListFlattener;
import net.sf.orcc.backends.transform.Multi2MonoToken;
import net.sf.orcc.backends.transform.ParameterImporter;
import net.sf.orcc.backends.transform.StoreOnceTransformation;
import net.sf.orcc.backends.util.Metis;
import net.sf.orcc.backends.util.Validator;
import net.sf.orcc.backends.util.Mapping;
import net.sf.orcc.df.Actor;
import net.sf.orcc.df.Instance;
import net.sf.orcc.df.Network;
import net.sf.orcc.df.transform.ArgumentEvaluator;
import net.sf.orcc.df.transform.Instantiator;
import net.sf.orcc.df.transform.NetworkFlattener;
import net.sf.orcc.df.transform.TypeResizer;
import net.sf.orcc.df.transform.UnitImporter;
import net.sf.orcc.df.util.DfSwitch;
import net.sf.orcc.df.util.DfVisitor;
import net.sf.orcc.ir.CfgNode;
import net.sf.orcc.ir.Expression;
import net.sf.orcc.ir.transform.BlockCombine;
import net.sf.orcc.ir.transform.ControlFlowAnalyzer;
import net.sf.orcc.ir.transform.DeadCodeElimination;
import net.sf.orcc.ir.transform.DeadGlobalElimination;
import net.sf.orcc.ir.transform.PhiRemoval;
import net.sf.orcc.ir.transform.RenameTransformation;
import net.sf.orcc.ir.transform.SSATransformation;
import net.sf.orcc.ir.transform.TacTransformation;
import net.sf.orcc.ir.util.IrUtil;
import net.sf.orcc.tools.classifier.Classifier;
import net.sf.orcc.tools.merger.action.ActionMerger;
import net.sf.orcc.tools.merger.actor.ActorMerger;
import net.sf.orcc.tools.stats.StatisticsPrinter;
import net.sf.orcc.util.OrccLogger;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* C back-end.
*
* @author Matthieu Wipliez
* @author Herve Yviquel
* @author Antoine Lorence
*
*/
public class CBackend extends AbstractBackend {
/**
* Path to target "src" folder
*/
private String srcPath;
@Override
protected void doInitializeOptions() {
// Create empty folders
new File(path + File.separator + "build").mkdirs();
new File(path + File.separator + "bin").mkdirs();
srcPath = path + File.separator + "src";
}
@Override
protected void doTransformActor(Actor actor) {
Map<String, String> replacementMap = new HashMap<String, String>();
replacementMap.put("abs", "abs_my_precious");
replacementMap.put("getw", "getw_my_precious");
replacementMap.put("index", "index_my_precious");
replacementMap.put("max", "max_my_precious");
replacementMap.put("min", "min_my_precious");
replacementMap.put("select", "select_my_precious");
replacementMap.put("OUT", "OUT_my_precious");
replacementMap.put("IN", "IN_my_precious");
if (mergeActions) {
new ActionMerger().doSwitch(actor);
}
if (convertMulti2Mono) {
new Multi2MonoToken().doSwitch(actor);
}
List<DfSwitch<?>> transformations = new ArrayList<DfSwitch<?>>();
transformations.add(new TypeResizer(true, false, true, false));
transformations.add(new RenameTransformation(replacementMap));
// If "-t" option is passed to command line, apply additional
// transformations
if (getAttribute(ADDITIONAL_TRANSFOS, false)) {
transformations.add(new StoreOnceTransformation());
transformations.add(new DfVisitor<Void>(new SSATransformation()));
transformations.add(new DfVisitor<Object>(new PhiRemoval()));
transformations.add(new Multi2MonoToken());
transformations.add(new DivisionSubstitution());
transformations.add(new ParameterImporter());
transformations.add(new DfVisitor<Void>(new Inliner(true, true)));
// transformations.add(new UnaryListRemoval());
// transformations.add(new GlobalArrayInitializer(true));
transformations.add(new DfVisitor<Void>(new InstTernaryAdder()));
transformations.add(new DeadGlobalElimination());
transformations.add(new DfVisitor<Void>(new DeadVariableRemoval()));
transformations.add(new DfVisitor<Void>(new DeadCodeElimination()));
transformations.add(new DfVisitor<Void>(new DeadVariableRemoval()));
transformations.add(new DfVisitor<Void>(new ListFlattener()));
transformations.add(new DfVisitor<Expression>(
new TacTransformation()));
transformations.add(new DfVisitor<CfgNode>(
new ControlFlowAnalyzer()));
transformations
.add(new DfVisitor<Void>(new InstPhiTransformation()));
transformations.add(new DfVisitor<Void>(new EmptyBlockRemover()));
transformations.add(new DfVisitor<Void>(new BlockCombine()));
transformations.add(new DfVisitor<Expression>(new CastAdder(true,
true)));
}
for (DfSwitch<?> transformation : transformations) {
transformation.doSwitch(actor);
if (debug) {
ResourceSet set = new ResourceSetImpl();
if (!IrUtil.serializeActor(set, srcPath, actor)) {
OrccLogger.warnln("Error with " + transformation
+ " on actor " + actor.getName());
}
}
}
}
protected void doTransformNetwork(Network network) {
OrccLogger.traceln("Instantiating...");
new Instantiator(true, fifoSize).doSwitch(network);
OrccLogger.traceln("Flattening...");
new NetworkFlattener().doSwitch(network);
new UnitImporter().doSwitch(network);
if (classify) {
OrccLogger.traceln("Classification of actors...");
new Classifier().doSwitch(network);
}
if (mergeActors) {
OrccLogger.traceln("Merging of actors...");
new ActorMerger().doSwitch(network);
}
new CBroadcastAdder().doSwitch(network);
new ArgumentEvaluator().doSwitch(network);
}
@Override
protected void doVtlCodeGeneration(List<IFile> files) {
// do not generate a C VTL
}
@Override
protected void doXdfCodeGeneration(Network network) {
Validator.checkTopLevel(network);
Validator.checkMinimalFifoSize(network, fifoSize);
doTransformNetwork(network);
if (debug) {
// Serialization of the actors will break proxy link
EcoreUtil.resolveAll(network);
}
transformActors(network.getAllActors());
network.computeTemplateMaps();
// print instances
printChildren(network);
// print network
OrccLogger.trace("Printing network... ");
if (new NetworkPrinter(network, options).print(srcPath) > 0) {
OrccLogger.traceRaw("Cached\n");
} else {
OrccLogger.traceRaw("Done\n");
}
// print CMakeLists
OrccLogger.traceln("Printing CMake project files");
new CMakePrinter(network).printCMakeFiles(path);
new StatisticsPrinter().print(srcPath, network);
if (balanceMapping) {
// Solve load balancing using Metis. The 'mapping' variable should
// be the weightsMap, giving a weight to each actor/instance.
mapping = new Metis().partition(network, path, processorNumber,
mapping);
}
if (!getAttribute(GENETIC_ALGORITHM, false)) {
new Mapping().print(srcPath, network, mapping);
}
}
protected void printCMake(Network network) {
// print CMakeLists
OrccLogger.traceln("Printing CMake project files");
new CMakePrinter(network).printCMakeFiles(path);
}
@Override
public boolean exportRuntimeLibrary() {
boolean exportLibrary = !getAttribute(NO_LIBRARY_EXPORT, false);
if (exportLibrary) {
String libsPath = path + File.separator + "libs";
// Copy specific windows batch file
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
copyFileToFilesystem("/runtime/C/run_cmake_with_VS_env.bat",
path + File.separator + "run_cmake_with_VS_env.bat",
debug);
}
copyFileToFilesystem("/runtime/C/README.txt", path + File.separator
+ "README.txt", debug);
OrccLogger.trace("Export libraries sources into " + libsPath
+ "... ");
if (copyFolderToFileSystem("/runtime/C/libs", libsPath, debug)) {
OrccLogger.traceRaw("OK" + "\n");
return true;
} else {
OrccLogger.warnRaw("Error" + "\n");
return false;
}
}
return false;
}
@Override
protected boolean printInstance(Instance instance) {
return new InstancePrinter(options).print(srcPath, instance) > 0;
}
@Override
protected boolean printActor(Actor actor) {
return new InstancePrinter(options).print(srcPath, actor) > 0;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
ab8fbbf65f317d71522c0fb85fd176c07a6371fa | 5357c176cc8f7f5124abc64c2e8ce752e10bc7ad | /set02/src/com/vinod02/Manager03.java | 66ce98fa4268d765d5cbf5b790ef3b411c88e1e3 | [] | no_license | vinodharari/JDBC | 2ec5f16da5e59e1bad2c389f476787771eae094b | 79aca847a7592c195a476b6faf8461baa52ea2ab | refs/heads/master | 2021-01-11T05:15:47.385752 | 2016-10-23T14:26:29 | 2016-10-23T14:26:29 | 71,707,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 503 | java | package com.vinod02;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
public class Manager03 {
public static void main(String[] args) {
Connection con=null;
CallableStatement cstmt=null;
try {
con=DBUtil.getConnection();
cstmt=con.prepareCall("{call p1}");
cstmt.execute();
System.out.println("done");
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.closeAll(null, cstmt, con);
}
}
}
| [
"itsvins63"
] | itsvins63 |
da30d5ac94bc18a1e5064052bc52f20739260c29 | 7d07ade245881ccb57ceb17b5733a5dd0dbd58f8 | /app/src/main/java/com/katariya/smartimageupload/MultipartUtility.java | 3500d993311515a5430565247a7fc4136c28d895 | [] | no_license | AndroidHelp/SmartImageUpload | c7f9f17e4335fcae8bb1e3c8fdfb0f59aacbf4fd | 56240f90b9df6290ca65d36053fcfbba584ee07e | refs/heads/master | 2021-01-12T14:50:20.415662 | 2016-10-27T12:21:01 | 2016-10-27T12:21:01 | 72,102,651 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,444 | java | package com.katariya.smartimageupload;
/**
* Created by Administrator on 10/26/2016.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
/**
* This utility class provides an abstraction layer for sending multipart HTTP
* POST requests to a web server.
* @author www.codejava.net
*
*/
public class MultipartUtility {
private final String boundary;
private static final String LINE_FEED = "\r\n";
private HttpURLConnection httpConn;
private String charset;
private OutputStream outputStream;
private PrintWriter writer;
/**
* This constructor initializes a new HTTP POST request with content type
* is set to multipart/form-data
* @param requestURL
* @param charset
* @throws IOException
*/
public MultipartUtility(String requestURL, String charset)
throws IOException {
this.charset = charset;
// creates a unique boundary based on time stamp
boundary = "===" + System.currentTimeMillis() + "===";
URL url = new URL(requestURL);
if (httpConn!=null)
{
httpConn.setRequestProperty("connection", "close");
}
else
{
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setUseCaches(false);
httpConn.setDoOutput(true); // indicates POST method
httpConn.setDoInput(true);
httpConn.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + boundary);
// httpConn.setRequestProperty("User-Agent", "CodeJava Agent");
// httpConn.setRequestProperty("Test", "Bonjour");
outputStream = httpConn.getOutputStream();
writer = new PrintWriter(new OutputStreamWriter(outputStream, charset),
true);
}
}
/**
* Adds a form field to the request
* @param name field name
* @param value field value
*/
public void addFormField(String name, String value) {
writer.append("--" + boundary).append(LINE_FEED);
writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
.append(LINE_FEED);
writer.append("Content-Type: text/plain; charset=" + charset).append(
LINE_FEED);
writer.append(LINE_FEED);
writer.append(value).append(LINE_FEED);
writer.flush();
}
/**
* Adds a upload file section to the request
* @param fieldName name attribute in <input type="file" name="..." />
* @param uploadFile a File to be uploaded
* @throws IOException
*/
public void addFilePart(String fieldName, File uploadFile)
throws IOException {
String fileName = uploadFile.getName();
writer.append("--" + boundary).append(LINE_FEED);
writer.append(
"Content-Disposition: form-data; name=\"" + fieldName
+ "\"; filename=\"" + fileName + "\"")
.append(LINE_FEED);
writer.append(
"Content-Type: "
+ URLConnection.guessContentTypeFromName(fileName))
.append(LINE_FEED);
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
writer.append(LINE_FEED);
writer.flush();
FileInputStream inputStream = new FileInputStream(uploadFile);
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
inputStream.close();
writer.append(LINE_FEED);
writer.flush();
}
/**
* Adds a header field to the request.
* @param name - name of the header field
* @param value - value of the header field
*/
public void addHeaderField(String name, String value) {
writer.append(name + ": " + value).append(LINE_FEED);
writer.flush();
}
/**
* Completes the request and receives response from the server.
* @return a list of Strings as response in case the server returned
* status OK, otherwise an exception is thrown.
* @throws IOException
*/
public List<String> finish() throws IOException {
List<String> response = new ArrayList<String>();
writer.append(LINE_FEED).flush();
writer.append("--" + boundary + "--").append(LINE_FEED);
writer.close();
// checks server's status code first
int status = httpConn.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
response.add(line);
}
reader.close();
httpConn.disconnect();
} else {
throw new IOException("Server returned non-OK status: " + status);
}
return response;
}
} | [
"android.developer20@gmail.com"
] | android.developer20@gmail.com |
b47e0cb42c846d5cda11c3e5f6f9088a7a738a36 | 51c2a501abfdfc22b6ea1cda2328cc5310b16767 | /src/main/java/com/alibaba/druid/sql/ast/statement/SQLAlterTableDropPrimaryKey.java | 5e93b530efc9cf333535a1156bcaa088344eaefc | [
"Apache-2.0"
] | permissive | dazen/druid | 1e34bf07cb7a61122a4acf2da241860900878444 | 183572a9d330810dacabc9c729d8f666a6a67a93 | refs/heads/master | 2021-01-18T10:22:50.911316 | 2015-08-05T08:32:47 | 2015-08-05T08:32:47 | 40,251,980 | 1 | 0 | null | 2015-08-05T15:04:33 | 2015-08-05T15:04:33 | null | UTF-8 | Java | false | false | 994 | java | /*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAlterTableDropPrimaryKey extends SQLObjectImpl implements SQLAlterTableItem {
@Override
protected void accept0(SQLASTVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
}
}
| [
"szujobs@hotmail.com"
] | szujobs@hotmail.com |
a2b85f76d91aa4986592e8f3bfc0eb5377e3ff67 | 34c4c950085ae664b129edffcaf9fba6e0c6af6d | /PDgame_improved/T4TPlayer.java | 91138a977d4a33be4c9d688399cd634e502d1783 | [] | no_license | johnkichu/CSS605 | 1171b5981fcf864a7c5a82ea97f11f49e2b0f6a7 | 12e5638604b2a8d97a6ad56249e7a5c8e606e0ef | refs/heads/master | 2020-05-19T21:51:18.117042 | 2011-12-08T14:15:33 | 2011-12-08T14:15:33 | 2,311,437 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 675 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package PDgame;
/**
*
* @author JPANG
*/
public class T4TPlayer extends BasicPlayer {
int oppLastMove=GameMove.COOPERATE;
public T4TPlayer() {
myID="T4T Player";
}
public int makeMove() {
if (oppLastMove==GameMove.COOPERATE)
return GameMove.COOPERATE;
else
return GameMove.DEFECT;
}
@Override
public void setScore(int myMove, int oppMove, int myScore, int oppScore, String oppID) {
oppLastMove=oppMove;
super.setScore(myMove,oppMove,myScore,oppScore,oppID);
}
}
| [
"johnkichu@gmail.com"
] | johnkichu@gmail.com |
25c06c5754f69e442da474f149ce002a89052ee6 | e706ec454815119eb287591b2cff6d887caba3a5 | /logic/Color.java | 15b6c5cb6c06a7a1c90c1e5e060cd2b97a72b1b8 | [] | no_license | senkevichmax/Task_02 | c752841f188b450033a17b9ff5fedc06e7573148 | d9accf6a20a566f08ca8dd3a69cb006f1e1e2b6e | refs/heads/main | 2023-08-23T12:09:43.111255 | 2021-11-02T14:06:40 | 2021-11-02T14:06:40 | 423,866,761 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 179 | java | package by.epamtc.senkevichmaxim.task02.logic;
public enum Color {
BLACK,
WHITE,
RED,
PURPLE,
BLUE,
GREEN,
YELLOW,
PINK,
BROWN,
ORANGE,
}
| [
"senkevichmax@gmail.com"
] | senkevichmax@gmail.com |
c71033dee98bb2100f298bd0f40ac51d0cbaedab | 4e51a9ca7e447406fe21b0850e345e7797bc66a5 | /ClassroomServices/src/main/java/com/classroom/services/web/controllers/CircularsController.java | 621270b3ab685c7caf8bdb1f8c6365b5df3cd99a | [] | no_license | EzzalddeenAli/ClassroomServices | 0e0e9a4505367139d84fdef2b00e45425690e6ae | 87e561960d9d5dfe47a9621ded012c0e10dc18ae | refs/heads/master | 2020-05-18T02:56:59.995499 | 2015-11-03T02:52:09 | 2015-11-03T02:52:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,039 | java | package com.classroom.services.web.controllers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.classroom.services.facade.dto.entities.CircularBatchDTO;
import com.classroom.services.facade.dto.entities.CircularBatchSearchDTO;
import com.classroom.services.facade.dto.entities.CircularDTO;
import com.classroom.services.facade.dto.entities.CircularSearchDTO;
import com.classroom.services.facade.dto.entities.CircularsBatchDTO;
import com.classroom.services.facade.dto.entities.CircularsDTO;
import com.classroom.services.facade.dto.entities.HomeworkDTO;
import com.classroom.services.facade.interfaces.ICircularsService;
@RequestMapping("/circulars")
@Controller
public class CircularsController {
private static final Logger LOG = LoggerFactory
.getLogger(CircularsController.class);
@Autowired
private ICircularsService service;
/**
* Add Circular
*
*/
@RequestMapping(value = "/update" ,method = RequestMethod.POST)
@ResponseBody
public CircularDTO updateCircular(@RequestBody CircularDTO circularDTO) {
try {
service.updateCircular(circularDTO);
} catch (Exception e) {
System.out.println(e.getMessage());
LOG.error("Error");
circularDTO.setErrorCode(e.getMessage());
}
return circularDTO;
}
/**
* Gets the Circular details.
*
* @param id
*
* @return the Circular details
*/
@RequestMapping(value = "/search", method = RequestMethod.POST)
@ResponseBody
public CircularsDTO getCircularDetails(@RequestBody CircularSearchDTO searchDTO) {
CircularsDTO dto = null;
try {
//System.out.println("here .. ");
//System.out.println(searchDTO.getStartDate());
dto = service.getCircularDetails(searchDTO);
} catch (Exception e) {
LOG.error("Error");
System.out.println(e.getMessage());
}
return dto;
} /**
* Gets the Circular details.
*
* @param id
*
* @return the Circular details
*/
@RequestMapping(value = "/searchBatch", method = RequestMethod.POST)
@ResponseBody
public CircularsBatchDTO getCircularDetails(@RequestBody CircularBatchSearchDTO searchDTO) {
CircularsBatchDTO dto = null;
try {
//System.out.println("here .. ");
//System.out.println(searchDTO.getStartDate());
dto = service.getCircularBatchDetails(searchDTO);
} catch (Exception e) {
LOG.error("Error");
System.out.println(e.getMessage());
}
return dto;
}
}
| [
"narender.bheemireddy@kony.com"
] | narender.bheemireddy@kony.com |
3259ca5b04d83f493ea2e4814665a2c2aae6b4c3 | 87a0ddd63ad59eece0b7964a22a710c43f333ad5 | /src/main/java/com/baizhitong/resource/model/res/ResExerciseStructure.java | c0ae876f0e624c5acc56d43e9115db45db4c423e | [] | no_license | royxpf/cloud | b41101f87b4edf3e228266f533836d1951768959 | 84f81431536c11ebe98fc67773e0c8a1223f7b7b | refs/heads/master | 2020-06-27T02:13:56.374981 | 2017-04-25T07:48:42 | 2017-04-25T07:48:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,996 | java | package com.baizhitong.resource.model.res;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author lusm 练习结构实体类
*/
@Entity
@Table(name = "res_exercise_structure")
public class ResExerciseStructure implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键 */
private @Id Integer id;
/** 练习Id */
private Integer exerciseId;
/** 本题型顺序号 */
private Integer orderInExercise;
/** 学科题型编码 */
private String questionTypeSubjectCode;
/** 题型总分 */
private Double typeScore;
/** 题型内可否随机出题 */
private Integer canRandomInType;
/** 题目内可否乱序出题 */
private Integer canRandomInQuestion;
/** 题型小题数量 */
private Integer typeNumber;
/** 题型说明 */
private String typeDesc;
/** 题型排序 */
private Integer typeSort;
/** 所属板块(不需要了吧?) */
private String plate;
/** 难度系数描述 */
private String difficultyDescription;
/** 答案不允许上传附件 */
private Integer flagNoAttachment;
/** 答题只能上传图片 */
private Integer flagOnlyPhotos;
/** 答题防粘贴 */
private Integer flagPreventPaste;
/** 最低字数限 */
private Integer minChars;
/** 音视频播放次数 */
private Integer audioPlayTimes;
/** 音视频播放间隔 */
private Integer audioPlayInterval;
/** 音视频播放方式 */
private Integer audioPlayType;
/** 音频播放单词间的间隔时间 */
private Integer audioPlayWordInterval;
/** 小题是连续序号还是独立序号 */
private Integer flagOrderSeriesOrIndep;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getExerciseId() {
return exerciseId;
}
public void setExerciseId(Integer exerciseId) {
this.exerciseId = exerciseId;
}
public String getQuestionTypeSubjectCode() {
return questionTypeSubjectCode;
}
public void setQuestionTypeSubjectCode(String questionTypeSubjectCode) {
this.questionTypeSubjectCode = questionTypeSubjectCode;
}
public Double getTypeScore() {
return typeScore;
}
public void setTypeScore(Double typeScore) {
this.typeScore = typeScore;
}
public Integer getcanRandomInType() {
return canRandomInType;
}
public void setcanRandomInType(Integer canRandomInType) {
this.canRandomInType = canRandomInType;
}
public Integer getTypeNumber() {
return typeNumber;
}
public void setTypeNumber(Integer typeNumber) {
this.typeNumber = typeNumber;
}
public String getTypeDesc() {
return typeDesc;
}
public void setTypeDesc(String typeDesc) {
this.typeDesc = typeDesc;
}
public Integer getTypeSort() {
return typeSort;
}
public void setTypeSort(Integer typeSort) {
this.typeSort = typeSort;
}
public String getPlate() {
return plate;
}
public void setPlate(String plate) {
this.plate = plate;
}
public String getDifficultyDescription() {
return difficultyDescription;
}
public void setDifficultyDescription(String difficultyDescription) {
this.difficultyDescription = difficultyDescription;
}
public Integer getFlagOnlyPhotos() {
return flagOnlyPhotos;
}
public void setFlagOnlyPhotos(Integer flagOnlyPhotos) {
this.flagOnlyPhotos = flagOnlyPhotos;
}
public Integer getFlagPreventPaste() {
return flagPreventPaste;
}
public void setFlagPreventPaste(Integer flagPreventPaste) {
this.flagPreventPaste = flagPreventPaste;
}
public Integer getMinChars() {
return minChars;
}
public void setMinChars(Integer minChars) {
this.minChars = minChars;
}
public Integer getAudioPlayTimes() {
return audioPlayTimes;
}
public void setAudioPlayTimes(Integer audioPlayTimes) {
this.audioPlayTimes = audioPlayTimes;
}
public Integer getAudioPlayInterval() {
return audioPlayInterval;
}
public void setAudioPlayInterval(Integer audioPlayInterval) {
this.audioPlayInterval = audioPlayInterval;
}
public Integer getAudioPlayType() {
return audioPlayType;
}
public void setAudioPlayType(Integer audioPlayType) {
this.audioPlayType = audioPlayType;
}
public Integer getAudioPlayWordInterval() {
return audioPlayWordInterval;
}
public void setAudioPlayWordInterval(Integer audioPlayWordInterval) {
this.audioPlayWordInterval = audioPlayWordInterval;
}
public Integer getFlagOrderSeriesOrIndep() {
return flagOrderSeriesOrIndep;
}
public void setFlagOrderSeriesOrIndep(Integer flagOrderSeriesOrIndep) {
this.flagOrderSeriesOrIndep = flagOrderSeriesOrIndep;
}
public Integer getOrderInExercise() {
return orderInExercise;
}
public void setOrderInExercise(Integer orderInExercise) {
this.orderInExercise = orderInExercise;
}
public Integer getCanRandomInQuestion() {
return canRandomInQuestion;
}
public void setCanRandomInQuestion(Integer canRandomInQuestion) {
this.canRandomInQuestion = canRandomInQuestion;
}
public Integer getFlagNoAttachment() {
return flagNoAttachment;
}
public void setFlagNoAttachment(Integer flagNoAttachment) {
this.flagNoAttachment = flagNoAttachment;
}
}
| [
"2636011620@qq.com"
] | 2636011620@qq.com |
d9bb58c6849275a244fa52a5d2ed3818311742db | 84703cd0b35b73d7ff6a2df28ec31e78248a5387 | /app/src/main/java/com/me/xpf/pigggeon/model/entity/UserFollower.java | ba4888d705e95d4c66e2e6582841965c854de17d | [] | no_license | willbe058/Pigggeon | 5af14212903ef75bcc4c5845a5031d98978dd733 | faf60e9bb23068e4b6a4fab2e41d726a3e31f25c | refs/heads/master | 2021-01-10T02:15:01.863214 | 2016-04-09T13:31:05 | 2016-04-09T13:31:05 | 50,593,658 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,181 | java | package com.me.xpf.pigggeon.model.entity;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by xpf on 2015/7/29.
*/
public class UserFollower implements Following{
@Expose
private Integer id;
@SerializedName("created_at")
@Expose
private String createdAt;
@Expose
private Follower follower;
/**
*
* @return
* The id
*/
public Integer getId() {
return id;
}
/**
*
* @param id
* The id
*/
public void setId(Integer id) {
this.id = id;
}
/**
*
* @return
* The createdAt
*/
public String getCreatedAt() {
return createdAt;
}
/**
*
* @param createdAt
* The created_at
*/
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
/**
*
* @return
* The follower
*/
public Follower getFollower() {
return follower;
}
/**
*
* @param follower
* The follower
*/
public void setFollower(Follower follower) {
this.follower = follower;
}
}
| [
"willbe058@gmail.com"
] | willbe058@gmail.com |
4c134af45fe26dc3eece2bf55c6662f062f4df32 | f03a8f6df128bcc3cde6d09452685336730cce3a | /src/interface_sample/Dog.java | fe8a10bc8069450168d1762289921ac5200677a3 | [] | no_license | nakaearth/java_samples | 639b59f4b1dcc374f92b85581769e9fd528fe184 | 1a4a44a8b463919e83be3f771912a3653fbe2178 | refs/heads/master | 2020-04-29T00:42:36.430532 | 2013-10-24T01:57:08 | 2013-10-24T01:57:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 220 | java | package interface_sample;
public class Dog implements Animal {
@Override
public void eat() {
System.out.println("I eat a dog food.");
}
@Override
public void sayHello() {
System.out.println("WON WON!");
}
}
| [
"naka5313@gmail.com"
] | naka5313@gmail.com |
aa1b3f61f79e0d27ed6c6cf8c9ea738e7824f2a9 | fe94bb01bbaf452ab1752cb3c1d1e4ecf297b9be | /src/main/java/com/opencart/setting/ModelSettingStoreResource.java | adb52d4059f2289d80a1d034cc58de1db102ec34 | [] | no_license | gmai2006/opencart | 9d3b037f09294973112bafbadd22d5edd8457de5 | dba44adabf4b8eab3bdb07062c887ba0a2a5405f | refs/heads/master | 2020-12-31T06:13:33.113098 | 2018-01-24T07:35:45 | 2018-01-24T07:35:45 | 80,637,392 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,791 | java | /*************************************************************************
*
* DATASCIENCE9 LLC CONFIDENTIAL
* __________________
*
* [2018] Datascience9 LLC
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Datascience9 LLC and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Datascience9 LLC
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Datascience9 LLC.
* @author Paul Mai - Datascience9 LLC
*/
package com.opencart.setting;
import static java.util.Objects.requireNonNull;
import java.util.List;
import java.util.logging.Logger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import com.google.inject.Inject;
import javax.ws.rs.core.MediaType;
import com.opencart.entity.*;
import com.opencart.entity.service.*;
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public class ModelSettingStoreResource {
private final static Logger logger = Logger.getLogger(ModelSettingStoreResource.class.getName());
private final ModelSettingStoreService service;
@Inject
protected ModelSettingStoreResource(final ModelSettingStoreService service) {
requireNonNull(service);
this.service = service;
}
@Path("/getStores")
@GET
public List<OcStore> getStores() {
//TOTO
//Normally no business logic should in RESTful but may be form validation can be here
//TODO
return service.getStores();
}
} | [
"gmai2006@gmail.com"
] | gmai2006@gmail.com |
c64165477efe1e068cd7baad9a45949b4e12e398 | de3145ba9eee5c2aa81bc0d1d98b77c97bfb7bc6 | /services/order/src/main/java/com/jemmy/services/order/model/domain/OmcShipping.java | a617402ce5d80fd32406080255e22de86cfa5712 | [
"Apache-2.0"
] | permissive | hijemmy/spring-cloud-blueprint | 63c718f66847d691924e4f35fd3d6edd666f1bf9 | 8ffa25bd59eb68df76dcf4978d4657f5be08b6c4 | refs/heads/master | 2020-04-01T03:37:22.347292 | 2018-11-28T03:44:14 | 2018-11-28T03:44:14 | 152,829,128 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,178 | java | /*
* Copyright (c) 2018. paascloud.net All Rights Reserved.
* 项目名称:paascloud快速搭建企业级分布式微服务平台
* 类名称:OmcShipping.java
* 创建人:刘兆明
* 联系方式:paascloud.net@gmail.com
* 开源地址: https://github.com/paascloud
* 博客地址: http://blog.paascloud.net
* 项目官网: http://paascloud.net
*/
package com.jemmy.services.order.model.domain;
import com.jemmy.common.core.mybatis.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.persistence.Column;
import javax.persistence.Table;
/**
* The class Omc shipping.
*
* @author paascloud.net@gmail.com
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "pc_omc_shipping")
public class OmcShipping extends BaseEntity {
private static final long serialVersionUID = 7337074530378267740L;
/**
* 用户id
*/
@Column(name = "user_id")
private Long userId;
/**
* 收货姓名
*/
@Column(name = "receiver_name")
private String receiverName;
/**
* 收货固定电话
*/
@Column(name = "receiver_phone_no")
private String receiverPhoneNo;
/**
* 收货移动电话
*/
@Column(name = "receiver_mobile_no")
private String receiverMobileNo;
/**
* 收货人省ID
*/
@Column(name = "province_id")
private Long provinceId;
/**
* 省份
*/
@Column(name = "province_name")
private String provinceName;
/**
* 收货人城市ID
*/
@Column(name = "city_id")
private Long cityId;
/**
* 收货人城市名称
*/
@Column(name = "city_name")
private String cityName;
/**
* 区/县
*/
@Column(name = "district_name")
private String districtName;
/**
* 区/县 编码
*/
@Column(name = "district_id")
private Long districtId;
/**
* 街道ID
*/
@Column(name = "street_id")
private Long streetId;
/**
* 接到名称
*/
@Column(name = "street_name")
private String streetName;
/**
* 详细地址
*/
@Column(name = "detail_address")
private String detailAddress;
/**
* 邮编
*/
@Column(name = "receiver_zip_code")
private String receiverZipCode;
/**
* 邮编
*/
@Column(name = "default_address")
private Integer defaultAddress;
} | [
"caiqingh2006@126.com"
] | caiqingh2006@126.com |
e1aafce73d7503558a1f75e3f79c8c7b7c781b21 | 95fa181c8a9bb16b19eb21a43b8b66bac4db0eac | /PR190-Parceler/app/src/androidTest/java/es/iessaladillo/pedrojoya/pr156/ApplicationTest.java | 09b0b7574d900b0006e51b8349783c853f48af61 | [] | no_license | Maycon1992/studio | 4ec746b46fc2d4a2ffb5ec6f739459034d213cfc | 0eb083b259786920efbd086ab02fca4164d032e4 | refs/heads/master | 2021-01-02T09:20:10.630345 | 2016-12-21T11:40:14 | 2016-12-21T11:40:14 | 78,685,531 | 1 | 0 | null | 2017-01-11T22:25:38 | 2017-01-11T22:25:38 | null | UTF-8 | Java | false | false | 362 | java | package es.iessaladillo.pedrojoya.pr190;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"pedrojoya@gmail.com"
] | pedrojoya@gmail.com |
506665e2f8d80b754233a2c6498103077a8787d9 | f6944f95fcb0d111f167e501d622dd11999ddd89 | /app/src/main/java/com/weiyu/sp/lsjy/utils/download/Engine.java | ebf02e9bc2f188ea446db9d17695dcae31b00aae | [] | no_license | bdxtx/aaaa | 07a391763ec3649439e22f96e7450b3f9edbb80e | f3a2cee82ad81c49f159094e442abc9739ef9110 | refs/heads/master | 2022-07-17T20:11:14.188196 | 2020-05-18T09:57:29 | 2020-05-18T09:57:29 | 264,182,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,887 | java | package com.weiyu.sp.lsjy.utils.download;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.http.GET;
import retrofit2.http.Streaming;
import retrofit2.http.Url;
/**
* 作者:王浩 邮件:bingoogolapple@gmail.com
* 创建时间:16/12/16 上午10:53
* 描述:
*/
class Engine {
private static Engine sInstance;
private DownloadApi mDownloadApi;
static final Engine getInstance() {
if (sInstance == null) {
synchronized (Engine.class) {
if (sInstance == null) {
sInstance = new Engine();
}
}
}
return sInstance;
}
private Engine() {
// 这里的 url 我随便填的,反正 DownloadApi 的 downloadFile 方法传的是绝对路径进来
mDownloadApi = new Retrofit.Builder()
.baseUrl("https://github.com/bingoogolapple/")
.client(getDownloadOkHttpClient())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
.create(DownloadApi.class);
}
private static OkHttpClient getDownloadOkHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.addNetworkInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder().body(new DownloadResponseBody(originalResponse.body())).build();
}
});
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[0];
}
}};
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
builder.sslSocketFactory(sslSocketFactory).hostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
return builder.build();
}
DownloadApi getDownloadApi() {
return mDownloadApi;
}
public interface DownloadApi {
@Streaming
@GET
Call<ResponseBody> downloadFile(@Url String url);
}
}
| [
"527146643@qq.com"
] | 527146643@qq.com |
de5354a0e9a6ad129955f8b0407831fc4d8219e1 | 64bdf13cd7157e51704bf8c2af386a124063be72 | /src/main/java/com/meldiron/infinityparkour/events/MoveEvent.java | ad7fb6b811b789d96d573febbb47661d22f99f25 | [] | no_license | Deathinflames/InfinityParkour | a3fcc3a2fb3d1fa197c4ca89ccdb7d553e19e24f | 03e25a68b4c13673122af020e763503069557100 | refs/heads/master | 2020-08-09T04:55:26.690149 | 2018-11-10T08:11:45 | 2018-11-10T08:11:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,148 | java | package com.meldiron.infinityparkour.events;
import com.meldiron.infinityparkour.managers.Game;
import com.meldiron.infinityparkour.managers.GameManager;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class MoveEvent implements Listener {
@EventHandler
public void onMove(PlayerMoveEvent e)
{
Location pLoc = e.getPlayer().getLocation();
Location underPlayer = pLoc.clone();
underPlayer.setX(Math.floor(underPlayer.getX()));
underPlayer.setY(Math.floor(underPlayer.getY()) - 1);
underPlayer.setZ(Math.floor(underPlayer.getZ()));
GameManager gm = GameManager.getInstance();
if(gm.isInArena(e.getPlayer()) == true) {
Game game = gm.getGameByLoc(underPlayer);
if(game != null) {
game.spawnAtRandomPos(underPlayer);
game.addScore();
}
}
Game g = gm.getGameByPlayer(e.getPlayer());
if(g != null) {
g.checkIfFalled();
}
}
}
| [
"matejbacocom@gmail.com"
] | matejbacocom@gmail.com |
7ab3b23bed14424465e96231e6008d4c9a655de7 | d9f9c73e19e19509ee6ab8f197672ff169065a71 | /CukeTest/src/test/java/TestRunner/RunnerClass.java | 4a90ab402a47b272a71a51aec13c6507f16d5fc6 | [] | no_license | MyOwnProject3108/BDD-DSAPI-New | 00877c26a06f7bdcd1e0063c5e27dfb0354567a7 | 04c058ed455d4ec51fd9bafdfb2870d9bb15d6bb | refs/heads/master | 2020-04-14T18:18:22.626320 | 2019-01-03T19:22:25 | 2019-01-03T19:22:25 | 164,013,751 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 333 | java | package TestRunner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src\\test\\java\\Resources",
glue = "C:\\Users\\Faiyyaz.Shaik\\entellitrack\\src\\test\\java\\StepDefinitions",
tags= {"@test1"})
public class RunnerClass {
}
| [
"Faiyyaz.Shaik@adstream.com"
] | Faiyyaz.Shaik@adstream.com |
60d36bf64f03f2179baabbef5419aba2207a825b | 36a7fa340de8f13f8bb7aea683ffa06273f2ef15 | /src/main/java/com/xiwei/xiangxu/dao/classses/IClassDao.java | ea675916c42d3b8f1d4a4c937ce2946e7923cd37 | [] | no_license | moujianbing/xiangxu | 2192100caf2057242c7ef943f6d0355c719ea132 | 0443d83b53885ba94dd814cec44268546a27ded1 | refs/heads/master | 2021-08-16T02:13:19.811624 | 2021-02-23T14:22:35 | 2021-02-23T14:22:35 | 244,955,217 | 0 | 0 | null | 2021-02-23T14:11:04 | 2020-03-04T16:56:06 | Java | UTF-8 | Java | false | false | 370 | java | package com.xiwei.xiangxu.dao.classses;
import com.xiwei.xiangxu.entity.Classes;
import org.apache.ibatis.annotations.Mapper;
import java.util.ArrayList;
/**
* @author limq7
* @version 1.0
* @date 2019/12/30 15:46
*/
@Mapper
public interface IClassDao {
public ArrayList<Classes> getAll();
public Classes getOneById(String classId,String classGradeId);
}
| [
"4053697902qq.com"
] | 4053697902qq.com |
0c4b7c82f0388da45af9d73aff3aa7793e574f7e | 2b1d331675dfc46acb9257a4ee280f8642a069f7 | /GraphImplementation.java | 5a8fbeb9ccdf56d39a04bcbeb7027633f379429e | [] | no_license | USF-CS-245-Spring-2020/cs-245-practice-09-Ray-popo | dce6464a1256d43be05cf664208e1e8a1cc0abba | 7c8b5e9e3c966d055edf9b357a91142ca5e0b7e1 | refs/heads/master | 2022-06-07T05:19:06.941518 | 2020-05-01T02:35:28 | 2020-05-01T02:35:28 | 260,324,689 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,064 | java | import java.util.ArrayList;
import java.util.List;
public class GraphImplementation implements Graph {
public int[][] graph;
public List <Integer> sortedList;
public int size;
public GraphImplementation(int s) {
size =s;
graph = new int[size][size];
sortedList = new ArrayList<>();
}
@Override
public void addEdge(int v1, int v2) throws Exception {
//checking size
if (v1>=size || v2>=size){
throw new Exception();
}//put into
graph[v1][v2]=1;
}
@Override
public List<Integer> topologicalSort() {
int[] numIncident = new int[size];
//any edge is in list(matrix), then increase the total number of incident
for (int i=0; i<size; i++) {
for (int j=0; j<size; j++) {
//checking if it is =1.
if (graph[i][j] == 1) {
numIncident[j]++;
}
}
}
//sort all vertices
while (sortedList.size() != size) {
for (int i=0; i<numIncident.length; i++) {
if (numIncident[i] == 0) {
//add elements into sorted list and -1 from total number of the vertices.(no second run)
sortedList.add(i);
numIncident[i] = -1;
for (int j=0; j<size; j++) {
if (graph[i][j] != 0) {
numIncident[j]--;
}
}
}
}
}
return sortedList;
}
@Override
public List<Integer> neighbors(int vertex) throws Exception {
//checking size fittable
if (vertex >= size) {
throw new Exception();
}
List<Integer> neighbors = new ArrayList<>();
// checking edges from vertex if is =1
for (int i=0; i<graph.length; i++) {
if (graph[vertex][i] == 1) {
neighbors.add(i);
}
}
return neighbors;
}
}
| [
"Ma3092353"
] | Ma3092353 |
124ff990b2e91357f028704400c1666b23d24e83 | 10048a9f869261fc568f94a050be453b9770b83d | /resources/src/main/java/com/infra/resources/core/usecase/networking/UpdateTrafficPolicy.java | 01ca156b1436613c7a5d3211ff37a01328f8ecde | [] | no_license | hmalatini/microservices-infrastructure | be765a313c8c9ba687d4099a72d7f2b670c608e3 | 2e4a36478db9965186264c7e9fb8e3f393ab5107 | refs/heads/main | 2023-06-15T11:32:20.101064 | 2021-07-09T14:36:34 | 2021-07-09T14:36:34 | 371,738,292 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,823 | java | package com.infra.resources.core.usecase.networking;
import com.infra.resources.adapter.controller.networking.NetworkingTrafficPolicyDTO;
import com.infra.resources.adapter.gateway.deployment.DeploymentGateway;
import com.infra.resources.adapter.repository.NetworkingTrafficPolicyRepository;
import com.infra.resources.core.domain.networking.NetworkingTrafficPolicy;
import com.infra.resources.core.exceptions.TrafficPolicyNotFoundException;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class UpdateTrafficPolicy {
private final NetworkingTrafficPolicyRepository repository;
private final TrafficPolictyDTOtoNetworkTrafficPolicy mapper;
private final DeploymentGateway deploymentGateway;
public NetworkingTrafficPolicy execute(String microserviceName, String environmentName, String name,
NetworkingTrafficPolicyDTO config) {
if (Objects.isNull(config)) {
return null;
}
NetworkingTrafficPolicy current = getTrafficPolicy(microserviceName, environmentName, name);
NetworkingTrafficPolicy update = mapper.map(microserviceName, environmentName, name, config, current.getId());
repository.save(update);
deploymentGateway.updateConfig(microserviceName, environmentName, "Updated traffic policy " + update.getName());
return update;
}
private NetworkingTrafficPolicy getTrafficPolicy(String microserviceName, String environmentName, String name) {
return repository.findByMicroserviceNameAndEnvironmentNameAndName(microserviceName, environmentName, name)
.orElseThrow(
TrafficPolicyNotFoundException::new);
}
}
| [
"hernan.malatini@glovoapp.com"
] | hernan.malatini@glovoapp.com |
7c7c3e5b1ec5ab6e883521be406052fd44a108af | e00f9d5987ec8a89dd7db0d08fbfcb6128522fbd | /src/collectionframeworkinjava/LinkedList_03.java | f4d291c12c0c01b6642a899a1237966ecb3f2750 | [] | no_license | sharifSel17/CoreJavaSolution | c393671140420e357ed4ea74c39faba8d961840f | 120d3e4d2cbfb50e6e1ca58805b9ae39f44f1c7d | refs/heads/master | 2021-01-01T19:59:29.455352 | 2017-08-13T22:55:05 | 2017-08-13T22:55:05 | 98,740,317 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package collectionframeworkinjava;
import java.util.LinkedList;
import java.util.List;
public class LinkedList_03 {
public static void main(String[] args) {
List<String> list = new LinkedList<String>();
list.add("10");
list.add("20");
list.add("true");
list.add("test");
System.out.println(list);
//list.clear();
System.out.println(list);
System.out.println(list.isEmpty());
List<String> list1 = new LinkedList<String>();
list1.add("10");
list1.add("20");
list1.add("true");
list1.add("test");
System.out.println(list);
}
}
| [
"sharifaiub09@gmail.com"
] | sharifaiub09@gmail.com |
a4b7b3509829a140ba6d9616fb7b789877389481 | 8e5bd9f132d58e42e34a47392f034e174d4cd2f2 | /PoligonalPoints/src/points/CheckPoints.java | 9a78256f2d2395d4cb2055ddaf3123f7451b8e75 | [] | no_license | D13seL93/WorkRepo | 8e43e846afede6fb872311200009f49fb38d7275 | 1c1cae3d57bcc7f39aa8e70b91351af8c74c951b | refs/heads/master | 2016-09-09T17:02:44.104075 | 2015-07-13T06:29:51 | 2015-07-13T06:29:51 | 38,994,268 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | package points;
public class CheckPoints {
private int x;
private int y;
public CheckPoints(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
| [
"alexandru.tuduce@recognos.ro"
] | alexandru.tuduce@recognos.ro |
bb344d4e5b5b05c90924d0bc8c8c5c9919a1dc87 | 8bc8e94e7d9d2a6c6aaae2a03b1280a1baa5dd23 | /src/apple/coreservices/struct/DXInfo.java | df4ac3329b8ad240f9a74b056013f5c10e4152a7 | [] | no_license | VadimZharkov/natj-mac-example | fd5eb814371bde26d7b77c54edbeebb3fa667851 | 94af6b2c1d01fb3f9ebd28550d5996fe49fe3ddc | refs/heads/master | 2020-06-22T00:09:07.333774 | 2019-07-18T12:44:25 | 2019-07-18T12:44:25 | 197,585,255 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,375 | java | /*
Copyright 2014-2016 Intel Corporation
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 apple.coreservices.struct;
import org.moe.natj.c.StructObject;
import org.moe.natj.c.ann.Structure;
import org.moe.natj.c.ann.StructureField;
import org.moe.natj.general.NatJ;
import org.moe.natj.general.Pointer;
import org.moe.natj.general.ann.ByValue;
import org.moe.natj.general.ann.Generated;
import apple.struct.Point;
@Generated
@Structure(alignment = 2)
public final class DXInfo extends StructObject {
static {
NatJ.register();
}
private static long __natjCache;
@Generated
public DXInfo() {
super(DXInfo.class);
}
@Generated
protected DXInfo(Pointer peer) {
super(peer);
}
@Generated
@StructureField(order = 0, isGetter = true)
@ByValue
public native Point frScroll();
@Generated
@StructureField(order = 0, isGetter = false)
public native void setFrScroll(@ByValue Point value);
@Generated
@StructureField(order = 1, isGetter = true)
public native int frOpenChain();
@Generated
@StructureField(order = 1, isGetter = false)
public native void setFrOpenChain(int value);
@Generated
@StructureField(order = 2, isGetter = true)
public native byte frScript();
@Generated
@StructureField(order = 2, isGetter = false)
public native void setFrScript(byte value);
@Generated
@StructureField(order = 3, isGetter = true)
public native byte frXFlags();
@Generated
@StructureField(order = 3, isGetter = false)
public native void setFrXFlags(byte value);
@Generated
@StructureField(order = 4, isGetter = true)
public native short frComment();
@Generated
@StructureField(order = 4, isGetter = false)
public native void setFrComment(short value);
@Generated
@StructureField(order = 5, isGetter = true)
public native int frPutAway();
@Generated
@StructureField(order = 5, isGetter = false)
public native void setFrPutAway(int value);
}
| [
"vadim.zharkov@gmail.com"
] | vadim.zharkov@gmail.com |
60bfe3a784b2ebe941976d3821b00e4defe2525e | 3c7fa11025a91ce6f87709f3e5f3001ced55afc8 | /src/com/main/wego/Fragment2.java | 755deece7dd9f071399f79c4c82829cd45e6f706 | [] | no_license | alvaro-ramirez/Wego | 96a1b3ca78831e0edb279e42afccf3209afa4c78 | dc7228b076c6a77a3ec68a2c4feea89786721d27 | refs/heads/master | 2020-12-30T11:14:52.198018 | 2014-08-17T16:31:10 | 2014-08-17T16:31:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 414 | java | package com.main.wego;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_2, container, false);
}
}
| [
"alvaro@localhost.localdomain"
] | alvaro@localhost.localdomain |
2a19fb9d5708f5346753bc35e33cb4cc9264b7da | 1e6722a77f4ff28cc40c8c062c1d731949eabe5e | /src/main/java/com/eorionsolution/iot/epaper/service/UploadPictureToRSService.java | 9aef6607da4a049d7feb8e464332359cad5da70e | [] | no_license | iamfocused/epaper | 993ec0729abdfb0eb9cd55ce965e9e162d955ea4 | 1ac77e8978391f0216279d9ce9ff8e9cdfe22928 | refs/heads/master | 2022-06-25T06:27:32.066164 | 2019-10-16T02:42:00 | 2019-10-16T02:42:00 | 215,441,326 | 0 | 0 | null | 2022-06-17T02:34:15 | 2019-10-16T02:41:54 | JavaScript | UTF-8 | Java | false | false | 6,318 | java | package com.eorionsolution.iot.epaper.service;
import com.eorionsolution.iot.epaper.config.PdfProperties;
import com.eorionsolution.iot.epaper.repository.ScreenDeviceRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriComponentsBuilder;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@Service
@Slf4j
public class UploadPictureToRSService {
@Autowired
ScreenDeviceRepository screenDeviceRepository;
@Autowired
PdfProperties pdfProperties;
public boolean upload(MultipartFile file, String ip, Boolean emptyFolders, Integer refresh_interval) throws Exception {
String filename = StringUtils.cleanPath(file.getOriginalFilename());
Optional<String> fileExtensionOptional = Optional.ofNullable(filename).filter(f -> f.contains(".")).map(f -> f.substring(filename.lastIndexOf(".") + 1));
String fileExtension = fileExtensionOptional.orElse("unknown");
List<String> fileType = Arrays.asList("pdf", "png");
List<String> picType = Arrays.asList("png");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
if (fileType.stream().anyMatch(str -> str.trim().equals(fileExtension))) {
if (picType.stream().anyMatch(str -> str.trim().equals(fileExtension))) {
InputStream inputStream = file.getInputStream();
BufferedImage image = ImageIO.read(inputStream);
//convert image to black and white picture and zip
byte[] greyArray = picToGreyArrey(image);
ZipEntry entry = new ZipEntry("png_" + Long.toString(System.currentTimeMillis()) + ".bitmap");
entry.setSize(greyArray.length);
zos.putNextEntry(entry);
zos.write(greyArray);
zos.closeEntry();
} else {//处理pdf
String currentEpoch = Long.toString(System.currentTimeMillis());
final PDDocument document = PDDocument.load(file.getInputStream());
try {
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, pdfProperties.getDpi(), ImageType.RGB);
byte[] greyArray = picToGreyArrey(bim);
ZipEntry entry = new ZipEntry("pdf_" + currentEpoch + "_" + page + ".bitmap");
entry.setSize(greyArray.length);
zos.putNextEntry(entry);
zos.write(greyArray);
zos.closeEntry();
}
document.close();
} catch (IOException e) {
throw new Exception("Exception while trying to create pdf document - " + e);
}
}
} else {
throw new Exception("File suffix error,Upload pdf or png only");
}
zos.close();
byte[] input = baos.toByteArray();
//send to Raspberry Pi
try {
RestTemplate restTemplate = new RestTemplate();
HttpEntity<byte[]> entity = new HttpEntity<>(input, null);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://" + ip + ":5000/api/upload")
.queryParam("empty_folders", emptyFolders)
.queryParam("refresh_interval", refresh_interval)
.queryParam("voltage", screenDeviceRepository.findFirstByDeviceIp(ip).get().getDeviceVoltage());
ResponseEntity<String> responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
HttpStatus status = responseEntity.getStatusCode();
if (!status.is2xxSuccessful()) {
throw new Exception("Send to Raspberry Pi error,Please contact the administrator");
}
} catch (Exception e) {
throw new Exception("Connect Raspberry Pi error,Please contact the administrator");
}
return true;
}
public static byte[] picToGreyArrey(BufferedImage bufferedImage) throws Exception{
//Image tmp = bufferedImage.getScaledInstance(1872, 1404, Image.SCALE_SMOOTH);
//BufferedImage copImage = new BufferedImage(1872, 1404, BufferedImage.TYPE_INT_ARGB);
Image tmp = bufferedImage.getScaledInstance(1200, 825, Image.SCALE_SMOOTH);
BufferedImage copImage = new BufferedImage(1200, 825, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = copImage.createGraphics();
g2d.drawImage(tmp, 0, 0, null);
g2d.dispose();
javax.imageio.ImageIO.write(copImage, "png", new File("D:\\zipzip\\test\\"+ Long.toString(System.currentTimeMillis())+".png"));
byte[] greyArray = new byte[copImage.getHeight() * copImage.getWidth()];
for (int i = 0; i < copImage.getHeight(); i++)
for (int j = 0; j < copImage.getWidth(); j++) {
try {
java.awt.Color color = new Color(copImage.getRGB(j, i));
greyArray[copImage.getWidth() * i + j] = (byte) (((color.getBlue() + color.getGreen() + color.getRed()) / 3) & 0xFF);
} catch (Exception e) {
e.printStackTrace();
System.out.format("i=%d, j=%d\n", i, j);
}
}
return greyArray;
}
}
| [
"bao.isaac@gmail.com"
] | bao.isaac@gmail.com |
a5c8a8ef7580f706669f2f4d75fac1cf138c5ed8 | 9d32980f5989cd4c55cea498af5d6a413e08b7a2 | /A1_7_1_1/src/main/java/android/provider/SearchIndexablesProvider.java | ae994ef2bbcbbd2c5b7a278696952b0beafbe31d | [] | no_license | liuhaosource/OppoFramework | e7cc3bcd16958f809eec624b9921043cde30c831 | ebe39acabf5eae49f5f991c5ce677d62b683f1b6 | refs/heads/master | 2023-06-03T23:06:17.572407 | 2020-11-30T08:40:07 | 2020-11-30T08:40:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,333 | java | package android.provider;
import android.Manifest.permission;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.net.Uri;
import android.provider.SearchIndexablesContract.NonIndexableKey;
import android.provider.SearchIndexablesContract.RawData;
import android.provider.SearchIndexablesContract.XmlResource;
public abstract class SearchIndexablesProvider extends ContentProvider {
private static final int MATCH_NON_INDEXABLE_KEYS_CODE = 3;
private static final int MATCH_RAW_CODE = 2;
private static final int MATCH_RES_CODE = 1;
private static final String TAG = "IndexablesProvider";
private String mAuthority;
private UriMatcher mMatcher;
public abstract Cursor queryNonIndexableKeys(String[] strArr);
public abstract Cursor queryRawData(String[] strArr);
public abstract Cursor queryXmlResources(String[] strArr);
public void attachInfo(Context context, ProviderInfo info) {
this.mAuthority = info.authority;
this.mMatcher = new UriMatcher(-1);
this.mMatcher.addURI(this.mAuthority, SearchIndexablesContract.INDEXABLES_XML_RES_PATH, 1);
this.mMatcher.addURI(this.mAuthority, SearchIndexablesContract.INDEXABLES_RAW_PATH, 2);
this.mMatcher.addURI(this.mAuthority, SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH, 3);
if (!info.exported) {
throw new SecurityException("Provider must be exported");
} else if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grantUriPermissions");
} else if (permission.READ_SEARCH_INDEXABLES.equals(info.readPermission)) {
super.attachInfo(context, info);
} else {
throw new SecurityException("Provider must be protected by READ_SEARCH_INDEXABLES");
}
}
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
switch (this.mMatcher.match(uri)) {
case 1:
return queryXmlResources(null);
case 2:
return queryRawData(null);
case 3:
return queryNonIndexableKeys(null);
default:
throw new UnsupportedOperationException("Unknown Uri " + uri);
}
}
public String getType(Uri uri) {
switch (this.mMatcher.match(uri)) {
case 1:
return XmlResource.MIME_TYPE;
case 2:
return RawData.MIME_TYPE;
case 3:
return NonIndexableKey.MIME_TYPE;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
}
public final Uri insert(Uri uri, ContentValues values) {
throw new UnsupportedOperationException("Insert not supported");
}
public final int delete(Uri uri, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException("Delete not supported");
}
public final int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException("Update not supported");
}
}
| [
"dstmath@163.com"
] | dstmath@163.com |
3811c8ed22ba0140107a9b5bf82dd12c1c620b36 | 13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3 | /crash-reproduction-new-fitness/results/XWIKI-13196-1-13-Single_Objective_GGA-IntegrationSingleObjective-BasicBlockCoverage/org/xwiki/model/reference/EntityReference_ESTest.java | 82eca55a350d24cca06fa8f6598f1c29e5e841d3 | [
"MIT",
"CC-BY-4.0"
] | permissive | STAMP-project/Botsing-basic-block-coverage-application | 6c1095c6be945adc0be2b63bbec44f0014972793 | 80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da | refs/heads/master | 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,144 | java | /*
* This file was automatically generated by EvoSuite
* Sat May 16 20:58:17 UTC 2020
*/
package org.xwiki.model.reference;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
import org.xwiki.model.EntityType;
import org.xwiki.model.reference.EntityReference;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class EntityReference_ESTest extends EntityReference_ESTest_scaffolding {
@Test(timeout = 4000)
public void test0() throws Throwable {
String string0 = "";
String string1 = "] does not belong to the parents chain of the reference [";
EntityType entityType0 = EntityType.SPACE;
EntityReference entityReference0 = new EntityReference("] does not belong to the parents chain of the reference [", entityType0);
EntityReference entityReference1 = entityReference0.getRoot();
entityReference0.getType();
// Undeclared exception!
entityReference1.setName("");
}
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
d960a95df3760629ea06ce73d9fee4622719b891 | 3a4f8c1c4b6b01ae4930b7eb5f62b442e49d5ae8 | /frequent/_304_RangeSumQuery2D.java | 07dae9640c5a1c1ec27ece69007d26289b7898d5 | [] | no_license | eric-0x72/leetcode | 29f9e9a76dc31c6fbaaf37fcc210d7259227066a | 3ecb422a30fc063b02a0efd1922a0d73ff1b0139 | refs/heads/master | 2022-10-07T07:43:23.420978 | 2022-09-30T02:02:34 | 2022-09-30T02:02:34 | 246,808,952 | 1 | 0 | null | 2020-03-27T12:50:29 | 2020-03-12T10:43:03 | Java | UTF-8 | Java | false | false | 1,210 | java | package frequent;
import java.util.Arrays;
import javax.print.attribute.standard.PDLOverrideSupported;
/**
* Your NumMatrix object will be instantiated and called as such:
*
* NumMatrix obj = new NumMatrix(matrix);
*
* int param_1 = obj.sumRegion(row1,col1,row2,col2);
*
*/
public class _304_RangeSumQuery2D {
private int[][] dp;
public _304_RangeSumQuery2D(int[][] matrix) {
if (matrix.length == 0 || matrix[0].length == 0)
return;
int n = matrix.length;
int m = matrix[0].length;
dp = new int[n][m];
for (int row = 0; row < n; row++) {
for (int col = 0; col < m; col++) {
// if col==0, then keep matrix element
dp[row][col] = (col >= 1 ? dp[row][col - 1] + matrix[row][col] : matrix[row][col]);
}
}
System.out.println(Arrays.deepToString(dp));
}
public int sumRegion(int row1, int col1, int row2, int col2) {
int sum = 0;
for (int row = row1; row <= row2; row++) {
sum += dp[row][col2] - (col1 >= 1 ? dp[row][col1 - 1] : 0);
}
return sum;
}
public static void main(String[] args) {
int[][] mat = { { -1 } };
_304_RangeSumQuery2D a = new _304_RangeSumQuery2D(mat);
int res = a.sumRegion(0, 0, 0, 0);
System.out.println(res);
}
}
| [
"1466870240@qq.com"
] | 1466870240@qq.com |
0f5ab1cacb01a2121252e20b5e73d3fbd26ff097 | d082096a53dbdb0f7a30cdc9d9b1697cce89ca2c | /app/src/main/java/com/example/passwordmanagerapp/generateNewPassword.java | c0f880f6a33c29c6e3e0bfca92155c19d4a4a84d | [] | no_license | mjohnston548/passwordManagerAndroid | eddaec5c495b719e4b5062ee23813ae600b2e8e9 | e5f6a935aa7e27382d11ad3122c52407e9057616 | refs/heads/master | 2022-06-21T01:00:31.924540 | 2020-05-13T12:46:24 | 2020-05-13T12:46:24 | 263,627,643 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,295 | java | package com.example.passwordmanagerapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
public class generateNewPassword extends AppCompatActivity {
Button managePasswordsButton, savePasswordButton,generateNewDigitsButton;
EditText passwordBlock1,passwordBlock2,passwordBlock3,passwordBlock4,passwordBlock5;
EditText websiteApp,usernameEmail;
final static ArrayList<Password> passwordArrayList=new ArrayList<Password>();
static ArrayList<String> usedPasswordCategories=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_generate_new_password);
passwordBlock1=findViewById(R.id.editText);
passwordBlock2=findViewById(R.id.editText2);
passwordBlock3=findViewById(R.id.editText3);
passwordBlock4=findViewById(R.id.editText4);
passwordBlock5=findViewById(R.id.editText5);
websiteApp=findViewById(R.id.editText7);
usernameEmail=findViewById(R.id.editText6);
generateNewDigitsButton=findViewById(R.id.button3);
generateNewDigitsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText [] passwordBlockArray = new EditText[]{passwordBlock1, passwordBlock2, passwordBlock3, passwordBlock4, passwordBlock5};
for (int i=1;i<6;i++){
digitGenerator(9,0,passwordBlockArray[i-1]);
}
// digitGenerator(9,0,passwordBlock1);
}
});
//spinner configuration
final Spinner spinner=(Spinner) findViewById(R.id.spinner2);
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this,R.array.passwordCategoriesArray,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
savePasswordButton=findViewById(R.id.button);
savePasswordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
//make the password object from entered data
Password newPassword=new Password(passwordBlock1.getText().toString()+
passwordBlock2.getText().toString()+passwordBlock3.getText().toString()+passwordBlock4.getText().toString()
+passwordBlock5.getText().toString(),usernameEmail.getText().toString(),websiteApp.getText().toString(),spinner.getSelectedItem().toString(),new Date());
passwordArrayList.add(newPassword);
//add the password category that the user selected to a persistent array
usedPasswordCategories.add(spinner.getSelectedItem().toString());
Toast.makeText(getApplicationContext(),"Password Stored",Toast.LENGTH_SHORT).show();
// clearing the user input fields
EditText [] textFieldsArray = new EditText[]{passwordBlock1, passwordBlock2, passwordBlock3, passwordBlock4, passwordBlock5,usernameEmail,websiteApp};
clearFields(textFieldsArray); //should reset spinner too
//maybe send user to manage passwords activity after storing password?
Intent intent=new Intent(getApplicationContext(),managePasswords.class);
startActivity(intent);
}catch (IllegalArgumentException e){
Toast.makeText(getApplicationContext(), e.getMessage(),Toast.LENGTH_LONG).show();
}
}
});
managePasswordsButton=findViewById(R.id.button4);
managePasswordsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(getApplicationContext(),managePasswords.class);
startActivity(intent);
}
});
}
public void digitGenerator(int max, int min, EditText passwordBlock){
// First time on this course where ive written a function which takes a non-primitive type!
Random rand=new Random();
int randomNum=(int) rand.nextInt((max-min)+1)+min;
int randomNum2=(int) rand.nextInt((max-min)+1)+min;
passwordBlock.setText(String.valueOf(randomNum)+String.valueOf(randomNum2), TextView.BufferType.EDITABLE);
}
public void clearFields(EditText [] textFields){
for (int i=0;i<textFields.length;i++){
textFields[i].getText().clear();
}
}
public static ArrayList<Password> getPasswordArray(){
return passwordArrayList;
}
public static ArrayList<String> getPasswordCategoryArray(){return usedPasswordCategories;}
}
| [
"53264004+mjohnston548@users.noreply.github.com"
] | 53264004+mjohnston548@users.noreply.github.com |
6bc3cc13f6a58030b532abf938d84feb6f52bf32 | 8341fd6d7ee1a42d0d97fb812dff0555d653db48 | /src/main/java/me/hackerguardian/main/Utils/SLMaths.java | 71c59a7cc2ab311ba84657570e2e1e393bc35ac1 | [] | no_license | hypersmc/HackerGuardian | a24f761af263dabdff5f72e9712ee1cf06d1acfe | 3503a2b7a8d00de1d43f2bfb9258566e33929251 | refs/heads/master | 2023-07-07T16:26:33.674291 | 2021-08-16T08:42:11 | 2021-08-16T08:42:11 | 352,810,266 | 3 | 0 | null | 2021-08-16T08:42:12 | 2021-03-29T23:20:06 | Java | UTF-8 | Java | false | false | 5,795 | java | package me.hackerguardian.main.Utils;
import me.hackerguardian.main.HackerGuardian;
import me.hackerguardian.main.ML.LabeledData;
import org.apache.commons.lang.ArrayUtils;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Function;
import java.util.stream.Collectors;
public class SLMaths {
private SLMaths() {}
public static double[] extractFeatures(List<Float> angleSequence) {
List<Double> anglesDouble = toDoubleList(angleSequence);
List<Double> anglesDoubleDelta = calculateDelta(anglesDouble);
double featureA = stddev(anglesDouble);
double featureB = mean(anglesDouble);
double featureC = stddev(anglesDoubleDelta);
double featureD = mean(anglesDoubleDelta);
return new double[] {featureA, featureB, featureC, featureD};
}
public static List<Double> calculateDelta(List<Double> doubleList) {
if (doubleList.size() <= 1) {
throw new IllegalArgumentException(
"There is supposed to be 2 instead of 1 to calculate Delta"
);
}
List<Double> out = new ArrayList<>();
for (int i = 1; i <= doubleList.size() - 1; i++)
out.add(doubleList.get(i) - doubleList.get(i - 1));
return out;
}
public static List<Double> toDoubleList(List<Float> floatList) {
try {
return floatList.stream().map(e -> (double) e).collect(Collectors.toList());
} catch (Exception e) {
if (HackerGuardian.getInstance().getConfig().getBoolean("debug")) e.printStackTrace();
}
return null;
}
public static double mean(List<Double> angles) {
return angles.stream().mapToDouble(e -> e).sum() / angles.size();
}
public static double stddev(List<Double> angles) {
double mean = mean(angles);
double output = 0;
for (double angle : angles)
output += Math.pow(angle - mean, 2);
return output / angles.size();
}
public static double euclideanDistance(double[] vectorA, double[] vectorB) {
validateDimension("2 vectors are needed to be in the same dim!", vectorA, vectorB);
double dist = 0;
for (int i = 0; i <= vectorA.length -1; i++)
dist += Math.pow(vectorA[i] - vectorB[i], 2);
return Math.sqrt(dist);
}
public static List<Double> toList(double[] doubleArray) {
return Arrays.asList(ArrayUtils.toObject(doubleArray));
}
public static double[] toArray(List<Double> doubleList) {
return doubleList.stream().mapToDouble(e -> e).toArray();
}
public static double[] randomArray(int length) {
double[] randomArray = new double[length];
applyFunc(randomArray, e -> e = ThreadLocalRandom.current().nextDouble());
return randomArray;
}
public static void applyFunc(double[] doubleArray, Function<Double, Double> func) {
for (int i = 0; i <= doubleArray.length - 1; i++)
doubleArray[i] = func.apply(doubleArray[i]);
}
public static double[] add(double[] vectorA, double[] vectorB) {
validateDimension("Two vectors need to have exact the same dimension", vectorA, vectorB);
double[] output = new double[vectorA.length];
for (int i = 0; i <= vectorA.length - 1; i++)
output[i] = vectorA[i] + vectorB[i];
return output;
}
public static double[] subtract(double[] vectorA, double[] vectorB) {
validateDimension("Two vectors need to have exact the same dimension", vectorA, vectorB);
return add(vectorA, opposite(vectorB));
}
public static double[] opposite(double[] vector) {
return multiply(vector, -1);
}
public static double[] multiply(double[] vector, double factor) {
double[] output = vector.clone();
applyFunc(output, e -> e * factor);
return output;
}
public static double[][] normalize(List<LabeledData> dataset) {
validateDimension("Data in dataset have inconsistent features",
dataset.stream().map(LabeledData::getData).toArray(double[][]::new));
int dimension = dataset.get(0).getData().length;
double[][] minMax = new double[dimension][2];
for (int row = 0; row <= dimension - 1; row++) {
int rowCurrent = row;
double min = Collections.min(dataset.stream()
.map(data -> data.getData()[rowCurrent]).collect(Collectors.toList()));
double max = Collections.max(dataset.stream()
.map(data -> data.getData()[rowCurrent]).collect(Collectors.toList()));
minMax[row] = new double[]{min, max};
for (int i = 0; i <= dataset.size() - 1; i++) {
double originalValue = dataset.get(i).getData()[row];
dataset.get(i).setData(row, (originalValue - min) / (max - min));
}
}
return minMax;
}
public static double normalize(double value, double min, double max) {
return (value - min) / (max - min);
}
public static double round(double value, int precision, RoundingMode mode) {
return BigDecimal.valueOf(value).round(new MathContext(precision, mode)).doubleValue();
}
@SuppressWarnings("SameParameterValue")
private static void validateDimension(String message, double[]... vectors) {
for (int i = 0; i <= vectors.length - 1; i++) {
if (vectors[0].length != vectors[i].length)
throw new IllegalArgumentException(message);
}
}
}
| [
"mhypers@gmail.com"
] | mhypers@gmail.com |
3c37faa983b69ea0472cd953e7619c35bb40cf4f | c2a279c151ad5efac3acb635830fa942b927a5a5 | /WebServer/src/main/java/webserver/entities/MeteoData.java | 26dd8d29da02b4cf1197cca3920d2a3b9099306e | [] | no_license | ZeroPointSystem/MeteoServiceSystem | e5b9c3af7775fa795a9457181d7f737a8cf2ab27 | ad803539c03b12976f74a1cf9bf800ad5b7dac5d | refs/heads/master | 2016-08-12T08:46:20.969791 | 2015-06-04T01:14:46 | 2015-06-04T01:14:46 | 36,839,959 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,540 | java | package webserver.entities;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* Created by Zetro on 11.05.2015.
*/
@Entity
@Table(name = "meteo_data")
public class MeteoData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "temperature")
private float temperature;
@Column(name = "pressure")
private float pressure;
@Column(name = "humidity")
private float humidity;
@Column(name = "time")
private Timestamp time;
// PRTS
public float getTemperature() {
return temperature;
}
public void setTemperature(float temperature) {
this.temperature = temperature;
}
public float getPressure() {
return pressure;
}
public void setPressure(float pressure) {
this.pressure = pressure;
}
public float getHumidity() {
return humidity;
}
public void setHumidity(float humidity) {
this.humidity = humidity;
}
public Timestamp getTime() {
return time;
}
public void setTime(Timestamp time) {
this.time = time;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public String toString() {
return "MeteoData{" +
"humidity=" + humidity +
", id=" + id +
", temperature=" + temperature +
", pressure=" + pressure +
", time=" + time +
'}';
}
}
| [
"ZeroPointSystem@gmail.com"
] | ZeroPointSystem@gmail.com |
86feec7f1a794c0a14c3709626b6d80a42aabc0b | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/27/27_d1f0b2e97ffd57f6d4ecaef4c6413681a3a44273/IRClassCompiler/27_d1f0b2e97ffd57f6d4ecaef4c6413681a3a44273_IRClassCompiler_t.java | e659098d0c120b6676c13bb2035915f61ca8631c | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 49,019 | java | package gwtsu;
import com.google.gwt.thirdparty.guava.common.collect.Lists;
import com.google.gwt.thirdparty.guava.common.collect.Maps;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import gw.lang.ir.IRAnnotation;
import gw.lang.ir.IRClass;
import gw.lang.ir.IRElement;
import gw.lang.ir.IRExpression;
import gw.lang.ir.IRStatement;
import gw.lang.ir.IRSymbol;
import gw.lang.ir.IRType;
import gw.lang.ir.expression.IRArithmeticExpression;
import gw.lang.ir.expression.IRArrayLengthExpression;
import gw.lang.ir.expression.IRArrayLoadExpression;
import gw.lang.ir.expression.IRBooleanLiteral;
import gw.lang.ir.expression.IRCastExpression;
import gw.lang.ir.expression.IRCharacterLiteral;
import gw.lang.ir.expression.IRClassLiteral;
import gw.lang.ir.expression.IRCompositeExpression;
import gw.lang.ir.expression.IRConditionalAndExpression;
import gw.lang.ir.expression.IRConditionalOrExpression;
import gw.lang.ir.expression.IREqualityExpression;
import gw.lang.ir.expression.IRFieldGetExpression;
import gw.lang.ir.expression.IRIdentifier;
import gw.lang.ir.expression.IRInstanceOfExpression;
import gw.lang.ir.expression.IRMethodCallExpression;
import gw.lang.ir.expression.IRNegationExpression;
import gw.lang.ir.expression.IRNewArrayExpression;
import gw.lang.ir.expression.IRNewExpression;
import gw.lang.ir.expression.IRNewMultiDimensionalArrayExpression;
import gw.lang.ir.expression.IRNoOpExpression;
import gw.lang.ir.expression.IRNotExpression;
import gw.lang.ir.expression.IRNullLiteral;
import gw.lang.ir.expression.IRNumericLiteral;
import gw.lang.ir.expression.IRPrimitiveTypeConversion;
import gw.lang.ir.expression.IRRelationalExpression;
import gw.lang.ir.expression.IRStringLiteralExpression;
import gw.lang.ir.expression.IRTernaryExpression;
import gw.lang.ir.statement.IRArrayStoreStatement;
import gw.lang.ir.statement.IRAssignmentStatement;
import gw.lang.ir.statement.IRBreakStatement;
import gw.lang.ir.statement.IRCatchClause;
import gw.lang.ir.statement.IRContinueStatement;
import gw.lang.ir.statement.IRDoWhileStatement;
import gw.lang.ir.statement.IREvalStatement;
import gw.lang.ir.statement.IRFieldDecl;
import gw.lang.ir.statement.IRFieldSetStatement;
import gw.lang.ir.statement.IRForEachStatement;
import gw.lang.ir.statement.IRIfStatement;
import gw.lang.ir.statement.IRMethodCallStatement;
import gw.lang.ir.statement.IRMethodStatement;
import gw.lang.ir.statement.IRMonitorLockAcquireStatement;
import gw.lang.ir.statement.IRMonitorLockReleaseStatement;
import gw.lang.ir.statement.IRNoOpStatement;
import gw.lang.ir.statement.IRReturnStatement;
import gw.lang.ir.statement.IRStatementList;
import gw.lang.ir.statement.IRSwitchStatement;
import gw.lang.ir.statement.IRSyntheticStatement;
import gw.lang.ir.statement.IRThrowStatement;
import gw.lang.ir.statement.IRTryCatchFinallyStatement;
import gw.lang.ir.statement.IRWhileStatement;
import gw.lang.reflect.IMethodInfo;
import gw.lang.reflect.IParameterInfo;
import gw.lang.reflect.IType;
import gw.lang.reflect.Modifier;
import gw.lang.reflect.TypeSystem;
import gw.lang.reflect.gs.IGosuClass;
import gw.lang.reflect.java.IJavaType;
import gw.util.GosuClassUtil;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import static gwtsu.CheckedExceptionAnalyzer.*;
/**
* @author kprevas
*/
public class IRClassCompiler {
private final static Map<String, String> replacementTypes = Maps.newHashMap();
private final static Map<String, String> replacementMethods = Maps.newHashMap();
static {
replacementTypes.put("gw.lang.reflect.IType", "Class");
replacementTypes.put("gw.lang.parser.EvaluationException", "RuntimeException");
replacementMethods.put("gw.internal.gosu.ir.transform.statement.ForEachStatementTransformer.makeIterator",
"gwtsu.Util.makeIterator");
replacementMethods.put("gw.internal.gosu.runtime.GosuRuntimeMethods.typeof",
"gwtsu.Util.typeof");
replacementMethods.put("gw.lang.reflect.TypeSystem.getFromObject",
"gwtsu.Util.typeof");
}
private IRClass irClass;
private ExceptionMap exceptionMap;
private Stack<StringBuilder> auxMethodsBuilders = new Stack<StringBuilder>();
private Set<IRMethodStatement> ctors = Sets.newHashSet();
private int uid = 0;
private boolean isOverlay;
private boolean isStatic;
public IRClassCompiler(IRClass irClass, ExceptionMap exceptionMap) {
this.irClass = irClass;
this.exceptionMap = exceptionMap;
}
public String compileToJava() {
StringBuilder builder = new StringBuilder();
builder.append("package ")
.append(GosuClassUtil.getPackage(getTypeName(irClass.getThisType())))
.append(";\n");
appendClass(builder);
return builder.toString();
}
private void appendClass(StringBuilder builder) {
for (IRAnnotation annotation : irClass.getAnnotations()) {
appendAnnotation(builder, annotation);
}
builder.append(Modifier.toModifierString(
irClass.getModifiers() & ~Modifier.SYNCHRONIZED));
if (irClass.getThisType().isInterface()) {
builder.append(" interface ");
} else {
builder.append(" class ");
}
String relativeName = getRelativeClassName();
builder.append(relativeName);
IRType superType = irClass.getSuperType();
if (superType != null) {
if (getTypeName(superType).equals("gwtsu.JSONOverlay")) {
isOverlay = true;
builder.append(" extends com.google.gwt.core.client.JavaScriptObject");
} else {
builder.append(" extends ")
.append(getTypeName(superType));
}
}
List<IRType> interfaces = Lists.newArrayList(irClass.getInterfaces());
Iterator<IRType> iterator = interfaces.iterator();
while (iterator.hasNext()) {
IRType type = iterator.next();
if (getTypeName(type).equals("gw.lang.reflect.gs.IGosuClassObject")) {
iterator.remove();
}
}
if (!interfaces.isEmpty()) {
builder.append(" implements ");
for (int i = 0, interfacesSize = interfaces.size(); i < interfacesSize; i++) {
if (i > 0) {
builder.append(", ");
}
builder.append(getTypeName(interfaces.get(i)));
}
}
builder.append(" {\n");
if (isOverlay) {
builder.append("protected ")
.append(getRelativeClassName())
.append("() {}\n")
.append("public static native ")
.append(getRelativeClassName())
.append(" $gwtsu$parse(String json) /*-{ return JSON.parse(json); }-*/;\n");
} else {
for (IRFieldDecl field : irClass.getFields()) {
appendField(builder, field);
}
}
for (IRMethodStatement method : irClass.getMethods()) {
if (method.getName().equals("<init>")) {
ctors.add(method);
}
}
for (IRMethodStatement method : irClass.getMethods()) {
appendMethod(builder, method);
}
builder.append("}");
}
private void appendField(StringBuilder builder, IRFieldDecl field) {
for (IRAnnotation annotation : field.getAnnotations()) {
appendAnnotation(builder, annotation);
}
int modifiers = field.getModifiers();
if (field.getName().startsWith("typeparam$")) {
modifiers &= ~Modifier.FINAL;
}
builder.append(Modifier.toModifierString(modifiers))
.append(" ")
.append(getTypeName(field.getType()))
.append(" ")
.append(field.getName());
// TODO kcp - initializer?
builder.append(";\n");
}
private void appendMethod(StringBuilder builder, IRMethodStatement method) {
if (method.getName().equals("getIntrinsicType") || method.getName().startsWith("$")) {
return;
}
isStatic = Modifier.isStatic(method.getModifiers());
IRStatement methodBody = method.getMethodBody();
if (isOverlay) {
if (method.getName().startsWith("get") && method.getParameters().isEmpty()) {
if (methodBody instanceof IRStatementList) {
List<IRStatement> statements = ((IRStatementList) methodBody).getStatements();
if (statements.size() == 1 && statements.get(0) instanceof IRReturnStatement) {
IRExpression returnValue = ((IRReturnStatement) statements.get(0)).getReturnValue();
if (returnValue instanceof IRFieldGetExpression) {
builder.append("public final native ")
.append(getTypeName(((IRFieldGetExpression) returnValue).getFieldType()))
.append(" ")
.append(method.getName())
.append("() /*-{ return this.")
.append(method.getName().substring("get".length()))
.append("; }-*/;\n");
return;
}
}
}
}
if (method.getName().startsWith("set")
&& method.getReturnType().isVoid()
&& method.getParameters().size() == 1) {
if (methodBody instanceof IRStatementList) {
List<IRStatement> statements = ((IRStatementList) methodBody).getStatements();
if (statements.size() == 2
&& statements.get(0) instanceof IRFieldSetStatement
&& statements.get(1) instanceof IRReturnStatement) {
builder.append("public final native void ")
.append(method.getName())
.append("(")
.append(getTypeName(method.getParameters().get(0).getType()))
.append(" ")
.append(method.getParameters().get(0).getName())
.append(") /*-{ this.")
.append(method.getName().substring("set".length()))
.append(" = ")
.append(method.getParameters().get(0).getName())
.append("; }-*/;\n");
return;
}
}
}
if (method.getName().equals("<init>")) {
return;
}
}
Map<String, IRSymbol> symbols = Maps.newLinkedHashMap();
for (IRAnnotation annotation : method.getAnnotations()) {
appendAnnotation(builder, annotation);
}
List<String> exceptionsThrown = Lists.newArrayList();
List<String> exceptionsCaught = Lists.newArrayList();
if (!method.getName().equals("<clinit>")) {
builder.append(Modifier.toModifierString(method.getModifiers()))
.append(" ");
if (method.getName().equals("<init>")) {
builder.append(getRelativeClassName());
} else {
builder.append(getTypeName(method.getReturnType()))
.append(" ")
.append(method.getName());
}
builder.append("(");
List<IRSymbol> parameters = method.getParameters();
for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) {
if (i > 0) {
builder.append(", ");
}
IRSymbol parameter = parameters.get(i);
String paramName = getSymbolName(parameter);
builder.append(getTypeName(parameter.getType()))
.append(" ")
.append(paramName);
symbols.put(paramName, parameter);
}
builder.append(")");
List<IType> exceptionsFromSuper = getExceptionsFromSuper(method);
List<IType> exceptionsFromBody;
if (method.getName().equals("<init>")) {
exceptionsFromBody = exceptionMap.getExceptions(getCtorInfoFromSymbols(
(IGosuClass) irClass.getThisType().getType(), method.getParameters()));
} else {
exceptionsFromBody = exceptionMap.getExceptions(getMethodInfoFromSymbols(
(IGosuClass) irClass.getThisType().getType(), method.getName(), method.getParameters()));
}
if (exceptionsFromSuper == null) {
for (IType exception : exceptionsFromBody) {
exceptionsThrown.add(exception.getName());
}
} else {
for (IType exception : exceptionsFromSuper) {
exceptionsThrown.add(exception.getName());
}
for (IType exception : exceptionsFromBody) {
boolean thrown = false;
for (IType superException : exceptionsFromSuper) {
if (superException.isAssignableFrom(exception)) {
thrown = true;
break;
}
}
if (!thrown) {
exceptionsCaught.add(exception.getName());
}
}
}
appendThrows(builder, exceptionsThrown);
}
if (methodBody != null) {
if (!exceptionsCaught.isEmpty()) {
builder.append("{\ntry ");
}
if (!(methodBody instanceof IRStatementList)) {
builder.append("{\n");
}
appendStatement(builder, methodBody, symbols);
if (!(methodBody instanceof IRStatementList)) {
builder.append("}\n");
}
if (!exceptionsCaught.isEmpty()) {
for (String exception : exceptionsCaught) {
builder.append("catch (")
.append(exception)
.append(" e")
.append(uid)
.append(") {\n")
.append("throw new java.lang.RuntimeException(e")
.append(uid)
.append(");\n")
.append("}\n");
uid++;
}
builder.append("}\n");
}
} else {
builder.append(";\n");
}
while (!auxMethodsBuilders.empty()) {
builder.append(auxMethodsBuilders.pop());
}
}
private void appendStatement(StringBuilder builder, IRStatement statement, Map<String, IRSymbol> symbols) {
if (statement instanceof IRFieldDecl) {
// TODO kcp
builder.append("/* IRFieldDecl */");
} else if (statement instanceof IRMethodStatement) {
// TODO kcp
builder.append("/* IRMethodStatement */");
} else if (statement instanceof IRArrayStoreStatement) {
IRArrayStoreStatement arrayStoreStatement = (IRArrayStoreStatement) statement;
appendExpression(builder, arrayStoreStatement.getTarget(), symbols);
builder.append("[");
appendExpression(builder, arrayStoreStatement.getIndex(), symbols);
builder.append("] = ");
appendExpression(builder, arrayStoreStatement.getValue(), symbols);
builder.append(";\n");
} else if (statement instanceof IRAssignmentStatement) {
IRAssignmentStatement assignmentStatement = (IRAssignmentStatement) statement;
String symbolName = getSymbolName(assignmentStatement.getSymbol());
if (!symbols.containsKey(symbolName)) {
builder.append(getTypeName(assignmentStatement.getSymbol().getType()))
.append(" ");
}
builder.append(symbolName)
.append(" = ");
appendExpression(builder, assignmentStatement.getValue(), symbols);
builder.append(";\n");
symbols.put(symbolName, assignmentStatement.getSymbol());
} else if (statement instanceof IRBreakStatement) {
builder.append("break;\n");
} else if (statement instanceof IRContinueStatement) {
builder.append("continue;\n");
} else if (statement instanceof IRDoWhileStatement) {
IRDoWhileStatement doWhileStatement = (IRDoWhileStatement) statement;
builder.append("do ");
appendStatement(builder, doWhileStatement.getBody(), Maps.newHashMap(symbols));
builder.append("while(");
appendExpression(builder, doWhileStatement.getLoopTest(), symbols);
builder.append(");\n");
} else if (statement instanceof IREvalStatement) {
// TODO kcp
builder.append("/* IREvalStatement */");
} else if (statement instanceof IRFieldSetStatement) {
IRFieldSetStatement fieldSetStatement = (IRFieldSetStatement) statement;
if (fieldSetStatement.getLhs() != null) {
appendExpression(builder, fieldSetStatement.getLhs(), symbols);
builder.append(".");
}
builder.append(fieldSetStatement.getName())
.append(" = ");
appendExpression(builder, fieldSetStatement.getRhs(), symbols);
builder.append(";\n");
} else if (statement instanceof IRForEachStatement) {
IRForEachStatement forEachStatement = (IRForEachStatement) statement;
Map<String, IRSymbol> innerSymbols = Maps.newHashMap(symbols);
List<IRStatement> initializers = forEachStatement.getInitializers();
builder.append("{\n");
for (IRStatement initializer : initializers) {
appendStatement(builder, initializer, innerSymbols);
}
builder.append("while (");
appendExpression(builder, forEachStatement.getLoopTest(), symbols);
builder.append(") {\n");
List<IRStatement> incrementors = forEachStatement.getIncrementors();
for (IRStatement incrementor : incrementors) {
appendStatement(builder, incrementor, innerSymbols);
}
appendStatement(builder, forEachStatement.getBody(), innerSymbols);
builder.append("}\n")
.append("}\n");
} else if (statement instanceof IRIfStatement) {
IRIfStatement ifStatement = (IRIfStatement) statement;
if (ifStatement.getExpression() instanceof IRInstanceOfExpression) {
IRInstanceOfExpression instanceOfExpression = (IRInstanceOfExpression) ifStatement.getExpression();
IType testType = instanceOfExpression.getTestType().getType();
IType rootType = instanceOfExpression.getRoot().getType().getType();
if (!testType.isInterface() && !rootType.isAssignableFrom(testType)
&& !testType.isAssignableFrom(rootType)) {
appendStatement(builder, ifStatement.getElseStatement(), symbols);
return;
}
}
builder.append("if (");
appendExpression(builder, ifStatement.getExpression(), symbols);
builder.append(") ");
appendStatement(builder, ifStatement.getIfStatement(), Maps.newHashMap(symbols));
if (ifStatement.getElseStatement() != null) {
builder.append(" else ");
appendStatement(builder, ifStatement.getElseStatement(), Maps.newHashMap(symbols));
}
} else if (statement instanceof IRMethodCallStatement) {
appendExpression(builder, ((IRMethodCallStatement) statement).getExpression(), symbols);
builder.append(";\n");
} else if (statement instanceof IRMonitorLockAcquireStatement) {
// TODO kcp
builder.append("/* IRMonitorLockAcquireStatement */");
} else if (statement instanceof IRMonitorLockReleaseStatement) {
// TODO kcp
builder.append("/* IRMonitorLockReleaseStatement */");
} else if (statement instanceof IRNoOpStatement) {
// no-op
} else if (statement instanceof IRReturnStatement) {
IRElement ancestor = statement.getParent();
while (ancestor != null) {
if (ancestor instanceof IRMethodStatement &&
((IRMethodStatement) ancestor).getName().endsWith("init>")) {
return;
}
ancestor = ancestor.getParent();
}
builder.append("return");
IRReturnStatement returnStatement = (IRReturnStatement) statement;
if (returnStatement.getReturnValue() != null) {
builder.append(" ");
appendExpression(builder, returnStatement.getReturnValue(), symbols);
}
builder.append(";\n");
} else if (statement instanceof IRStatementList) {
List<IRStatement> children = ((IRStatementList) statement).getStatements();
builder.append("{\n");
Map<String, IRSymbol> innerSymbols = Maps.newHashMap(symbols);
IRMethodCallStatement ctorCall = null;
if (statement.getParent() instanceof IRMethodStatement
&& ((IRMethodStatement) statement.getParent()).getName().equals("<init>")) {
for (IRStatement child : children) {
if (child instanceof IRMethodCallStatement) {
IRMethodCallStatement methodCallStatement = (IRMethodCallStatement) child;
if (methodCallStatement.getExpression() instanceof IRMethodCallExpression) {
if (((IRMethodCallExpression) methodCallStatement.getExpression()).getName().equals("<init>")) {
ctorCall = methodCallStatement;
break;
}
}
if (methodCallStatement.getExpression() instanceof IRCompositeExpression) {
IRCompositeExpression compositeExpression =
(IRCompositeExpression) methodCallStatement.getExpression();
IRElement lastElement =
compositeExpression.getElements().get(compositeExpression.getElements().size() - 1);
if (lastElement instanceof IRMethodCallExpression
&& ((IRMethodCallExpression) lastElement).getName().equals("<init>")) {
ctorCall = methodCallStatement;
break;
}
}
}
}
}
if (ctorCall != null) {
appendStatement(builder, ctorCall, innerSymbols);
}
for (IRStatement child : children) {
if (child != null && child != ctorCall) {
appendStatement(builder, child, innerSymbols);
}
}
builder.append("}\n");
} else if (statement instanceof IRSwitchStatement) {
// TODO kcp
builder.append("/* IRSwitchStatement */");
} else if (statement instanceof IRSyntheticStatement) {
// TODO kcp
builder.append("/* IRSyntheticStatement */");
} else if (statement instanceof IRThrowStatement) {
builder.append("throw ");
appendExpression(builder, ((IRThrowStatement) statement).getException(), symbols);
builder.append(";\n");
} else if (statement instanceof IRTryCatchFinallyStatement) {
builder.append("try ");
IRTryCatchFinallyStatement tryCatchFinallyStatement = (IRTryCatchFinallyStatement) statement;
appendStatement(builder, tryCatchFinallyStatement.getTryBody(), Maps.newHashMap(symbols));
for (IRCatchClause catchClause : tryCatchFinallyStatement.getCatchStatements()) {
builder.append(" catch (")
.append(getTypeName(catchClause.getIdentifier().getType()))
.append(" ")
.append(getSymbolName(catchClause.getIdentifier()))
.append(") ");
appendStatement(builder, catchClause.getBody(), Maps.newHashMap(symbols));
}
if (tryCatchFinallyStatement.getFinallyBody() != null) {
builder.append(" finally ");
appendStatement(builder, tryCatchFinallyStatement.getFinallyBody(), Maps.newHashMap(symbols));
}
} else if (statement instanceof IRWhileStatement) {
builder.append("while (");
IRWhileStatement whileStatement = (IRWhileStatement) statement;
appendExpression(builder, whileStatement.getLoopTest(), symbols);
builder.append(") ");
appendStatement(builder, whileStatement.getBody(), Maps.newHashMap(symbols));
} else {
throw new IllegalArgumentException("Unknown statement type " + statement.getClass().getSimpleName());
}
}
private void appendExpression(StringBuilder builder, IRExpression expression, Map<String, IRSymbol> symbols) {
if (expression instanceof IRArithmeticExpression) {
IRArithmeticExpression arithmeticExpression = (IRArithmeticExpression) expression;
appendExpression(builder, arithmeticExpression.getLhs(), symbols);
builder.append(" ");
switch (arithmeticExpression.getOp()) {
case Addition:
builder.append('+');
break;
case Subtraction:
builder.append('-');
break;
case Multiplication:
builder.append('*');
break;
case Division:
builder.append('/');
break;
case Remainder:
builder.append('%');
break;
case ShiftLeft:
builder.append("<<");
break;
case ShiftRight:
builder.append(">>");
break;
case UnsignedShiftRight:
builder.append(">>>");
break;
case BitwiseAnd:
builder.append('&');
break;
case BitwiseOr:
builder.append('|');
break;
case BitwiseXor:
builder.append('^');
break;
}
builder.append(" ");
appendExpression(builder, arithmeticExpression.getRhs(), symbols);
} else if (expression instanceof IRArrayLengthExpression) {
appendExpression(builder, ((IRArrayLengthExpression) expression).getRoot(), symbols);
builder.append(".length");
} else if (expression instanceof IRArrayLoadExpression) {
IRArrayLoadExpression arrayLoadExpression = (IRArrayLoadExpression) expression;
appendExpression(builder, arrayLoadExpression.getRoot(), symbols);
builder.append("[");
appendExpression(builder, arrayLoadExpression.getIndex(), symbols);
builder.append("]");
} else if (expression instanceof IRBooleanLiteral) {
builder.append(((IRBooleanLiteral) expression).getValue());
} else if (expression instanceof IRCastExpression) {
builder.append("((")
.append(getTypeName(expression.getType()))
.append(") ");
appendExpression(builder, ((IRCastExpression) expression).getRoot(), symbols);
builder.append(")");
} else if (expression instanceof IRCharacterLiteral) {
builder.append("'")
.append(((IRCharacterLiteral) expression).getValue())
.append("'");
} else if (expression instanceof IRClassLiteral) {
builder.append(getTypeName(((IRClassLiteral) expression).getLiteralType()));
} else if (expression instanceof IRCompositeExpression) {
transformCompositeExpression(builder, (IRCompositeExpression) expression, symbols);
} else if (expression instanceof IRConditionalAndExpression) {
IRConditionalAndExpression andExpression = (IRConditionalAndExpression) expression;
appendExpression(builder, andExpression.getLhs(), symbols);
builder.append(" && ");
appendExpression(builder, andExpression.getRhs(), symbols);
} else if (expression instanceof IRConditionalOrExpression) {
IRConditionalOrExpression orExpression = (IRConditionalOrExpression) expression;
appendExpression(builder, orExpression.getLhs(), symbols);
builder.append(" || ");
appendExpression(builder, orExpression.getRhs(), symbols);
} else if (expression instanceof IREqualityExpression) {
IREqualityExpression equalityExpression = (IREqualityExpression) expression;
appendExpression(builder, equalityExpression.getLhs(), symbols);
builder.append(" == ");
appendExpression(builder, equalityExpression.getRhs(), symbols);
} else if (expression instanceof IRFieldGetExpression) {
IRFieldGetExpression fieldGetExpression = (IRFieldGetExpression) expression;
if (fieldGetExpression.getLhs() != null) {
appendExpression(builder, fieldGetExpression.getLhs(), symbols);
builder.append(".");
} else if (!fieldGetExpression.getOwnersType().equals(irClass.getThisType())) {
builder.append(getTypeName(fieldGetExpression.getOwnersType()))
.append(".");
}
builder.append(fieldGetExpression.getName());
} else if (expression instanceof IRIdentifier) {
builder.append(getSymbolName(((IRIdentifier) expression).getSymbol()));
} else if (expression instanceof IRInstanceOfExpression) {
IRInstanceOfExpression instanceOfExpression = (IRInstanceOfExpression) expression;
appendExpression(builder, instanceOfExpression.getRoot(), symbols);
builder.append(" instanceof ")
.append(getTypeName(instanceOfExpression.getTestType()));
} else if (expression instanceof IRMethodCallExpression) {
IRMethodCallExpression methodCallExpression = (IRMethodCallExpression) expression;
if (methodCallExpression.getOwnersType().getName()
.equals("gw.internal.gosu.parser.expressions.AdditiveExpression")) {
builder.append('(');
appendExpression(builder, methodCallExpression.getArgs().get(1), symbols);
builder.append(" + ");
appendExpression(builder, methodCallExpression.getArgs().get(2), symbols);
builder.append(')');
return;
}
if (methodCallExpression.getOwnersType().getName().equals("gw.lang.reflect.TypeSystem")
&& methodCallExpression.getName().equals("get")) {
appendExpression(builder, methodCallExpression.getArgs().get(0), symbols);
builder.append(".class");
return;
}
if (methodCallExpression.getOwnersType().getName().equals("gw.lang.reflect.TypeSystem")
&& methodCallExpression.getName().equals("getByFullName")) {
IRExpression arg = methodCallExpression.getArgs().get(0);
if (arg instanceof IRStringLiteralExpression) {
builder.append(((IRStringLiteralExpression) arg).getValue())
.append(".class");
} else {
// TODO kcp - ???
builder.append("Object.class");
}
return;
}
if (methodCallExpression.getOwnersType().getName().equals("gwtsu.JSONOverlayListEnhx")
&& methodCallExpression.getName().equals("parse")
&& methodCallExpression.getArgs().size() == 3) {
appendListJSONParse(builder, symbols,
methodCallExpression.getArgs().get(0),
methodCallExpression.getArgs().get(2));
return;
}
if (methodCallExpression.getOwnersType().getName().equals("ronin.IRoninUtilsEnhancement")
&& methodCallExpression.getName().equals("urlFor")) {
IRNewExpression newExpression = (IRNewExpression) methodCallExpression.getArgs().get(0);
String className = ((IRStringLiteralExpression) ((IRMethodCallExpression) newExpression.getArgs().get(0)).getArgs().get(0)).getValue();
String methodName = ((IRStringLiteralExpression) newExpression.getArgs().get(1)).getValue();
List<? extends IMethodInfo> methods = TypeSystem.getByFullName(className).getTypeInfo().getMethods();
IParameterInfo[] parameters = null;
for (IMethodInfo method : methods) {
if (method.getDisplayName().equals(methodName)) {
parameters = method.getParameters();
}
}
if (parameters != null) {
builder.append("gwtsu.Util.roninUrl(\"")
.append(getRelativeClassName(className))
.append("\", \"")
.append(methodName)
.append("\"");
for (int i = 2; i < newExpression.getArgs().size(); i += 2) {
builder.append(", \"")
.append(parameters[(i - 2) / 2].getName())
.append("\", ");
appendExpression(builder, newExpression.getArgs().get(i), symbols);
builder.append(", ");
appendExpression(builder, newExpression.getArgs().get(i + 1), symbols);
}
builder.append(")");
return;
}
}
boolean skipName = false;
String replacement = replacementMethods.get(
getTypeName(methodCallExpression.getOwnersType()) + "." + methodCallExpression.getName());
IRExpression root = methodCallExpression.getRoot();
if (root != null) {
if (root instanceof IRIdentifier && getSymbolName(((IRIdentifier) root).getSymbol()).equals("this")
&& methodCallExpression.getName().equals("<init>")) {
IRElement ancestor = expression.getParent();
while (ancestor.getParent() != null && !(ancestor instanceof IRMethodStatement)) {
ancestor = ancestor.getParent();
}
boolean isThis = false;
for (IRMethodStatement ctor : ctors) {
if (ctor == ancestor) {
continue;
}
List<IRExpression> args = methodCallExpression.getArgs();
if (args.size() == ctor.getParameters().size()) {
boolean match = true;
for (int i = 0, argsSize = args.size(); i < argsSize; i++) {
IRExpression arg = args.get(i);
if (!arg.getType().equals(ctor.getParameters().get(i).getType())) {
match = false;
break;
}
}
if (match) {
isThis = true;
break;
}
}
}
if (isThis) {
builder.append("this(");
} else {
builder.append("super(");
}
skipName = true;
} else {
appendExpression(builder, root, symbols);
builder.append(".");
}
} else {
if (!irClass.getThisType().isAssignableFrom(methodCallExpression.getOwnersType()) && replacement == null) {
builder.append(getTypeName(methodCallExpression.getOwnersType()))
.append(".");
}
}
if (!skipName) {
if (replacement != null) {
builder.append(replacement);
} else {
builder.append(methodCallExpression.getName());
}
builder.append("(");
}
List<IRExpression> args = methodCallExpression.getArgs();
for (int i = 0, argsSize = args.size(); i < argsSize; i++) {
if (i > 0) {
builder.append(", ");
}
appendExpression(builder, args.get(i), symbols);
}
builder.append(")");
} else if (expression instanceof IRNegationExpression) {
builder.append("-");
appendExpression(builder, ((IRNegationExpression) expression).getRoot(), symbols);
} else if (expression instanceof IRNewArrayExpression) {
IRNewArrayExpression newArrayExpression = (IRNewArrayExpression) expression;
builder.append("new ")
.append(getTypeName(newArrayExpression.getComponentType()))
.append("[");
if (newArrayExpression.getSizeExpression() != null) {
appendExpression(builder, newArrayExpression.getSizeExpression(), symbols);
}
builder.append("]");
} else if (expression instanceof IRNewExpression) {
IRNewExpression newExpression = (IRNewExpression) expression;
List<IRExpression> args = newExpression.getArgs();
if (TypeSystem.getByFullName("gwtsu.JSONOverlay")
.isAssignableFrom(newExpression.getOwnersType().getType()) &&
args.size() == 1 &&
args.get(0).getType().getName().equals("java.lang.String")) {
appendSingleJSONParse(builder, symbols, newExpression, args);
} else {
builder.append("new ")
.append(getTypeName(newExpression.getOwnersType()))
.append("(");
for (int i = 0, argsSize = args.size(); i < argsSize; i++) {
if (i > 0) {
builder.append(", ");
}
appendExpression(builder, args.get(i), symbols);
}
builder.append(")");
}
} else if (expression instanceof IRNewMultiDimensionalArrayExpression) {
IRNewMultiDimensionalArrayExpression arrayExpression = (IRNewMultiDimensionalArrayExpression) expression;
builder.append("new ")
.append(getTypeName(arrayExpression.getResultType()));
for (IRExpression size : arrayExpression.getSizeExpressions()) {
builder.append("[");
appendExpression(builder, size, symbols);
builder.append("]");
}
} else if (expression instanceof IRNotExpression) {
builder.append("!");
appendExpression(builder, ((IRNotExpression) expression).getRoot(), symbols);
} else if (expression instanceof IRNoOpExpression) {
// no-op
} else if (expression instanceof IRNullLiteral) {
builder.append("null");
} else if (expression instanceof IRNumericLiteral) {
builder.append(((IRNumericLiteral) expression).getValue());
} else if (expression instanceof IRPrimitiveTypeConversion) {
// TODO kcp
builder.append("/* IRPrimitiveTypeConversion */");
} else if (expression instanceof IRRelationalExpression) {
IRRelationalExpression relationalExpression = (IRRelationalExpression) expression;
appendExpression(builder, relationalExpression.getLhs(), symbols);
builder.append(" ");
switch (relationalExpression.getOp()) {
case GT:
builder.append('>');
break;
case GTE:
builder.append(">=");
break;
case LT:
builder.append('<');
break;
case LTE:
builder.append("<=");
break;
}
builder.append(" ");
appendExpression(builder, relationalExpression.getRhs(), symbols);
} else if (expression instanceof IRStringLiteralExpression) {
builder.append("\"")
.append(((IRStringLiteralExpression) expression).getValue()
.replace("\"", "\\\""))
.append("\"");
} else if (expression instanceof IRTernaryExpression) {
builder.append('(');
IRTernaryExpression ternaryExpression = (IRTernaryExpression) expression;
appendExpression(builder, ternaryExpression.getTest(), symbols);
builder.append(" ? ");
appendExpression(builder, ternaryExpression.getTrueValue(), symbols);
builder.append(" : ");
appendExpression(builder, ternaryExpression.getFalseValue(), symbols);
builder.append(')');
} else {
throw new IllegalArgumentException("Unknown expression type " + expression.getClass().getSimpleName());
}
}
private void appendAnnotation(StringBuilder builder, IRAnnotation annotation) {
builder.append("@")
.append(getTypeName(annotation.getDescriptor()))
// TODO kcp - args?
.append("\n");
}
private void transformCompositeExpression(StringBuilder builder, IRCompositeExpression expression, Map<String, IRSymbol> symbols) {
StringBuilder auxMethodsBuilder = new StringBuilder();
auxMethodsBuilders.push(auxMethodsBuilder);
List<IRElement> elements = expression.getElements();
IRElement lastElement = elements.get(elements.size() - 1);
// Null-safe property/method access?
if (elements.size() == 2 &&
elements.get(0) instanceof IRAssignmentStatement &&
elements.get(1) instanceof IRTernaryExpression) {
IRTernaryExpression ternaryExpression = (IRTernaryExpression) elements.get(1);
if (ternaryExpression.getTrueValue() instanceof IRCastExpression &&
((IRCastExpression) ternaryExpression.getTrueValue()).getRoot() instanceof IRNullLiteral &&
ternaryExpression.getTest() instanceof IREqualityExpression &&
((IREqualityExpression) ternaryExpression.getTest()).getRhs() instanceof IRNullLiteral) {
IRAssignmentStatement assignmentStatement = (IRAssignmentStatement) elements.get(0);
String rootTypeName = getTypeName(assignmentStatement.getSymbol().getType());
String rtnTypeName = getTypeName(ternaryExpression.getResultType());
String auxMethodName = "$gwtsu$aux" + (uid++);
String argName = getSymbolName(assignmentStatement.getSymbol());
builder.append(auxMethodName)
.append("(");
appendExpression(builder, assignmentStatement.getValue(), symbols);
appendSymbolsAsArgs(builder, symbols, true);
builder.append(")");
auxMethodsBuilder.append("private ");
if (isStatic) {
auxMethodsBuilder.append("static ");
}
auxMethodsBuilder.append(rtnTypeName)
.append(auxMethodName)
.append("(")
.append(rootTypeName)
.append(" ")
.append(argName);
appendSymbolsAsParams(auxMethodsBuilder, symbols, true);
auxMethodsBuilder.append(") ");
List<String> exceptionNames = Lists.newArrayList();
for (IType exception : exceptionMap.getExceptions(expression)) {
exceptionNames.add(exception.getName());
}
appendThrows(auxMethodsBuilder, exceptionNames);
auxMethodsBuilder.append("{\n")
.append("return ");
HashMap<String, IRSymbol> tempSymbols = Maps.newHashMap(symbols);
appendExpression(auxMethodsBuilder, ternaryExpression, tempSymbols);
auxMethodsBuilder.append(";\n}\n");
return;
}
}
// Field set(s) + ctor (this/super) call?
if (lastElement instanceof IRMethodCallExpression &&
((IRMethodCallExpression) lastElement).getName().equals("<init>")) {
boolean areAllStatements = true;
for (IRElement element : elements) {
areAllStatements = areAllStatements && (element instanceof IRStatement || element == lastElement);
}
if (areAllStatements) {
appendExpression(builder, (IRMethodCallExpression) lastElement, symbols);
builder.append(";\n");
for (IRElement element : elements) {
if (element instanceof IRStatement) {
appendStatement(builder, (IRStatement) element, symbols);
}
}
return;
}
}
// TODO kcp - check for other types of known composite expressions
// Fallback: if elements are statements + 1 expression, transform directly into aux method.
if (lastElement instanceof IRExpression) {
boolean areAllStatements = true;
for (IRElement element : elements) {
areAllStatements = areAllStatements && (element instanceof IRStatement || element == lastElement);
}
if (areAllStatements) {
String auxMethodName = "$gwtsu$aux" + (uid++);
builder.append(auxMethodName)
.append("(");
appendSymbolsAsArgs(builder, symbols, false);
builder.append(")");
auxMethodsBuilder.append("private ");
if (isStatic) {
auxMethodsBuilder.append("static ");
}
auxMethodsBuilder.append(getTypeName(((IRExpression) lastElement).getType()))
.append(" ")
.append(auxMethodName)
.append("(");
appendSymbolsAsParams(auxMethodsBuilder, symbols, false);
auxMethodsBuilder.append(") ");
List<String> exceptionNames = Lists.newArrayList();
for (IType exception : exceptionMap.getExceptions(expression)) {
exceptionNames.add(exception.getName());
}
appendThrows(auxMethodsBuilder, exceptionNames);
auxMethodsBuilder.append("{\n");
HashMap<String,IRSymbol> tempSymbols = Maps.newHashMap(symbols);
for (IRElement element : elements) {
if (element instanceof IRStatement) {
appendStatement(auxMethodsBuilder, (IRStatement) element, tempSymbols);
} else if (element instanceof IRMethodCallExpression &&
((IRMethodCallExpression) element).getReturnType().isVoid()) {
appendExpression(auxMethodsBuilder, (IRExpression) element, tempSymbols);
auxMethodsBuilder.append(";\n");
} else {
auxMethodsBuilder.append("return ");
appendExpression(auxMethodsBuilder, (IRExpression) element, tempSymbols);
auxMethodsBuilder.append(";\n");
}
}
auxMethodsBuilder.append("}\n");
return;
}
}
// TODO kcp
builder.append("/* unknown IRCompositeExpression */");
}
private void appendSymbolsAsArgs(StringBuilder builder, Map<String, IRSymbol> symbols, boolean comma) {
for (Map.Entry<String, IRSymbol> symbol : symbols.entrySet()) {
if (comma) {
builder.append(", ");
}
comma = true;
builder.append(symbol.getKey());
}
}
private void appendSymbolsAsParams(StringBuilder builder, Map<String, IRSymbol> symbols, boolean comma) {
for (Map.Entry<String, IRSymbol> symbol : symbols.entrySet()) {
if (comma) {
builder.append(", ");
}
comma = true;
builder.append(getTypeName(symbol.getValue().getType()))
.append(" ")
.append(symbol.getKey());
}
}
private void appendSingleJSONParse(StringBuilder builder, Map<String, IRSymbol> symbols,
IRNewExpression newExpression, List<IRExpression> args) {
builder.append(getTypeName(newExpression.getOwnersType()))
.append(".$gwtsu$parse(");
appendExpression(builder, args.get(0), symbols);
builder.append(")");
}
private void appendListJSONParse(StringBuilder builder, Map<String, IRSymbol> symbols,
IRExpression listExpression, IRExpression dataExpression) {
builder.append("{java.util.List gwtsu$jsonList = ");
appendExpression(builder, listExpression, symbols);
builder.append(";\n")
.append("for (com.google.gwt.core.client.JavaScriptObject gwtsu$jsonTmp : gwtsu.Util.splitJSON(");
appendExpression(builder, dataExpression, symbols);
builder.append(")) {\n")
.append("gwtsu$jsonList.add(gwtsu$jsonTmp);\n")
.append("}}\n");
}
private void appendThrows(StringBuilder builder, List<String> exceptionsThrown) {
for (int i = 0, exceptionsSize = exceptionsThrown.size(); i < exceptionsSize; i++) {
String exception = exceptionsThrown.get(i);
if (i > 0) {
builder.append(", ");
} else {
builder.append(" throws ");
}
if (replacementTypes.containsKey(exception)) {
builder.append(replacementTypes.get(exception));
} else {
builder.append(exception);
}
}
builder.append(" ");
}
private String getSymbolName(IRSymbol symbol) {
return symbol.getName().replace("*", "gwtsu$");
}
private String getTypeName(IRType type) {
if (type.isArray()) {
return getTypeName(type.getComponentType()) + "[]";
}
IType iType = type.getType();
if (replacementTypes.containsKey(iType.getName())) {
return replacementTypes.get(iType.getName());
}
if (iType instanceof IGosuClass) {
return ((IGosuClass) iType).getBackingClass().getName().replace("$", "__");
}
return iType.getName();
}
private String getRelativeClassName() {
String typeName = getTypeName(irClass.getThisType());
return getRelativeClassName(typeName);
}
private String getRelativeClassName(String typeName) {
return typeName.substring(typeName.lastIndexOf(".") + 1);
}
private List<IType> getExceptionsFromSuper(IRMethodStatement method) {
IType type = irClass.getThisType().getType();
for (IType ancestor : type.getAllTypesInHierarchy()) {
if (ancestor instanceof IJavaType) {
Class javaClass = ((IJavaType) ancestor).getBackingClass();
for (Method ancestorMethod : javaClass.getMethods()) {
if (ancestorMethod.getName().equals(method.getName()) &&
ancestorMethod.getParameterTypes().length == method.getParameters().size()) {
boolean match = true;
Class<?>[] parameterTypes = ancestorMethod.getParameterTypes();
for (int i = 0, parameterTypesLength = parameterTypes.length; i < parameterTypesLength; i++) {
Class<?> paramType = parameterTypes[i];
if (!paramType.getName().equals(method.getParameters().get(i).getType().getName())) {
match = false;
break;
}
}
if (match) {
List<IType> exceptions = Lists.newArrayList();
for (Class<?> exceptionType : ancestorMethod.getExceptionTypes()) {
exceptions.add(TypeSystem.getByFullNameIfValid(exceptionType.getName()));
}
return exceptions;
}
}
}
}
}
return null;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
6979196f0642322dab773e0e2bf5dc4cf02f3ecd | f89e946e75dfa8c76d07267adc58c7b4bc07416f | /app/src/main/java/com/wasder/wasderapp/util/IabResult.java | 47a941b94800df2c97e82eb7e4c88601f3bf66fe | [] | no_license | AlAskalany/wasder-android | b07780374e34e20d47f1ec11001ad8fc5d0f3774 | c5db581591040499c1b1e0dec05badb46c521aca | refs/heads/master | 2020-04-05T18:26:06.026803 | 2017-09-28T23:21:31 | 2017-09-28T23:21:31 | 157,101,791 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,712 | java | /* Copyright (c) 2012 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.wasder.wasderapp.util;
/**
* Represents the result of an in-app billing operation.
* A result is composed of a response code (an integer) and possibly a
* message (String). You can get those by calling
* {@link #getResponse} and {@link #getMessage()}, respectively. You
* can also inquire whether a result is a success or a failure by
* calling {@link #isSuccess()} and {@link #isFailure()}.
*/
public class IabResult {
int mResponse;
String mMessage;
public IabResult(int response, String message) {
mResponse = response;
if (message == null || message.trim().length() == 0) {
mMessage = IabHelper.getResponseDesc(response);
} else {
mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")";
}
}
public int getResponse() {
return mResponse;
}
public boolean isFailure() {
return !isSuccess();
}
public boolean isSuccess() {
return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK;
}
public String toString() {
return "IabResult: " + getMessage();
}
public String getMessage() {
return mMessage;
}
}
| [
"ahmed.alaskalany@gmail.com"
] | ahmed.alaskalany@gmail.com |
4c5000591c29736736345e65b2c08c10b89a6783 | d86b70b3dfcdbbb0fa1e6a67105243bd336a98ed | /src/main/java/com/example/bookstorebackend/controller/AdmController.java | ed78638b57e33b20fe5861ffea79319ac4d65f04 | [] | no_license | sjtu-ren/mybookstore-end | ec6e18ca421abff5bf147146004fded58c48c042 | 747b9e3294a76ec1c8132ed7923ec50866a4e15e | refs/heads/main | 2023-08-26T09:09:20.162498 | 2021-10-08T12:11:02 | 2021-10-08T12:11:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,852 | java | package com.example.bookstorebackend.controller;
import com.example.bookstorebackend.entity.User;
import com.example.bookstorebackend.service.OrderService;
import com.example.bookstorebackend.service.UserService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
public class AdmController {
@Autowired
private UserService userService;
@Autowired
private OrderService orderService;
@RequestMapping("/getUsers")
public List<User> getUsers(@RequestBody JSONObject params){
return userService.getUsers();
}
@RequestMapping("/banUser")
public JSONObject banUser(@RequestBody JSONObject params){
Integer userId=params.getInt("userId");
JSONObject obj=new JSONObject();
obj.put("msg",userService.banUser(userId));
return obj;
}
@RequestMapping("/releaseUser")
public JSONObject releaseUser(@RequestBody JSONObject params){
Integer userId=params.getInt("userId");
JSONObject obj=new JSONObject();
obj.put("msg",userService.releaseUser(userId));
return obj;
}
@RequestMapping("/admGetOrders")
public JSONObject getOrders(@RequestBody JSONObject param){
return orderService.admGetAll();
}
@RequestMapping("/admOrdByTime")
public JSONObject admGetOrdersByTime(@RequestBody JSONObject params){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start=new Date();
Date end=new Date();
try {
start=simpleDateFormat.parse(params.getString("start"));
} catch (ParseException e) {
e.printStackTrace();
}
try {
end=simpleDateFormat.parse(params.getString("end"));
} catch (ParseException e) {
e.printStackTrace();
}
return orderService.admGetAll(start,end);
}
@RequestMapping("/admCBook")
public JSONObject admComBook(@RequestBody JSONObject params){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start=new Date();
Date end=new Date();
try {
start=simpleDateFormat.parse(params.getString("start"));
} catch (ParseException e) {
e.printStackTrace();
}
try {
end=simpleDateFormat.parse(params.getString("end"));
} catch (ParseException e) {
e.printStackTrace();
}
return orderService.comBooks(start,end);
}
@RequestMapping("/admByUser")
public JSONObject admByUser(@RequestBody JSONObject params){
String username=params.getString("username");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start=new Date();
Date end=new Date();
try {
start=simpleDateFormat.parse(params.getString("start"));
} catch (ParseException e) {
e.printStackTrace();
String x="2000-01-01 00:00:00";
try {
start=simpleDateFormat.parse(x);
} catch (ParseException ex) {
ex.printStackTrace();
}
}
try {
end=simpleDateFormat.parse(params.getString("end"));
} catch (ParseException e) {
e.printStackTrace();
}
return orderService.comBooks(username,start,end);
}
}
| [
"2512618003@qq.com"
] | 2512618003@qq.com |
7b700b452f530cd12c576fad9a1a94aee827f34e | b025f53590a9c4625e6a541d2671e244c032d1bb | /Android/app/src/main/java/com/example/automaticlights/data/LoginDataSource.java | d222193370746cec9f980e5389547cb04cd38aec | [] | no_license | Nunofexki/automatic_lights | e7be88038e7e858b90a45a0115871e25df7e5029 | b092150e2116b477d3d52a6e5cd777bd396afc2f | refs/heads/main | 2023-05-26T21:36:45.624200 | 2021-06-06T22:58:06 | 2021-06-06T22:58:06 | 349,577,841 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 841 | java | package com.example.automaticlights.data;
import com.example.automaticlights.data.model.LoggedInUser;
import java.io.IOException;
/**
* Class that handles authentication w/ login credentials and retrieves user information.
*/
public class LoginDataSource {
public Result<LoggedInUser> login(String username, String password) {
try {
// TODO: handle loggedInUser authentication
LoggedInUser fakeUser =
new LoggedInUser(
java.util.UUID.randomUUID().toString(),
"Jane Doe");
return new Result.Success<>(fakeUser);
} catch (Exception e) {
return new Result.Error(new IOException("Error logging in", e));
}
}
public void logout() {
// TODO: revoke authentication
}
} | [
"47788905+jpsmonteiro98@users.noreply.github.com"
] | 47788905+jpsmonteiro98@users.noreply.github.com |
635f66c98ba58e90be75db8f03e4322062b3801c | 0fe35ed7314b5aa95ffe3de785201ceb170f9275 | /src/main/java/davis/john/DataValidator.java | 49d1d2047e1e0ae4caaba7afee90bf22b7ffbab5 | [] | no_license | infinitumnihilum/Regex | e821ee2689d709b481f16546f1f641121f1b79eb | db8de768eeb5b59224f30a9b9520c6d2f7a20af7 | refs/heads/master | 2021-01-10T09:47:01.077587 | 2016-02-20T04:43:29 | 2016-02-20T04:43:29 | 52,136,690 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 915 | java | package davis.john;
/**
* Created by jrdavis on 2/19/16.
*/
public class DataValidator {
public boolean isValidUsername(String s) {
String compare = s;
if (compare.matches("[a-z]{3,25}")) {
return true;
} else {
return false;
}
}
public boolean isValidEnhancedUsername(String enhanced) {
String newcompare = enhanced;
if (newcompare.matches("[a-zA-Z][a-zA-Z0-9_]{3,25}")) {
return true;
} else {
return false;
}
}
public boolean isValidIP(String ip){
String newip= ip;
if (newip.matches("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}")) {
return true;
}else {
return false;
}
}
public String isPalindrome(){
String d = "Palindromes are not a regular language";
return d;
}
}
| [
"jrdavis1989@gmail.com"
] | jrdavis1989@gmail.com |
fd448d50fa5cdefed12f4ad6744bbc5892b3462f | c6e3a895297a04f06c556e7d0ecbfd552d1c7f2e | /src/main/java/com/example/demo/Service/ItemService.java | c8a8335717a4cbf5077e6d713d616d23cb1cdb67 | [] | no_license | RasmusKW/student_admin | 174c440fba25a18829c5bc090324a003d3633e5a | 23bdd9048e47e6e67beaa21f9141724cad913f81 | refs/heads/master | 2022-06-21T11:22:16.698809 | 2020-05-01T15:01:50 | 2020-05-01T15:01:50 | 261,145,932 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 755 | java | package com.example.demo.Service;
import com.example.demo.Model.Item;
import com.example.demo.Repository.ItemRepo;
import com.example.demo.Repository.ItemRepoJPA;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ItemService {
@Autowired
ItemRepoJPA itemRepo;
public List<Item> fetchAllItems(){
return itemRepo.findAll();
}
public void addItem(Item i){
itemRepo.save(i);
}
public void deleteItem(int id){
itemRepo.deleteById(id);
}
public Item findItemById(int id){
return itemRepo.getOne(id);
}
public void updateItem(Item i){
itemRepo.save(i);
}
}
| [
"rasmus_w@hotmail.dk"
] | rasmus_w@hotmail.dk |
be7682c4b1ce73553a09fc95c17f3e0b9c534597 | 35fa4da7f211942e5676460739ed356b61ff51e6 | /src/ListaInvertida.java | 1565a657c0e3d064d2fa8f73d244f7c30aee8be9 | [] | no_license | thiagomoraesn13/Recuperacao_da_Informacao | efeb9a7d666dc1d3654a2de6643f7b8457ba9ffc | 822d3cb0aac120d672a6344ee1996a6dc5fa15ec | refs/heads/master | 2021-06-30T17:41:52.918379 | 2017-09-20T01:27:08 | 2017-09-20T01:27:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 679 | java | import javax.swing.text.html.HTMLDocument;
import java.util.ArrayList;
import java.util.Iterator;
public class ListaInvertida {
String termo;
int frequenciaCol;
double idf;
ArrayList<Documento> documentos;
public ListaInvertida(String termo, Documento doc){
this.termo = termo;
this.documentos = new ArrayList<Documento>();
this.documentos.add(doc);
}
public static void imprimeListaInvertida(ListaInvertida lista){
Iterator<Documento> iterator = lista.documentos.iterator();
while(iterator.hasNext()){
Documento atual = iterator.next();
Documento.imprime(atual);
}
}
}
| [
"tmr@icomp.ufam.edu.br"
] | tmr@icomp.ufam.edu.br |
b58f88986ce0482980612d9df0fe00b915635d15 | 50733ab0b54b9ff869babbc6eab4cc5bd0e409a8 | /src/test/java/com/alastair/textanalysis/service/DefaultDocumentParsingServiceTest.java | 14c5b2b8c3971d5d5f0dd74017c63ad665eb6e17 | [] | no_license | Alastair-Watts/test-analysis | 9f8f575ccfddfcdd261488afe955a6329068a30d | 0417811e974d5a0c8092a24d028f208d1c0ead51 | refs/heads/master | 2020-12-03T00:20:13.453008 | 2017-07-07T06:53:49 | 2017-07-07T06:53:49 | 96,016,791 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,946 | java | package com.alastair.textanalysis.service;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import com.alastair.textanalysis.dao.WordSetDao;
import com.alastair.textanalysis.model.WordSet;
@RunWith(MockitoJUnitRunner.class)
public class DefaultDocumentParsingServiceTest {
@Mock
private WordSetDao wordSetDao;
private Integer sizeOfPartition = 10;
private DocumentParsingService documentParsingService;
@Before
public void setup() {
documentParsingService = new DefaultDocumentParsingService(wordSetDao, sizeOfPartition);
}
@Test
public void parseDocument_SmallFile_StoresCorrectLists() {
String sourceFile = "simple.test";
documentParsingService.parseDocument(sourceFile);
ArgumentCaptor<WordSet> wordSetCaptor = ArgumentCaptor.forClass(WordSet.class);
Mockito.verify(wordSetDao, Mockito.times(2)).createWordSet(wordSetCaptor.capture());
List<WordSet> wordSets = wordSetCaptor.getAllValues();
List<String> firstWordSet = wordSets.get(0).getWords();
Assert.assertEquals("one", firstWordSet.get(0));
Assert.assertEquals("two", firstWordSet.get(1));
Assert.assertEquals("three", firstWordSet.get(2));
Assert.assertEquals("four", firstWordSet.get(3));
Assert.assertEquals("five", firstWordSet.get(4));
Assert.assertEquals("six", firstWordSet.get(5));
Assert.assertEquals("seven", firstWordSet.get(6));
Assert.assertEquals("eight", firstWordSet.get(7));
Assert.assertEquals("nine", firstWordSet.get(8));
Assert.assertEquals("ten", firstWordSet.get(9));
List<String> secondWordSet = wordSets.get(1).getWords();
Assert.assertEquals("eleven", secondWordSet.get(0));
Assert.assertEquals("twelve", secondWordSet.get(1));
Assert.assertEquals("thirteen", secondWordSet.get(2));
Assert.assertEquals("fourteen", secondWordSet.get(3));
Assert.assertEquals("fifteen", secondWordSet.get(4));
Assert.assertEquals("sixteen", secondWordSet.get(5));
Assert.assertEquals("seventeen", secondWordSet.get(6));
Assert.assertEquals("eighteen", secondWordSet.get(7));
Assert.assertEquals("nineteen", secondWordSet.get(8));
Assert.assertEquals("twenty", secondWordSet.get(9));
}
@Test
public void parseDocument_LargeFile_StoresListsOfStrings() {
documentParsingService.parseDocument("test.txt");
ArgumentCaptor<WordSet> wordSetCaptor = ArgumentCaptor.forClass(WordSet.class);
Mockito.verify(wordSetDao, Mockito.atLeastOnce()).createWordSet(wordSetCaptor.capture());
assertTrue(wordSetCaptor.getAllValues().stream()
.allMatch(wordSet -> "test.txt".equals(wordSet.getDocumentName())));
assertTrue(wordSetCaptor.getAllValues().stream()
.allMatch(wordSet -> wordSet.getWords().size() <= sizeOfPartition));
}
}
| [
"Alastair"
] | Alastair |
b9b63431204d7df86ecb0414c4723808ab450765 | a547eebe8add78928b970568b513c132f39bb43f | /core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataManager.java | 3907e44ab82e36ccbc68700ac98952748a08de3d | [] | no_license | jahow/core-geonetwork | 852549026a4198885d195008cb1f8534d084f99f | ee495d695231b0b1d0d506d71b390679f53c09e8 | refs/heads/develop | 2022-10-21T07:10:35.196424 | 2017-09-15T07:44:52 | 2017-09-15T07:44:52 | 86,352,464 | 0 | 0 | null | 2020-01-23T15:28:48 | 2017-03-27T15:30:52 | JavaScript | UTF-8 | Java | false | false | 52,438 | java | package org.fao.geonet.kernel.datamanager.base;
import static org.springframework.data.jpa.domain.Specifications.where;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.Root;
import org.apache.commons.lang.StringUtils;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.constants.Edit;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.constants.Params;
import org.fao.geonet.domain.Constants;
import org.fao.geonet.domain.Group;
import org.fao.geonet.domain.ISODate;
import org.fao.geonet.domain.Metadata;
import org.fao.geonet.domain.MetadataCategory;
import org.fao.geonet.domain.MetadataDataInfo;
import org.fao.geonet.domain.MetadataDataInfo_;
import org.fao.geonet.domain.MetadataFileUpload;
import org.fao.geonet.domain.MetadataFileUpload_;
import org.fao.geonet.domain.MetadataSourceInfo;
import org.fao.geonet.domain.MetadataType;
import org.fao.geonet.domain.MetadataValidation;
import org.fao.geonet.domain.Metadata_;
import org.fao.geonet.domain.OperationAllowed;
import org.fao.geonet.domain.OperationAllowedId;
import org.fao.geonet.domain.Pair;
import org.fao.geonet.domain.ReservedGroup;
import org.fao.geonet.domain.ReservedOperation;
import org.fao.geonet.domain.User;
import org.fao.geonet.kernel.AccessManager;
import org.fao.geonet.kernel.EditLib;
import org.fao.geonet.kernel.HarvestInfoProvider;
import org.fao.geonet.kernel.SchemaManager;
import org.fao.geonet.kernel.ThesaurusManager;
import org.fao.geonet.kernel.UpdateDatestamp;
import org.fao.geonet.kernel.XmlSerializer;
import org.fao.geonet.kernel.datamanager.IMetadataIndexer;
import org.fao.geonet.kernel.datamanager.IMetadataManager;
import org.fao.geonet.kernel.datamanager.IMetadataOperations;
import org.fao.geonet.kernel.datamanager.IMetadataSchemaUtils;
import org.fao.geonet.kernel.datamanager.IMetadataUtils;
import org.fao.geonet.kernel.datamanager.IMetadataValidator;
import org.fao.geonet.kernel.schema.MetadataSchema;
import org.fao.geonet.kernel.search.LuceneSearcher;
import org.fao.geonet.kernel.search.MetaSearcher;
import org.fao.geonet.kernel.search.SearchManager;
import org.fao.geonet.kernel.search.SearchParameter;
import org.fao.geonet.kernel.search.SearcherType;
import org.fao.geonet.kernel.search.index.IndexingList;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.kernel.setting.Settings;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.notifier.MetadataNotifierManager;
import org.fao.geonet.repository.GroupRepository;
import org.fao.geonet.repository.MetadataCategoryRepository;
import org.fao.geonet.repository.MetadataFileUploadRepository;
import org.fao.geonet.repository.MetadataRatingByIpRepository;
import org.fao.geonet.repository.MetadataRepository;
import org.fao.geonet.repository.MetadataStatusRepository;
import org.fao.geonet.repository.MetadataValidationRepository;
import org.fao.geonet.repository.OperationAllowedRepository;
import org.fao.geonet.repository.PathSpec;
import org.fao.geonet.repository.SortUtils;
import org.fao.geonet.repository.Updater;
import org.fao.geonet.repository.UserRepository;
import org.fao.geonet.repository.UserSavedSelectionRepository;
import org.fao.geonet.repository.specification.MetadataFileUploadSpecs;
import org.fao.geonet.repository.specification.MetadataSpecs;
import org.fao.geonet.repository.specification.OperationAllowedSpecs;
import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;
import org.jdom.Namespace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.transaction.TransactionStatus;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import jeeves.constants.Jeeves;
import jeeves.server.ServiceConfig;
import jeeves.server.UserSession;
import jeeves.server.context.ServiceContext;
import jeeves.transaction.TransactionManager;
import jeeves.transaction.TransactionTask;
import jeeves.xlink.Processor;
public class BaseMetadataManager implements IMetadataManager {
@Autowired
private IMetadataUtils metadataUtils;
@Autowired
private IMetadataIndexer metadataIndexer;
@Autowired
private IMetadataValidator metadataValidator;
@Autowired
private IMetadataOperations metadataOperations;
@Autowired
private IMetadataSchemaUtils metadataSchemaUtils;
@Autowired
private GroupRepository groupRepository;
@Autowired
private MetadataStatusRepository metadataStatusRepository;
@Autowired
private MetadataValidationRepository metadataValidationRepository;
@Autowired
private MetadataRepository metadataRepository;
@Autowired
private SearchManager searchManager;
private EditLib editLib;
@Autowired
private MetadataRatingByIpRepository metadataRatingByIpRepository;
@Autowired
private MetadataFileUploadRepository metadataFileUploadRepository;
@Autowired(required = false)
private XmlSerializer xmlSerializer;
@Autowired
@Lazy
private SettingManager settingManager;
@Autowired
private MetadataCategoryRepository metadataCategoryRepository;
@Autowired(required = false)
private HarvestInfoProvider harvestInfoProvider;
@Autowired
private UserRepository userRepository;
@Autowired
private SchemaManager schemaManager;
@Autowired
private ThesaurusManager thesaurusManager;
@Autowired
private AccessManager accessManager;
@Autowired
private UserSavedSelectionRepository userSavedSelectionRepository;
private static final int METADATA_BATCH_PAGE_SIZE = 100000;
private String baseURL;
@Autowired
private ApplicationContext _applicationContext;
@PersistenceContext
private EntityManager _entityManager;
@Override
public EditLib getEditLib() {
return editLib;
}
/**
* To avoid cyclic references on autowired
*/
@PostConstruct
public void init() {
editLib = new EditLib(schemaManager);
metadataValidator.setMetadataManager(this);
metadataUtils.setMetadataManager(this);
}
public void init(ServiceContext context, Boolean force) throws Exception {
metadataUtils = context.getBean(IMetadataUtils.class);
metadataIndexer = context.getBean(IMetadataIndexer.class);
metadataStatusRepository = context.getBean(MetadataStatusRepository.class);
metadataValidationRepository = context.getBean(MetadataValidationRepository.class);
metadataRepository = context.getBean(MetadataRepository.class);
metadataValidator = context.getBean(IMetadataValidator.class);
metadataSchemaUtils = context.getBean(IMetadataSchemaUtils.class);
searchManager = context.getBean(SearchManager.class);
metadataRatingByIpRepository = context.getBean(MetadataRatingByIpRepository.class);
metadataFileUploadRepository = context.getBean(MetadataFileUploadRepository.class);
groupRepository = context.getBean(GroupRepository.class);
xmlSerializer = context.getBean(XmlSerializer.class);
settingManager = context.getBean(SettingManager.class);
metadataCategoryRepository = context.getBean(MetadataCategoryRepository.class);
try {
harvestInfoProvider = context.getBean(HarvestInfoProvider.class);
} catch (Exception e) {
// If it doesn't exist, that's fine
}
userRepository = context.getBean(UserRepository.class);
schemaManager = context.getBean(SchemaManager.class);
thesaurusManager = context.getBean(ThesaurusManager.class);
accessManager = context.getBean(AccessManager.class);
// From DataManager:
// get lastchangedate of all metadata in index
Map<String, String> docs = getSearchManager().getDocsChangeDate();
// set up results HashMap for post processing of records to be indexed
ArrayList<String> toIndex = new ArrayList<String>();
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "INDEX CONTENT:");
Sort sortByMetadataChangeDate = SortUtils.createSort(Metadata_.dataInfo, MetadataDataInfo_.changeDate);
int currentPage = 0;
Page<Pair<Integer, ISODate>> results = metadataRepository
.findAllIdsAndChangeDates(new PageRequest(currentPage, METADATA_BATCH_PAGE_SIZE, sortByMetadataChangeDate));
// index all metadata in DBMS if needed
while (results.getNumberOfElements() > 0) {
for (Pair<Integer, ISODate> result : results) {
// get metadata
String id = String.valueOf(result.one());
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "- record (" + id + ")");
}
String idxLastChange = docs.get(id);
// if metadata is not indexed index it
if (idxLastChange == null) {
Log.debug(Geonet.DATA_MANAGER, "- will be indexed");
toIndex.add(id);
// else, if indexed version is not the latest index it
} else {
docs.remove(id);
String lastChange = result.two().toString();
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "- lastChange: " + lastChange);
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "- idxLastChange: " + idxLastChange);
// date in index contains 't', date in DBMS contains 'T'
if (force || !idxLastChange.equalsIgnoreCase(lastChange)) {
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "- will be indexed");
toIndex.add(id);
}
}
}
currentPage++;
results = metadataRepository
.findAllIdsAndChangeDates(new PageRequest(currentPage, METADATA_BATCH_PAGE_SIZE, sortByMetadataChangeDate));
}
// if anything to index then schedule it to be done after servlet is
// up so that any links to local fragments are resolvable
if (toIndex.size() > 0) {
metadataIndexer.batchIndexInThreadPool(context, toIndex);
}
if (docs.size() > 0) { // anything left?
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "INDEX HAS RECORDS THAT ARE NOT IN DB:");
}
}
// remove from index metadata not in DBMS
for (String id : docs.keySet()) {
getSearchManager().delete(id);
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "- removed record (" + id + ") from index");
}
}
}
private SearchManager getSearchManager() {
return searchManager;
}
/**
* You should not use a direct flush. If you need to use this to properly run your code, you are missing something. Check the
* transaction annotations and try to comply to Spring/Hibernate
*/
@Override
@Deprecated
public void flush() {
TransactionManager.runInTransaction("DataManager flush()", getApplicationContext(),
TransactionManager.TransactionRequirement.CREATE_ONLY_WHEN_NEEDED, TransactionManager.CommitBehavior.ALWAYS_COMMIT, false,
new TransactionTask<Object>() {
@Override
public Object doInTransaction(TransactionStatus transaction) throws Throwable {
_entityManager.flush();
return null;
}
});
}
private ApplicationContext getApplicationContext() {
final ConfigurableApplicationContext applicationContext = ApplicationContextHolder.get();
return applicationContext == null ? _applicationContext : applicationContext;
}
private void deleteMetadataFromDB(ServiceContext context, String id) throws Exception {
// --- remove operations
metadataOperations.deleteMetadataOper(context, id, false);
int intId = Integer.parseInt(id);
metadataRatingByIpRepository.deleteAllById_MetadataId(intId);
metadataValidationRepository.deleteAllById_MetadataId(intId);
metadataStatusRepository.deleteAllById_MetadataId(intId);
userSavedSelectionRepository.deleteAllByUuid(metadataUtils.getMetadataUuid(id));
// Logical delete for metadata file uploads
PathSpec<MetadataFileUpload, String> deletedDatePathSpec = new PathSpec<MetadataFileUpload, String>() {
@Override
public javax.persistence.criteria.Path<String> getPath(Root<MetadataFileUpload> root) {
return root.get(MetadataFileUpload_.deletedDate);
}
};
metadataFileUploadRepository.createBatchUpdateQuery(deletedDatePathSpec, new ISODate().toString(),
MetadataFileUploadSpecs.isNotDeletedForMetadata(intId));
// --- remove metadata
getXmlSerializer().delete(id, context);
}
// --------------------------------------------------------------------------
// ---
// --- Metadata thumbnail API
// ---
// --------------------------------------------------------------------------
private XmlSerializer getXmlSerializer() {
return xmlSerializer;
}
/**
* Removes a metadata.
*/
@Override
public synchronized void deleteMetadata(ServiceContext context, String metadataId) throws Exception {
String uuid = metadataUtils.getMetadataUuid(metadataId);
Metadata findOne = metadataRepository.findOne(metadataId);
if (findOne != null) {
boolean isMetadata = findOne.getDataInfo().getType() == MetadataType.METADATA;
deleteMetadataFromDB(context, metadataId);
// Notifies the metadata change to metatada notifier service
if (isMetadata) {
context.getBean(MetadataNotifierManager.class).deleteMetadata(metadataId, uuid, context);
}
}
// --- update search criteria
getSearchManager().delete(metadataId + "");
// _entityManager.flush();
// _entityManager.clear();
}
/**
*
* @param context
* @param metadataId
* @throws Exception
*/
@Override
public synchronized void deleteMetadataGroup(ServiceContext context, String metadataId) throws Exception {
deleteMetadataFromDB(context, metadataId);
// --- update search criteria
getSearchManager().delete(metadataId + "");
}
/**
* Creates a new metadata duplicating an existing template creating a random uuid.
*
* @param isTemplate
* @param fullRightsForGroup
*/
@Override
public String createMetadata(ServiceContext context, String templateId, String groupOwner, String source, int owner, String parentUuid,
String isTemplate, boolean fullRightsForGroup) throws Exception {
return createMetadata(context, templateId, groupOwner, source, owner, parentUuid, isTemplate, fullRightsForGroup,
UUID.randomUUID().toString());
}
/**
* Creates a new metadata duplicating an existing template with an specified uuid.
*
* @param isTemplate
* @param fullRightsForGroup
*/
@Override
public String createMetadata(ServiceContext context, String templateId, String groupOwner, String source, int owner, String parentUuid,
String isTemplate, boolean fullRightsForGroup, String uuid) throws Exception {
Metadata templateMetadata = metadataRepository.findOne(templateId);
if (templateMetadata == null) {
throw new IllegalArgumentException("Template id not found : " + templateId);
}
String schema = templateMetadata.getDataInfo().getSchemaId();
String data = templateMetadata.getData();
Element xml = Xml.loadString(data, false);
if (templateMetadata.getDataInfo().getType() == MetadataType.METADATA) {
xml = updateFixedInfo(schema, Optional.<Integer> absent(), uuid, xml, parentUuid, UpdateDatestamp.NO, context);
}
final Metadata newMetadata = new Metadata().setUuid(uuid);
newMetadata.getDataInfo().setChangeDate(new ISODate()).setCreateDate(new ISODate()).setSchemaId(schema)
.setType(MetadataType.lookup(isTemplate));
newMetadata.getSourceInfo().setGroupOwner(Integer.valueOf(groupOwner)).setOwner(owner).setSourceId(source);
// If there is a default category for the group, use it:
Group group = groupRepository.findOne(Integer.valueOf(groupOwner));
if (group.getDefaultCategory() != null) {
newMetadata.getMetadataCategories().add(group.getDefaultCategory());
}
Collection<MetadataCategory> filteredCategories = Collections2.filter(templateMetadata.getMetadataCategories(),
new Predicate<MetadataCategory>() {
@Override
public boolean apply(@Nullable MetadataCategory input) {
return input != null;
}
});
newMetadata.getMetadataCategories().addAll(filteredCategories);
int finalId = insertMetadata(context, newMetadata, xml, false, true, true, UpdateDatestamp.YES, fullRightsForGroup, true).getId();
return String.valueOf(finalId);
}
/**
* Inserts a metadata into the database, optionally indexing it, and optionally applying automatic changes to it (update-fixed-info).
*
* @param context the context describing the user and service
* @param schema XSD this metadata conforms to
* @param metadataXml the metadata to store
* @param uuid unique id for this metadata
* @param owner user who owns this metadata
* @param groupOwner group this metadata belongs to
* @param source id of the origin of this metadata (harvesting source, etc.)
* @param metadataType whether this metadata is a template
* @param docType ?!
* @param category category of this metadata
* @param createDate date of creation
* @param changeDate date of modification
* @param ufo whether to apply automatic changes
* @param index whether to index this metadata
* @return id, as a string
* @throws Exception hmm
*/
@Override
public String insertMetadata(ServiceContext context, String schema, Element metadataXml, String uuid, int owner, String groupOwner,
String source, String metadataType, String docType, String category, String createDate, String changeDate, boolean ufo,
boolean index) throws Exception {
boolean notifyChange = true;
if (source == null) {
source = settingManager.getSiteId();
}
if (StringUtils.isBlank(metadataType)) {
metadataType = MetadataType.METADATA.codeString;
}
final Metadata newMetadata = new Metadata().setUuid(uuid);
final ISODate isoChangeDate = changeDate != null ? new ISODate(changeDate) : new ISODate();
final ISODate isoCreateDate = createDate != null ? new ISODate(createDate) : new ISODate();
newMetadata.getDataInfo().setChangeDate(isoChangeDate).setCreateDate(isoCreateDate).setSchemaId(schema).setDoctype(docType)
.setRoot(metadataXml.getQualifiedName()).setType(MetadataType.lookup(metadataType));
newMetadata.getSourceInfo().setOwner(owner).setSourceId(source);
if (StringUtils.isNotEmpty(groupOwner)) {
newMetadata.getSourceInfo().setGroupOwner(Integer.valueOf(groupOwner));
}
if (StringUtils.isNotEmpty(category)) {
MetadataCategory metadataCategory = metadataCategoryRepository.findOneByName(category);
if (metadataCategory == null) {
throw new IllegalArgumentException("No category found with name: " + category);
}
newMetadata.getMetadataCategories().add(metadataCategory);
} else if (StringUtils.isNotEmpty(groupOwner)) {
// If the group has a default category, use it
Group group = groupRepository.findOne(Integer.valueOf(groupOwner));
if (group.getDefaultCategory() != null) {
newMetadata.getMetadataCategories().add(group.getDefaultCategory());
}
}
boolean fullRightsForGroup = false;
int finalId = insertMetadata(context, newMetadata, metadataXml, notifyChange, index, ufo, UpdateDatestamp.NO, fullRightsForGroup,
false).getId();
return String.valueOf(finalId);
}
@Override
public Metadata insertMetadata(ServiceContext context, Metadata newMetadata, Element metadataXml, boolean notifyChange, boolean index,
boolean updateFixedInfo, UpdateDatestamp updateDatestamp, boolean fullRightsForGroup, boolean forceRefreshReaders)
throws Exception {
final String schema = newMetadata.getDataInfo().getSchemaId();
// Check if the schema is allowed by settings
String mdImportSetting = settingManager.getValue(Settings.METADATA_IMPORT_RESTRICT);
if (mdImportSetting != null && !mdImportSetting.equals("")) {
if (!Arrays.asList(mdImportSetting.split(",")).contains(schema)) {
throw new IllegalArgumentException(schema + " is not permitted in the database as a non-harvested metadata. "
+ "Apply a import stylesheet to convert file to allowed schemas");
}
}
// --- force namespace prefix for iso19139 metadata
setNamespacePrefixUsingSchemas(schema, metadataXml);
if (updateFixedInfo && newMetadata.getDataInfo().getType() == MetadataType.METADATA) {
String parentUuid = null;
metadataXml = updateFixedInfo(schema, Optional.<Integer> absent(), newMetadata.getUuid(), metadataXml, parentUuid,
updateDatestamp, context);
}
// --- store metadata
final Metadata savedMetadata = getXmlSerializer().insert(newMetadata, metadataXml, context);
final String stringId = String.valueOf(savedMetadata.getId());
String groupId = null;
final Integer groupIdI = newMetadata.getSourceInfo().getGroupOwner();
if (groupIdI != null) {
groupId = String.valueOf(groupIdI);
}
metadataOperations.copyDefaultPrivForGroup(context, stringId, groupId, fullRightsForGroup);
if (index) {
metadataIndexer.indexMetadata(stringId, forceRefreshReaders, null);
}
if (notifyChange) {
// Notifies the metadata change to metatada notifier service
metadataUtils.notifyMetadataChange(metadataXml, stringId);
}
return savedMetadata;
}
/**
* Retrieves a metadata (in xml) given its id; adds editing information if requested and validation errors if requested.
*
* @param forEditing Add extra element to build metadocument {@link EditLib#expandElements(String, Element)}
* @param keepXlinkAttributes When XLinks are resolved in non edit mode, do not remove XLink attributes.
*/
@Override
public Element getMetadata(ServiceContext srvContext, String id, boolean forEditing, boolean withEditorValidationErrors,
boolean keepXlinkAttributes) throws Exception {
boolean doXLinks = getXmlSerializer().resolveXLinks();
Element metadataXml = getXmlSerializer().selectNoXLinkResolver(id, false, forEditing);
if (metadataXml == null)
return null;
String version = null;
if (forEditing) { // copy in xlink'd fragments but leave xlink atts to editor
if (doXLinks)
Processor.processXLink(metadataXml, srvContext);
String schema = metadataSchemaUtils.getMetadataSchema(id);
// Inflate metadata
Path inflateStyleSheet = metadataSchemaUtils.getSchemaDir(schema).resolve(Geonet.File.INFLATE_METADATA);
if (Files.exists(inflateStyleSheet)) {
// --- setup environment
Element env = new Element("env");
env.addContent(new Element("lang").setText(srvContext.getLanguage()));
// add original metadata to result
Element result = new Element("root");
result.addContent(metadataXml);
result.addContent(env);
metadataXml = Xml.transform(result, inflateStyleSheet);
}
if (withEditorValidationErrors) {
version = metadataValidator
.doValidate(srvContext.getUserSession(), schema, id, metadataXml, srvContext.getLanguage(), forEditing).two();
} else {
editLib.expandElements(schema, metadataXml);
version = editLib.getVersionForEditing(schema, id, metadataXml);
}
} else {
if (doXLinks) {
if (keepXlinkAttributes) {
Processor.processXLink(metadataXml, srvContext);
} else {
Processor.detachXLink(metadataXml, srvContext);
}
}
}
metadataXml.addNamespaceDeclaration(Edit.NAMESPACE);
Element info = buildInfoElem(srvContext, id, version);
metadataXml.addContent(info);
metadataXml.detach();
return metadataXml;
}
/**
* Retrieves a metadata (in xml) given its id. Use this method when you must retrieve a metadata in the same transaction.
*/
@Override
public Element getMetadata(String id) throws Exception {
Element md = getXmlSerializer().selectNoXLinkResolver(id, false, false);
if (md == null)
return null;
md.detach();
return md;
}
/**
* For update of owner info.
*/
@Override
public synchronized void updateMetadataOwner(final int id, final String owner, final String groupOwner) throws Exception {
metadataRepository.update(id, new Updater<Metadata>() {
@Override
public void apply(@Nonnull Metadata entity) {
entity.getSourceInfo().setGroupOwner(Integer.valueOf(groupOwner));
entity.getSourceInfo().setOwner(Integer.valueOf(owner));
}
});
}
/**
* Updates a metadata record. Deletes validation report currently in session (if any). If user asks for validation the validation report
* will be (re-)created then.
*
* @return metadata if the that was updated
*/
@Override
public synchronized Metadata updateMetadata(final ServiceContext context, final String metadataId, final Element md,
final boolean validate, final boolean ufo, final boolean index, final String lang, final String changeDate,
final boolean updateDateStamp) throws Exception {
Element metadataXml = md;
// when invoked from harvesters, session is null?
UserSession session = context.getUserSession();
if (session != null) {
session.removeProperty(Geonet.Session.VALIDATION_REPORT + metadataId);
}
String schema = metadataSchemaUtils.getMetadataSchema(metadataId);
if (ufo) {
String parentUuid = null;
Integer intId = Integer.valueOf(metadataId);
final Metadata metadata = metadataRepository.findOne(metadataId);
String uuid = null;
if (schemaManager.getSchema(schema).isReadwriteUUID() && metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE
&& metadata.getDataInfo().getType() != MetadataType.TEMPLATE_OF_SUB_TEMPLATE) {
uuid = metadataUtils.extractUUID(schema, metadataXml);
}
metadataXml = updateFixedInfo(schema, Optional.of(intId), uuid, metadataXml, parentUuid,
(updateDateStamp ? UpdateDatestamp.YES : UpdateDatestamp.NO), context);
}
// --- force namespace prefix for iso19139 metadata
setNamespacePrefixUsingSchemas(schema, metadataXml);
// Notifies the metadata change to metatada notifier service
final Metadata metadata = metadataRepository.findOne(metadataId);
String uuid = null;
if (schemaManager.getSchema(schema).isReadwriteUUID() && metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE
&& metadata.getDataInfo().getType() != MetadataType.TEMPLATE_OF_SUB_TEMPLATE) {
uuid = metadataUtils.extractUUID(schema, metadataXml);
}
// --- write metadata to dbms
getXmlSerializer().update(metadataId, metadataXml, changeDate, updateDateStamp, uuid, context);
// Notifies the metadata change to metatada notifier service
metadataUtils.notifyMetadataChange(metadataXml, metadataId);
try {
// --- do the validation last - it throws exceptions
if (session != null && validate) {
metadataValidator.doValidate(session, schema, metadataId, metadataXml, lang, false);
}
} finally {
if (index) {
// --- update search criteria
metadataIndexer.indexMetadata(metadataId, true, null);
}
}
if (metadata.getDataInfo().getType() == MetadataType.SUB_TEMPLATE) {
if (!index) {
metadataIndexer.indexMetadata(metadataId, true, null);
}
MetaSearcher searcher = context.getBean(SearchManager.class).newSearcher(SearcherType.LUCENE, Geonet.File.SEARCH_LUCENE);
Element parameters = new Element(Jeeves.Elem.REQUEST);
parameters.addContent(new Element(Geonet.IndexFieldNames.XLINK).addContent("*" + metadata.getUuid() + "*"));
parameters.addContent(new Element(Geonet.SearchResult.BUILD_SUMMARY).setText("false"));
parameters.addContent(new Element(SearchParameter.ISADMIN).addContent("true"));
parameters.addContent(new Element(SearchParameter.ISTEMPLATE).addContent("y or n"));
ServiceConfig config = new ServiceConfig();
searcher.search(context, parameters, config);
Map<Integer, Metadata> result = ((LuceneSearcher) searcher).getAllMdInfo(context, 500);
for (Integer id : result.keySet()) {
IndexingList list = context.getBean(IndexingList.class);
list.add(id);
}
}
// Return an up to date metadata record
return metadataRepository.findOne(metadataId);
}
/**
* TODO : buildInfoElem contains similar portion of code with indexMetadata
*/
private Element buildInfoElem(ServiceContext context, String id, String version) throws Exception {
Metadata metadata = metadataRepository.findOne(id);
final MetadataDataInfo dataInfo = metadata.getDataInfo();
String schema = dataInfo.getSchemaId();
String createDate = dataInfo.getCreateDate().getDateAndTime();
String changeDate = dataInfo.getChangeDate().getDateAndTime();
String source = metadata.getSourceInfo().getSourceId();
String isTemplate = dataInfo.getType().codeString;
String title = dataInfo.getTitle();
String uuid = metadata.getUuid();
String isHarvested = "" + Constants.toYN_EnabledChar(metadata.getHarvestInfo().isHarvested());
String harvestUuid = metadata.getHarvestInfo().getUuid();
String popularity = "" + dataInfo.getPopularity();
String rating = "" + dataInfo.getRating();
String owner = "" + metadata.getSourceInfo().getOwner();
String displayOrder = "" + dataInfo.getDisplayOrder();
Element info = new Element(Edit.RootChild.INFO, Edit.NAMESPACE);
addElement(info, Edit.Info.Elem.ID, id);
addElement(info, Edit.Info.Elem.SCHEMA, schema);
addElement(info, Edit.Info.Elem.CREATE_DATE, createDate);
addElement(info, Edit.Info.Elem.CHANGE_DATE, changeDate);
addElement(info, Edit.Info.Elem.IS_TEMPLATE, isTemplate);
addElement(info, Edit.Info.Elem.TITLE, title);
addElement(info, Edit.Info.Elem.SOURCE, source);
addElement(info, Edit.Info.Elem.UUID, uuid);
addElement(info, Edit.Info.Elem.IS_HARVESTED, isHarvested);
addElement(info, Edit.Info.Elem.POPULARITY, popularity);
addElement(info, Edit.Info.Elem.RATING, rating);
addElement(info, Edit.Info.Elem.DISPLAY_ORDER, displayOrder);
if (metadata.getHarvestInfo().isHarvested()) {
if (harvestInfoProvider != null) {
info.addContent(harvestInfoProvider.getHarvestInfo(harvestUuid, id, uuid));
}
}
if (version != null) {
addElement(info, Edit.Info.Elem.VERSION, version);
}
Map<String, Element> map = Maps.newHashMap();
map.put(id, info);
buildPrivilegesMetadataInfo(context, map);
// add owner name
User user = userRepository.findOne(owner);
if (user != null) {
String ownerName = user.getName();
addElement(info, Edit.Info.Elem.OWNERNAME, ownerName);
}
for (MetadataCategory category : metadata.getMetadataCategories()) {
addElement(info, Edit.Info.Elem.CATEGORY, category.getName());
}
// add subtemplates
/*
* -- don't add as we need to investigate indexing for the fields -- in the metadata table used here List subList =
* getSubtemplates(dbms, schema); if (subList != null) { Element subs = new Element(Edit.Info.Elem.SUBTEMPLATES);
* subs.addContent(subList); info.addContent(subs); }
*/
// Add validity information
List<MetadataValidation> validationInfo = metadataValidationRepository.findAllById_MetadataId(Integer.parseInt(id));
if (validationInfo == null || validationInfo.size() == 0) {
addElement(info, Edit.Info.Elem.VALID, "-1");
} else {
String isValid = "1";
for (Object elem : validationInfo) {
MetadataValidation vi = (MetadataValidation) elem;
String type = vi.getId().getValidationType();
if (!vi.isValid()) {
isValid = "0";
}
String ratio = "xsd".equals(type) ? "" : vi.getNumFailures() + "/" + vi.getNumTests();
info.addContent(new Element(Edit.Info.Elem.VALID + "_details").addContent(new Element("type").setText(type)).addContent(
new Element("status").setText(vi.isValid() ? "1" : "0").addContent(new Element("ratio").setText(ratio))));
}
addElement(info, Edit.Info.Elem.VALID, isValid);
}
// add baseUrl of this site (from settings)
String protocol = settingManager.getValue(Settings.SYSTEM_SERVER_PROTOCOL);
String host = settingManager.getValue(Settings.SYSTEM_SERVER_HOST);
String port = settingManager.getValue(Settings.SYSTEM_SERVER_PORT);
if (port.equals("80")) {
port = "";
} else {
port = ":" + port;
}
addElement(info, Edit.Info.Elem.BASEURL, protocol + "://" + host + port + baseURL);
addElement(info, Edit.Info.Elem.LOCSERV, "/srv/en");
return info;
}
/**
* Update metadata record (not template) using update-fixed-info.xsl
*
* @param uuid If the metadata is a new record (not yet saved), provide the uuid for that record
* @param updateDatestamp updateDatestamp is not used when running XSL transformation
*/
@Override
public Element updateFixedInfo(String schema, Optional<Integer> metadataId, String uuid, Element md, String parentUuid,
UpdateDatestamp updateDatestamp, ServiceContext context) throws Exception {
boolean autoFixing = settingManager.getValueAsBool(Settings.SYSTEM_AUTOFIXING_ENABLE, true);
if (autoFixing) {
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER,
"Autofixing is enabled, trying update-fixed-info (updateDatestamp: " + updateDatestamp.name() + ")");
}
Metadata metadata = null;
if (metadataId.isPresent()) {
metadata = metadataRepository.findOne(metadataId.get());
boolean isTemplate = metadata != null && metadata.getDataInfo().getType() != MetadataType.METADATA;
// don't process templates
if (isTemplate) {
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "Not applying update-fixed-info for a template");
}
return md;
}
}
String currentUuid = metadata != null ? metadata.getUuid() : null;
String id = metadata != null ? metadata.getId() + "" : null;
uuid = uuid == null ? currentUuid : uuid;
// --- setup environment
Element env = new Element("env");
env.addContent(new Element("id").setText(id));
env.addContent(new Element("uuid").setText(uuid));
env.addContent(thesaurusManager.buildResultfromThTable(context));
Element schemaLoc = new Element("schemaLocation");
schemaLoc.setAttribute(schemaManager.getSchemaLocation(schema, context));
env.addContent(schemaLoc);
if (updateDatestamp == UpdateDatestamp.YES) {
env.addContent(new Element("changeDate").setText(new ISODate().toString()));
}
if (parentUuid != null) {
env.addContent(new Element("parentUuid").setText(parentUuid));
}
if (metadataId.isPresent()) {
String metadataIdString = String.valueOf(metadataId.get());
final Path resourceDir = Lib.resource.getDir(context, Params.Access.PRIVATE, metadataIdString);
env.addContent(new Element("datadir").setText(resourceDir.toString()));
}
// add user information to env if user is authenticated (should be)
Element elUser = new Element("user");
UserSession usrSess = context.getUserSession();
if (usrSess.isAuthenticated()) {
String myUserId = usrSess.getUserId();
User user = getApplicationContext().getBean(UserRepository.class).findOne(myUserId);
if (user != null) {
Element elUserDetails = new Element("details");
elUserDetails.addContent(new Element("surname").setText(user.getSurname()));
elUserDetails.addContent(new Element("firstname").setText(user.getName()));
elUserDetails.addContent(new Element("organisation").setText(user.getOrganisation()));
elUserDetails.addContent(new Element("username").setText(user.getUsername()));
elUser.addContent(elUserDetails);
env.addContent(elUser);
}
}
// add original metadata to result
Element result = new Element("root");
result.addContent(md);
// add 'environment' to result
env.addContent(new Element("siteURL").setText(settingManager.getSiteURL(context)));
env.addContent(new Element("node").setText(context.getNodeId()));
// Settings were defined as an XML starting with root named config
// Only second level elements are defined (under system).
List<?> config = settingManager.getAllAsXML(true).cloneContent();
for (Object c : config) {
Element settings = (Element) c;
env.addContent(settings);
}
result.addContent(env);
// apply update-fixed-info.xsl
Path styleSheet = metadataSchemaUtils.getSchemaDir(schema).resolve(Geonet.File.UPDATE_FIXED_INFO);
result = Xml.transform(result, styleSheet);
return result;
} else {
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "Autofixing is disabled, not applying update-fixed-info");
}
return md;
}
}
/**
* Updates all children of the selected parent. Some elements are protected in the children according to the stylesheet used in
* xml/schemas/[SCHEMA]/update-child-from-parent-info.xsl.
*
* Children MUST be editable and also in the same schema of the parent. If not, child is not updated.
*
* @param srvContext service context
* @param parentUuid parent uuid
* @param children children
* @param params parameters
*/
@Override
public Set<String> updateChildren(ServiceContext srvContext, String parentUuid, String[] children, Map<String, Object> params)
throws Exception {
String parentId = (String) params.get(Params.ID);
String parentSchema = (String) params.get(Params.SCHEMA);
// --- get parent metadata in read/only mode
boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
Element parent = getMetadata(srvContext, parentId, forEditing, withValidationErrors, keepXlinkAttributes);
Element env = new Element("update");
env.addContent(new Element("parentUuid").setText(parentUuid));
env.addContent(new Element("siteURL").setText(settingManager.getSiteURL(srvContext)));
env.addContent(new Element("parent").addContent(parent));
// Set of untreated children (out of privileges, different schemas)
Set<String> untreatedChildSet = new HashSet<String>();
// only get iso19139 records
for (String childId : children) {
// Check privileges
if (!accessManager.canEdit(srvContext, childId)) {
untreatedChildSet.add(childId);
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "Could not update child (" + childId + ") because of privileges.");
continue;
}
Element child = getMetadata(srvContext, childId, forEditing, withValidationErrors, keepXlinkAttributes);
String childSchema = child.getChild(Edit.RootChild.INFO, Edit.NAMESPACE).getChildText(Edit.Info.Elem.SCHEMA);
// Check schema matching. CHECKME : this suppose that parent and
// child are in the same schema (even not profil different)
if (!childSchema.equals(parentSchema)) {
untreatedChildSet.add(childId);
if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) {
Log.debug(Geonet.DATA_MANAGER, "Could not update child (" + childId + ") because schema (" + childSchema
+ ") is different from the parent one (" + parentSchema + ").");
}
continue;
}
if (Log.isDebugEnabled(Geonet.DATA_MANAGER))
Log.debug(Geonet.DATA_MANAGER, "Updating child (" + childId + ") ...");
// --- setup xml element to be processed by XSLT
Element rootEl = new Element("root");
Element childEl = new Element("child").addContent(child.detach());
rootEl.addContent(childEl);
rootEl.addContent(env.detach());
// --- do an XSL transformation
Path styleSheet = metadataSchemaUtils.getSchemaDir(parentSchema).resolve(Geonet.File.UPDATE_CHILD_FROM_PARENT_INFO);
Element childForUpdate = Xml.transform(rootEl, styleSheet, params);
getXmlSerializer().update(childId, childForUpdate, new ISODate().toString(), true, null, srvContext);
// Notifies the metadata change to metatada notifier service
metadataUtils.notifyMetadataChange(childForUpdate, childId);
rootEl = null;
}
return untreatedChildSet;
}
// ---------------------------------------------------------------------------
// ---
// --- Static methods are for external modules like GAST to be able to use
// --- them.
// ---
// ---------------------------------------------------------------------------
/**
* Add privileges information about metadata record which depends on context and usually could not be stored in db or Lucene index
* because depending on the current user or current client IP address.
*
* @param mdIdToInfoMap a map from the metadata Id -> the info element to which the privilege information should be added.
*/
@VisibleForTesting
@Override
public void buildPrivilegesMetadataInfo(ServiceContext context, Map<String, Element> mdIdToInfoMap) throws Exception {
Collection<Integer> metadataIds = Collections2.transform(mdIdToInfoMap.keySet(), new Function<String, Integer>() {
@Nullable
@Override
public Integer apply(String input) {
return Integer.valueOf(input);
}
});
Specification<OperationAllowed> operationAllowedSpec = OperationAllowedSpecs.hasMetadataIdIn(metadataIds);
final Collection<Integer> allUserGroups = accessManager.getUserGroups(context.getUserSession(), context.getIpAddress(), false);
final SetMultimap<Integer, ReservedOperation> operationsPerMetadata = loadOperationsAllowed(context,
where(operationAllowedSpec).and(OperationAllowedSpecs.hasGroupIdIn(allUserGroups)));
final Set<Integer> visibleToAll = loadOperationsAllowed(context,
where(operationAllowedSpec).and(OperationAllowedSpecs.isPublic(ReservedOperation.view))).keySet();
final Set<Integer> downloadableByGuest = loadOperationsAllowed(context,
where(operationAllowedSpec).and(OperationAllowedSpecs.hasGroupId(ReservedGroup.guest.getId()))
.and(OperationAllowedSpecs.hasOperation(ReservedOperation.download))).keySet();
final Map<Integer, MetadataSourceInfo> allSourceInfo = metadataRepository
.findAllSourceInfo(MetadataSpecs.hasMetadataIdIn(metadataIds));
for (Map.Entry<String, Element> entry : mdIdToInfoMap.entrySet()) {
Element infoEl = entry.getValue();
final Integer mdId = Integer.valueOf(entry.getKey());
MetadataSourceInfo sourceInfo = allSourceInfo.get(mdId);
Set<ReservedOperation> operations = operationsPerMetadata.get(mdId);
if (operations == null) {
operations = Collections.emptySet();
}
boolean isOwner = accessManager.isOwner(context, sourceInfo);
if (isOwner) {
operations = Sets.newHashSet(Arrays.asList(ReservedOperation.values()));
}
if (isOwner || operations.contains(ReservedOperation.editing)) {
addElement(infoEl, Edit.Info.Elem.EDIT, "true");
}
if (isOwner) {
addElement(infoEl, Edit.Info.Elem.OWNER, "true");
}
addElement(infoEl, Edit.Info.Elem.IS_PUBLISHED_TO_ALL, visibleToAll.contains(mdId));
addElement(infoEl, ReservedOperation.view.name(), operations.contains(ReservedOperation.view));
addElement(infoEl, ReservedOperation.notify.name(), operations.contains(ReservedOperation.notify));
addElement(infoEl, ReservedOperation.download.name(), operations.contains(ReservedOperation.download));
addElement(infoEl, ReservedOperation.dynamic.name(), operations.contains(ReservedOperation.dynamic));
addElement(infoEl, ReservedOperation.featured.name(), operations.contains(ReservedOperation.featured));
if (!operations.contains(ReservedOperation.download)) {
addElement(infoEl, Edit.Info.Elem.GUEST_DOWNLOAD, downloadableByGuest.contains(mdId));
}
}
}
private SetMultimap<Integer, ReservedOperation> loadOperationsAllowed(ServiceContext context,
Specification<OperationAllowed> operationAllowedSpec) {
final OperationAllowedRepository operationAllowedRepo = context.getBean(OperationAllowedRepository.class);
List<OperationAllowed> operationsAllowed = operationAllowedRepo.findAll(operationAllowedSpec);
SetMultimap<Integer, ReservedOperation> operationsPerMetadata = HashMultimap.create();
for (OperationAllowed allowed : operationsAllowed) {
final OperationAllowedId id = allowed.getId();
operationsPerMetadata.put(id.getMetadataId(), ReservedOperation.lookup(id.getOperationId()));
}
return operationsPerMetadata;
}
/**
*
* @param md
* @throws Exception
*/
private void setNamespacePrefixUsingSchemas(String schema, Element md) throws Exception {
// --- if the metadata has no namespace or already has a namespace prefix
// --- then we must skip this phase
Namespace ns = md.getNamespace();
if (ns == Namespace.NO_NAMESPACE)
return;
MetadataSchema mds = schemaManager.getSchema(schema);
// --- get the namespaces and add prefixes to any that are
// --- default (ie. prefix is '') if namespace match one of the schema
ArrayList<Namespace> nsList = new ArrayList<Namespace>();
nsList.add(ns);
@SuppressWarnings("unchecked")
List<Namespace> additionalNamespaces = md.getAdditionalNamespaces();
nsList.addAll(additionalNamespaces);
for (Object aNsList : nsList) {
Namespace aNs = (Namespace) aNsList;
if (aNs.getPrefix().equals("")) { // found default namespace
String prefix = mds.getPrefix(aNs.getURI());
if (prefix == null) {
Log.warning(Geonet.DATA_MANAGER, "Metadata record contains a default namespace " + aNs.getURI()
+ " (with no prefix) which does not match any " + schema + " schema's namespaces.");
}
ns = Namespace.getNamespace(prefix, aNs.getURI());
metadataValidator.setNamespacePrefix(md, ns);
if (!md.getNamespace().equals(ns)) {
md.removeNamespaceDeclaration(aNs);
md.addNamespaceDeclaration(ns);
}
}
}
}
/**
*
* @param root
* @param name
* @param value
*/
private static void addElement(Element root, String name, Object value) {
root.addContent(new Element(name).setText(value == null ? "" : value.toString()));
}
}
| [
"delawen@gmail.com"
] | delawen@gmail.com |
d0de3bed25411e939a03325ffb7e23795fd51c06 | fccce51dc5a7a518d3ff74d3641ecd1ec70a71cd | /blitz/jini2_1/source/src/com/sun/jini/tool/ClassDep.java | 803465bca90e357b7c37a24c8d63f59d20cabfe6 | [
"Apache-2.0"
] | permissive | arthur073/kings | 9520310d1073af650b22968e4318d0fe007f5685 | df0c0fe75fd35983de364bdd6277c8a300bd15c3 | refs/heads/master | 2021-01-01T19:01:44.850121 | 2013-06-10T09:15:56 | 2013-06-10T09:15:56 | 10,450,386 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 48,792 | java | /*
*
* Copyright 2005 Sun Microsystems, 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.sun.jini.tool;
import sun.tools.java.BinaryClass;
import sun.tools.java.ClassDeclaration;
import sun.tools.java.ClassFile;
import sun.tools.java.ClassNotFound;
import sun.tools.java.ClassPath;
import sun.tools.java.Constants;
import sun.tools.java.Environment;
import sun.tools.java.Identifier;
import sun.tools.java.MemberDefinition;
import sun.tools.java.Package;
import sun.tools.java.Type;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
/**
* Tool used to analyze a set of classes and determine on what other classes
* they directly or indirectly depend. Typically this tool is used to
* compute the necessary and sufficient set of classes to include in a JAR
* file, for use in the class path of a client or service, or for use in the
* codebase of a client or service. The tool starts with a set of "root"
* classes and recursively computes a dependency graph, finding all of the
* classes referenced directly by the root classes, finding all of the
* classes referenced in turn by those classes, and so on, until no new
* classes are found or until classes that are not of interest are
* found. The normal output of the tool is a list of all of the classes in
* the dependency graph. The output from this command can be used as input
* to the <code>jar</code> tool, to create a JAR file containing precisely
* those classes.
* <p>
* The following items are discussed below:
* <ul>
* <li><a href="#running">Running the Tool</a>
* <li><a href="#processing">Processing Options</a>
* <li><a href="#output">Output Options and Arguments</a>
* <li><a href="#examples">Examples</a>
* </ul>
*
* <a name="running"></a>
* <h3>Running the Tool</h3>
*
* The command line for running the tool has the form:
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>input_classpath</b></var> <var><b>processing_options</b></var> <var><b>output_options</b></var>
* </pre></blockquote>
* <p>
* where <var><b>install_dir</b></var> is the directory where the starter kit
* is installed.
* Note that the options for this tool can be specified in any order, and
* can be intermixed.
*
* <p>
* The <code>-cp</code> class path value,
* <var><b>input_classpath</b></var>,
* is an argument to the <code>ClassDep</code> tool itself and should
* include all of the classes that might need to be included in the
* dependency analysis. Typically this will include all of your application
* classes, classes from the starter kit, and any other classes on which
* your classes might depend. It is safe to include more classes than are
* actually necessary (since the purpose of this tool is, after all, to
* determine which subset of these classes is actually necessary), but it is
* not necessary to include any classes that are part of the Java 2 SDK.
* The class path should be in the form of a list of directories or JAR
* files, delimited by a colon (":") on UNIX platforms and a semi-colon
* (";") on Microsoft Windows platforms. The order of locations in the path
* does not matter. If you use JAR files, any <code>Class-Path</code>
* manifest entries in those JAR files are ignored, so you must include the
* values of those manifest entries explicitly in the path, or errors may
* result. For example, if you include <code>jini-ext.jar</code> then you
* should explicitly include <code>jini-core.jar</code> as well, because
* <code>jini-core.jar</code> is in the <code>Class-Path</code> manifest
* entry of <code>jini-ext.jar</code>.</dd>
*
* <a name="processing"></a>
* <h3>Processing Options</h3>
*
* The root classes of the dependency graph can be specified by any
* combination of individual classes and directories of classes. Each of
* these options can be used any number of times, and are illustrated in the
* <a href="#examples">Examples</a> section of this page.
* <p>
* In general, you only need to specify concrete classes as roots, not
* interface types. When analyzing classes for the class path of an
* application, you typically need to include the top-level class (the one
* with the <code>main</code> method). When analyzing classes for the
* codebase of a service, you typically need to include the top-level proxy
* classes used by the service, any trust verifier classes for those
* proxies, and any custom entry classes used by the service for lookup
* service attributes. Also when analyzing classes for the codebase of a
* service, if the service's proxy can return leases, registration objects,
* or other proxies, or if your service generates events, and if those
* objects are only referenced by interface type in the top-level proxy, not
* by concrete class, then you also need to include the concrete classes of
* those other objects. In all cases, you typically need to include any stub
* classes that you generated with the <code>rmic</code> tool.
* <p>
* <dl>
* <dt><b><var>class</var></b>
* <dd>This option specifies the fully qualified name of an individual class
* to include as a root of the dependency graph. This option can be
* specified zero or more times. Each class you specify with this option
* needs to be in a package that is defined to be "inside" the graph (as
* described further below).</dd>
* <p>
* <dt><b><var>directory</var></b>
* <dd>This option specifies the root directory of a tree of compiled class
* files, all of which are to be included as roots of the dependency
* graph. This option can be specified zero or more times. The directory
* must be one of the directories specified in
* <var><b>input_classpath</b></var>,
* or a subdirectory of one, and must contain at least one filename
* separator character. Each class in the tree needs to be in a package that
* is defined to be "inside" the graph (as described further below).
* <p>
* The <code>-prune</code> option can be used to exclude particular subtrees
* from the set of roots.
* <p>
* <dl>
* <dt><b><code>-prune</code> <var>package-prefix</var></b>
* <dd>Specifies a package namespace to exclude when selecting roots from
* directory trees. Within the directory trees, any classes that are in the
* given package or a subpackage of it are not treated as roots. Note that
* this option has <i>no</i> effect on whether the classes in question end
* up "inside" or "outside" the dependency graph (as defined further below);
* it simply controls their use as roots. This option can be specified zero
* or more times. Note that the argument to <code>-prune</code> is a package
* namespace (delimited by "."), not a directory.</dd>
* </dl>
* <p>
* The <code>-skip</code> option (described further below) can be used to
* exclude specific classes from the set of roots.
* </dd>
* </dl>
* <p>
* Starting with the root classes, a dependency graph is constructed by
* examining the compiled class file for a class, finding all of the classes
* it references, and then in turn examining those classes. The extent of
* the graph is determined by which packages are defined to be "inside" the
* graph and which are defined to be "outside" the graph. If a referenced
* class is in a package that is defined to be outside the graph, that class
* is not included in the graph, and none of classes that it references are
* examined. All of the root classes must be in packages that are defined to
* be "inside" the graph.
* <p>
* The inside and outside packages are specified by using the following
* options. Each of these options may be specified zero or more times. Some
* variations are illustrated in the <a href="#examples">Examples</a> section
* of this page.
* <p>
* <dl>
* <dt><b><code>-in</code> <var>package-prefix</var></b>
* <dd>Specifies a namespace of "inside" packages. Any classes in this
* package or a subpackage of it are included in the dependency graph (and
* hence are to be included in your JAR file), unless they are explicitly
* excluded using <code>-out</code> or <code>-skip</code> options. This
* option can be specified zero or more times. If no <code>-in</code>
* options are specified, the default is that all packages are considered to
* be inside packages. Note that the argument to <code>-in</code> is a
* namespace, so none of its subpackages need to be specified as an argument
* to <code>-in</code>.
* <p>
* If you use this option, you will likely need to use it multiple
* times. For example, if your application classes are in the
* <code>com.corp.foo</code> namespace, and you also use some classes in the
* <code>com.sun.jini</code> and <code>net.jini</code> namespaces, then you
* might specify:
* <pre>-in com.corp.foo -in com.sun.jini -in net.jini</pre>
* </dd>
* <p>
* <dt><b><code>-out</code> <var>package-prefix</var></b>
* <dd>Specifies a namespace of "outside" packages. Any classes in this
* package or a subpackage of it are excluded from the dependency graph (and
* hence are to be excluded from your JAR file). This option can be
* specified zero or more times. If you specify <code>-in</code> options,
* then each <code>-out</code> namespace should be a subspace of some
* <code>-in</code> namespace. Note that the argument to <code>-out</code>
* is a namespace, so none of its subpackages need to be specified as an
* argument to <code>-out</code>.
* <p>
* If you use this option, you will likely need to use it multiple
* times. For example, if you do not specify any <code>-in</code> options,
* then all packages are considered inside the graph, including packages
* defined in the Java 2 SDK that you typically want to exclude, so you
* might exclude them by specifying:
* <pre>-out java -out javax</pre>
* As another example, if you have specified <code>-in com.corp.foo</code>
* but you don't want to include any of the classes in the
* <code>com.corp.foo.test</code> or <code>com.corp.foo.qa</code> namespaces
* in the dependency graph, then you would specify:
* <pre>-out com.corp.foo.test -out com.corp.foo.qa</pre>
* </dd>
* <p>
* <dt><b><code>-skip</code> <var>class</var></b>
* <dd>Specifies the fully qualified name of a specific class to exclude
* from the dependency graph. This option allows an individual class to be
* considered "outside" without requiring the entire package it is defined
* in to be considered outside. This option can be specified zero or more
* times.
* </dd>
* <p>
* <dt><b><code>-outer</code></b>
* <dd>By default, if a static nested class is included in the dependency
* graph, all references from that static nested class to its immediate
* lexically enclosing class are ignored, to avoid inadvertent inclusion of
* the enclosing class. (The default is chosen this way because the compiled
* class file of a static nested class always contains a reference to the
* immediate lexically enclosing class.) This option causes all such
* references to be considered rather than ignored. Note that this option
* is needed very infrequently.</dd>
* </dl>
*
* <a name="output"></a>
* <h3>Output Options and Arguments</h3>
*
* The following options and arguments determine the content and format of
* the output produced by this tool. These options do not affect the
* dependency graph computation, only the information displayed in the
* output as a result of the computation. Most of these options may be
* specified multiple times. Some variations are illustrated in the
* <a href="#examples">Examples</a> section of this page.
* <dl>
* <dt><b><code>-edges</code></b>
* <dd>By default, the classes which are included in the dependency graph
* are displayed in the output. This option specifies that instead, the
* classes which are excluded from the dependency graph, but which are
* directly referenced by classes in the dependency graph, should be
* displayed in the output. These classes form the outside "edges" of the
* dependency graph.
* <p>
* For example, you might exclude classes from the Java 2 SDK from the
* dependency graph because you don't want to include them in your JAR file,
* but you might be interested in knowing which classes from the Java 2 SDK
* are referenced directly by the classes in your JAR file. The
* <code>-edges</code> option can be used to display this information.
* </dd>
* <p>
* <dt><b><code>-show</code> <var>package-prefix</var></b>
* <dd>Displays the classes that are in the specified package or a
* subpackage of it. This option can be specified zero or more times. If no
* <code>-show</code> options are specified, the default is that all classes
* in the dependency graph are displayed (or all edge classes, if
* <code>-edges</code> is specified). Note that the argument to
* <code>-show</code> is a namespace, so none of its subpackages need to be
* specified as an argument to <code>-show</code>.
* <p>
* For example, to determine which classes from the Java 2 SDK your
* application depends on, you might not specify any <code>-in</code>
* options, but limit the output by specifying:
* <pre>-show java -show javax</pre></dd>
* <p>
* <dt><b><code>-hide</code> <var>package-prefix</var></b>
* <dd>Specifies a namespace of packages which should not be displayed. Any
* classes in this package or a subpackage of it are excluded from the
* output. This option can be specified zero or more times. If you specify
* <code>-show</code> options, then each <code>-hide</code> namespace should
* be a subspace of some <code>-show</code> namespace. Note that the
* argument to <code>-hide</code> is a namespace, so none of its subpackages
* need to be specified as an argument to <code>-hide</code>.
* <p>
* For example, to determine which non-core classes from the
* <code>net.jini</code> namespace you use, you might specify:
* <pre>-show net.jini -hide net.jini.core</pre></dd>
* <p>
* <dt><b><code>-files</code></b>
* <dd>By default, fully qualified class names are displayed, with package
* names delimited by ".". This option causes the output to be in filename
* format instead, with package names delimited by filename separators and
* with ".class" appended. For example, using this option on Microsoft
* Windows platforms would produce output in the form of
* <code>com\corp\foo\Bar.class</code> instead of
* <code>com.corp.foo.Bar</code>. This option should be used to generate
* output suitable as input to the <code>jar</code> tool.
* <p>
* For more information on the <code>jar</code> tool, see:
* <ul>
* <li><a href="http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/jar.html">
* http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/jar.html</a>
* <li><a href="http://java.sun.com/j2se/1.4/docs/tooldocs/windows/jar.html">
* http://java.sun.com/j2se/1.4/docs/tooldocs/windows/jar.html</a>
* <li><a href="http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html">
* http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html</a>
* </ul>
* </dd>
* <p>
* <dt><b><code>-tell</code> <var>class</var></b>
* <dd>Specifies the fully qualified name of a class for which dependency
* information is desired. This option causes the tool to display
* information about every class in the dependency graph that references the
* specified class. This information is sent to the error stream of the
* tool, not to the normal output stream. This option can be specified zero
* or more times. If this option is used, all other output options are
* ignored, and the normal class output is not produced. This option is
* useful for debugging.
* </dd>
* </dl>
*
* <a name="examples"></a>
* <h3>Examples</h3>
*
* (The examples in this section assume you ran the starter kit installer
* with an "Install Set" selection that created the top-level
* <code>classes</code> directory. Alternatively, if you have compiled from
* the source code, substitute <code>source/classes</code> for
* <code>classes</code> in the examples.)
* <p>
* The following example computes the classes required for a codebase JAR
* file, starting with a smart proxy class and a stub class as roots, and
* displays them in filename format. (A more complete example would include
* additional roots for leases, registrations, events, and lookup service
* attributes, and would exclude platform classes such as those in
* <code>jsk-platform.jar</code>.)
* <p>
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>install_dir</b></var>/classes
* com.sun.jini.reggie.RegistrarProxy com.sun.jini.reggie.RegistrarImpl_Stub
* -in com.sun.jini -in net.jini
* -files
* </pre></blockquote>
* <p>
* The following example computes the classes required for a classpath JAR
* file, starting with all of the classes in a directory as roots, and
* displays them in class name format. (A more complete example would exclude
* platform classes such as those in <code>jsk-platform.jar</code>.)
* <p>
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>install_dir</b></var>/classes
* <var><b>install_dir</b></var>/classes/com/sun/jini/reggie
* -in com.sun.jini -in net.jini
* </pre></blockquote>
* <p>
* The following example computes the <code>com.sun.jini</code> classes used
* by a service implementation, and displays the <code>net.jini</code>
* classes that are immediately referenced by those classes.
* <p>
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>install_dir</b></var>/classes
* com.sun.jini.reggie.RegistrarImpl
* -in com.sun.jini
* -edges
* -show net.jini
* </pre></blockquote>
* <p>
* The following example computes all of the classes used by a service
* implementation that are not part of the Java 2 SDK, and displays the
* classes that directly reference the class <code>java.awt.Image</code>.
* <p>
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>install_dir</b></var>/classes
* com.sun.jini.reggie.RegistrarImpl
* -out java -out javax
* -tell java.awt.Image
* </pre></blockquote>
* <p>
* The following example computes all of the classes to include in
* <code>jini-ext.jar</code> and displays them in filename format. Note
* that both <code>-out</code> and <code>-prune</code> options are needed
* for the <code>net.jini.core</code> namespace; <code>-out</code> to
* exclude classes from the dependency graph, and <code>-prune</code> to
* prevent classes from being used as roots.
* <p>
* <blockquote><pre>
* java -jar <var><b>install_dir</b></var>/lib/classdep.jar
* -cp <var><b>install_dir</b></var>/classes
* -in net.jini -out net.jini.core -in com.sun.jini
* <var><b>install_dir</b></var>/classes/net/jini -prune net.jini.core
* -files
* </pre></blockquote>
*
* @author Sun Microsystems, Inc.
*/
public class ClassDep {
/**
* Container for all the classes that we have seen.
*/
private final HashSet seen = new HashSet();
/**
* Object used to load our classes.
*/
private Env env;
/**
* If true class names are printed using
* the system's File.separator, else the
* fully qualified class name is printed.
*/
private boolean files = false;
/**
* Set of paths to find class definitions in order to determine
* dependencies.
*/
private String classpath = "";
/**
* Flag to determine whether there is interest
* in dependencies that go outside the set of
* interested classes. If false then outside,
* references are ignored, if true they are noted.
* i.e, if looking only under <code>net.jini.core.lease</code>
* a reference to a class in <code>net.jini</code> is found it
* will be noted if the flag is set to true, else
* it will be ignored. <p>
* <b>Note:</b> these edge case dependencies must be
* included in the classpath in order to find their
* definitions.
*/
private boolean edges = false;
/**
* Static inner classes have a dependency on their outer
* parent class. Because the parent class may be really
* big and may pull other classes along with it we allow the
* choice to ignore the parent or not. If the flag is set to
* true we pull in the parent class. If it is false we don't
* look at the parent. The default is is to not include the
* parent. <p>
* <b>Note:</b> This is an optimization for those who plan
* on doing work with the output of this utility. It does
* not impact this utility, but the work done on its
* generated output may have an impact.
*/
private boolean ignoreOuter = true;
/**
* Package set that we have interest to work in.
*/
private final ArrayList inside = new ArrayList();
/**
* Package set to not work with. This is useful if
* there is a subpackage that needs to be ignored.
*/
private final ArrayList outside = new ArrayList();
/**
* Class set to look at for dependencies. These are
* fully qualified names, ie, net.jini.core.lease.Lease.
* This is a subset of the values in
* <code>inside</code>.
*/
private final ArrayList classes = new ArrayList();
/**
* Set of directories to find dependencies in.
*/
private final ArrayList roots = new ArrayList();
/**
* Set of packages to skip over in the processing of dependencies.
* This can be used in conjunction with <em>-out</em> option.
*/
private final ArrayList prunes = new ArrayList();
/**
* Set of package prefixes to skip over in the processing
* of dependencies.
*/
private final ArrayList skips = new ArrayList();
/**
* Given a specific fully qualified classes, what other classes
* in the roots list depend on it. This is more for debugging
* purposes rather then normal day to day usage.
*/
private final ArrayList tells = new ArrayList();
/**
* Only display found dependencies that fall under the provided
* <code>roots</code> subset.
*/
private final ArrayList shows = new ArrayList();
/**
* Suppress display of found dependencies that are under
* the provided package prefixes subset.
*/
private final ArrayList hides = new ArrayList();
/**
* Container for found dependency classes.
*/
private final ArrayList results = new ArrayList();
/**
* No argument constructor. The user must fill in the
* appropriate fields prior to asking for the processing
* of dependencies.
*/
public ClassDep() {
}
/**
* Constructor that takes command line arguments and fills in the
* appropriate fields. See the description of this class
* for a list and description of the acceptable arguments.
*/
public ClassDep(String[] cmdLine){
setupOptions(cmdLine);
}
/**
* Take the given argument and add it to the provided container.
* We make sure that each inserted package-prefix is unique. For
* example if we had the following packages:
* <ul>
* <li>a.b
* <li>a.bx
* <li>a.b.c
* </ul>
* Looking for <code>a.b</code> should not match
* <code>a.bx</code> and <code>a.b</code>,
* just <code>a.b</code>.
*
* @param arg the package-prefix in string form
* @param elts container to add elements to
*
*/
private static void add(String arg, ArrayList elts) {
if (!arg.endsWith("."))
arg = arg + '.';
if (".".equals(arg))
arg = null;
elts.add(arg);
}
/**
* See if the provided name is covered by package prefixes.
*
* @param n the name
* @param elts the list of package prefixes
*
* @return the length of the first matching package prefix
*
*/
private static int matches(String n, ArrayList elts) {
for (int i = 0; i < elts.size(); i++) {
String elt = (String)elts.get(i);
/*
* If we get a null element then see if we are looking
* at an anonymous package.
*/
if (elt == null) {
int j = n.indexOf('.');
/*
* If we did not find a dot, or we have a space
* at the beginning then we have an anonymous package.
*/
if (j < 0 || n.charAt(j + 1) == ' ')
return 0;
} else if (n.startsWith(elt))
return elt.length();
}
return -1;
}
/**
* See if a name is covered by in but not excluded by out.
*
* @param n the name
* @param in the package prefixes to include
* @param out the package prefixes to exclude
* @return true if covered by in but not excluded by out
*/
private static boolean matches(String n, ArrayList in, ArrayList out) {
int i = in.isEmpty() ? 0 : matches(n, in);
return i >= 0 && matches(n, out) < i;
}
/**
* Recursively traverse a given path, finding all the classes that
* make up the set to work with. We take into account skips,
* prunes, and out sets defined.
*
* @param path path to traverse down from
*
*/
private void traverse(String path) {
String apath = path;
/*
* We append File.separator to make sure that the path
* is unique for the matching that we are going to do
* next.
*/
if (!apath.startsWith(File.separator))
apath = File.separator + apath;
for (int i = 0; i < prunes.size(); i++) {
/*
* If we are on a root path that needs to be
* pruned leave this current recursive thread.
*/
if (apath.endsWith((String)prunes.get(i)))
return;
}
/*
* Get the current list of files at the current directory
* we are in. If there are no files then leave this current
* recursive thread.
*/
String[] files = new File(path).list();
if (files == null)
return;
outer:
/*
* Now, take the found list of files and iterate over them.
*/
for (int i = 0; i < files.length; i++) {
String file = files[i];
/*
* Now see if we have a ".class" file.
* If we do not then we lets call ourselves again.
* The assumption here is that we have a directory. If it
* is a class file we would have already been throw out
* by the empty directory contents test above.
*/
if (!file.endsWith(".class")) {
traverse(path + File.separatorChar + file);
} else {
/*
* We have a class file, so remove the ".class" from it
* using the pattern:
*
* directory_name + File.Separator + filename = ".class"
*
* At this point the contents of the skip container follow
* the pattern of:
*
* "File.Separator+DirectoryPath"
*
* with dots converted to File.Separators
*/
file = apath + File.separatorChar +
file.substring(0, file.length() - 6);
/*
* See if there are any class files that need to be skipped.
*/
for (int j = 0; j < skips.size(); j++) {
String skip = (String)skips.get(j);
int k = file.indexOf(skip);
if (k < 0)
continue;//leave this current loop.
k += skip.length();
/*
* If we matched the entire class or if we have
* a class with an inner class, skip it and go
* on to the next outer loop.
*/
if (file.length() == k || file.charAt(k) == '$')
continue outer;
}
/*
* things to do:
* prune when outside.
* handle inside when its empty.
*
* Now see if we have classes within our working set "in".
* If so add them to our working list "classes".
*/
for (int j = 0; j < inside.size(); j++) {
int k = file.indexOf(File.separatorChar +
((String)inside.get(j)).replace(
'.', File.separatorChar));
if (k >= 0) {
/*
* Insert the class and make sure to replace
* File.separators into dots.
*/
classes.add(file.substring(k + 1).replace(
File.separatorChar, '.'));
}
}
}
}
}
/**
* Depending on the part of the class file
* that we are on the class types that we are
* looking for can come in several flavors.
* They can be embedded in arrays, they can
* be labeled as Identifiers, or they can be
* labeled as Types. This method handles
* Types referenced by Identifiers. It'll take
* the Type and proceed to get its classname
* and then continue with the processing it
* for dependencies.
*/
private void process(Identifier from, Type type) {
while (type.isType(Constants.TC_ARRAY))
type = type.getElementType();
if (type.isType(Constants.TC_CLASS))
process(from, type.getClassName(), false);
}
/**
* Depending on the part of the class file
* that we are on the class types that we are
* looking for can come in several flavors.
* This method handles Identifiers and
* Identifiers referenced from other Identifiers.
* <p>
* Several actions happen here with the goal of
* generating the list of dependencies within the domain
* space provided by the user.
* These actions are:
* <ul>
* <li> printing out "-tell" output if user asks for it.
* <li> extracting class types from the class file.
* <ul>
* <li> either in arrays or by
* <li> themselves
* </ul>
* <li> noting classes we have already seen.
* <li> traversing the remainder of the class file.
* <li> resolving and looking for dependencies in
* inner classes.
* <li> saving found results for later use.
* </ul>
*
* @param from the Identifier referenced from <code>id</code>
* @param id the Identifier being looked at
* @param top ignored
*/
private void process(Identifier from, Identifier id, boolean top) {
/*
* If <code>from</code> is not null see if the "id" that
* references it is in our "tells" container. If there
* is a match show the class. This is for debugging purposes,
* in case you want to find out what classes use a particular class.
*/
if (from != null) {
for (int i = 0; i < tells.size(); i++) {
if (id.toString().equals((String)tells.get(i))) {
if (tells.size() > 1)
print("classdep.cause", id, from);
else
print("classdep.cause1", from);
}
}
}
/*
* Having taken care of the "-tells" switch, lets
* proceed with the rest by getting the id's string
* representation.
*/
String n = id.toString();
/*
* Remove any array definitions so we can get to the
* fully qualified class name that we are seeking.
*/
if (n.charAt(0) == '[') {
int i = 1;
while (n.charAt(i) == '[')
i++;
/*
* Now that we have removed possible array information
* see if we have a Class definition e.g Ljava/lang/Object;.
* If so, remove the 'L' and ';' and call ourselves
* with this newly cleaned up Identifier.
*/
if (n.charAt(i) == 'L')
process(from,
Identifier.lookup(n.substring(i + 1, n.length() - 1)),
false);
/*
* Pop out of our recursive path, since the real work
* is being down in another recursive thread.
*/
return;
}
/*
* If we have already seen the current Identifier, end this
* thread of recursion.
*/
if (seen.contains(id))
return;
/*
* See if we have an empty set OR the Identifier is in our
* "inside" set and the matched Identifier is not on the
* "outside" set.
*
* If we are not in the "inside" set and we are not asking
* for edges then pop out of this recursive thread.
*/
boolean in = matches(n, inside, outside);
if (!in && !edges)
return;
/*
* We have an actual Identifier, so at this point mark it
* as seen, so we don't create another recursive thread if
* we see it again.
*/
seen.add(id);
/*
* This is the test that decides whether this current
* Identifier needs to be added to the list of dependencies
* to save.
*
* "in" can be true in the following cases:
* <ul>
* <li>the in set is empty
* <li>the Identifier is in the "in" set and not on the "out" set.
* </ul>
*/
if (in != edges && matches(n, shows, hides))
results.add(Type.mangleInnerType(id).toString());
/*
* If we are not in the "inside" set and we want edges
* pop out of our recursive thread.
*/
if (!in && edges)
return;
/*
* At this point we have either added an Identifier
* to our save list, or we have not. In either case
* we need get the package qualified name of this so
* we can see if it has any nested classes.
*/
id = env.resolvePackageQualifiedName(id);
BinaryClass cdef;
try {
cdef = (BinaryClass)env.getClassDefinition(id);
cdef.loadNested(env);
} catch (ClassNotFound e) {
print("classdep.notfound", id);
return;
} catch (IllegalArgumentException e) {
print("classdep.illegal", id, e.getMessage());
return;
} catch (Exception e) {
print("classdep.failed", id);
e.printStackTrace();
return;
}
/*
* If the user asked to keep the outer parent for an
* inner class then we'll get the list of dependencies
* the inner class may have and iterate over then by
* "processing" them as well.
*/
Identifier outer = null;
if (ignoreOuter && cdef.isInnerClass() && cdef.isStatic())
outer = cdef.getOuterClass().getName();
for (Enumeration deps = cdef.getDependencies();
deps.hasMoreElements(); )
{
Identifier dep = ((ClassDeclaration)deps.nextElement()).getName();
/*
* If we dont' want the outer parent class of an inner class
* make this comparison.
*/
if (outer != dep)
process(id, dep, false);
}
/*
* Now we are going to walk the rest of the class file and see
* if we can find any other class references.
*/
for (MemberDefinition mem = cdef.getFirstMember();
mem != null;
mem = mem.getNextMember())
{
if (mem.isVariable()) {
process(id, mem.getType());
} else if (mem.isMethod() || mem.isConstructor()) {
Type[] args = mem.getType().getArgumentTypes();
for (int i = 0; i < args.length; i++) {
process(id, args[i]);
}
process(id, mem.getType().getReturnType());
}
}
}
private static class Compare implements Comparator {
public int compare(Object o1, Object o2) {
if (o1 == null)
return o2 == null ? 0 : 1;
else
return o2 == null ? -1 : ((Comparable) o2).compareTo(o1);
}
}
/**
* Method that takes the user provided switches that
* logically define the domain in which to look for
* dependencies.
*/
public String[] compute() {
/* sort ins and outs, longest first */
Comparator c = new Compare();
Collections.sort(inside, c);
Collections.sort(outside, c);
Collections.sort(shows, c);
Collections.sort(hides, c);
/*
* Create the environment from which we are going to be
* loading classes from.
*/
env = new Env(classpath);
/*
* Traverse the roots i.e the set of handed directories.
*/
for (int i = 0; i < roots.size(); i++) {
/*
* Get the classes that we want do to dependency checking on.
*/
traverse((String)roots.get(i));
}
for (int i = 0; i < classes.size(); i++) {
process(null, Identifier.lookup((String)classes.get(i)), true);
}
if (!tells.isEmpty())
return new String[0];
String[] vals = (String[])results.toArray(new String[results.size()]);
Arrays.sort(vals);
return vals;
}
/**
* Print out the usage for this utility.
*/
public static void usage() {
print("classdep.usage", null);
}
/**
* Set the classpath to use for finding our class definitions.
*/
public void setClassPath(String classpath) {
this.classpath = classpath;
}
/**
* Determines how to print out the fully qualified
* class names. If <code>true</code> it will use
* <code>File.separator</code>, else <code>.</code>'s
* will be used.
* If not set the default is <code>false</code>.
*/
public void setFiles(boolean files) {
this.files = files;
}
/**
* Add an entry into the set of package prefixes that
* are to remain hidden from processing.
*/
public void addHides(String packagePrefix) {
add(packagePrefix, hides);
}
/**
* Add an entry into the working set of package prefixes
* that will make up the working domain space.
*/
public void addInside(String packagePrefix) {
add(packagePrefix, inside);
}
/**
* Determines whether to include package references
* that lie outside the declared set of interest.
* <p>
* If true edges will be processed as well, else
* they will be ignored. If not set the default
* will be <code>false</code>.
* <p>
* <b>Note:</b> These edge classes must included
* in the classpath for this utility.
*/
public void setEdges(boolean edges) {
this.edges = edges;
}
/**
* Add an entry into the set of package prefixes
* that will bypassed during dependency checking.
* These entries should be subsets of the contents
* on the inside set.
*/
public void addOutside(String packagePrefix) {
add(packagePrefix, outside);
}
/**
* Add an entry into the set of package prefixes
* that will be skipped as part of the dependency
* generation.
*/
public void addPrune(String packagePrefix) {
String arg = packagePrefix;
if (arg.endsWith("."))
arg = arg.substring(0, arg.length() - 1);
/*
* Convert dots into File.separator for later usage.
*/
arg = File.separator + arg.replace('.', File.separatorChar);
prunes.add(arg);
}
/**
* Add an entry into the set of package prefixes
* that we want to display.
* This applies only to the final output, so this
* set should be a subset of the inside set with
* edges, if that was indicated.
*/
public void addShow(String packagePrefix) {
add(packagePrefix, shows);
}
/**
* Add an entry into the set of classes that
* should be skipped during dependency generation.
*/
public void addSkip(String packagePrefix){
String arg = packagePrefix;
if (arg.endsWith("."))
arg = arg.substring(0, arg.length() - 1);
else
seen.add(Identifier.lookup(arg));
/*
* Convert dots into File.separator for later usage.
*/
arg = File.separator + arg.replace('.', File.separatorChar);
skips.add(arg);
}
/**
* Add an entry in to the set of classes whose dependents
* that lie with the inside set are listed. This in
* the converse of the rest of the utility and is meant
* more for debugging purposes.
*/
public void addTells(String packagePrefix) {
tells.add(packagePrefix);
}
/**
* Add an entry into the set of directories to
* look under for the classes that fall within
* the working domain space as defined by the
* intersection of the following sets:
* inside,outside,prune,show, and hide.
*/
public void addRoots(String rootName) {
if (rootName.endsWith(File.separator))
//remove trailing File.separator
rootName = rootName.substring(0, rootName.length() - 1);
//these are directories.
roots.add(rootName);
}
/**
* Add an entry into the set of classes that
* dependencies are going to be computed on.
*/
public void addClasses(String className) {
classes.add(className);
}
/**
* If true classnames will be separated using
* File.separator, else it will use dots.
*/
public boolean getFiles() {
return files;
}
/**
* Accessor method for the found dependencies.
*/
public String[] getResults() {
String[] vals = (String[])results.toArray(new String[results.size()]);
Arrays.sort(vals);
return vals;
}
/**
* Convenience method for initializing an instance with specific
* command line arguments. See the description of this class
* for a list and description of the acceptable arguments.
*/
public void setupOptions(String[] args) {
for (int i = 0; i < args.length ; i++ ) {
String arg = args[i];
if (arg.equals("-cp")) {
i++;
setClassPath(args[i]);
} else if (arg.equals("-files")) {
setFiles(true);
} else if (arg.equals("-hide")) {
i++;
addHides(args[i]);
} else if (arg.equals("-in")) {
i++;
addInside(args[i]);
} else if (arg.equals("-edges")) {
setEdges(true);
} else if (arg.equals("-out")) {
i++;
addOutside(args[i]);
} else if (arg.equals("-outer")) {
ignoreOuter = false;
} else if (arg.equals("-prune")) {
i++;
addPrune(args[i]);
} else if (arg.equals("-show")) {
i++;
addShow(args[i]);
} else if (arg.equals("-skip")) {
i++;
addSkip(args[i]);
} else if (arg.equals("-tell")) {
i++;
addTells(args[i]);
} else if (arg.indexOf(File.separator) >= 0) {
addRoots(arg);
} else if (arg.startsWith("-")) {
usage();
} else {
addClasses(arg);
}
}
}
private static ResourceBundle resources;
private static boolean resinit = false;
/**
* Get the strings from our resource localization bundle.
*/
private static synchronized String getString(String key) {
if (!resinit) {
resinit = true;
try {
resources = ResourceBundle.getBundle
("com.sun.jini.tool.resources.classdep");
} catch (MissingResourceException e) {
e.printStackTrace();
}
}
if (resources != null) {
try {
return resources.getString(key);
} catch (MissingResourceException e) {
}
}
return null;
}
/**
* Print out string according to resourceBundle format.
*/
private static void print(String key, Object val) {
String fmt = getString(key);
if (fmt == null)
fmt = "no text found: \"" + key + "\" {0}";
System.err.println(MessageFormat.format(fmt, new Object[]{val}));
}
/**
* Print out string according to resourceBundle format.
*/
private static void print(String key, Object val1, Object val2) {
String fmt = getString(key);
if (fmt == null)
fmt = "no text found: \"" + key + "\" {0} {1}";
System.err.println(MessageFormat.format(fmt,
new Object[]{val1, val2}));
}
/**
* Command line interface for generating the list of classes that
* a set of classes depends upon. See the description of this class
* for a list and description of the acceptable arguments.
*/
public static void main(String[] args) {
if (args.length == 0) {
usage();
return;
}
ClassDep dep = new ClassDep();
//boolean files = false;
dep.setupOptions(args);
String[] vals = dep.compute();
for (int i = 0; i < vals.length; i++) {
if (dep.getFiles())
System.out.println(vals[i].replace('.', File.separatorChar) +
".class");
else
System.out.println(vals[i]);
}
}
/**
* Private class to load classes, resolve class names and report errors.
*
* @see sun.tools.java.Environment
*/
private static class Env extends Environment {
private final ClassPath noPath = new ClassPath("");
private final ClassPath path;
private final HashMap packages = new HashMap();
private final HashMap classes = new HashMap();
public Env(String classpath) {
for (StringTokenizer st =
new StringTokenizer(System.getProperty("java.ext.dirs"),
File.pathSeparator);
st.hasMoreTokens(); )
{
String dir = st.nextToken();
String[] files = new File(dir).list();
if (files != null) {
if (!dir.endsWith(File.separator)) {
dir += File.separator;
}
for (int i = files.length; --i >= 0; ) {
classpath =
dir + files[i] + File.pathSeparator + classpath;
}
}
}
path = new ClassPath(System.getProperty("sun.boot.class.path") +
File.pathSeparator + classpath);
}
/**
* We don't use flags so we override Environments and
* simply return 0.
*/
public int getFlags() {
return 0;
}
/**
* Take the identifier and see if the class that represents exists.
* <code>true</code> if the identifier is found, <code>false</code>
* otherwise.
*/
public boolean classExists(Identifier id) {
if (id.isInner())
id = id.getTopName();
Type t = Type.tClass(id);
try {
ClassDeclaration c = (ClassDeclaration)classes.get(t);
if (c == null) {
Package pkg = getPackage(id.getQualifier());
return pkg.getBinaryFile(id.getName()) != null;
}
return c.getName().equals(id);
} catch (IOException e) {
return false;
}
}
public ClassDeclaration getClassDeclaration(Identifier id) {
return getClassDeclaration(Type.tClass(id));
}
public ClassDeclaration getClassDeclaration(Type t) {
ClassDeclaration c = (ClassDeclaration)classes.get(t);
if (c == null) {
c = new ClassDeclaration(t.getClassName());
classes.put(t, c);
}
return c;
}
public Package getPackage(Identifier pkg) throws IOException {
Package p = (Package)packages.get(pkg);
if (p == null) {
p = new Package(noPath, path, pkg);
packages.put(pkg, p);
}
return p;
}
BinaryClass loadFile(ClassFile file) throws IOException {
DataInputStream in =
new DataInputStream(new BufferedInputStream(
file.getInputStream()));
try {
return BinaryClass.load(new Environment(this, file), in,
ATT_ALLCLASSES);
} catch (ClassFormatError e) {
throw new IllegalArgumentException("ClassFormatError: " +
file.getPath());
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
in.close();
}
}
/**
* Overridden method from Environment
*/
public void loadDefinition(ClassDeclaration c) {
Identifier id = c.getName();
if (c.getStatus() != CS_UNDEFINED)
throw new IllegalArgumentException("No file for: " + id);
Package pkg;
try {
pkg = getPackage(id.getQualifier());
} catch (IOException e) {
throw new IllegalArgumentException("IOException: " +
e.getMessage());
}
ClassFile file = pkg.getBinaryFile(id.getName());
if (file == null)
throw new IllegalArgumentException("No file for: " +
id.getName());
BinaryClass bc;
try {
bc = loadFile(file);
} catch (IOException e) {
throw new IllegalArgumentException("IOException: " +
e.getMessage());
}
if (bc == null)
throw new IllegalArgumentException("No class in: " +
file);
if (!bc.getName().equals(id))
throw new IllegalArgumentException("Wrong class in: " +
file);
c.setDefinition(bc, CS_BINARY);
bc.loadNested(this, ATT_ALLCLASSES);
}
private static ResourceBundle resources;
private static boolean resinit = false;
/**
* Get the strings from javac resource localization bundle.
*/
private static synchronized String getString(String key) {
if (!resinit) {
try {
resources = ResourceBundle.getBundle
("sun.tools.javac.resources.javac");
resinit = true;
} catch (MissingResourceException e) {
e.printStackTrace();
}
}
if (key.startsWith("warn."))
key = key.substring(5);
try {
return resources.getString("javac.err." + key);
} catch (MissingResourceException e) {
return null;
}
}
public void error(Object source,
long where,
String err,
Object arg1,
Object arg2,
Object arg3)
{
String fmt = getString(err);
if (fmt == null)
fmt = "no text found: \"" + err + "\" {0} {1} {2}";
output(MessageFormat.format(fmt, new Object[]{arg1, arg2, arg3}));
}
public void output(String msg) {
System.err.println(msg);
}
}
}
| [
"k1218492@pc171.dcs.kcl.ac.uk"
] | k1218492@pc171.dcs.kcl.ac.uk |
c469081571ed87293b1e7b8102982e00f1f2732a | aabd11045ea13168cddef9ce4d12ae014832d297 | /src/fr/badblock/game/core18R3/merchant/GameMerchantInventory.java | 31d813b8d1b27240e744d6da5dc3d3ad6dbf550a | [] | no_license | xMalware/BadBlock-GameAPI | 372ff0c6563d84121e5a305ffbddaa82d26464cd | 95a2c3be5fb875f8d0611bcb24a43b6984c33962 | refs/heads/master | 2020-07-23T01:41:16.985763 | 2018-11-13T22:00:37 | 2018-11-13T22:00:37 | 207,397,655 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,985 | java | package fr.badblock.game.core18R3.merchant;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
import fr.badblock.game.core18R3.players.GameBadblockPlayer;
import fr.badblock.gameapi.players.BadblockPlayer;
import fr.badblock.gameapi.utils.i18n.TranslatableString;
import fr.badblock.gameapi.utils.merchants.CustomMerchantInventory;
import fr.badblock.gameapi.utils.merchants.CustomMerchantRecipe;
import fr.badblock.gameapi.utils.reflection.ReflectionUtils;
import fr.badblock.gameapi.utils.reflection.Reflector;
import net.minecraft.server.v1_8_R3.EntityVillager;
import net.minecraft.server.v1_8_R3.MerchantRecipe;
import net.minecraft.server.v1_8_R3.MerchantRecipeList;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class GameMerchantInventory implements CustomMerchantInventory {
private MerchantRecipeList recipeList = new MerchantRecipeList();
@Override
public CustomMerchantRecipe[] getRecipes() {
CustomMerchantRecipe[] recipes = new CustomMerchantRecipe[recipeList.size()];
for(int i=0;i<recipeList.size();i++){
recipes[i] = fromNMS(recipeList.get(i));
}
return recipes;
}
@Override
public void removeRecipe(CustomMerchantRecipe recipe) {
recipeList.remove(toNMS(recipe));
}
@Override
public void addRecipe(CustomMerchantRecipe recipe) {
recipeList.add(toNMS(recipe));
}
@Override
public void applyTo(Villager villager) {
Object entityVillager = ReflectionUtils.getHandle(villager);
try {
new Reflector(entityVillager).setFieldValue("br", recipeList);
} catch (Exception e) {
e.printStackTrace();
}
}
public CustomMerchantRecipe fromNMS(MerchantRecipe recipe){
ItemStack a = CraftItemStack.asBukkitCopy(recipe.getBuyItem1());
ItemStack b = recipe.getBuyItem2() == null ? null : CraftItemStack.asBukkitCopy(recipe.getBuyItem2());
ItemStack c = CraftItemStack.asBukkitCopy(recipe.getBuyItem3());
return new CustomMerchantRecipe(a, b, c);
}
public MerchantRecipe toNMS(CustomMerchantRecipe recipe){
return new MerchantRecipe(CraftItemStack.asNMSCopy(recipe.getFirstItem()),
recipe.getSecondItem() == null ? null : CraftItemStack.asNMSCopy(recipe.getSecondItem()),
CraftItemStack.asNMSCopy(recipe.getResult()), 0, Integer.MAX_VALUE);
}
@Override
public void open(BadblockPlayer player) {
EntityVillager villager = new EntityVillager(MinecraftServer.getServer().getWorld());
applyTo((Villager) villager.getBukkitEntity());
GameBadblockPlayer gplayer = (GameBadblockPlayer) player;
gplayer.getHandle().openTrade(villager);
}
@Override
public void open(BadblockPlayer player, TranslatableString customName) {
FakeMerchant merchant = new FakeMerchant(player, recipeList, customName);
GameBadblockPlayer gplayer = (GameBadblockPlayer) player;
gplayer.getHandle().openTrade(merchant);
}
}
| [
"audrandoublet@gmail.com"
] | audrandoublet@gmail.com |
e683fc0ead385a140ebab24db6c35bf5c34932a4 | e83139ae7494c57ea1e25b32490a63b04c58cc3d | /app/src/main/java/com/aeye/doublecam/decode/AliveDetectHandler.java | 6300af3a55dfce2d3c9d919bbc190bcdc4377bc0 | [] | no_license | Kajon2018/HeLiBaoDemoLocal | 9088055e4d913912b16a9184af766afe0b166c41 | 1b4c4fab7bef9b07102f4af7869e898bf1901bac | refs/heads/master | 2021-07-09T20:47:42.955912 | 2017-10-11T01:53:27 | 2017-10-11T01:54:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,250 | java | package com.aeye.doublecam.decode;
import java.util.ArrayList;
import java.util.List;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.aeye.android.data.AEFaceInfo;
import com.aeye.android.uitls.BitmapUtils;
import com.aeye.helibao.AuthenActivity;
import com.aeye.sdk.AEFaceDetect;
import com.aeye.sdk.AEFaceQuality;
public class AliveDetectHandler extends Handler{
private boolean DEBUG = false;
private boolean DEBUG_TIME = false;
private int loseCount = 0;
private Handler mUIHdl = null;
private AliveDetectInterface mCallback;
AEFaceInfo faceInfo = new AEFaceInfo();
private int CfgLoseFace = 2;
// private AliveDetectThread mTask = null;
public AliveDetectHandler(Looper looper, int camId) {
super(looper);
// mTask = new AliveDetectThread(320, 240, this);
// mCamDev = CameraDeviceMgr.getInstance();
}
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case AliveDetectMessage.ALIVE_PREPARE:
// mTask.prepareThread();
prepare();
// post(mTask);
break;
case AliveDetectMessage.ALIVE_DECODE:
ArrayList<byte[]> list = (ArrayList<byte[]>) msg.obj;
// obj 鏄� 绗竴涓槸鍙鍏夛紝绗簩涓槸杩戠孩澶栫殑ArrayList<byte[]> list;
if(list !=null && list.size()>1) {
decode(list, msg.arg1, msg.arg2);
}
break;
case AliveDetectMessage.ALIVE_SIDE:
Log.d("ZDX", "MSG ALIVE_SIDE");
break;
case AliveDetectMessage.ALIVE_QUIT:
// mTask.freeThread();
getLooper().quit();
default:
break;
}
}
public void setUIHandler(Handler hdl) {
mUIHdl = hdl;
}
public void setCallback(AliveDetectInterface callback) {
mCallback = callback;
}
private void LOG_TIME(String str) {
if(DEBUG_TIME) {
Log.d("aliveHandler", str + " :" + System.currentTimeMillis());
}
}
private void LOG(String str) {
if(DEBUG) {
Log.d("aliveHandler", str);
}
}
private void initFaceInfo(List<byte[]> list, int width, int height) {
faceInfo.imgByteA = list.get(0);
faceInfo.imgWidth = width;
faceInfo.imgHeight = height;
faceInfo.imgByteANir = list.get(1);
faceInfo.imgWidthNir = width;
faceInfo.imgHeightNir = height;
faceInfo.width = width;
faceInfo.height = height;
}
private void decode(List<byte[]> list, int width, int height) {
if(!AuthenActivity.mNeed){
return;
}
initFaceInfo(list, width, height);
list.clear();
if (loseCount == 0) {
mCallback.updateFace(true);
loseCount = 1;
} else {
faceInfo.grayByteA = BitmapUtils.yuv2Array2Y(faceInfo.imgByteA, width, height, 0);
// 銆併�併�併�併�併�併�併�併�併�佸Bitmap杩涜绠楁硶澶勭悊 鏍规嵁 鍥惧儚鏁版嵁 鎵惧埌浜鸿劯鐨勫叿浣撲綅缃� 銆併�併�併�併�併�併�併�併�併�併�併��
Log.i("FUCK", "AEYE_FaceDetectImg VIS");
Rect[] rect = AEFaceDetect.getInstance().AEYE_FaceDetectImg(faceInfo.grayByteA,
faceInfo.imgWidth, faceInfo.imgHeight);
// 濡傛灉 鎵惧埌 浜鸿劯 鐨� 鍏蜂綋浣嶇疆 鍐嶅幓 鏍规嵁 绠楁硶 瀵绘壘 鐪肩潧浣嶇疆
if (rect != null) {
faceInfo.imgRect = rect[0];
mUIHdl.sendMessage(mUIHdl.obtainMessage(
AliveDetectMessage.MAIN_RECT, faceInfo.imgRect));
mCallback.updateFace(true);
loseCount = 1;
int quality = AEFaceQuality.QUALITY_OK;
quality = AEFaceQuality.getInstance().AEYE_FaceQuality(faceInfo.grayByteA,
faceInfo.imgWidth, faceInfo.imgHeight, faceInfo.imgRect);
System.out.println(" 质量评估:"+quality);
if (quality == AEFaceQuality.QUALITY_OK || quality == AEFaceQuality.QUALITY_BRIGHT || quality == AEFaceQuality.QUALITY_FAR || quality == AEFaceQuality.QUALITY_NEAR){
faceInfo.cutFaceImageNir();
// faceInfo.cutFaceImage();
Message message = Message.obtain(mUIHdl,
AliveDetectMessage.MAIN_SUCCESS, faceInfo);
message.sendToTarget();
return;
}
} else { // 濡傛灉娌℃壘鍒� 浜鸿劯 鐨� 鍏蜂綋浣嶇疆 灏辩户缁鎵�
if (loseCount++ == CfgLoseFace) {
mCallback.updateFace(false);
}
mUIHdl.sendMessage(mUIHdl.obtainMessage(
AliveDetectMessage.MAIN_RECT, null));
}
}
if (faceInfo.isAlive) {
return;
}
checkAgain();
LOG_TIME("end end end");
}
private void prepare() {
Log.d("aliveHandler", "prepare");
loseCount = 0;
if(mCallback != null) {
mCallback.updateStatsMsg(
AliveDetectMessage.STRING_LOOK_CAMERA, Color.WHITE);
} else {
Log.e("aliveHandler", "mCallback == NULL");
}
if(mUIHdl != null) {
Message message = Message.obtain(mUIHdl,
AliveDetectMessage.MAIN_RESET);
message.sendToTarget();
} else {
Log.e("aliveHandler", "mUIHdl == NULL");
}
LOG("prepare");
}
/**
* 鍐嶆妫�娴� <BR/>
*
* @see RecognizeActivity鐨凜aptureActivityHandler鎺ュ彈骞跺鐞嗗け璐ラ噸鏂版娴嬫秷鎭�
*/
private void checkAgain() {
if (mUIHdl != null) {
Message message = Message.obtain(mUIHdl,AliveDetectMessage.MAIN_DATA);
message.sendToTarget();
}
}
}
| [
"huangkaichun@maiditech.com"
] | huangkaichun@maiditech.com |
34d79f944aad533b0098ffa9f36d82a774f8adfa | 1dfee6544083ed696ce5d1f7efb24491925623a6 | /plugins/src/main/java/net/runelite/client/plugins/socket/org/json/Property.java | 508f3af162adf724ee99f05b0a4055f4b1b8d933 | [
"MIT"
] | permissive | digan-hub/dpSocket | 8c368832ceefd886920f1764c3ff652c61f76ba6 | 9f9b2b13706f592bbc5f6f388ba45d08257b84c4 | refs/heads/master | 2023-08-17T02:43:52.248982 | 2021-09-24T20:25:56 | 2021-09-24T20:25:56 | 410,089,754 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,678 | java | package net.runelite.client.plugins.socket.org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
/**
* Converts a Property file data into JSONObject and back.
* @author JSON.org
* @version 2015-05-05
*/
public class Property {
/**
* Converts a property file object into a JSONObject. The property file object is a table of name value pairs.
* @param properties java.util.Properties
* @return JSONObject
* @throws JSONException
*/
public static JSONObject toJSONObject(Properties properties) throws JSONException {
JSONObject jo = new JSONObject();
if (properties != null && !properties.isEmpty()) {
Enumeration<?> enumProperties = properties.propertyNames();
while(enumProperties.hasMoreElements()) {
String name = (String)enumProperties.nextElement();
jo.put(name, properties.getProperty(name));
}
}
return jo;
}
/**
* Converts the JSONObject into a property file object.
* @param jo JSONObject
* @return java.util.Properties
* @throws JSONException
*/
public static Properties toProperties(JSONObject jo) throws JSONException {
Properties properties = new Properties();
if (jo != null) {
Iterator<String> keys = jo.keys();
while (keys.hasNext()) {
String name = keys.next();
properties.put(name, jo.getString(name));
}
}
return properties;
}
}
| [
"capslock13.osrs@gmail.com"
] | capslock13.osrs@gmail.com |
31aaa37313e55c01c2814a691f12d2eb3a050570 | 636266905fc378508bd1c1589cc177050ede0cd3 | /csce4444/Android/src/com/landa/customer/Adapters/DrinkAdapter.java | 74f4bf9a09f5c930e063681988f3645a7581a2d0 | [] | no_license | emericaonline/SoftwareDevAndroid | f01c3c0a102d56bb053b62c192f8a87b6da16054 | 7770893e016b81be68bdd532a20a67be10920e8d | refs/heads/master | 2021-01-18T00:08:04.406036 | 2015-01-16T20:25:25 | 2015-01-16T20:25:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,763 | java | package com.landa.customer.Adapters;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.landa.R;
import com.landa.backend.Item;
public class DrinkAdapter extends BaseAdapter {
Context context;
int layoutResourceId;
private ArrayList<Item> listData;
private LayoutInflater layoutInflater;
public DrinkAdapter(Context context, ArrayList<Item> listData) {
this.context = context;
this.listData = listData;
}
@Override
public int getCount() {
return listData.size();
}
@Override
public Object getItem(int position) {
return listData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
OrderHolder holder;
if (convertView == null) {
layoutInflater = LayoutInflater.from(context);
convertView = layoutInflater.inflate(R.layout.drink_order_list_row,
parent, false);
holder = new OrderHolder();
holder.nameView = (TextView) convertView
.findViewById(R.id.drinkName);
holder.priceView = (TextView) convertView
.findViewById(R.id.drinkprice);
holder.descView = (TextView) convertView
.findViewById(R.id.drinkDesc);
convertView.setTag(holder);
} else {
holder = (OrderHolder) convertView.getTag();
}
Item item = listData.get(position);
holder.nameView.setText(item.getName());
holder.priceView.setText(item.getPriceFormatted());
holder.descView.setText(item.getDesc());
return convertView;
}
static class OrderHolder {
TextView nameView;
TextView priceView;
TextView descView;
}
}
| [
"poofylake@gmail.com"
] | poofylake@gmail.com |
0d4add0ff5deda93799ea15446c41352a823d4c8 | 0012475da934534fb0d23555cd99c7800903d232 | /src/main/java/com/lgc/ctps/sgpa/web/rest/errors/BadRequestAlertException.java | 670e020f623feac9b3dbff8067bdf80e2bb7f080 | [] | no_license | iorran/sgpa | 38c75c3d4870e98fbe70a1c506bd911cba0f2efa | a6bc6ed6dbd4f151c1d229b58edb79e662406e8d | refs/heads/master | 2021-04-12T08:45:43.060777 | 2018-03-23T19:45:23 | 2018-03-23T19:45:23 | 125,948,162 | 0 | 0 | null | 2018-03-20T03:30:57 | 2018-03-20T02:19:24 | Java | UTF-8 | Java | false | false | 1,266 | java | package com.lgc.ctps.sgpa.web.rest.errors;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class BadRequestAlertException extends AbstractThrowableProblem {
private final String entityName;
private final String errorKey;
public BadRequestAlertException(String defaultMessage, String entityName, String errorKey) {
this(ErrorConstants.DEFAULT_TYPE, defaultMessage, entityName, errorKey);
}
public BadRequestAlertException(URI type, String defaultMessage, String entityName, String errorKey) {
super(type, defaultMessage, Status.BAD_REQUEST, null, null, null, getAlertParameters(entityName, errorKey));
this.entityName = entityName;
this.errorKey = errorKey;
}
public String getEntityName() {
return entityName;
}
public String getErrorKey() {
return errorKey;
}
private static Map<String, Object> getAlertParameters(String entityName, String errorKey) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("message", "error." + errorKey);
parameters.put("params", entityName);
return parameters;
}
}
| [
"jhipster-bot@users.noreply.github.com"
] | jhipster-bot@users.noreply.github.com |
b76d5b3d0b1d0683443c88d3417f1af85436bfeb | e21d17cdcd99c5d53300a7295ebb41e0f876bbcb | /22_Chapters_Edition/src/main/resources/ExampleCodes/typeinfo/SnowRemovalRobot.java | 259e04014151449b2598625818dc340acc6989c7 | [] | no_license | lypgod/Thinking_In_Java_4th_Edition | dc42a377de28ae51de2c4000a860cd3bc93d0620 | 5dae477f1a44b15b9aa4944ecae2175bd5d8c10e | refs/heads/master | 2020-04-05T17:39:55.720961 | 2018-11-11T12:07:56 | 2018-11-11T12:08:26 | 157,070,646 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,367 | java | package ExampleCodes.typeinfo;//: typeinfo/SnowRemovalRobot.java
import java.util.*;
public class SnowRemovalRobot implements Robot {
private String name;
public SnowRemovalRobot(String name) {this.name = name;}
public String name() { return name; }
public String model() { return "SnowBot Series 11"; }
public List<Operation> operations() {
return Arrays.asList(
new Operation() {
public String description() {
return name + " can shovel snow";
}
public void command() {
System.out.println(name + " shoveling snow");
}
},
new Operation() {
public String description() {
return name + " can chip ice";
}
public void command() {
System.out.println(name + " chipping ice");
}
},
new Operation() {
public String description() {
return name + " can clear the roof";
}
public void command() {
System.out.println(name + " clearing roof");
}
}
);
}
public static void main(String[] args) {
Robot.Test.test(new SnowRemovalRobot("Slusher"));
}
} /* Output:
Robot name: Slusher
Robot model: SnowBot Series 11
Slusher can shovel snow
Slusher shoveling snow
Slusher can chip ice
Slusher chipping ice
Slusher can clear the roof
Slusher clearing roof
*///:~
| [
"lypgod@hotmail.com"
] | lypgod@hotmail.com |
24e38513a85a4bdbbac16d749f4303abba5ba6e1 | b398d9d19fb8b18c1822930a7cf0f2bb0b0c3840 | /gmp-epics-to-status/src/main/java/edu/gemini/aspen/gmp/epicstostatus/EpicsToStatusConfiguration.java | ae2006ea6cfc836100af1cffda55b3d9750c95f4 | [
"BSD-2-Clause"
] | permissive | framos-gemini/gmp | a9642be9fc12abbafe684125ca0d0bf1b0ad5e73 | 811826574676ec5247d48ebebec6cc6ea95a37b9 | refs/heads/master | 2023-08-18T00:53:17.583839 | 2023-07-19T15:04:19 | 2023-07-19T15:04:19 | 358,715,116 | 0 | 0 | NOASSERTION | 2023-09-13T18:59:25 | 2021-04-16T20:42:53 | Java | UTF-8 | Java | false | false | 1,165 | java | package edu.gemini.aspen.gmp.epicstostatus;
import edu.gemini.aspen.gmp.epicstostatus.generated.Channels;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.File;
/**
* An Epics Configuration built on top of the OSGI properties infraestructure
*/
public class EpicsToStatusConfiguration {
private final Channels _simChannels;
public EpicsToStatusConfiguration(String confFileName) throws JAXBException, SAXException {
JAXBContext jc = JAXBContext.newInstance(Channels.class);
Unmarshaller um = jc.createUnmarshaller();
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(this.getClass().getResource("gmp-epics-to-status-mapping.xsd"));
um.setSchema(schema); //to enable validation
_simChannels = (Channels) um.unmarshal(new File(confFileName));
}
public Channels getSimulatedChannels() {
return _simChannels;
}
} | [
"nbarriga@ee6ba543-07f8-4773-b02c-01d50e9d00ba"
] | nbarriga@ee6ba543-07f8-4773-b02c-01d50e9d00ba |
d9da83b212e4c5a8505829e7c5a0db46c46f49b0 | 7cda634d27902b6c3aa687455cdc30f8d50ffdb2 | /src/main/java/DBAccess/DBConnector.java | 5bdf8cd193ac5c24ea4eeb251f3d4a856f2156d0 | [] | no_license | LasseANielsen/Legoo | 1ac674822f009827b0e8d6d6cfb3be4e74cf3176 | 4f959868c3c59061e0f7bbbe653b540e4414b064 | refs/heads/master | 2020-04-01T09:53:35.126974 | 2018-10-17T12:03:17 | 2018-10-17T12:03:17 | 153,093,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 926 | java | package DBAccess;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnector {
private static final String IP = "46.101.122.191";
private static final String PORT = "3306";
public static final String DATABASE = "mydb";
private static final String USERNAME = "lasse";
private static final String PASSWORD = "1234";
private static Connection singleton;
public static void setConnection(Connection con) {
singleton = con;
}
public static Connection connection() throws ClassNotFoundException, SQLException {
if (singleton == null) {
Class.forName("com.mysql.cj.jdbc.Driver");
String URL = "jdbc:mysql://" + IP + ":" + PORT + "/" + DATABASE;
singleton = DriverManager.getConnection(URL, USERNAME, PASSWORD);
}
return singleton;
}
}
| [
"l.cph@hotmail.com"
] | l.cph@hotmail.com |
296271d70632834eceeed74747aac8c92a533eb9 | 942fb25840e093c19defc9bf573c0d8152054e2b | /app/src/main/java/np/com/rotaractnepalapp/rotaract/Adapter/ClubIVAdapter/ClubIV10Adapter.java | f1c3d4d30c932b7520f4cdeda0d3b6c490a623b9 | [] | no_license | RotaractNepal/SelectedApp | 1cb7c183d741ead5e07338135475d0931b47fac3 | 5a00bf84b9755ecbea0285061e49e4759604df9c | refs/heads/master | 2020-04-02T16:32:50.370368 | 2018-11-18T03:19:34 | 2018-11-18T03:19:34 | 154,617,225 | 0 | 0 | null | 2018-10-29T02:39:41 | 2018-10-25T05:55:21 | Java | UTF-8 | Java | false | false | 5,908 | java | package np.com.rotaractnepalapp.rotaract.Adapter.ClubIVAdapter;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import de.hdodenhof.circleimageview.CircleImageView;
import np.com.rotaractnepalapp.rotaract.Class.ClassClubIV.ClubIV10Class;
import np.com.rotaractnepalapp.rotaract.R;
public class ClubIV10Adapter extends RecyclerView.Adapter<ClubIV10Adapter.ClubViewHolder> {
ArrayList<ClubIV10Class> data = new ArrayList<>();
public ClubIV10Adapter(ArrayList<ClubIV10Class> data) {
this.data = data;
}
@NonNull
@Override
public ClubViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.itemadapter, viewGroup, false);
return new ClubViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ClubViewHolder clubViewHolder, int i) {
clubViewHolder.title.setText(data.get(i).getTitle());
clubViewHolder.images.setImageResource(data.get(i).getImages());
}
@Override
public int getItemCount() {
return data.size();
}
public class ClubViewHolder extends RecyclerView.ViewHolder {
TextView title;
CircleImageView images;
public ClubViewHolder(@NonNull View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.nameTextView);
images = (CircleImageView) itemView.findViewById(R.id.imageView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION){
final ClubIV10Class clickedDataItem = data.get(position);
final Dialog memInformation;
memInformation = new Dialog(v.getContext());
memInformation.setContentView(R.layout.mem_info_layout_recylerview);
ImageView memImageBackGround = (ImageView) memInformation.findViewById(R.id.memImageBackground);
memImageBackGround.setImageResource(clickedDataItem.getBimages());
CircleImageView memImage = (CircleImageView) memInformation.findViewById(R.id.memImageInfo);
memImage.setImageResource(clickedDataItem.getImages());
TextView memName = (TextView) memInformation.findViewById(R.id.memNameInfo);
memName.setText(clickedDataItem.getName());
TextView memDesignation = (TextView) memInformation.findViewById(R.id.memDesignationInfo);
memDesignation.setText(clickedDataItem.getTitle());
TextView memRIDNo = (TextView) memInformation.findViewById(R.id.memRIDNoInfo);
memRIDNo.setText(clickedDataItem.getRidno());
ImageView close = (ImageView) memInformation.findViewById(R.id.cancel);
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
memInformation.dismiss();
}
});
ImageView call = (ImageView) memInformation.findViewById(R.id.call);
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL);
String contactNo = clickedDataItem.getCall();
intent.setData(Uri.parse("tel:" + contactNo));
v.getContext().startActivity(intent);
}
});
ImageView email = (ImageView) memInformation.findViewById(R.id.email);
email.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intenEmail=null, chooserEmail=null;
intenEmail = new Intent(Intent.ACTION_SEND);
intenEmail.setData(Uri.parse("mailto:"));
String[] to = {clickedDataItem.getEmail()};
intenEmail.putExtra(Intent.EXTRA_EMAIL, to);
intenEmail.putExtra(Intent.EXTRA_SUBJECT, "Sent From Rotaract Nepal App");
intenEmail.putExtra(Intent.EXTRA_TEXT, "Dear Sir/Madam;");
intenEmail.setType("message/rfc822");
chooserEmail = intenEmail.createChooser(intenEmail,"Send Email");
v.getContext().startActivity(chooserEmail);
}
});
memInformation.setCanceledOnTouchOutside(false);
memInformation.setCancelable(false);
memInformation.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
memInformation.show();
}
}
});
}
}
}
| [
"35910030+rotaractnepalapp@users.noreply.github.com"
] | 35910030+rotaractnepalapp@users.noreply.github.com |
c482a799f3a74e82e75d0a6d88497e5aac3ae34a | 15f775a8fb0a67dccef0f15053e43ea62b88dead | /src/main/java/fcagnin/jgltut/tut10/VertexPointLighting.java | 046c823cbf889134f922d48496d08a6977a2183e | [
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | IngussNeilands/jgltut | 8912322bd8f2594eb150ec25871fed1fc09e068d | 9cf1ff78fe739cf0175ba756a537b6fbc7c2cb57 | refs/heads/master | 2021-01-22T00:19:11.117063 | 2014-06-07T00:01:48 | 2014-06-07T00:01:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,461 | java | package fcagnin.jgltut.tut10;
import fcagnin.jglsdk.BufferableData;
import fcagnin.jglsdk.glm.*;
import fcagnin.jglsdk.glutil.MatrixStack;
import fcagnin.jglsdk.glutil.MousePoles.*;
import fcagnin.jgltut.LWJGLWindow;
import fcagnin.jgltut.framework.Framework;
import fcagnin.jgltut.framework.Mesh;
import fcagnin.jgltut.framework.MousePole;
import fcagnin.jgltut.framework.Timer;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.glBindBufferRange;
import static org.lwjgl.opengl.GL31.*;
import static org.lwjgl.opengl.GL32.GL_DEPTH_CLAMP;
/**
* Visit https://github.com/integeruser/jgltut for info, updates and license terms.
* <p/>
* Part III. Illumination
* Chapter 10. Plane Lights
* http://www.arcsynthesis.org/gltut/Illumination/Tutorial%2010.html
* <p/>
* I,J,K,L - control the light's position. Holding LEFT_SHIFT with these keys will move in smaller increments.
* SPACE - toggle between drawing the uncolored cylinder and the colored one.
* Y - toggle the drawing of the light source.
* B - toggle the light's rotation on/off.
* <p/>
* LEFT CLICKING and DRAGGING - rotate the camera around the target point, both horizontally and vertically.
* LEFT CLICKING and DRAGGING + CTRL - rotate the camera around the target point, either horizontally or vertically.
* LEFT CLICKING and DRAGGING + ALT - change the camera's up direction.
* RIGHT CLICKING and DRAGGING - rotate the object horizontally and vertically, relative to the current camera
* view.
* RIGHT CLICKING and DRAGGING + CTRL - rotate the object horizontally or vertically only, relative to the current
* camera view.
* RIGHT CLICKING and DRAGGING + ALT - spin the object.
* WHEEL SCROLLING - move the camera closer to it's target point or farther away.
*
* @author integeruser
*/
public class VertexPointLighting extends LWJGLWindow {
public static void main(String[] args) {
Framework.CURRENT_TUTORIAL_DATAPATH = "/fcagnin/jgltut/tut10/data/";
new VertexPointLighting().start();
}
@Override
protected void init() {
initializePrograms();
try {
cylinderMesh = new Mesh( "UnitCylinder.xml" );
planeMesh = new Mesh( "LargePlane.xml" );
cubeMesh = new Mesh( "UnitCube.xml" );
} catch ( Exception exception ) {
exception.printStackTrace();
System.exit( -1 );
}
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
glFrontFace( GL_CW );
glEnable( GL_DEPTH_TEST );
glDepthMask( true );
glDepthFunc( GL_LEQUAL );
glDepthRange( 0.0f, 1.0f );
glEnable( GL_DEPTH_CLAMP );
projectionUniformBuffer = glGenBuffers();
glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
glBufferData( GL_UNIFORM_BUFFER, ProjectionBlock.SIZE, GL_DYNAMIC_DRAW );
// Bind the static buffers.
glBindBufferRange( GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE );
glBindBuffer( GL_UNIFORM_BUFFER, 0 );
}
@Override
protected void display() {
lightTimer.update( getElapsedTime() );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setMatrix( viewPole.calcMatrix() );
final Vec4 worldLightPos = calcLightPosition();
Vec4 lightPosCameraSpace = Mat4.mul( modelMatrix.top(), worldLightPos );
glUseProgram( whiteDiffuseColor.theProgram );
glUniform3( whiteDiffuseColor.lightPosUnif, lightPosCameraSpace.fillAndFlipBuffer( vec4Buffer ) );
glUseProgram( vertexDiffuseColor.theProgram );
glUniform3( vertexDiffuseColor.lightPosUnif, lightPosCameraSpace.fillAndFlipBuffer( vec4Buffer ) );
glUseProgram( whiteDiffuseColor.theProgram );
glUniform4f( whiteDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f );
glUniform4f( whiteDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f );
glUseProgram( vertexDiffuseColor.theProgram );
glUniform4f( vertexDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f );
glUniform4f( vertexDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f );
glUseProgram( 0 );
{
modelMatrix.push();
// Render the ground plane.
{
modelMatrix.push();
glUseProgram( whiteDiffuseColor.theProgram );
glUniformMatrix4( whiteDiffuseColor.modelToCameraMatrixUnif, false,
modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
Mat3 normMatrix = new Mat3( modelMatrix.top() );
glUniformMatrix3( whiteDiffuseColor.normalModelToCameraMatrixUnif, false,
normMatrix.fillAndFlipBuffer( mat3Buffer ) );
planeMesh.render();
glUseProgram( 0 );
modelMatrix.pop();
}
// Render the Cylinder
{
modelMatrix.push();
modelMatrix.applyMatrix( objtPole.calcMatrix() );
if ( drawColoredCyl ) {
glUseProgram( vertexDiffuseColor.theProgram );
glUniformMatrix4( vertexDiffuseColor.modelToCameraMatrixUnif, false,
modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
Mat3 normMatrix = new Mat3( modelMatrix.top() );
glUniformMatrix3( vertexDiffuseColor.normalModelToCameraMatrixUnif, false,
normMatrix.fillAndFlipBuffer( mat3Buffer ) );
cylinderMesh.render( "lit-color" );
} else {
glUseProgram( whiteDiffuseColor.theProgram );
glUniformMatrix4( whiteDiffuseColor.modelToCameraMatrixUnif, false,
modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
Mat3 normMatrix = new Mat3( modelMatrix.top() );
glUniformMatrix3( whiteDiffuseColor.normalModelToCameraMatrixUnif, false,
normMatrix.fillAndFlipBuffer( mat3Buffer ) );
cylinderMesh.render( "lit" );
}
glUseProgram( 0 );
modelMatrix.pop();
}
// Render the light
if ( drawLight ) {
modelMatrix.push();
modelMatrix.translate( worldLightPos.x, worldLightPos.y, worldLightPos.z );
modelMatrix.scale( 0.1f, 0.1f, 0.1f );
glUseProgram( unlit.theProgram );
glUniformMatrix4( unlit.modelToCameraMatrixUnif, false,
modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
glUniform4f( unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f );
cubeMesh.render( "flat" );
modelMatrix.pop();
}
modelMatrix.pop();
}
}
@Override
protected void reshape(int w, int h) {
MatrixStack persMatrix = new MatrixStack();
persMatrix.perspective( 45.0f, (w / (float) h), zNear, zFar );
ProjectionBlock projData = new ProjectionBlock();
projData.cameraToClipMatrix = persMatrix.top();
glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
glBufferSubData( GL_UNIFORM_BUFFER, 0, projData.fillAndFlipBuffer( mat4Buffer ) );
glBindBuffer( GL_UNIFORM_BUFFER, 0 );
glViewport( 0, 0, w, h );
}
@Override
protected void update() {
while ( Mouse.next() ) {
int eventButton = Mouse.getEventButton();
if ( eventButton != -1 ) {
boolean pressed = Mouse.getEventButtonState();
MousePole.forwardMouseButton( viewPole, eventButton, pressed, Mouse.getX(), Mouse.getY() );
MousePole.forwardMouseButton( objtPole, eventButton, pressed, Mouse.getX(), Mouse.getY() );
} else {
// Mouse moving or mouse scrolling
int dWheel = Mouse.getDWheel();
if ( dWheel != 0 ) {
MousePole.forwardMouseWheel( viewPole, dWheel, dWheel, Mouse.getX(), Mouse.getY() );
MousePole.forwardMouseWheel( objtPole, dWheel, dWheel, Mouse.getX(), Mouse.getY() );
}
if ( Mouse.isButtonDown( 0 ) || Mouse.isButtonDown( 1 ) || Mouse.isButtonDown( 2 ) ) {
MousePole.forwardMouseMotion( viewPole, Mouse.getX(), Mouse.getY() );
MousePole.forwardMouseMotion( objtPole, Mouse.getX(), Mouse.getY() );
}
}
}
float lastFrameDuration = getLastFrameDuration() * 5 / 1000.0f;
if ( Keyboard.isKeyDown( Keyboard.KEY_J ) ) {
if ( Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT ) ) {
lightRadius -= 0.05f * lastFrameDuration;
} else {
lightRadius -= 0.2f * lastFrameDuration;
}
} else if ( Keyboard.isKeyDown( Keyboard.KEY_L ) ) {
if ( Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT ) ) {
lightRadius += 0.05f * lastFrameDuration;
} else {
lightRadius += 0.2f * lastFrameDuration;
}
}
if ( Keyboard.isKeyDown( Keyboard.KEY_I ) ) {
if ( Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT ) ) {
lightHeight += 0.05f * lastFrameDuration;
} else {
lightHeight += 0.2f * lastFrameDuration;
}
} else if ( Keyboard.isKeyDown( Keyboard.KEY_K ) ) {
if ( Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT ) ) {
lightHeight -= 0.05f * lastFrameDuration;
} else {
lightHeight -= 0.2f * lastFrameDuration;
}
}
if ( lightRadius < 0.2f ) {
lightRadius = 0.2f;
}
while ( Keyboard.next() ) {
if ( Keyboard.getEventKeyState() ) {
switch ( Keyboard.getEventKey() ) {
case Keyboard.KEY_SPACE:
drawColoredCyl = !drawColoredCyl;
break;
case Keyboard.KEY_Y:
drawLight = !drawLight;
break;
case Keyboard.KEY_B:
lightTimer.togglePause();
break;
case Keyboard.KEY_ESCAPE:
leaveMainLoop();
break;
}
}
}
}
////////////////////////////////
private float zNear = 1.0f;
private float zFar = 1000.0f;
private ProgramData whiteDiffuseColor;
private ProgramData vertexDiffuseColor;
private UnlitProgData unlit;
private class ProgramData {
int theProgram;
int lightPosUnif;
int lightIntensityUnif;
int ambientIntensityUnif;
int modelToCameraMatrixUnif;
int normalModelToCameraMatrixUnif;
}
private class UnlitProgData {
int theProgram;
int objectColorUnif;
int modelToCameraMatrixUnif;
}
private FloatBuffer vec4Buffer = BufferUtils.createFloatBuffer( Vec4.SIZE );
private FloatBuffer mat3Buffer = BufferUtils.createFloatBuffer( Mat3.SIZE );
private FloatBuffer mat4Buffer = BufferUtils.createFloatBuffer( Mat4.SIZE );
private void initializePrograms() {
whiteDiffuseColor = loadLitProgram( "PosVertexLighting_PN.vert", "ColorPassthrough.frag" );
vertexDiffuseColor = loadLitProgram( "PosVertexLighting_PCN.vert", "ColorPassthrough.frag" );
unlit = loadUnlitProgram( "PosTransform.vert", "UniformColor.frag" );
}
private ProgramData loadLitProgram(String vertexShaderFileName, String fragmentShaderFileName) {
ArrayList<Integer> shaderList = new ArrayList<>();
shaderList.add( Framework.loadShader( GL_VERTEX_SHADER, vertexShaderFileName ) );
shaderList.add( Framework.loadShader( GL_FRAGMENT_SHADER, fragmentShaderFileName ) );
ProgramData data = new ProgramData();
data.theProgram = Framework.createProgram( shaderList );
data.modelToCameraMatrixUnif = glGetUniformLocation( data.theProgram, "modelToCameraMatrix" );
data.normalModelToCameraMatrixUnif = glGetUniformLocation( data.theProgram, "normalModelToCameraMatrix" );
data.lightPosUnif = glGetUniformLocation( data.theProgram, "lightPos" );
data.lightIntensityUnif = glGetUniformLocation( data.theProgram, "lightIntensity" );
data.ambientIntensityUnif = glGetUniformLocation( data.theProgram, "ambientIntensity" );
int projectionBlock = glGetUniformBlockIndex( data.theProgram, "Projection" );
glUniformBlockBinding( data.theProgram, projectionBlock, projectionBlockIndex );
return data;
}
private UnlitProgData loadUnlitProgram(String vertexShaderFileName, String fragmentShaderFileName) {
ArrayList<Integer> shaderList = new ArrayList<>();
shaderList.add( Framework.loadShader( GL_VERTEX_SHADER, vertexShaderFileName ) );
shaderList.add( Framework.loadShader( GL_FRAGMENT_SHADER, fragmentShaderFileName ) );
UnlitProgData data = new UnlitProgData();
data.theProgram = Framework.createProgram( shaderList );
data.modelToCameraMatrixUnif = glGetUniformLocation( data.theProgram, "modelToCameraMatrix" );
data.objectColorUnif = glGetUniformLocation( data.theProgram, "objectColor" );
int projectionBlock = glGetUniformBlockIndex( data.theProgram, "Projection" );
glUniformBlockBinding( data.theProgram, projectionBlock, projectionBlockIndex );
return data;
}
////////////////////////////////
private Mesh cylinderMesh;
private Mesh planeMesh;
private Mesh cubeMesh;
private float lightHeight = 1.5f;
private float lightRadius = 1.0f;
private Timer lightTimer = new Timer( Timer.Type.LOOP, 5.0f );
private boolean drawColoredCyl;
private boolean drawLight;
private Vec4 calcLightPosition() {
float currTimeThroughLoop = lightTimer.getAlpha();
Vec4 lightPos = new Vec4( 0.0f, lightHeight, 0.0f, 1.0f );
lightPos.x = (float) (Math.cos( currTimeThroughLoop * (3.14159f * 2.0f) ) * lightRadius);
lightPos.z = (float) (Math.sin( currTimeThroughLoop * (3.14159f * 2.0f) ) * lightRadius);
return lightPos;
}
////////////////////////////////
// View / Object setup.
private ViewData initialViewData = new ViewData(
new Vec3( 0.0f, 0.5f, 0.0f ),
new Quaternion( 0.92387953f, 0.3826834f, 0.0f, 0.0f ),
5.0f,
0.0f
);
private ViewScale viewScale = new ViewScale(
3.0f, 20.0f,
1.5f, 0.5f,
0.0f, 0.0f, // No camera movement.
90.0f / 250.0f
);
private ObjectData initialObjectData = new ObjectData(
new Vec3( 0.0f, 0.5f, 0.0f ),
new Quaternion( 1.0f, 0.0f, 0.0f, 0.0f )
);
private ViewPole viewPole = new ViewPole( initialViewData, viewScale, MouseButtons.MB_LEFT_BTN );
private ObjectPole objtPole = new ObjectPole( initialObjectData, 90.0f / 250.0f, MouseButtons.MB_RIGHT_BTN,
viewPole );
////////////////////////////////
private final int projectionBlockIndex = 2;
private int projectionUniformBuffer;
private class ProjectionBlock extends BufferableData<FloatBuffer> {
Mat4 cameraToClipMatrix;
static final int SIZE = Mat4.SIZE;
@Override
public FloatBuffer fillBuffer(FloatBuffer buffer) {
return cameraToClipMatrix.fillBuffer( buffer );
}
}
} | [
"francesco.cagnin@gmail.com"
] | francesco.cagnin@gmail.com |
55f99d4231bf7b2e4319df95606b60183683295f | f63f44339ba11429512e355ca8b59d0838fc5bd9 | /app/src/main/java/com/tomsky/androiddemo/util/AlgorithmUtils.java | 10409358679a179e3910bd0d89aa71945217f749 | [] | no_license | wangzt/androiddemo | e44c4e04d12b7ad57522b1c7f7532799de3af860 | b41ec579517830d4371dbc3b216970bcce6b659f | refs/heads/master | 2023-03-31T09:36:34.550399 | 2021-01-09T08:51:43 | 2021-01-09T08:51:43 | 2,840,560 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,369 | java | package com.tomsky.androiddemo.util;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AlgorithmUtils {
public static void testMergePoints() {
List<Point> points = new ArrayList<>();
points.add(new Point(3, 5));
points.add(new Point(1, 10));
points.add(new Point(12, 15));
points.add(new Point(12, 20));
points.add(new Point(13, 15));
points.add(new Point(15, 18));
points.add(new Point(19, 22));
List<Point> mergedPoints = mergePoints(points);
for (Point point: mergedPoints) {
Log.d("wzt-merge", point.toString());
}
}
public static List<Point> mergePoints(List<Point> points) {
Collections.sort(points, new PointComparator());
List<Point> result = new ArrayList<>();
Point current = points.get(0);
for (int i = 1; i < points.size(); i++) {
Point next = points.get(i);
if (current.end < next.start) { // 不重叠
result.add(current);
current = next;
} else if (current.end >= next.end) { // 前面包含后面
continue;
} else if (current.end < next.end) {
if (current.start== next.start) { // 后面包含前面
current = next;
} else { // 交叉
result.add(current);
current = next;
}
}
}
result.add(current);
return result;
}
private static final class Point {
public Point(int start, int end) {
this.start = start;
this.end = end;
}
@Override
public String toString() {
return "[" + start +
", " + end +
']';
}
int start;
int end;
}
private static final class PointComparator implements Comparator<Point> {
@Override
public int compare(Point o1, Point o2) {
if (o1 == null || o2 == null) return 0;
if (o1.start > o2.start) {
return 1;
} else if (o1.start < o2.start) {
return -1;
}
return 0;
}
}
}
| [
"wangzhitao@huajiao.tv"
] | wangzhitao@huajiao.tv |
0d9efc56516f15ef65319feb9eac92b3d26f80c3 | 7198994bd71ffb464916bc7f1c3164bb14d65f77 | /library/src/main/java/cn/app/library/dialog/styleddialog/view/SuperHolder.java | 7d544409b9cd1c5d93a268112b4188d2381c30e3 | [] | no_license | nakupenda178/lklib | 78f00b7f7a0aaf42389107638d810e0c5ffc407b | 7cc36badfe0cf8a1d2b17e579c9fd04adf3d3eb7 | refs/heads/master | 2020-07-05T04:29:54.729597 | 2018-05-04T06:54:21 | 2018-05-04T06:54:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 771 | java | package cn.app.library.dialog.styleddialog.view;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.view.View;
import cn.app.library.dialog.styleddialog.config.ConfigBean;
/**
* Created by Administrator on 2016/4/15 0015.
*/
public abstract class SuperHolder {
public View rootView;
public SuperHolder(Context context){
rootView = View.inflate(context,setLayoutRes(),null);
findViews();
}
protected abstract void findViews();
protected abstract @LayoutRes
int setLayoutRes();
/**
* 一般情况下,实现这个方法就足够了
* @param context
* @param bean
*/
public abstract void assingDatasAndEvents(Context context, ConfigBean bean);
}
| [
"zhaolin.tongwei@gmail.com"
] | zhaolin.tongwei@gmail.com |
673ea423b0c461bd413494c849fcb8ba4f6eb1e3 | 13ce706205e9db1a37dc4c11662351bcacdd4a09 | /src/com/expedite/apps/nalanda/adapter/AccountListAdapter.java | 16ba1a3e6734655358a7f052a436994cc98e24bf | [] | no_license | rampurawala/Nalanda | 72ee9d929231af60f33f895bc0b223f7d1c5fed2 | 6c555060304fe03e2130a0746b562bb65f239f73 | refs/heads/master | 2020-08-17T22:19:09.447343 | 2019-10-17T06:14:11 | 2019-10-17T06:14:11 | 215,716,823 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,277 | java | package com.expedite.apps.nalanda.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.expedite.apps.nalanda.R;
public class AccountListAdapter extends BaseAdapter {
private Context context;
private String[] names;
public AccountListAdapter(Context context, String[] names) {
this.context = context;
this.names = names;
}
public int getCount() {
return names.length;
}
public Object getItem(int arg) {
return arg;
}
public long getItemId(int arg) {
return 0;
}
public String getItenName(int arg) {
return names[arg];
}
public View getView(int position, View mView, ViewGroup mViewgroups) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.activity_item_list,mViewgroups,false);
TextView txtname = (TextView) view.findViewById(R.id.txtmessages);
if (names[position] != null && names[position].length() > 0)
txtname.setText(names[position]);
return view;
}
}
| [
"7865253jameela@gmail.com"
] | 7865253jameela@gmail.com |
1ec697fdcdde32c89a6c4a3cff6d9ed0e828fc8f | 7a494e516b31a177a4373eb323db4841db1ad6c7 | /app/src/main/java/com/example/yashbohara/project/ViewClassReport.java | 3d52c01f6d3c182512467b18a18ce3f38acf370d | [] | no_license | yashbohara/Project | e7c55e516e3c8658de19746cdb8ae25bc1c49b2b | 39dc53a095cf772161dff63ab1e6793f03eaee28 | refs/heads/master | 2021-01-19T21:02:35.590756 | 2017-05-01T14:33:23 | 2017-05-01T14:33:23 | 88,596,660 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,446 | java | package com.example.yashbohara.project;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import static com.example.yashbohara.project.M1.dbhandler;
public class ViewClassReport extends AppCompatActivity {
ListView l2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_class_report);
TextView t8=(TextView) findViewById(R.id.textView8);
TextView t9=(TextView) findViewById(R.id.textView9);
TextView t10=(TextView) findViewById(R.id.textView10);
TextView t11=(TextView) findViewById(R.id.textView11);
TextView t12=(TextView) findViewById(R.id.textView12);
Bundle bundle=getIntent().getExtras();
String a=bundle.getString("s1");
String b=bundle.getString("s2");
String c=bundle.getString("s3");
t8.setText(b+a+"02");
t9.setText(b+a+"03");
t10.setText(b+a+"04");
t11.setText(b+a+"05");
t12.setText(b+a+"01");
ArrayList<String> list2=dbhandler.databaseToString(b,c,a);
ListAdapter listAdapter2=new CustomAdapter2(this,list2);
l2=(ListView) findViewById(R.id.l2);
l2.setAdapter(listAdapter2);
// obj1=new ViewClassReport();
}
}
| [
"yashbohara001@gmail.com"
] | yashbohara001@gmail.com |
243eb67011341b682cefcaea0cee0258ac370f88 | 206b856989eb38f4b0309ee5821b89dcf397763f | /src/main/java/com/daikuan/until/AuthImageServlet.java | c0730df1deed5ecb4ab4b7485c1e52c48df14002 | [] | no_license | a6778859/daikuan | d2177a99fde8fdf4ec06ed7be241d6a5032af5d8 | a589579c5501b60ca24034fe57c25d466383ba55 | refs/heads/master | 2021-01-20T12:21:01.784478 | 2017-09-22T09:31:59 | 2017-09-22T09:31:59 | 101,710,941 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,926 | java | package com.daikuan.until;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import redis.clients.jedis.Jedis;
public class AuthImageServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=utf-8";
// 设置字母的大小,大小
private Font mFont = new Font("Times New Roman", Font.PLAIN, 18);
public void init() throws ServletException {
super.init();
}
Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 表明生成的响应是图片
response.setContentType("image/jpeg");
int width = 100, height = 28;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getRandColor(200, 250));
g.fillRect(1, 1, width - 1, height - 1);
g.setColor(new Color(102, 102, 102));
g.drawRect(0, 0, width - 1, height - 1);
g.setFont(mFont);
g.setColor(getRandColor(160, 200));
// 画随机线
for (int i = 0; i < 155; i++) {
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int xl = random.nextInt(6) + 1;
int yl = random.nextInt(12) + 1;
g.drawLine(x, y, x + xl, y + yl);
}
// 从另一方向画随机线
for (int i = 0; i < 70; i++) {
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int xl = random.nextInt(12) + 1;
int yl = random.nextInt(6) + 1;
g.drawLine(x, y, x - xl, y - yl);
}
// 生成随机数,并将随机数字转换为字母
String sRand = "";
int t = 4;
for (int i = 0; i < t; i++) {
int itmp = random.nextInt(26) + 65;
char ctmp = (char) itmp;
sRand += String.valueOf(ctmp);
g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
g.drawString(String.valueOf(ctmp), 15 * i + 20, 18);
}
String temptoken = request.getParameter("temptoken");
if (temptoken != null && temptoken.length() == 36) {
RedisUtil.set(temptoken,sRand,5 * 60);
}
g.dispose();
response.reset();
ImageIO.write(image, "JPEG", response.getOutputStream());
}
}
| [
"382335873@qq.com"
] | 382335873@qq.com |
15052f8900ec2a38148db059c386f3c95b6137d0 | 948ccae1ab96be76693c63c2ba3e209511deec77 | /src/test/java/com/pokemonCollection/PokemonCollectionApplicationTests.java | 41d401257ab2cd29c8e93e5b47e2ad949ff462c7 | [] | no_license | Pawulon447/pokemonCollection2 | d7002302adcf4707d442cef4fbb4ff086a99a316 | 475c310b1a4e6ba78519e98bae850fb38e6f675e | refs/heads/master | 2023-09-03T16:08:47.763025 | 2021-10-22T20:11:15 | 2021-10-22T20:11:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 224 | java | package com.pokemonCollection;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class PokemonCollectionApplicationTests {
@Test
void contextLoads() {
}
}
| [
"gm91b09@gmail.com"
] | gm91b09@gmail.com |
ba0443ae35cb717ae821256fbb4eecabba9fcf53 | 8339dab6a1c2f545a5aeeba863a870401aa18396 | /src/main/java/cz/czechitas/webapp/Panenka.java | f47e9eacf1ae9bba1ef3978a1484165d5449f108 | [] | no_license | Danakut/jaro2019-ukol10-ukazka | 80855f9612e2bcd9e40ffa8d22a7405d84de5492 | 302204f4fc0bfb3ab48b1b3849da07e27e74d446 | refs/heads/master | 2020-05-20T23:15:10.326016 | 2019-05-16T13:11:13 | 2019-05-16T13:11:13 | 185,796,808 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,289 | java | package cz.czechitas.webapp;
public class Panenka {
private Long id;
private String jmeno;
private String vrsek;
private String spodek;
private String datumVzniku;
private int verze;
public Panenka() {
}
public Panenka(String jmeno, String vrsek, String spodek, String datumVzniku) {
this.jmeno = jmeno;
this.vrsek = vrsek;
this.spodek = spodek;
this.datumVzniku = datumVzniku;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getJmeno() {
return jmeno;
}
public void setJmeno(String jmeno) {
this.jmeno = jmeno;
}
public String getVrsek() {
return vrsek;
}
public void setVrsek(String vrsek) {
this.vrsek = vrsek;
}
public String getSpodek() {
return spodek;
}
public void setSpodek(String spodek) {
this.spodek = spodek;
}
public String getDatumVzniku() {
return datumVzniku;
}
public void setDatumVzniku(String datumVzniku) {
this.datumVzniku = datumVzniku;
}
public int getVerze() {
return verze;
}
public void setVerze(int verze) {
this.verze = verze;
}
}
| [
"kutalkovad@gmail.com"
] | kutalkovad@gmail.com |
8dbaf0a3c161998b765c13680f1b0beea9edfb2f | a7c083799a8b0765091aea7916d8819a76abe2f1 | /LeetCode/src/com/bsb/leetcode/vip/bytedance/T62.java | 655cd1f75f443c619765ad261e1d8252c4d3ee06 | [] | no_license | challengerzsz/Algorithm | 121cc2109f75f73b8a9cad892f5195258c898f5e | 3baded2d7626d86fa2a31191394f35b7f865a2cd | refs/heads/master | 2021-05-26T05:51:11.892323 | 2020-04-23T14:16:57 | 2020-04-23T14:16:57 | 127,735,766 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 778 | java | package com.bsb.leetcode.vip.bytedance;
import java.util.Arrays;
/**
* @author : zengshuaizhi
* @date : 2020-03-31 20:20
*/
public class T62 {
// 不同路径
// dfs可以做 但是大量回溯加重复计算 可以用记忆化优化 但是不是最优解
public int uniquePaths(int m, int n) {
// dp[i][j]表示走到{i, j}有多少种走法
int[][] dp = new int[n][m];
Arrays.fill(dp[0], 1);
for (int i = 0; i < n; i++) dp[i][0] = 1;
for (int i = 1; i < n; i++) {
for (int j = 1; j < m; j++) {
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
}
return dp[n - 1][m - 1];
}
public static void main(String[] args) {
new T62().uniquePaths(3, 2);
}
}
| [
"challengerzsz@126.com"
] | challengerzsz@126.com |
639cbf48d412ee96802451c4e7031fbcb9ff34f0 | fcbc669200213fd71e3e83737387e1f508c9aa65 | /lang/java/practicejsf/src/practicejsf/bean/service/simple/CustomerSimpleMap.java | d9aa9ebaa24828e5611f75403e3be65f9e2591c1 | [] | no_license | moguonyanko/moglabo | 84e138a35b5ef4e22f45ad615f839ba3cd536e7c | b03bdd7e68d4c32b48e8f114bd793b77dd047ac5 | refs/heads/master | 2023-09-04T07:25:27.589619 | 2023-09-01T16:58:54 | 2023-09-01T16:58:54 | 4,608,440 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,150 | java | package practicejsf.bean.service.simple;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import practicejsf.bean.Customer;
import practicejsf.bean.service.CustomerLookupService;
import practicejsf.util.Faces;
/**
* いわゆるビジネスロジックの実装
*/
public class CustomerSimpleMap implements CustomerLookupService {
private final Map<String, Customer> customers = new HashMap<>();
private static final List<Customer> SAMPLE_CUSTOMERS = Arrays.asList(
new Customer("id001", "Usao", "Foo", -1000.50),
new Customer("id002", "Mog", "Bar", 7654.32),
new Customer("id003", "Pusuta", "Baz", 20000.88)
);
public CustomerSimpleMap() {
SAMPLE_CUSTOMERS.forEach(c -> addCustomer(c));
printOwnClassName();
}
private void addCustomer(Customer customer) {
customers.put(customer.getId(), customer);
}
@Override
public Customer findCustomer(String id) {
if(!Faces.isNullOrEmpty(id)){
return customers.get(id);
}else{
return null;
}
}
protected final void printOwnClassName() {
System.out.println(this.getClass().getSimpleName() + " initialized!");
}
}
| [
"k-yamada@tg-inet.co.jp"
] | k-yamada@tg-inet.co.jp |
6aff8df74db7b2941fb1d5ad4275163b8140c26c | a841d3c21395168f761656293d45c71f924b98fd | /hybris/bin/custom/johndeere/johndeerestorefront/web/src/com/deere/storefront/interceptors/beforecontroller/RequireHardLoginBeforeControllerHandler.java | e707234a037b23115e087ae46f9e5c58ad46aebb | [] | no_license | vinayj344/johndeere | 7add3c82175159d56a84538441c3f6ec49115e0e | cbf87ca7d3dd012214f01a0d5de60c69e8e508db | refs/heads/master | 2020-03-26T16:29:55.733222 | 2018-08-22T13:43:49 | 2018-08-22T13:43:49 | 145,105,874 | 0 | 0 | null | 2018-08-22T13:43:50 | 2018-08-17T10:14:04 | Java | UTF-8 | Java | false | false | 3,763 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved.
*
* This software is the confidential and proprietary information of SAP
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with SAP.
*/
package com.deere.storefront.interceptors.beforecontroller;
import java.lang.annotation.Annotation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.web.method.HandlerMethod;
import de.hybris.platform.acceleratorstorefrontcommons.annotations.RequireHardLogIn;
import de.hybris.platform.acceleratorstorefrontcommons.interceptors.BeforeControllerHandler;
import com.deere.storefront.security.evaluator.impl.RequireHardLoginEvaluator;
/**
*/
public class RequireHardLoginBeforeControllerHandler implements BeforeControllerHandler
{
private static final Logger LOG = Logger.getLogger(RequireHardLoginBeforeControllerHandler.class);
public static final String SECURE_GUID_SESSION_KEY = "acceleratorSecureGUID";
private String loginUrl;
private String loginAndCheckoutUrl;
private RedirectStrategy redirectStrategy;
private RequireHardLoginEvaluator requireHardLoginEvaluator;
protected String getLoginUrl()
{
return loginUrl;
}
@Required
public void setLoginUrl(final String loginUrl)
{
this.loginUrl = loginUrl;
}
protected RedirectStrategy getRedirectStrategy()
{
return redirectStrategy;
}
@Required
public void setRedirectStrategy(final RedirectStrategy redirectStrategy)
{
this.redirectStrategy = redirectStrategy;
}
public String getLoginAndCheckoutUrl()
{
return loginAndCheckoutUrl;
}
@Required
public void setLoginAndCheckoutUrl(final String loginAndCheckoutUrl)
{
this.loginAndCheckoutUrl = loginAndCheckoutUrl;
}
protected RequireHardLoginEvaluator getRequireHardLoginEvaluator()
{
return requireHardLoginEvaluator;
}
@Required
public void setRequireHardLoginEvaluator(RequireHardLoginEvaluator requireHardLoginEvaluator)
{
this.requireHardLoginEvaluator = requireHardLoginEvaluator;
}
@Override
public boolean beforeController(final HttpServletRequest request, final HttpServletResponse response,
final HandlerMethod handler) throws Exception
{
// We only care if the request is secure
if (request.isSecure())
{
// Check if the handler has our annotation
final RequireHardLogIn annotation = findAnnotation(handler, RequireHardLogIn.class);
if (annotation != null)
{
boolean redirect = requireHardLoginEvaluator.evaluate(request, response);
if (redirect)
{
LOG.warn("Redirection required");
getRedirectStrategy().sendRedirect(request, response, getRedirectUrl(request));
return false;
}
}
}
return true;
}
protected String getRedirectUrl(final HttpServletRequest request)
{
if (request != null && request.getServletPath().contains("checkout"))
{
return getLoginAndCheckoutUrl();
}
else
{
return getLoginUrl();
}
}
protected <T extends Annotation> T findAnnotation(final HandlerMethod handlerMethod, final Class<T> annotationType)
{
// Search for method level annotation
final T annotation = handlerMethod.getMethodAnnotation(annotationType);
if (annotation != null)
{
return annotation;
}
// Search for class level annotation
return AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), annotationType);
}
}
| [
"vinay.j344@gmail.com"
] | vinay.j344@gmail.com |
d64447d9e5a6af5156a6d744356ee302ed00f542 | 54105531ab61942ca91b953b424c20c2e6ee73f2 | /towns-webapp/src/main/generated-java/com/bazoud/springbatch/towns/webapp/web/permission/support/TypeAwarePermission.java | 7ea8ff58460dfbc15dc6228332b2a12f885daaa0 | [] | no_license | rejwan052/spring-batch-towns | 74bce333a375875a477fe6fdeebe6b5fb93d3a7c | 4eb74468c3e32d123a96bb079fae17134d8b1ccb | refs/heads/master | 2021-01-19T20:15:29.067045 | 2013-11-21T12:02:26 | 2013-11-21T12:02:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,741 | java | /*
* (c) Copyright 2005-2013 JAXIO, http://www.jaxio.com
* Source code generated by Celerio, a Jaxio product
* Want to purchase Celerio ? email us at info@jaxio.com
* Follow us on twitter: @springfuse
* Documentation: http://www.jaxio.com/documentation/celerio/
* Template pack-jsf2-spring-conversation:src/main/java/permission/support/TypeAwarePermission.p.vm.java
*/
package com.bazoud.springbatch.towns.webapp.web.permission.support;
import static com.google.common.collect.Maps.newHashMap;
import static org.hibernate.proxy.HibernateProxyHelper.getClassWithoutInitializingProxy;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.bazoud.springbatch.towns.webapp.domain.Identifiable;
/**
* Permission service that should be used only in certain cases (e.g. from facelet tags).
*
* @see GenericPermission
*/
@Named("permission")
@Singleton
@SuppressWarnings("rawtypes")
public class TypeAwarePermission {
private Map<Class, GenericPermission<?>> permissions = newHashMap();
@Inject
void buildCache(List<GenericPermission> registredPermissions) {
for (GenericPermission permission : registredPermissions) {
permissions.put(permission.getTarget(), permission);
}
}
@SuppressWarnings("unchecked")
private <E extends Identifiable<? extends Serializable>> GenericPermission<E> getPermission(E entity) {
// note: getClassWithoutInitializingProxy expects a non null object
// _HACK_ as we depend on hibernate here.
return (GenericPermission<E>) permissions.get(getClassWithoutInitializingProxy(entity));
}
// --------------------------------------------------------------
// Permission shortcut methods that can be used from facelet tags
// --------------------------------------------------------------
public <E extends Identifiable<?>> boolean canView(E e) {
return e == null ? false : getPermission(e).canView(e);
}
public <E extends Identifiable<?>> boolean canEdit(E e) {
return e == null ? false : getPermission(e).canEdit(e);
}
public <E extends Identifiable<?>> boolean canDelete(E e) {
return e == null ? false : getPermission(e).canDelete(e);
}
public <E extends Identifiable<?>> boolean canSearch(E e) {
return e == null ? false : getPermission(e).canSearch(e);
}
public <E extends Identifiable<?>> boolean canSelect(E e) {
return e == null ? false : getPermission(e).canSelect(e);
}
public <E extends Identifiable<?>> boolean canUse(E e) {
return e == null ? false : getPermission(e).canUse(e);
}
} | [
"olivier.bazoud@gmail.com"
] | olivier.bazoud@gmail.com |
a8b2dbb93b54fc495cdb95c27bd5aefb1ed92e4e | 73c9d08c357bcbb15d5eca64c438fc322f56a920 | /app/src/main/java/com/example/saisai/yoho/adapter/FenleiPinpaiSearchAdapter.java | 0f9dce849395c9693d0e5700bfac4fca304be16f | [] | no_license | xvsaisai/YoHo88 | 04f1c20ac2487773f279de44c4c717a86be606a8 | 71cf2fc89f47f19a2e4b88a065b4d57d88a4679f | refs/heads/master | 2020-07-03T18:27:03.642276 | 2016-09-11T03:27:12 | 2016-09-11T03:27:12 | 66,820,845 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | java | package com.example.saisai.yoho.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.saisai.yoho.R;
import com.example.saisai.yoho.bean.PinPaiBean;
import java.util.List;
/**
* Created by saisai on 2016/8/26.
*/
public class FenleiPinpaiSearchAdapter extends BaseSearchLVAdapter<PinPaiBean.BrandBean> {
public FenleiPinpaiSearchAdapter(List<PinPaiBean.BrandBean> list, Context context) {
super(list, context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder=null;
if(convertView==null){
convertView=View.inflate(context, R.layout.item_fenlei_pinpai_search_lv,null);
holder=new Holder();
holder.textView= (TextView) convertView.findViewById(R.id.tv_item_fenlei_pinpai_search_lv);
convertView.setTag(holder);
}else {
holder= (Holder) convertView.getTag();
}
PinPaiBean.BrandBean item = getItem(position);
holder.textView.setText(item.getName());
return convertView;
}
static class Holder{
TextView textView;
}
}
| [
"47806328@qq.com"
] | 47806328@qq.com |
25f9f31f728b1093cae1b44d5315f21c7957706e | d6b467da7999bb29ef659768890d4138b8e38195 | /chinaw/src/com/wuxi/app/activity/homepage/fantasticwuxi/ChannelActivity.java | 511b9fbf4cabfedbc0e4e59d009dd428a35d3d4b | [] | no_license | ChinaWuxiandroid/chianwuxi_android | 0975b6ece55af95182b13616aad92ce2d3121928 | 320fb895583c11bf5d7b2701ef3c8b459492cadf | refs/heads/master | 2023-06-07T09:04:06.527140 | 2023-06-06T04:01:16 | 2023-06-06T04:01:16 | 12,722,746 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,896 | java | /*
* (#)ChannelActivity.java 1.0 2013-8-29 2013-8-29 GMT+08:00
*/
package com.wuxi.app.activity.homepage.fantasticwuxi;
import java.util.List;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
import com.wuxi.app.BaseFragment;
import com.wuxi.app.R;
import com.wuxi.app.activity.BaseSlideActivity;
import com.wuxi.app.engine.ChannelService;
import com.wuxi.app.fragment.commonfragment.NavigatorWithContentFragment;
import com.wuxi.app.fragment.homepage.fantasticwuxi.ChannelContentListFragment;
import com.wuxi.app.fragment.homepage.fantasticwuxi.CityMapFragment;
import com.wuxi.app.listeners.InitializContentLayoutListner;
import com.wuxi.app.util.CacheUtil;
import com.wuxi.app.util.Constants;
import com.wuxi.app.util.LogUtil;
import com.wuxi.app.view.TitleScrollLayout;
import com.wuxi.domain.Channel;
import com.wuxi.domain.MenuItem;
import com.wuxi.exception.NetException;
/**
* @author wanglu 泰得利通 魅力锡城Activity 频道最外层activity
* @version $1.0, 2013-8-29 2013-8-29 GMT+08:00
*
*/
public class ChannelActivity extends BaseSlideActivity implements
InitializContentLayoutListner {
private TitleScrollLayout mtitleScrollLayout;
private static final int MANCOTENT_ID = R.id.model_main;
private static final int TITLE__LOAD_SUCESS = 0;
private static final int TITLE_LOAD_ERROR = 1;
protected static final String TAG = "ChannelFragment";
public static final String SHOWCHANNEL_LAYOUT_INDEXKEY = Constants.CheckPositionKey.LEVEL_TWO__KEY;
private ImageButton ib_nextItems;
private List<Channel> titleChannels;// 头部频道
private int perCount = 4;
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
String tip = "";
if (msg.obj != null) {
tip = msg.obj.toString();
}
switch (msg.what) {
case TITLE__LOAD_SUCESS:
showTitleData();
break;
case TITLE_LOAD_ERROR:
Toast.makeText(ChannelActivity.this, tip, Toast.LENGTH_SHORT)
.show();
break;
}
};
};
@Override
protected void findMainContentViews(View view) {
Bundle bundle = getIntent().getExtras();
int showIndex = 0;
if (bundle != null) {
showIndex = bundle.getInt(SHOWCHANNEL_LAYOUT_INDEXKEY);//
}
mtitleScrollLayout = (TitleScrollLayout) view.findViewById(R.id.title_scroll_action);// 头部控件
mtitleScrollLayout.setInitializContentLayoutListner(this);// 设置绑定内容界面监听器
mtitleScrollLayout.setPerscreenCount(perCount);
int screenIndex = showIndex / perCount;// 第几屏
int showScreenIndex = showIndex % perCount;// 屏的
mtitleScrollLayout.setShowItemIndex(showScreenIndex);// 设置显示的默认布局
mtitleScrollLayout.setmCurScreen(screenIndex);
ib_nextItems = (ImageButton) view.findViewById(R.id.btn_next_screen);// 头部下一个按钮
ib_nextItems.setOnClickListener(this);
loadTitleData();
}
@Override
public void bindContentLayout(BaseFragment fragment) {
bindFragment(fragment);
}
/**
*
* wanglu 泰得利通 加载头部Channel
*/
@SuppressWarnings("unchecked")
public void loadTitleData() {
if (CacheUtil.get(menuItem.getChannelId()) != null) {// 从缓存获取
titleChannels = (List<Channel>) CacheUtil.get(menuItem.getChannelId());
showTitleData();
return;
}
new Thread(new Runnable() {
@Override
public void run() {
ChannelService channelService = new ChannelService(
ChannelActivity.this);
try {
titleChannels = channelService.getSubChannels(menuItem.getChannelId());
if (null != titleChannels) {
handler.sendEmptyMessage(TITLE__LOAD_SUCESS);
} else {
Message message = handler.obtainMessage();
message.obj = "error";
handler.sendEmptyMessage(TITLE_LOAD_ERROR);
}
} catch (NetException e) {
LogUtil.i(TAG, "出错");
e.printStackTrace();
Message message = handler.obtainMessage();
message.obj = e.getMessage();
handler.sendEmptyMessage(TITLE_LOAD_ERROR);
}
}
}
).start();
}
/**
* 显示头部数据 wanglu 泰得利通
*/
private void showTitleData() {
initializSubFragmentsLayout();
mtitleScrollLayout.initChannelScreen(
ChannelActivity.this, getLayoutInflater(), titleChannels);// 初始化头部空间
// initData(titleChannels.get(0));// 默认显示第一个channel的子channel页
}
@Override
public void onClick(View v) {
super.onClick(v);
switch (v.getId()) {
case R.id.btn_next_screen:// 下一屏
mtitleScrollLayout.goNextScreen();
break;
}
}
private void bindFragment(BaseFragment fragment) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(MANCOTENT_ID, fragment);// 替换内容界面
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commitAllowingStateLoss();
}
public void setMenuItem(MenuItem menuItem) {
this.menuItem = menuItem;
}
public void initializSubFragmentsLayout() {
for (Channel channel : titleChannels) {
if (channel.getChannelName().equals("城市地图")) {
channel.setContentFragment(CityMapFragment.class);
} else if (channel.getChildrenChannelsCount() > 0) {
channel.setContentFragment(NavigatorWithContentFragment.class);
} else if (channel.getChildrenContentsCount() > 0) {
channel.setContentFragment(ChannelContentListFragment.class);
}
}
}
@Override
protected int getLayoutId() {
return R.layout.fragment_chanel_layout;
}
@Override
protected String getTitleText() {
return menuItem.getName();
}
@Override
public void redirectFragment(MenuItem showMenuItem, int showMenuPositon,
int subMenuPostion) {
}
}
| [
"wanglu0919@163.com"
] | wanglu0919@163.com |
5397e97e305406afe4bfd6e99a97f2ace2bfccb1 | 9a7e206bb951ad93cf3fa4c95998af9c0fbd0557 | /information/src/main/java/com/sdxm/information/entity/Manager.java | 430d40aafda1c0bcd1ce506760a928ffab4e6953 | [] | no_license | vtne/spring-cloud | cfdeb556f9da343c97587fed6e5c4a3353fc5ec6 | f4f2b0054e1a4d9988331e365601f7fbd0434b05 | refs/heads/master | 2022-06-21T05:25:12.501373 | 2019-10-21T05:24:47 | 2019-10-21T05:24:47 | 216,482,707 | 0 | 0 | null | 2022-06-17T02:37:44 | 2019-10-21T05:14:12 | Java | UTF-8 | Java | false | false | 3,291 | java | package com.sdxm.information.entity;
import java.util.Date;
public class Manager {
private Integer id;
private String name;
private Integer sex;
private String number;
private String organ;
private String remark;
private Integer type;
private String credentialName;
private Date createTime;
private Date updateTime;
private String pic1Path;
private String pic2Path;
private String openId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number == null ? null : number.trim();
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ == null ? null : organ.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getCredentialName() {
return credentialName;
}
public void setCredentialName(String credentialName) {
this.credentialName = credentialName == null ? null : credentialName.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getPic1Path() {
return pic1Path;
}
public void setPic1Path(String pic1Path) {
this.pic1Path = pic1Path == null ? null : pic1Path.trim();
}
public String getPic2Path() {
return pic2Path;
}
public void setPic2Path(String pic2Path) {
this.pic2Path = pic2Path == null ? null : pic2Path.trim();
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId == null ? null : openId.trim();
}
@Override
public String toString() {
return "Manager{" +
"id=" + id +
", name='" + name + '\'' +
", sex=" + sex +
", number='" + number + '\'' +
", organ='" + organ + '\'' +
", remark='" + remark + '\'' +
", type=" + type +
", credentialName='" + credentialName + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", pic1Path='" + pic1Path + '\'' +
", pic2Path='" + pic2Path + '\'' +
", openId='" + openId + '\'' +
'}';
}
} | [
"690742338@qq.com"
] | 690742338@qq.com |
77197e923a6a725126d9d16d58214d58ef9e45c4 | 33fbbd23010cc7e19130b7afcd2b8905837dbcb8 | /src/main/java/com/example/demo/social/AppOAuth2UserRequestEntityConverter.java | a96b2646c8231cc004dfc9d49e711f4321de0320 | [] | no_license | wayne-keepo/oauth2twitch | a44c564530477ac888e2c4a7ec75e990c661f72c | bd3580e64282cac9c7efd1b4f4c35a93cc43ec80 | refs/heads/master | 2022-09-18T09:28:58.757120 | 2020-05-30T21:09:58 | 2020-05-30T21:09:58 | 268,139,401 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,557 | java | package com.example.demo.social;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;
import org.springframework.security.oauth2.core.AuthenticationMethod;
import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.util.Collections;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
public class AppOAuth2UserRequestEntityConverter implements Converter<OAuth2UserRequest, RequestEntity<?>> {
private static final MediaType DEFAULT_CONTENT_TYPE = MediaType.valueOf(APPLICATION_FORM_URLENCODED_VALUE + ";charset=UTF-8");
@Override
public RequestEntity<?> convert(OAuth2UserRequest userRequest) {
ClientRegistration clientRegistration = userRequest.getClientRegistration();
HttpMethod httpMethod = HttpMethod.GET;
if (AuthenticationMethod.FORM.equals(clientRegistration.getProviderDetails().getUserInfoEndpoint().getAuthenticationMethod())) {
httpMethod = HttpMethod.POST;
}
HttpHeaders headers = new HttpHeaders();
headers.add("Client-ID", userRequest.getClientRegistration().getClientId());
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
URI uri = UriComponentsBuilder.fromUriString(clientRegistration.getProviderDetails().getUserInfoEndpoint().getUri())
.build()
.toUri();
RequestEntity<?> request;
if (HttpMethod.POST.equals(httpMethod)) {
headers.setContentType(DEFAULT_CONTENT_TYPE);
MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>();
formParameters.add(OAuth2ParameterNames.ACCESS_TOKEN, userRequest.getAccessToken().getTokenValue());
request = new RequestEntity<>(formParameters, headers, httpMethod, uri);
} else {
headers.setBearerAuth(userRequest.getAccessToken().getTokenValue());
request = new RequestEntity<>(headers, httpMethod, uri);
}
return request;
}
}
| [
"dimapimushkin@mail.ru"
] | dimapimushkin@mail.ru |
ab75709d383c97554b2f93ee02ec996d7939839f | d64086f7881a6dd905a35e6efe6f7be79b7328c7 | /homework-3/src/test/java/ua/com/shtanko/h3/util/content/ContentCsvParserTest.java | 5dca69c9783e999d954d360340610853361d41bf | [] | no_license | SexWithCode/2020-11-otus-spring-shtanko | 164cf7f252350a3751f520fbebde8b337dda42be | c0e79b9b765daa278e24083287108254cfbae9a0 | refs/heads/master | 2023-03-10T15:55:43.462402 | 2021-02-27T02:37:49 | 2021-02-27T02:37:49 | 316,347,500 | 0 | 0 | null | 2020-12-01T08:51:49 | 2020-11-26T22:19:27 | null | UTF-8 | Java | false | false | 2,110 | java | package ua.com.shtanko.h3.util.content;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import ua.com.shtanko.h3.domain.Question;
import java.io.IOException;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
@SpringBootTest
@RunWith(SpringRunner.class)
public class ContentCsvParserTest {
final static Integer EXPECTED_QUESTIONS_COUNT = 5;
final static String EXPECTED_QUESTION_MESSAGE = "How much legs does a rat has?";
final static String CORRECT_ANSWER = "4";
final static String WRONG_ANSWER = "2";
final static String DATA = new StringBuilder()
.append("How much legs does a rat has?,4,6,2")
.append("\n")
.append("What's colour is rat's nose?,rose,black,white")
.append("\n")
.append("Does a rat has a fur?,yes,no,unsure")
.append("\n")
.append("What's an average rat's tail length in centimetres?,6,7,8")
.append("\n")
.append("Do you like rats?,yes,no,unsure")
.toString();
@Autowired
ContentCsvParser contentCsvParser;
@Test
public void shouldReturnExpectedQuestionsList() throws IOException {
List<Question> questions = contentCsvParser.parse(CSVParser.parse(DATA, CSVFormat.DEFAULT).getRecords());
assertThat(questions, is(notNullValue()));
assertThat(questions, hasSize(EXPECTED_QUESTIONS_COUNT));
assertThat(questions.get(0).getQuestionMessage(), is(EXPECTED_QUESTION_MESSAGE));
assertThat(questions.get(0).isValidAnswer(CORRECT_ANSWER), is(Boolean.TRUE));
assertThat(questions.get(0).isValidAnswer(WRONG_ANSWER), is(Boolean.FALSE));
}
}
| [
"sexwithcode@gmail.com"
] | sexwithcode@gmail.com |
033627c9131c2aafa4d0a01c87015079df3fc566 | 8a29a66a531f17520d437e1aae2bea299f50fc77 | /src/main/java/com/statreduce/reducer/AbstractStatReducer.java | 45d03863c769eaecb1c1e245a63d47bf88e8ce17 | [] | no_license | flipkart-incubator/statreduce | 39577ee30428fbfac3f9a69a3eae54f34c6f38a3 | 077d297f5e885209f76660837962d295e511e3da | refs/heads/master | 2023-03-29T06:01:11.560330 | 2015-05-18T17:11:06 | 2015-05-18T17:11:06 | 35,710,052 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,246 | java | package com.statreduce.reducer;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Reducer;
import org.ddahl.jvmr.RInJava;
import java.io.IOException;
public abstract class AbstractStatReducer<K extends Writable, V extends Writable> extends Reducer<K, V, K, V> {
RInJava R;
public AbstractStatReducer() {
R = new RInJava();
}
@Override
protected void setup(Context context) throws IOException, InterruptedException {
initializeRFunction();
}
@Override
protected void reduce(K key, Iterable<V> values, Context context) throws IOException, InterruptedException {
assignRInput(values);
invokeR();
context.write(key, (V) getROutputAsWritable());
}
private void initializeRFunction() {
R.eval(getRFunction());
}
private void assignRInput(Iterable<V> values) {
R.update(getInputVar(), getRInput(values));
}
protected abstract Object getRInput(Iterable<V> values);
private void invokeR() {
R.eval(getRFunctionCall());
}
private Writable getROutputAsWritable() {
if(getOutputType() == Double.class){
return new DoubleWritable((Double) getROutput());
} else if (getOutputType() == Integer.class) {
return new IntWritable((Integer) getROutput());
} else {
throw new IllegalArgumentException("Invalid output value type in StatReducer: " + getOutputType());
}
}
private Object getROutput() {
if(getOutputType() == Double.class){
return R.toPrimitiveDouble(getOutputVar());
} else if (getOutputType() == Integer.class){
return R.toPrimitiveInt(getOutputVar());
} else {
throw new IllegalArgumentException("Invalid output value type in StatReducer: " + getOutputType());
}
}
protected abstract String getInputVar();
protected abstract String getRFunction();
protected abstract String getRFunctionCall();
protected abstract String getOutputVar();
protected abstract Class getInputType();
protected abstract Class getOutputType();
}
| [
"sathish316@gmail.com"
] | sathish316@gmail.com |
6bedaf2d5bd5f45e901963cea8c2f2f36d2673cc | 89aa449b020d2f6ea00fdd8ea184fc3b470f16d5 | /src/AlgorithmAndDataStructureTests/LeetCode/Question118/ListNode.java | 2e8115ac42218526fbb4879f9ce5fec4b2d03e25 | [] | no_license | zoebbmm/CodeTests | 56ea2f9cc3cf6083b1baa2c2b0c4875309bc5e30 | 384edbd526558b38dc165bb4e0f22ad1f4d94456 | refs/heads/master | 2021-01-23T07:59:37.797605 | 2017-03-28T14:11:44 | 2017-03-28T14:11:44 | 86,468,094 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 223 | java | package AlgorithmAndDataStructureTests.LeetCode.Question118;
/**
* Created by weizhou on 10/31/16.
*/
public class ListNode {
int data;
ListNode next;
public ListNode(int d) {
this.data = d;
}
}
| [
"zoebbmm@gmail.com"
] | zoebbmm@gmail.com |
fcaee28453bc0d7a3a129bb151c08cb7f59e1e46 | 3989812aba4b8d012ace66592cff3b6c909526a0 | /HelloWorldADT/src/com/example/helloworldadt/dummy/DummyContent.java | fa11cef66a32404cba048ca900863039114c8fd9 | [] | no_license | kanastasov/Introduction-to-Programming-with-Java-Liang | dc36fc6d1112795f017fff3ec9313af1845c1d42 | aa79b83ea2195eab295eb809004dc7932a46ab84 | refs/heads/master | 2020-04-05T10:36:05.054851 | 2012-08-06T14:55:20 | 2012-08-06T14:55:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 929 | java | package com.example.helloworldadt.dummy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DummyContent {
public static class DummyItem {
public String id;
public String content;
public DummyItem(String id, String content) {
this.id = id;
this.content = content;
}
@Override
public String toString() {
return content;
}
}
public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
static {
addItem(new DummyItem("1", "Item 1"));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 3"));
}
private static void addItem(DummyItem item) {
ITEMS.add(item);
ITEM_MAP.put(item.id, item);
}
}
| [
"Anastasov@kAnastasov.(none)"
] | Anastasov@kAnastasov.(none) |
c1c1b56fdc32c20769cb159cb39cd649b1aefebe | 0a51fd796bac5dd19a4232e43360aca8a9d7024a | /StudentList.java | d3d38d07f35ec404e38d6403ede0317bc990e811 | [] | no_license | Bhargavikulkarni/Assignment | a8b778e49e739d8568b9cbc06b41c1e31d5c4fd3 | ea688b13e57ed6371da4388bff0bb2f77cfd2b1a | refs/heads/master | 2023-08-18T00:13:26.677995 | 2021-09-07T12:10:04 | 2021-09-07T12:10:04 | 397,523,718 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,130 | java | package CaseStudy;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;
public class StudentList {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int choice, n = 0;
while (true) {
System.out.println("01. Sort By ID");
System.out.println("02.Sort By Character ");
System.out.println("03.Sort By Name ");
System.out.println("04. Exit");
System.out.print("Enter Your Choice : ");
choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("Sorting By Id.....");
ArrayList<Student> studentarraylist = new ArrayList<Student>();
studentarraylist.add(new Student(1, "Sam", 25, 72));
studentarraylist.add(new Student(3, "Jack", 22, 78));
studentarraylist.add(new Student(2, "Alexa", 28, 90));
studentarraylist.add(new Student(5, "Kevin", 26, 56));
studentarraylist.add(new Student(4, "Max", 23, 76));
Collections.sort(studentarraylist);
for (Student studentbyid : studentarraylist) {
System.out.print(studentbyid.getStudent_id() + "\t" + " ");
System.out.print(studentbyid.getStudent_name() + "\t" + " ");
System.out.print(studentbyid.getStudent_age() + "\t" + " ");
System.out.print(studentbyid.getStudent_marks() + "\t" + "\n ");
}
break;
case 2:
System.out.println("Sorting By Student Character");
TreeSet<Student1> treeset = new TreeSet<Student1>(new SortByCharacter());
// ArrayList<Student1> arrayliststudent = new ArrayList<Student1>((Collection<?
// extends Student1>) new SortByCharacter());
treeset.add(new Student1(1, "Sam", "Polite"));
treeset.add(new Student1(3, "Jack", "Silent"));
treeset.add(new Student1(2, "Alexa", "Dedicated"));
treeset.add(new Student1(5, "Kevin", "Focused"));
treeset.add(new Student1(4, "Max", "Smart"));
for (Student1 student : treeset) {
System.out.println(student.getStudent_id());
System.out.println(student.getStudent_name());
System.out.println(student.getScharacter());
System.out.println("****************\n****************");
}
break;
case 3:
System.out.println("Sorting By Student Name");
TreeSet<Student> treeset1 = new TreeSet<Student>(new SortByName());
treeset1.add(new Student(1, "Sam", 25, 72));
treeset1.add(new Student(3, "Jack", 22, 78));
treeset1.add(new Student(2, "Alexa", 28, 90));
treeset1.add(new Student(5, "Kevin", 26, 56));
treeset1.add(new Student(4, "Max", 23, 76));
for (Student student : treeset1) {
System.out.println(student.getStudent_id());
System.out.println(student.getStudent_name());
System.out.println(student.student_age);
System.out.println(student.student_marks);
System.out.println("****************\n****************");
}
break;
case 4:
if (choice < 4) {
System.out.println(" Continue......");
} else {
System.out.println("Completed successfully...");
}
// System.exit(0);
// System.out.println("Completed successfully...");
}
}
}
} | [
"bhargavikulkarni44@gmail.com"
] | bhargavikulkarni44@gmail.com |
ef3cbbdb50e180176bb1a9573d768cd65875b70d | 41fc7b22371f95874accd41de79484d57b201341 | /src/main/java/com/app/server/model/MessageModel.java | b158b7b6971c737e32886f54ddb9cc87d8bb0386 | [] | no_license | xuwenkai357/Server | 9e60ddee7ff7c1f9844c6faee9b560a28d421c6d | e7947bcef0c013ce10cd6de8e2e278e933a0a4d5 | refs/heads/master | 2020-03-18T18:12:39.336191 | 2018-05-27T19:57:30 | 2018-05-27T19:57:30 | 135,077,344 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,278 | java | package com.app.server.model;
public class MessageModel {
String message_id;
String user_id;
String body;
String create_time;
String status;
public String getMessage_id() {
return message_id;
}
public void setMessage_id(String message_id) {
this.message_id = message_id;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "MessageModel{" +
"message_id='" + message_id + '\'' +
", user_id='" + user_id + '\'' +
", body='" + body + '\'' +
", create_time='" + create_time + '\'' +
", status='" + status + '\'' +
'}';
}
}
| [
"1002699636@qq.com"
] | 1002699636@qq.com |
5ed3efdcc1b65ea1509a484b297d12718991f6cf | b0f2249198ba35cfe7f5e3cebbe4413eef264f14 | /src/main/java/nd/esp/service/lifecycle/support/busi/SessionUtil.java | 7632151b89287e005e0d7d040366552e8416bb8f | [] | no_license | 434480761/wisdom_knowledge | f5f520cfb07685fd97d2d1a5970630a00b1fc69f | 1ee22a3536c1247f7b78f6815befbd104670119b | refs/heads/master | 2021-04-28T23:39:24.844625 | 2017-01-05T06:26:29 | 2017-01-05T06:26:29 | 77,729,017 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 4,365 | java | package nd.esp.service.lifecycle.support.busi;
import com.nd.gaea.client.http.WafSecurityHttpClient;
import nd.esp.service.lifecycle.support.Constant;
import nd.esp.service.lifecycle.support.Constant.CSInstanceInfo;
import nd.esp.service.lifecycle.utils.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class SessionUtil {
private static Map<String,Map<String,Object>> cacheSessions = new HashMap<String,Map<String,Object>>();
//默认创建session的用户id
public final static String DEAFULT_SESSION_USERID="777";
/**
* 调用cs接口获取session
*
* @param uid 用户id
*
* @return session id
*/
public static String createSession(String uid) {
return SessionUtil.createSession(uid, Constant.CS_INSTANCE_MAP.get(Constant.CS_DEFAULT_INSTANCE).getUrl(),
Constant.CS_INSTANCE_MAP.get(Constant.CS_DEFAULT_INSTANCE).getPath(),
Constant.CS_INSTANCE_MAP.get(Constant.CS_DEFAULT_INSTANCE).getServiceId());
}
/**
* 调用cs接口获取session
*
* @param uid 用户id
* @param url 获取session的api
* @param path 请求session的作用path
* @param serviceId 服务id
*
*/
public static String createSession(String uid, String url, String path, String serviceId) {
if (cacheSessions.containsKey(uid + "@" + serviceId + path)) {
Map<String, Object> sessionBefore = cacheSessions.get(uid + "@" + serviceId + path);
long expireTime = Long.parseLong(String.valueOf(sessionBefore.get("expire_at")));
if (expireTime - System.currentTimeMillis() > 6000000) {
return String.valueOf(sessionBefore.get("session"));
}
}
Map<String, Object> requestBody = new HashMap<String, Object>();
requestBody.put("path", path);
requestBody.put("service_id", serviceId);
requestBody.put("uid",uid);
requestBody.put("role",Constant.FILE_OPERATION_ROLE);
requestBody.put("expires",Constant.FILE_OPERATION_EXPIRETIME);
WafSecurityHttpClient wafSecurityHttpClient = new WafSecurityHttpClient(Constant.WAF_CLIENT_RETRY_COUNT);
url = url + "/sessions";
Map<String, Object> session = wafSecurityHttpClient.postForObject( url, requestBody, Map.class);
cacheSessions.put(uid+"@"+serviceId+path, session);
return String.valueOf(session.get("session"));
}
/**
* @desc: 获取session
* @createtime: 2015年6月25日
* @author: liuwx
* @param uid
* @param instanceInfo
* @return
*/
public static String createSession(String uid,CSInstanceInfo instanceInfo){
return SessionUtil.createSession(uid,
instanceInfo.getUrl(),
instanceInfo.getPath(),
instanceInfo.getServiceId());
}
/**
* @desc: 获取session uid使用默认值
* @createtime: 2015年6月25日
* @author: liuwx
* @param instanceInfo
* @return
*/
public static String createSession(CSInstanceInfo instanceInfo){
return createSession(DEAFULT_SESSION_USERID, instanceInfo);
}
/**
* @desc:获取Href中对应的cs实例key ${ref-path}/edu
* @createtime: 2015年6月25日
* @author: liuwx
* @param href
* @see Constant.CSInstanceInfo
* @see Constant#CS_INSTANCE_MAP
* @return
*/
public static String getHrefInstanceKey(String href){
if(StringUtils.isEmpty(href)){
throw new IllegalArgumentException("href必须不为空");
}
if(href.indexOf("/") < 0){
throw new IllegalArgumentException("href格式不对");
}
int secondSlash = href.indexOf("/", href.indexOf("/")+1);
return href.substring(0, secondSlash);
}
public static void main(String[] args) {
String s="${ref-path}/edu/esp/coursewares/4108bde5-470d-404e-a252-29d915dce254.pkg/main.xml";
System.out.println(s.substring(0,s.indexOf("/", s.indexOf("/")+1)));
System.out.println(s.indexOf("/", s.indexOf("/")+1));
System.out.println(getHrefInstanceKey(s));
}
}
| [
"901112@nd.com"
] | 901112@nd.com |
07386fc3c7a059b3fc7a9b0d1143253e8053c079 | 93dec8516dd1f5f4c40012593577b8f4c249a173 | /MyApp2/app/src/androidTest/java/com/example/gilbertojimenezorench/myapp/ApplicationTest.java | 282bea8d19b273eca3d9c50490e3d4f1a0ebafb1 | [] | no_license | LuisSalaOrtiz/DB-DrScanner_Project | b57897305630f08f1f238e34e0fa112955ba71ca | 8e276d2896271e7df4094e82922bde6374e165bf | refs/heads/master | 2020-12-03T00:47:56.831751 | 2016-12-13T03:57:33 | 2016-12-13T03:57:33 | 67,749,791 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 370 | java | package com.example.gilbertojimenezorench.myapp;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"albertitoclick@hotmail.com"
] | albertitoclick@hotmail.com |
d0f7f518e1c59bb7eaf5d977703f42746c75bff7 | 6b45b9ba5dadbe18364305e03363fcfbac853685 | /AddressBook.java | c0f1c48066288e47885fa5c6886733d9f2f8bdb1 | [] | no_license | deepsaha288/AddressBook2List | 609c2766d26c8e8369629ff8c01435000421f4d0 | 6fc4163a0bf5f7311acb882833349e7831ea6df9 | refs/heads/main | 2023-03-18T19:18:08.354606 | 2021-03-10T14:51:33 | 2021-03-10T14:51:33 | 346,378,918 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,544 | java | import java.util.*;
class ContactDetails {
private String firstName;
private String lastName;
private String area;
private String city;
private String state;
private int pin;
private int phoneNumber;
private String email;
public ContactDetails(String firstName, String lastName, String area, String city, String state, int pin,
int phoneNumber, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.area = area;
this.city = city;
this.state = state;
this.pin = pin;
this.phoneNumber = phoneNumber;
this.email = email;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String fname) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lname) {
this.lastName = lastName;
}
public String getArea() {
return this.area;
}
public void setArea(String ar) {
this.area = area;
}
public String getCity() {
return this.city;
}
public void setCity(String cty) {
this.city = city;
}
public String getState() {
return this.state;
}
public void setState(String st) {
this.state = state;
}
public int getpin() {
return this.pin;
}
public void setpin(int pn) {
this.pin = pin;
}
public int getPhoneNumber() {
return this.phoneNumber;
}
public void setPhoneNumber(int phn) {
this.phoneNumber = phoneNumber;
}
public String getEmail() {
return this.email;
}
public void setEmail(String eml) {
this.email = email;
}
public String toString() {
return "Details of: " + firstName + " " + lastName + "\n" + "Area: " + area + "\n" + "City: " + city + "\n"
+ "State: " + state + "\n" + "Pin: " + pin + "\n" + "Phone Number: " + phoneNumber + "\n" + "Email: "
+ email;
}
public void setPin(int nextInt) {
}
}
class AddressBookDetails {
public String addressBookName;
public String firstName;
public String lastName;
public String area, city, state, email;
public int pin, phoneNumber;
public static int indexNum;
public AddressBookDetails(String addressBookName) {
this.addressBookName = addressBookName;
}
public static ArrayList<ContactDetails> list = new ArrayList<ContactDetails>();
public Scanner sc = new Scanner(System.in);
public boolean checkName() {
System.out.println("Enter First Name");
firstName = sc.next();
System.out.println("Enter Last Name");
lastName = sc.next();
for (indexNum = 0; indexNum < list.size(); indexNum++) {
if (firstName.equals(list.get(indexNum).getFirstName())
&& lastName.equals(list.get(indexNum).getLastName())) {
System.out.println("Contact Name Exists");
return true;
}
}
return false;
}
public void addDetails() {
if (!checkName()) {
System.out.println("Enter Area");
area = sc.next();
System.out.println("Enter CityName");
city = sc.next();
System.out.println("Enter StateName");
state = sc.next();
System.out.println("Enter PinCode");
pin = sc.nextInt();
System.out.println("Enter PhoneNumber");
phoneNumber = sc.nextInt();
System.out.println("Enter Email");
email = sc.next();
}
list.add(new ContactDetails(firstName, lastName, area, city, state, pin, phoneNumber, email));
}
public String editDetails() {
Scanner sc = new Scanner(System.in);
System.out.println("Details to be Edited: ");
if (checkName()) {
System.out.println("Enter FirstName");
list.get(indexNum).setFirstName(sc.next());
System.out.println("Enter LastName");
list.get(indexNum).setLastName(sc.next());
System.out.println("Enter Area");
list.get(indexNum).setArea(sc.next());
System.out.println("Enter CityName");
list.get(indexNum).setCity(sc.next());
System.out.println("Enter StateName");
list.get(indexNum).setState(sc.next());
System.out.println("Enter pinCode");
list.get(indexNum).setpin(sc.nextInt());
System.out.println("Enter PhoneNumber");
list.get(indexNum).setPhoneNumber(sc.nextInt());
System.out.println("Enter Email");
list.get(indexNum).setEmail(sc.next());
return "Edited";
}
return "Name Not Available in List";
}
public String deleteDetails() {
System.out.print("Details to be Deleted");
if (checkName()) {
list.remove(indexNum);
return "Deleted";
}
return "Name Not Available in List";
}
public void displayDetails() {
for (int i = 0; i < list.size(); i++) {
System.out.println();
System.out.println(list.get(i));
}
}
@Override
public String toString() {
return addressBookName;
}
}
public class AddressBook {
private static int bookNumber = 0;
private static String firstName;
private static String lastName;
private static String area;
private static String city;
private static String state;
private static int pin;
private static int phoneNumber;
private static String email;
public static Scanner sc = new Scanner(System.in);
public static Map<String, String> dictionaryCity = new HashMap<>();
public static Map<String, String> dictionaryState = new HashMap<>();
public static ArrayList<AddressBookDetails> addressBook = new ArrayList<>();
public static void addAdressBookDetails() {
System.out.println("Enter Name of Address Book");
String name = sc.next();
addressBook.add(new AddressBookDetails(name));
}
public static void pickAddressBook() {
System.out.println("You are Currently in " + addressBook.get(bookNumber) + " AddressBook");
if (addressBook.size() > 1) {
for (int i = 0; i < addressBook.size(); i++)
System.out.println(i + ". " + addressBook.get(i));
System.out.println("Pick Address Book Number");
bookNumber = Integer.parseInt(sc.next());
}
}
public static void personByState() {
System.out.println("Enter State Name");
state = sc.next();
for (int i = 0; i < addressBook.size(); i++)
for (int j = 0; j < addressBook.get(i).list.size(); j++)
if (addressBook.get(i).list.get(j).getState().equals(state))
System.out.println(addressBook.get(i).list.get(j));
}
public static void personByCity() {
System.out.println("Enter City Name");
city = sc.next();
for (int i = 0; i < addressBook.size(); i++)
for (int j = 0; j < addressBook.get(i).list.size(); j++)
if (addressBook.get(i).list.get(j).getCity().equals(city))
System.out.println(addressBook.get(i).list.get(j));
}
private static void cityPersonDict() {
for (AddressBookDetails address : addressBook)
for (ContactDetails contact : address.list) {
String name = contact.getFirstName() + " " + contact.getLastName();
dictionaryCity.put(name, contact.getCity());
}
System.out.println("Enter City");
city = sc.next();
for (Map.Entry<String, String> ls : dictionaryCity.entrySet())
if (city.equals(ls.getValue()))
System.out.println("Name " + ls.getKey());
}
private static void statePersonDict() {
for (AddressBookDetails address : addressBook)
for (ContactDetails contact : address.list) {
String name = contact.getFirstName() + " " + contact.getLastName();
dictionaryCity.put(name, contact.getState());
}
System.out.println("Enter State");
state = sc.next();
for (Map.Entry<String, String> ls : dictionaryCity.entrySet())
if (state.equals(ls.getValue()))
System.out.println("Name " + ls.getKey());
}
public static void option() {
Scanner sc = new Scanner(System.in);
String check = "Y";
while ((check.equals("Y")) || (check.equals("y"))) {
System.out.println("Choose Below Option");
System.out.println("1: Add Contact");
System.out.println("2: Edit Contact");
System.out.println("3: Delete Contact");
System.out.println("4: Display Contact");
System.out.println("5: Exit");
String choose = sc.next();
switch (choose) {
case "1":
addressBook.get(bookNumber).addDetails();
break;
case "2":
pickAddressBook();
System.out.println(addressBook.get(bookNumber).editDetails());
break;
case "3":
pickAddressBook();
System.out.println(addressBook.get(bookNumber).deleteDetails());
break;
case "4":
pickAddressBook();
addressBook.get(bookNumber).displayDetails();
break;
default:
System.out.println("Exit");
System.out.println("Want to Make More Changes in This Address Book? (y/n)");
check = sc.next();
}
}
}
public static void search() {
System.out.println("Choose Option");
System.out.println("1: By City Name");
System.out.println("2: By State Name");
System.out.println("3: View Person in City");
System.out.println("4: View Person in State");
String choose = sc.next();
switch (choose) {
case "1":
personByCity();
break;
case "2":
personByState();
break;
case "3":
cityPersonDict();
break;
case "4":
statePersonDict();
break;
default:
System.out.println("Wrong Input");
}
}
public static void main(String[] args) {
System.out.println("Welcome to Address Book Program");
String check = "Y";
while ((check.equals("Y")) || (check.equals("y"))) {
addAdressBookDetails();
option();
System.out.println("Do You Want to Search Contacts By Certain Details Like by City, State, etc?");
System.out.println("Do You Want to Search or View Contacts By Certain Details Like by City, State, etc?");
System.out.println("Press y if You Want to Search");
String num = sc.next();
if (num.equals("Y") || num.equals("y")) {
search();
} else {
System.out.println("You Can Proceed Further");
}
System.out.println("Want to Add More Address Book (y/n)");
check = sc.next();
}
}
}
| [
"deepsaha288@yahoo.com"
] | deepsaha288@yahoo.com |
47c7e5c87b4109dda6b7101a640a66fe43a800ae | 909c051d5ffc94b0a15e982c5e31779335595399 | /src/main/java/nikdevs/motifs/webui/formatter/AlgorithmTypeFormatter.java | 19e6e19ab93c6361f189aa9606f5d598a1b346b1 | [] | no_license | danyzhukov/MotifApp | e13519333203dfeb2d3a18fb951277e49458df6c | 7676c45f6203845d76ab1de63a0c4e9a73e66c6c | refs/heads/master | 2022-07-08T07:06:38.137447 | 2020-05-17T11:52:44 | 2020-05-17T11:52:44 | 264,652,642 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 761 | java | package nikdevs.motifs.webui.formatter;
import nikdevs.motifs.webui.model.AlgorithmType;
import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.util.Locale;
/**
* Formatter ENUM AlgorithmType
*/
@Component
public class AlgorithmTypeFormatter implements Formatter<AlgorithmType> {
@Override
public AlgorithmType parse(String s, Locale locale) throws ParseException {
for (AlgorithmType at : AlgorithmType.values()) {
if (at.toString().equals(s))
return at;
}
return null;
}
@Override
public String print(AlgorithmType algorithmType, Locale locale) {
return algorithmType.toString();
}
}
| [
"danil2010z@yandex.ru"
] | danil2010z@yandex.ru |
078218b4f312c65c8c33663f1707aa54fbaa0a02 | c62536326421297c8701d33e973ece005db5bd47 | /app/src/androidTest/java/br/com/alura/leilao/ExampleInstrumentedTest.java | e28a08ce328bfe814981ac2df67bfb3621be2f04 | [] | no_license | guireino/Leilao-teste-automatizado | 621362a23696aef955c5f1ed5d6bd7c091b6dcb1 | ec3d6ef9655b98cee0f77a90af8118c12525cba0 | refs/heads/master | 2022-12-12T10:05:05.615338 | 2020-09-11T21:21:21 | 2020-09-11T21:21:21 | 294,811,920 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,217 | java | package br.com.alura.leilao;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.Arrays;
import br.com.alura.leilao.model.Leilao;
import br.com.alura.leilao.ui.recyclerview.adapter.ListaLeilaoAdapter;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
ListaLeilaoAdapter adapter = new ListaLeilaoAdapter(appContext);
adapter.atualiza(new ArrayList<>(Arrays.asList(new Leilao("Console"), new Leilao("Computador"))));
int quantidadeLeiloes = adapter.getItemCount();
assertThat(quantidadeLeiloes, is(2));
assertEquals("br.com.alura.leilao", appContext.getPackageName());
}
}
| [
"guiabucarma@hotmail.com"
] | guiabucarma@hotmail.com |
0fe50f2eed823ded8c1deb277a33b9e96c31590f | 6d4f2dd2617ebd478720730ba1394262328e95c8 | /src/com/smartstart/util/ChatServer.java | 3d02d78fa2ddac87a357b9dbc4831a2397d210db | [] | no_license | MohamedSouissi/smartstart | 65f794fbe59457b77c0251f6f9b9cdfe64b9dec8 | 412009477002e1a755b5aeb4328cf606feef38f0 | refs/heads/master | 2020-04-25T22:33:01.881257 | 2019-02-28T12:19:36 | 2019-02-28T12:19:36 | 173,114,795 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,915 | java | package com.smartstart.util;
import com.smartstart.controllers.ServerGUIController;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class ChatServer extends Application {
private Stage primaryStage;
private VBox serverLayout;
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Server Chat");
initServerLayout();
}
private void initServerLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
System.out.println(getClass().getResource("/com/smartstart/gui/ServerGUI.fxml"));
loader.setLocation(getClass().getResource("/com/smartstart/gui/ServerGUI.fxml"));
ServerGUIController serverController = new ServerGUIController();
loader.setController(serverController);
serverLayout = (VBox) loader.load();
Scene scene = new Scene(serverLayout);
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
// We need to eliminate the Server Threads
// If the User decides to close it.
if (serverController.server != null) {
serverController.server.stop();
serverController.server = null;
}
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
| [
"gentil-22@hotmail.fr"
] | gentil-22@hotmail.fr |
c227bda93acede6d7a4907496706d67e0604d19b | 61ddee6130f6e1c96c05347ecdb14b75bd8803f8 | /src/com/serlib/entity/Project.java | d16effc57cc1696643d12eb23f4307226928464f | [] | no_license | sunxu/serlib | 49cd84161be65c456f4b1adc9ccc3a34fd1ed306 | da941abdb71adc3958d9782aac211897b8cd2aba | refs/heads/master | 2020-06-07T18:17:33.824033 | 2012-11-11T07:46:16 | 2012-11-11T07:46:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,889 | java | package com.serlib.entity;
/**
* Project entity. @author MyEclipse Persistence Tools
*/
public class Project implements java.io.Serializable {
private static final long serialVersionUID = -8235418176617142247L;
public static final String ID = "id";
public static final String NAME = "name";
public static final String HOME = "home";
public static final String COMPANY = "company";
public static final String DETAIL = "detail";
public static final String LICENSE = "license";
public static final String LICENSEID = "licenseId";
public static final String ADDTIME = "addtime";
public static final String DELTIME = "deltime";
public static final String STATUS = "status";
// Fields
private Integer id;
private String name;
private String home;
private String company;
private String detail;
private String license;
private Integer licenseId;
private Integer addtime;
private Integer deltime;
private Boolean status;
// Constructors
/** default constructor */
public Project() {
}
/** minimal constructor */
public Project(String name, String home, Integer addtime, Boolean status) {
this.name = name;
this.home = home;
this.addtime = addtime;
this.status = status;
}
/** full constructor */
public Project(String name, String home, String company, String detail,
String license, Integer licenseId, Integer addtime,
Integer deltime, Boolean status) {
this.name = name;
this.home = home;
this.company = company;
this.detail = detail;
this.license = license;
this.licenseId = licenseId;
this.addtime = addtime;
this.deltime = deltime;
this.status = status;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getHome() {
return this.home;
}
public void setHome(String home) {
this.home = home;
}
public String getCompany() {
return this.company;
}
public void setCompany(String company) {
this.company = company;
}
public String getDetail() {
return this.detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String getLicense() {
return this.license;
}
public void setLicense(String license) {
this.license = license;
}
public Integer getLicenseId() {
return this.licenseId;
}
public void setLicenseId(Integer licenseId) {
this.licenseId = licenseId;
}
public Integer getAddtime() {
return this.addtime;
}
public void setAddtime(Integer addtime) {
this.addtime = addtime;
}
public Integer getDeltime() {
return this.deltime;
}
public void setDeltime(Integer deltime) {
this.deltime = deltime;
}
public Boolean getStatus() {
return this.status;
}
public void setStatus(Boolean status) {
this.status = status;
}
} | [
"sunxu@MacBook.local"
] | sunxu@MacBook.local |
beadc5d12c07a0f31c1cdd8b34cafcf54ed305e0 | 5ba7de903a2753f00a2e0551237f644f64ce8d71 | /TP4-EMF/fr.tpt.mem4csd.dag.model/src/fr/tpt/mem4csd/dag/model/dag/NamedElement.java | 76c954d1a7ea45262caf655a9d74a0dae054fe69 | [] | no_license | Renan-r1212/SE206_TP | fae7aff0c7d4fcb5bc3f1a6fe5ac00ea779f9746 | 4343520804ae5e0c063557a1f65d0cf6db9b52c9 | refs/heads/master | 2021-01-05T04:43:37.163810 | 2020-04-21T15:55:49 | 2020-04-21T15:55:49 | 240,883,389 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,393 | java | /**
*/
package fr.tpt.mem4csd.dag.model.dag;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Named Element</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link fr.tpt.mem4csd.dag.model.dag.NamedElement#getName <em>Name</em>}</li>
* </ul>
*
* @see fr.tpt.mem4csd.dag.model.dag.DagPackage#getNamedElement()
* @model abstract="true"
* @generated
*/
public interface NamedElement extends EObject {
/**
* Returns the value of the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Name</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see fr.tpt.mem4csd.dag.model.dag.DagPackage#getNamedElement_Name()
* @model required="true"
* @generated
*/
String getName();
/**
* Sets the value of the '{@link fr.tpt.mem4csd.dag.model.dag.NamedElement#getName <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Name</em>' attribute.
* @see #getName()
* @generated
*/
void setName(String value);
} // NamedElement
| [
"renan.rodrigues.r1212@gmail.com"
] | renan.rodrigues.r1212@gmail.com |
721d6ae95c71a07bb56552ecc178814e019c6c2f | 78659f07e348174c71bda8af5febc4d1f7fda8cc | /src/com/techzhai/dao/ArticleDao.java | cfc9c92ab9b537a444e2949ef9beec8428e12a88 | [] | no_license | TaXueWWL/Technology_Zhai_Blog | 28f2f144d38f4c6f74f75978a4b52cccdf7e173f | 2be200618b5e50a78b50fa33f2f531d8d25621cf | refs/heads/master | 2020-04-03T07:50:24.290426 | 2016-07-04T02:43:21 | 2016-07-04T02:43:21 | 62,435,456 | 2 | 0 | null | 2016-07-02T05:26:48 | 2016-07-02T05:26:48 | null | UTF-8 | Java | false | false | 716 | java | package com.techzhai.dao;
import java.util.List;
import com.techzhai.model.ArticleBean;
/**
* 文章部分处理的dao
* @author duanjigui
* 2016.6.30
*/
public interface ArticleDao {
public void saveArticle(ArticleBean articleBean); //保存一篇文章
public List<ArticleBean> fetchAllArticle(); //获取所有文章的列表
public void deletArticle(ArticleBean articleBean); //删除指定的文章
public void modifyArticle(ArticleBean articleBean); //修改指定文章
public ArticleBean fetchArticleById(int articleId); //根据文章id查看文章信息
public List<ArticleBean> fetchArticelistByTypeId(int type_id); //通过文章类型id获取对应类型下所有文章
}
| [
"1210812591@qq.com"
] | 1210812591@qq.com |
efbc98b040efbb40c8b4787f39bcfa0cac2cbc11 | a68797db21c01bbc8370308dbaaaedc15a445638 | /src/main/java/net/novatech/jbserver/world/WorldException.java | 1d36436a032cda644672a6281c03f93d75ddb604 | [] | no_license | BroPro40/JBServer | 8068eb6cc7680bf0af3719ce143ee16f0a2cd6a7 | 5594141e38ff0c1642fc179a4591d3862feb9336 | refs/heads/master | 2023-05-24T03:22:27.601054 | 2021-06-15T21:10:16 | 2021-06-15T21:10:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 225 | java | package net.novatech.jbserver.world;
import net.novatech.jbserver.server.ServerException;
public class WorldException extends ServerException {
public WorldException(String message) {
super(message);
}
} | [
"gebab.urumci.kv@gmail.com"
] | gebab.urumci.kv@gmail.com |
72bd03629f61a0708603972fe9f3b9b9ad0c662f | 3370a0d2a9e3c73340b895de3566f6e32aa3ca4a | /alwin-middleware-grapescode/alwin-core/src/main/java/com/codersteam/alwin/core/service/impl/scheduler/strategy/UpdateCompaniesInvolvementSchedulerExecution.java | 1aacb9fba134e2a4d785049e4a922e9438972548 | [] | no_license | Wilczek01/alwin-projects | 8af8e14601bd826b2ec7b3a4ce31a7d0f522b803 | 17cebb64f445206320fed40c3281c99949c47ca3 | refs/heads/master | 2023-01-11T16:37:59.535951 | 2020-03-24T09:01:01 | 2020-03-24T09:01:01 | 249,659,398 | 0 | 0 | null | 2023-01-07T16:18:14 | 2020-03-24T09:02:28 | Java | UTF-8 | Java | false | false | 1,487 | java | package com.codersteam.alwin.core.service.impl.scheduler.strategy;
import com.codersteam.alwin.common.scheduler.SchedulerTaskType;
import com.codersteam.alwin.core.api.service.scheduler.SchedulerExecutionInfoService;
import com.codersteam.alwin.core.service.impl.customer.UpdateCompaniesInvolvementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
/**
* Zadanie cykliczne uaktualnienia zaangażowania firm z otwartym zleceniem windykacyjnym
*
* @author Michal Horowic
*/
public class UpdateCompaniesInvolvementSchedulerExecution extends SchedulerExecution {
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final String DESCRIPTION = "Update company involvement";
private final UpdateCompaniesInvolvementService involvementService;
public UpdateCompaniesInvolvementSchedulerExecution(final SchedulerExecutionInfoService schedulerExecutionService, final UpdateCompaniesInvolvementService involvementService) {
super(schedulerExecutionService, SchedulerTaskType.UPDATE_COMPANIES_INVOLVEMENT);
this.involvementService = involvementService;
}
@Override
protected void executeScheduler() {
involvementService.updateCompaniesInvolvement();
}
@Override
protected Logger getLogger() {
return LOG;
}
@Override
protected String getDescription() {
return DESCRIPTION;
}
}
| [
"grogus@ad.aliorleasing.pl"
] | grogus@ad.aliorleasing.pl |
0762b98514e16bd3a6ee9e223323b1f9044a9fbd | 9231c90ff6e5dfc7a7c8a28104d7e20e40b22c0f | /OOP4/src/ui/GraphicsListing.java | 67785b81a6f141167516f52427ddacc28bb4b995 | [] | no_license | jojojames/Java | 21448c457431990372057ee065aac1c0705298dd | 38d353da0abbffd1774a83afccf527f4d384e182 | refs/heads/master | 2021-01-22T01:28:10.490197 | 2013-09-22T03:27:06 | 2013-09-22T03:27:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 27,862 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ui;
import business.Item;
import business.Order;
import business.Supplier;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JList;
/**
*
* @author james
*/
@SuppressWarnings("serial")
public class GraphicsListing extends javax.swing.JFrame {
/**
* Creates new form GraphicsListing
*/
public GraphicsListing() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
computerOutput = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
listOfSupplies__ = new javax.swing.JList();
jScrollPane3 = new javax.swing.JScrollPane();
supplierListing__ = new javax.swing.JList();
exitButton = new javax.swing.JButton();
jScrollPane4 = new javax.swing.JScrollPane();
orderListing__ = new javax.swing.JList();
selectSupplierButton = new javax.swing.JButton();
removeSupplierButton = new javax.swing.JButton();
addSupplyButton = new javax.swing.JButton();
finishOrderButton = new javax.swing.JButton();
removeSupplyButton = new javax.swing.JButton();
totalLabel = new javax.swing.JLabel();
totalTextField = new javax.swing.JTextField();
jScrollPane5 = new javax.swing.JScrollPane();
quantityList__ = new javax.swing.JList();
dateLabel = new javax.swing.JLabel();
dateTextField = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
deliverButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
computerOutput.setColumns(20);
computerOutput.setRows(5);
jScrollPane1.setViewportView(computerOutput);
jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Supplies"));
jScrollPane2.setViewportView(listOfSupplies__);
jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Supplier"));
jScrollPane3.setViewportView(supplierListing__);
exitButton.setText("Exit");
exitButton.setToolTipText("");
exitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitButtonActionPerformed(evt);
}
});
jScrollPane4.setBorder(javax.swing.BorderFactory.createTitledBorder("Order"));
jScrollPane4.setViewportView(orderListing__);
selectSupplierButton.setText("Select Supplier");
removeSupplierButton.setText("Remove Supplier");
addSupplyButton.setText("Add Supply");
finishOrderButton.setText("Finish Order");
removeSupplyButton.setText("Remove Supply");
totalLabel.setText("Total:");
jScrollPane5.setBorder(javax.swing.BorderFactory.createTitledBorder("Quantity"));
jScrollPane5.setViewportView(quantityList__);
dateLabel.setText("Date:");
jLabel1.setText("James Nguyen");
deliverButton.setText("Deliver");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 397, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane1)
.add(layout.createSequentialGroup()
.add(6, 6, 6)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(exitButton))
.add(layout.createSequentialGroup()
.add(selectSupplierButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(removeSupplierButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(addSupplyButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(removeSupplyButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(finishOrderButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(deliverButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(dateLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(dateTextField)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(totalLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(totalTextField)))))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane2)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
.add(jScrollPane4)
.add(jScrollPane5))
.add(11, 11, 11)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(selectSupplierButton)
.add(removeSupplierButton)
.add(addSupplyButton)
.add(finishOrderButton)
.add(removeSupplyButton)
.add(totalLabel)
.add(totalTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(dateLabel)
.add(dateTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(deliverButton))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 97, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(exitButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
// Exit the application
System.exit(0);
}//GEN-LAST:event_exitButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) throws FileNotFoundException, IOException {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GraphicsListing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GraphicsListing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GraphicsListing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GraphicsListing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
// The object that controls all input/output.
final GraphicsListing Listing = new GraphicsListing();
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
//new GraphicsListing().setVisible(true);
Listing.setVisible(true);
}
});
Listing.startListing();
Listing.outPut_PromptUser();
}
String userCurrentInput;
ArrayList<Supplier> listSuppliers; // the list of suppliers, only one is created in the driver
Scanner userInputGetter; // scanner for user input
boolean supplierLocked;
/* Set the program Listing up as well as set the list models. */
void startListing() {
supplierLocked = false; // let the user poke around before settling in on a supplier
userCurrentInput = new String();
userInputGetter = new Scanner(System.in);
listSuppliers = new ArrayList<>();
Supplier firstSupplier = new Supplier("J"); // list two suppliers in this program
Supplier secondSupplier = new Supplier("Extra"); // ideally, open up a list of suppliers from a file
listSuppliers.add(firstSupplier);
listSuppliers.add(secondSupplier);
DefaultListModel listModel;
listModel = new DefaultListModel();
listModel.addElement("J");
listModel.addElement("Extra");
supplierListing__.setModel(listModel);
listOfSupplies__.setModel(new DefaultListModel());
orderListing__.setModel(new DefaultListModel());
quantityList__.setModel(new DefaultListModel());
computerOutput.setEditable(false); // user can't edit text area
}
/* Users get to make a choice between selecting a supplier and entering the supplier by name.
* If there is an input, print the contents of the supplier picked to the right pane in the JList.*/
public void gui_createListenersForSupplierChoice() {
createMouseSelect();
createSelectSupplierButton();
createRemoveSupplierButton();
createAddSupplyButton();
createRemoveSupplyButton();
createFinishOrderButton();
createDeliverButton();
}
public void createMouseSelect() {
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 1 && !supplierLocked) {
userCurrentInput = (String) supplierListing__.getSelectedValue();
outPut_printSuppliesToScreen(getSupplier());
}
}
};
this.supplierListing__.addMouseListener(mouseListener);
}
public void createSelectSupplierButton() {
this.selectSupplierButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// supplier list becomes locked when this button is clicked
if(!supplierLocked) {
supplierLocked = !supplierLocked;
}
outPut_PickingSupplies();
printOldOrders(getSupplier());
}
});
}
public void createRemoveSupplierButton() {
this.removeSupplierButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!listSuppliers.isEmpty() && !supplierLocked) {
int selectedIndex = supplierListing__.getSelectedIndex();
removeFromList(supplierListing__); // remove the supplier from list
clearAllInLists(listOfSupplies__); // clear the supplies list
listSuppliers.remove(selectedIndex); // remove from array
}
}
});
}
public void createAddSupplyButton() {
this.addSupplyButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!supplierLocked) {
return; // if not locked, order hasn't started yet, so can't add anything
}
addingElementToOrder(orderListing__, listOfSupplies__.getSelectedValue());
}
});
}
public void createRemoveSupplyButton() {
this.removeSupplyButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!supplierLocked) {
return; // if not locked, can't remove anything from something that hasn't happened yet
}
removeFromList(orderListing__); // remove it from the order list
}
});
}
public void createFinishOrderButton() {
this.finishOrderButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!supplierLocked) {
return;
}
Order newOrder = new Order(); // Create a new order.
DefaultListModel quanModel = (DefaultListModel) quantityList__.getModel();
for(int i=0; i<orderListing__.getModel().getSize(); i++) {
Item oneOrderedItem = getItemFromOrderList(orderListing__, i);
int quantity = Integer.valueOf(quanModel.getElementAt(i).toString());
newOrder.addItem(oneOrderedItem, quantity);
}
newOrder.recordDate(setDate()); // record and set the date
getSupplier().addOrderToBrain(newOrder);
totalTextField.setText("" + newOrder.getTotalPrice() + ".00 $$"); // set the total price in price label
appendCompleteOrder(getSupplier(), newOrder);
saveToFile(getSupplier());
}
});
}
public void createDeliverButton() {
this.deliverButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!supplierLocked) {
return;
}
int indexOrder = getSupplier().callBrainToGetOrders().size()-1;
Order deliveredOrder = getSupplier().callBrainToGetOrders().get(indexOrder);
deliveredOrder.checkOrderDelivered();
computerOutput.setText("Your order has been delivered on and received 3 days after " + dateTextField.getText() + ".");
}
});
}
public String setDate() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
// get the current date and time with Date()
Date date = new Date();
String currentDate = dateFormat.format(date);
this.dateTextField.setText(currentDate);
return currentDate;
}
/* Using the string from order list, find the item id and use that to get the actual item.
* Return that item so it can be added to the order. */
public Item getItemFromOrderList(JList list, int index) {
ArrayList<Item> itemsFromSupplier = getSupplier().getItemsInInventory();
DefaultListModel model = (DefaultListModel) list.getModel();
String longString = model.get(index).toString();
int positionOfSpace = longString.indexOf(' ');
String itemId = longString.substring(0, positionOfSpace);
for(int i=0; i<itemsFromSupplier.size(); i++) {
if(itemsFromSupplier.get(i).getID().equals(itemId)) {
return itemsFromSupplier.get(i);
}
}
return itemsFromSupplier.get(0); // return the first item, in the program, it wouldn't be able to get here.
}
public void addingElementToOrder(JList list, Object element) {
DefaultListModel model = (DefaultListModel) list.getModel();
DefaultListModel quanModel = (DefaultListModel) this.quantityList__.getModel();
for(int i=0; i<model.getSize(); i++) {
if(element.equals(model.getElementAt(i))) {
Integer number = Integer.valueOf(quanModel.getElementAt(i).toString());
number++;
quanModel.add(i, number);
quanModel.remove(i+1);
return;
}
}
model.addElement(element); // if no matches, create a new entry in the order list
quanModel.addElement("1"); // add a quantity of 1 to the item
}
public void removeFromList(JList selectedList) {
DefaultListModel model = (DefaultListModel) selectedList.getModel();
int selectedIndex = selectedList.getSelectedIndex();
if(selectedIndex != -1) {
model.remove(selectedIndex);
}
}
/* Saves the most recent order information to the file and overwrites the previous order information. */
public void saveToFile(Supplier oneSupplier) {
ArrayList<Order> orders = oneSupplier.callBrainToGetOrders();
for(int singleorder=0; singleorder<orders.size(); singleorder++) {
Order oneOrder = orders.get(singleorder);
String content = oneOrder.returnForFileFormat();
System.out.println(content);
File file = new File(oneSupplier.getName() + "orders.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException ex) {
System.out.println("Couldn't find or open file to save.");
Logger.getLogger(GraphicsListing.class.getName()).log(Level.SEVERE, null, ex);
}
} // create if it doesn't exist
FileWriter filewriter;
try {
filewriter = new FileWriter(file.getAbsoluteFile());
try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) {
bufferedwriter.write(content);
}
} catch (IOException ex) {
System.out.println("Couldn't write to file.");
Logger.getLogger(GraphicsListing.class.getName()).log(Level.SEVERE, null, ex);
}
}
this.computerOutput.setText("Saving... ");
}
public void appendCompleteOrder(Supplier oneSupplier, Order newOrder) {
ArrayList<Order> supplierOrders = oneSupplier.callBrainToGetOrders();
supplierOrders.add(newOrder);
}
/* Retrive order informtion from file: itemid, name, description, price, quantity, orderPaidFor
* Then print the order from the file. */
public void printOldOrders(Supplier oneSupplier) {
ArrayList<Order> supplierOrders = oneSupplier.callBrainToGetOrders();
this.computerOutput.append("\n---------------------------------------\n");
this.computerOutput.append("The past orders from this supplier are:\n");
for(int numOrders=0; numOrders<supplierOrders.size(); numOrders++) {
Order printOrder = supplierOrders.get(numOrders);
ArrayList<Item> items__ = printOrder.returnListOfItems();
ArrayList<Integer> quantities__ = printOrder.returnListQuantity();
for(int numItems=0; numItems<items__.size(); numItems++) {
Item printItem = items__.get(numItems);
String oneOldOrder = printItem.getID() + " " + printItem.getName() + " "
+ printItem.getDescription() + " " + printItem.getPrice() + " " + quantities__.get(numItems);
this.computerOutput.append(oneOldOrder + "\n");
}
}
}
public void clearAllInLists(JList selectedList) {
DefaultListModel listModel = (DefaultListModel) selectedList.getModel();
listModel.removeAllElements();
}
public void outPut_PromptUser() {
userCurrentInput = ""; // set the current text input to null;
this.computerOutput.setText("Which supplier do you want to order from? "
+ "\nSelect the supplier to view their items."
+ "\nPress the select button to choose your supplier.");
gui_createListenersForSupplierChoice();
// Wait until an adequate input is obtained to continue the program.
while(userCurrentInput.equals("")) {
// Nothing to do while waiting.
}
}
public Supplier getSupplier() {
Supplier oneSupplier = null;
for(int numSuppliers=0; numSuppliers<listSuppliers.size(); numSuppliers++) {
oneSupplier = listSuppliers.get(numSuppliers);
if(userCurrentInput.equals(oneSupplier.getName())) {
return oneSupplier;
}
}
return oneSupplier;
}
// Takes a supplier, and then prints its supplies to the screen in a JList.
public void outPut_printSuppliesToScreen(Supplier oneSupplier) {
this.computerOutput.setText("Items in inventory of Supplier: " + oneSupplier.getName());
this.computerOutput.append("\nClick the [Select Supplier] button to get started with your order.");
this.computerOutput.append("\nClick the [Remove Supplier] button to remove a Supplier from your Approved Supplier List.");
ArrayList<Item> itemsFromSupplier = oneSupplier.getItemsInInventory();
DefaultListModel listOfSuppliesModel = (DefaultListModel) this.listOfSupplies__.getModel();
listOfSuppliesModel.clear(); // clear the previous list field
for(int numItems=0; numItems<itemsFromSupplier.size(); numItems++) {
listOfSuppliesModel.addElement(stringOfItem(itemsFromSupplier.get(numItems)));
}
}
public String stringOfItem(Item __item__) {
String stringItem = new String();
stringItem = __item__.getID() + " " + __item__.getName() + " " + __item__.getDescription() + " " + __item__.getPrice();
return stringItem;
}
public void outPut_PickingSupplies() {
this.computerOutput.setText("Now that you have picked a supplier. \nYou can select supplies and press add to add them to an order.");
this.computerOutput.append("\nWhat would you like to order from " + getSupplier().getName());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addSupplyButton;
private javax.swing.JTextArea computerOutput;
private javax.swing.JLabel dateLabel;
private javax.swing.JTextField dateTextField;
private javax.swing.JButton deliverButton;
private javax.swing.JButton exitButton;
private javax.swing.JButton finishOrderButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JList listOfSupplies__;
private javax.swing.JList orderListing__;
private javax.swing.JList quantityList__;
private javax.swing.JButton removeSupplierButton;
private javax.swing.JButton removeSupplyButton;
private javax.swing.JButton selectSupplierButton;
private javax.swing.JList supplierListing__;
private javax.swing.JLabel totalLabel;
private javax.swing.JTextField totalTextField;
// End of variables declaration//GEN-END:variables
}
| [
"ja.nguyen@gmail.com"
] | ja.nguyen@gmail.com |
d9f304fd24b384837123d735d25c8a0a85454d1a | dd61b553197f7072942a636fc38151d6434ca557 | /0001-0050/26/src/Solution.java | 5650376a26e0ec5caa8ef9e8f691f1823a36dbdc | [] | no_license | yeshaoting/LeetCode-Solution-Java | 4064d1756ca3b3720ee72b83c18c8a5c88c098fc | f02993fad941047b2cc307d373eb2bb3a69f3f38 | refs/heads/master | 2020-07-06T22:50:47.382887 | 2019-07-13T00:40:54 | 2019-07-13T00:40:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,141 | java | import java.util.Arrays;
// https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/description/
// 常规题目:这里利用到数组的有序性,如果遇到和上一个一样的元素,就什么都不做
public class Solution {
public int removeDuplicates(int[] nums) {
int len = nums.length;
if (len == 0) {
return 0;
}
int pre = nums[0];
int l = 1;
for (int i = 1; i < len; i++) {
if (nums[i] != pre) {
// 注意顺序:先更新值,再递增脚标
pre = nums[i];
nums[l] = nums[i];
l++;
}
}
// 注意 l 是遍历到的与之前不同元素的个数,要把第 1 个元素算进去,所以要加 1
return l;
}
public static void main(String[] args) {
int[] nums = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4};
Solution solution = new Solution();
int ret = solution.removeDuplicates(nums);
System.out.println(ret);
System.out.println(Arrays.toString(nums));
}
}
| [
"121088825@qq.com"
] | 121088825@qq.com |
cee04aafdc84ad8c9448249b69ad9c0ea5d68eed | fc4e919b7a6836a3aee7066deaca0caa1063add0 | /app/src/main/java/com/flf/funny/service/config/disklrucache/DiskCacheManager.java | 1ddda6846e9b24e72e4cd0565ed7eb678f5bb65d | [] | no_license | JustOneCoder/funny | 1665db8c47e4c116e05512d16420eb43f390939a | ef5696c870ef0b04d99e0188437c645bbb1eccc9 | refs/heads/master | 2021-01-21T17:37:08.852941 | 2017-05-22T11:15:23 | 2017-05-22T11:15:23 | 91,965,719 | 12 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,992 | java | package com.flf.funny.service.config.disklrucache;
import android.content.Context;
import android.os.Environment;
import com.flf.funny.FunnyApplication;
import com.flf.funny.service.config.Constants;
import com.jakewharton.disklrucache.DiskLruCache;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
/**
* Created by PandaQ on 2017/2/6.
* email : 767807368@qq.com
* 磁盘缓存工具类
*/
public class DiskCacheManager {
private static DiskLruCache mDiskLruCache = null;
private DiskLruCache.Editor mEditor = null;
private DiskLruCache.Snapshot mSnapshot = null;
public DiskCacheManager(Context context, String uniqueName) {
try {
//先关闭已有的缓存
if (mDiskLruCache != null) {
mDiskLruCache.close();
mDiskLruCache = null;
}
File cacheFile = getCacheFile(context, uniqueName);
mDiskLruCache = DiskLruCache.open(cacheFile, FunnyApplication.getAppVersionCode(), 1, Constants.CACHE_MAXSIZE);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 获取缓存的路径 两个路径在卸载程序时都会删除,因此不会在卸载后还保留乱七八糟的缓存
* 有SD卡时获取 /sdcard/Android/data/<application package>/cache
* 无SD卡时获取 /data/data/<application package>/cache
*
* @param context 上下文
* @param uniqueName 缓存目录下的细分目录,用于存放不同类型的缓存
* @return 缓存目录 File
*/
private File getCacheFile(Context context, String uniqueName) {
String cachePath = null;
if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable())
&& context.getExternalCacheDir() != null) {
cachePath = context.getExternalCacheDir().getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
return new File(cachePath + File.separator + uniqueName);
}
/**
* 获取缓存 editor
*
* @param key 缓存的key
* @return editor
* @throws IOException
*/
private DiskLruCache.Editor edit(String key) throws IOException {
key = SecretUtil.getMD5Result(key); //存取的 key
if (mDiskLruCache != null) {
mEditor = mDiskLruCache.edit(key);
}
return mEditor;
}
/**
* 根据 key 获取缓存缩略
*
* @param key 缓存的key
* @return Snapshot
*/
private DiskLruCache.Snapshot snapshot(String key) {
if (mDiskLruCache != null) {
try {
mSnapshot = mDiskLruCache.get(key);
} catch (IOException e) {
e.printStackTrace();
}
}
return mSnapshot;
}
/*************************
* 字符串读写
*************************/
/**
* 缓存 String
*
* @param key 缓存文件键值(MD5加密结果作为缓存文件名)
* @param value 缓存内容
*/
public void put(String key, String value) {
DiskLruCache.Editor editor = null;
BufferedWriter writer = null;
try {
editor = edit(key);
if (editor == null) {
return;
}
OutputStream os = editor.newOutputStream(0);
writer = new BufferedWriter(new OutputStreamWriter(os));
writer.write(value);
editor.commit();
} catch (IOException e) {
e.printStackTrace();
try {
if (editor != null)
editor.abort();
} catch (IOException e1) {
e1.printStackTrace();
}
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 获取字符串缓存
*
* @param key cache'key
* @return string
*/
public String getString(String key) {
InputStream inputStream = getCacheInputStream(key);
if (inputStream == null) {
return null;
}
try {
return inputStream2String(inputStream);
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
inputStream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
/*************************
* Json对象读写
*************************/
//Json 数据转换成 String 存储
public void put(String key, JSONObject value) {
put(key, value.toString());
}
//取得 json 字符串再转为 Json对象
public JSONObject getJsonObject(String key) {
String json = getString(key);
try {
return new JSONObject(json);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
/*************************
* Json数组对象读写
*************************/
public void put(String key, JSONArray array) {
put(key, array.toString());
}
public JSONArray getJsonArray(String key) {
try {
return new JSONArray(getString(key));
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
/*************************
* byte 数据读写
*************************/
/**
* 存入byte数组
*
* @param key cache'key
* @param bytes bytes to save
*/
public void put(String key, byte[] bytes) {
OutputStream out = null;
DiskLruCache.Editor editor = null;
try {
editor = edit(key);
if (editor == null) {
return;
}
out = editor.newOutputStream(0);
out.write(bytes);
out.flush();
editor.commit();
} catch (IOException e) {
e.printStackTrace();
try {
if (editor != null) {
editor.abort();
}
} catch (IOException e1) {
e1.printStackTrace();
}
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 获取缓存的 byte 数组
*
* @param key cache'key
* @return bytes
*/
public byte[] getBytes(String key) {
byte[] bytes = null;
InputStream inputStream = getCacheInputStream(key);
if (inputStream == null) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[256];
int len = 0;
try {
while ((len = inputStream.read(buf)) != -1) {
bos.write(buf, 0, len);
}
bytes = bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
}
return bytes;
}
/*************************
* 序列化对象数据读写
*************************/
/**
* 序列化对象写入
*
* @param key cache'key
* @param object 待缓存的序列化对象
*/
public void put(String key, Serializable object) {
ObjectOutputStream oos = null;
DiskLruCache.Editor editor = null;
try {
editor = edit(key);
if (editor == null) {
return;
}
oos = new ObjectOutputStream(editor.newOutputStream(0));
oos.writeObject(object);
oos.flush();
editor.commit();
} catch (IOException e) {
e.printStackTrace();
try {
if (editor != null)
editor.abort();
} catch (IOException e1) {
e1.printStackTrace();
}
} finally {
try {
if (oos != null) {
oos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 获取 序列化对象
*
* @param key cache'key
* @param <T> 对象类型
* @return 读取到的序列化对象
*/
@SuppressWarnings("unchecked")
public <T> T getSerializable(String key) {
T object = null;
ObjectInputStream ois = null;
InputStream in = getCacheInputStream(key);
if (in == null) {
return null;
}
try {
ois = new ObjectInputStream(in);
object = (T) ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return object;
}
/************************************************************************
********************** 辅助工具方法 分割线 ****************************
************************************************************************/
/**
* inputStream 转 String
*
* @param is 输入流
* @return 结果字符串
*/
private String inputStream2String(InputStream is) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuilder buffer = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
buffer.append(line);
}
return buffer.toString();
}
/**
* 获取 缓存数据的 InputStream
*
* @param key cache'key
* @return InputStream
*/
private InputStream getCacheInputStream(String key) {
key = SecretUtil.getMD5Result(key);
InputStream in;
DiskLruCache.Snapshot snapshot = snapshot(key);
if (snapshot == null) {
return null;
}
in = snapshot.getInputStream(0);
return in;
}
/**
* 同步记录文件
*/
public static void flush() {
if (mDiskLruCache != null) {
try {
mDiskLruCache.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
| [
"1009285246@qq.com"
] | 1009285246@qq.com |
0c4f04b1460200dcccc0e0e5010a46ffabfe9bb0 | 05435323fb569fb677d2473230e237f7dad1acf7 | /skripta_Adventura/Adventura/adventura/Main.java | 6dd62c5c59daaacf1180e57447ade61c068cfb25 | [
"Unlicense"
] | permissive | hailstorm75/consoleAdventure | da6f86157bc9e02036dc533bd16e864353b4f006 | 2cc40671a3d84a349d1a8c3c3a801fb95d616a12 | refs/heads/main | 2023-02-18T03:42:29.619945 | 2021-01-20T18:44:24 | 2021-01-20T18:44:24 | 311,073,759 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133 | java | public class Main {
public static void main(String[] args) throws InterruptedException {
GameEngine.getInstance().run();
}
}
| [
"denis.akopyan@seznam.cz"
] | denis.akopyan@seznam.cz |
c63c53cabb8caa39e7eefaef8f75ea86393ba978 | 96f8d42c474f8dd42ecc6811b6e555363f168d3e | /baike/sources/qsbk/app/adapter/ParticipateAdapter.java | 2b54dd4d905e3207cf71c51284659a29df7b9d2a | [] | no_license | aheadlcx/analyzeApk | 050b261595cecc85790558a02d79739a789ae3a3 | 25cecc394dde4ed7d4971baf0e9504dcb7fabaca | refs/heads/master | 2020-03-10T10:24:49.773318 | 2018-04-13T09:44:45 | 2018-04-13T09:44:45 | 129,332,351 | 6 | 2 | null | null | null | null | UTF-8 | Java | false | false | 7,029 | java | package qsbk.app.adapter;
import android.app.Activity;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import com.facebook.common.executors.UiThreadImmediateExecutorService;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.request.ImageRequest;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONObject;
import qsbk.app.QsbkApp;
import qsbk.app.R;
import qsbk.app.adapter.ArticleAdapter.AcrossChangeDate;
import qsbk.app.adapter.ArticleAdapter.ViewHolder;
import qsbk.app.model.Article;
import qsbk.app.model.ParticipateArticle;
import qsbk.app.model.RssArticle.Type;
import qsbk.app.utils.LogUtil;
import qsbk.app.utils.UIHelper;
import qsbk.app.utils.UIHelper$Theme;
import qsbk.app.widget.DiggerBar;
public class ParticipateAdapter extends BaseVideoAdapter {
private static HashMap<String, SubscribeIcon> e = null;
public static class SubscribeIcon {
public String day_icon_url;
public String night_icon_url;
public String text;
public String type;
public String getIconUrl() {
return UIHelper.isNightTheme() ? this.night_icon_url : this.day_icon_url;
}
public String getText() {
return TextUtils.isEmpty(this.text) ? "" : this.text;
}
public String toString() {
return "SubscribeIcon{type='" + this.type + '\'' + ", text='" + this.text + '\'' + ", day_icon_url='" + this.day_icon_url + '\'' + ", night_icon_url='" + this.night_icon_url + '\'' + '}';
}
}
class a extends ViewHolder {
DiggerBar b;
TextView c;
final /* synthetic */ ParticipateAdapter d;
public a(ParticipateAdapter participateAdapter, View view) {
this.d = participateAdapter;
super(participateAdapter, view);
this.b = (DiggerBar) view.findViewById(R.id.diggerbar);
this.c = (TextView) view.findViewById(R.id.type);
}
}
public ParticipateAdapter(Activity activity, ListView listView, ArrayList<Object> arrayList, String str, String str2) {
this(activity, listView, arrayList, str, str2, null);
}
public ParticipateAdapter(Activity activity, ListView listView, ArrayList<Object> arrayList, String str, String str2, AcrossChangeDate acrossChangeDate) {
super(activity, listView, arrayList, str, str2, acrossChangeDate);
}
public static SubscribeIcon getSubscribIcons(String str) {
if (e == null) {
e = new HashMap();
try {
JSONObject optJSONObject = QsbkApp.indexConfig.optJSONObject("subscribe_icon");
LogUtil.d("subscribe_icon");
String optString = optJSONObject.optString("prefix");
JSONArray optJSONArray = optJSONObject.optJSONArray("conf");
if (optJSONArray != null && optJSONArray.length() > 0) {
for (int i = 0; i < optJSONArray.length(); i++) {
JSONObject optJSONObject2 = optJSONArray.optJSONObject(i);
SubscribeIcon subscribeIcon = new SubscribeIcon();
subscribeIcon.type = optJSONObject2.optString("type");
subscribeIcon.text = optJSONObject2.optString("text");
subscribeIcon.day_icon_url = optString + optJSONObject2.optString("day");
subscribeIcon.night_icon_url = optString + optJSONObject2.optString(UIHelper$Theme.THEME_NIGHT);
LogUtil.d("put subicon:" + subscribeIcon.toString());
e.put(subscribeIcon.type, subscribeIcon);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return (SubscribeIcon) e.get(str);
}
public static void initType(ParticipateArticle participateArticle, TextView textView) {
String str = participateArticle.type;
if (Type.SUB.equals(str) && participateArticle.containsAction("publish")) {
str = "publish";
}
textView.setVisibility(0);
int paddingLeft = textView.getPaddingLeft();
int paddingRight = textView.getPaddingRight();
int paddingTop = textView.getPaddingTop();
int paddingBottom = textView.getPaddingBottom();
String str2 = "";
SubscribeIcon subscribIcons = getSubscribIcons(str);
if (subscribIcons != null) {
str2 = subscribIcons.getText();
if (subscribIcons.type.equals(Type.NEARBY)) {
textView.setText(" " + String.format("%s·%s", new Object[]{participateArticle.city, participateArticle.district}));
} else {
textView.setText(" " + str2);
}
String iconUrl = subscribIcons.getIconUrl();
textView.setTag(iconUrl);
if (TextUtils.isEmpty(iconUrl)) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
} else {
Fresco.getImagePipeline().fetchDecodedImage(ImageRequest.fromUri(iconUrl), textView.getContext().getApplicationContext()).subscribe(new cm(textView, iconUrl, paddingLeft, paddingTop, paddingRight, paddingBottom), UiThreadImmediateExecutorService.getInstance());
}
} else {
textView.setVisibility(8);
}
if (participateArticle.qiushiTopic != null && participateArticle.qiushiTopic.hasEvent()) {
textView.setVisibility(8);
}
}
public View getView(int i, View view, ViewGroup viewGroup) {
return super.getView(i, view, viewGroup);
}
protected ViewHolder a(View view) {
return new a(this, view);
}
protected void a(Article article, ViewHolder viewHolder, int i, View view) {
super.a(article, viewHolder, i, view);
if ((article instanceof ParticipateArticle) && (viewHolder instanceof a)) {
a((ParticipateArticle) article, (a) viewHolder);
b((ParticipateArticle) article, (a) viewHolder);
}
}
protected int a() {
return R.layout.layout_article_item;
}
private void a(ParticipateArticle participateArticle, a aVar) {
initType(participateArticle, aVar.c);
aVar.unlikeView.setVisibility(8);
}
private void b(ParticipateArticle participateArticle, a aVar) {
aVar.b.setVisibility(participateArticle.hasOwnComment() ? 0 : 8);
aVar.b.belongTo(participateArticle.id);
aVar.b.removeAllViews();
if (participateArticle.hasOwnComment()) {
aVar.b.addText("", "评论了:" + participateArticle.mOwnComment.content + (participateArticle.mOwnComment.hasImage() ? "[图片]" : ""));
}
}
}
| [
"aheadlcxzhang@gmail.com"
] | aheadlcxzhang@gmail.com |
ee560e57b8f25457b4a4879226ddd3831388777f | 230e5d6dbf2c2927d8646a6060fcfef8738615af | /src/main/java/com/heima/test/service/CourseScheduleDetailService.java | f0a2166bd0f0e645783084982d406d600d398ce6 | [] | no_license | buguniaoyst/heima-tea | 24186ce608dc714b1ddc1f85f7de43353891f7fa | 518358b7a7d540d58d48c4406704e886bf3186d2 | refs/heads/master | 2021-05-14T05:52:01.004527 | 2018-01-10T01:00:33 | 2018-01-10T01:00:33 | 116,231,861 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,416 | java | package com.heima.test.service;
import com.github.abel533.entity.Example;
import com.heima.test.domain.CourseScheduleDetail;
import com.heima.test.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* @author 布谷鸟
* @version V1.0
* @Package ${package_name}
* @date ${date} ${time}
*/
@Service
@Transactional
public class CourseScheduleDetailService extends BaseService<CourseScheduleDetail>{
public List<CourseScheduleDetail> queryListByBaseIdOrderByClassDate(Integer baseId) {
Example example = new Example(CourseScheduleDetail.class);
example.setOrderByClause("class_date asc");
example.createCriteria().andEqualTo("baseId", baseId);
return this.getMapper().selectByExample(example);
}
public void importCourseScheduleExcel(List<List<Object>> listob, Integer baseId, String className) {
//先清除所有的课表数据再更新
Example example = new Example(CourseScheduleDetail.class);
example.createCriteria().andEqualTo("baseId", baseId);
getMapper().deleteByExample(example);
//将list中的数据封装到 CourseScheduleDetail中
//基数 根据课程内容计算课程天数
Integer daySort=1;
for (int i = 0; i < listob.size(); i++) {
List<Object> lo = listob.get(i);
CourseScheduleDetail c= new CourseScheduleDetail();
if(null != lo.get(0)){
//开班日期
Date classDate = DateUtils.getDateFromStr(String.valueOf(lo.get(0)));
c.setClassDate(classDate);
System.out.println(classDate);
c.setWeekSort(Integer.valueOf(classDate.getDay()));
}
if(null != lo.get(1) && !"".equals(lo.get(1))){
//课程内容
c.setContent(String.valueOf(lo.get(1)));
//如果有课程内容 则将hasHonorsDay赋值为1
c.setHasHonorsDay(1);
}else{
c.setHasHonorsDay(0);
}
if(null != lo.get(2) && !"".equals(lo.get(2))){
//是否大纲课程
Integer isOutline = 0;
if ("是".equals(String.valueOf(lo.get(2)))) {
isOutline = 1;
c.setDaySort(daySort++);
}else {
isOutline = 0;
}
c.setIsOutline(isOutline);
}else{
c.setIsOutline(0);
}
if(null != lo.get(3) && !"".equals(lo.get(3))){
//授课模式
String classMode = String.valueOf(lo.get(3));
if("传统全天".equals(classMode)){
c.setClassMode(0);
} else if ("AB上午".equals(classMode)) {
c.setClassMode(1);
}else if("AB下午".equals(classMode)){
c.setClassMode(2);
}else {
c.setClassMode(3);
}
}else {
c.setClassMode(3);
}
if (null != lo.get(4) && !"".equals(lo.get(4))) {
//教室名
c.setClassRoomName(String.valueOf(lo.get(4)));
}
if (null != lo.get(5) && !"".equals(lo.get(5))) {
//讲师名
c.setTeacherName(String.valueOf(lo.get(5)));
}
if (null != lo.get(6) && !"".equals(lo.get(6))) {
//讲师工号
c.setJobNumber(String.valueOf(lo.get(6)));
}
if (null != lo.get(7) && !"".equals(lo.get(7))) {
c.setAssistant(String.valueOf(lo.get(7)));
}
if(lo.size()>=9){
if (null != lo.get(8) && !"".equals(lo.get(8))) {
c.setRemark(String.valueOf(lo.get(8)));
}
}
c.setBaseId(baseId);
c.setClassName(className);
//保存数据
save(c);
}
}
/**
* 组合条件查询
* @param assistant
* @param teacherName
* @param fromDate
* @param endDate
* @return
*/
public List<CourseScheduleDetail> queryListByExample( String assistant, String teacherName, String fromDate, String endDate) {
Example example = new Example(CourseScheduleDetail.class);
example.setOrderByClause("class_date asc");
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(assistant)) {
criteria.andLike("assistant", "%" + assistant + "%");
}
if (StringUtils.isNotBlank(teacherName)) {
criteria.andLike("teacherName", "%" + teacherName + "%");
}
if(StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(endDate)){
criteria.andBetween("classDate", fromDate, endDate);
}else if(StringUtils.isBlank(fromDate) && StringUtils.isNotBlank(endDate)){
criteria.andLessThanOrEqualTo("classDate", endDate);
}else if(StringUtils.isNotBlank(fromDate) && StringUtils.isBlank(endDate)){
criteria.andGreaterThanOrEqualTo("classDate", fromDate);
}
return getMapper().selectByExample(example);
}
}
| [
"1084169217@qq.com"
] | 1084169217@qq.com |
d9f78311c5d1f46556f9d824feb7275c44e88134 | 044bb31bafee84586739ddb0217f47ff5421d725 | /src/io/liveware/sgoodiscordbot/BotListener.java | 578fa308e907364aa34fd161ecd77380baacbd29 | [] | no_license | chepeleff/sgooDiscordBot | 42f24baaf17920d3e3a942f2724ed2380b1aa2ec | 8d7291019b188bcc36943ea16f8efef718c8c21c | refs/heads/master | 2020-12-08T23:52:32.542144 | 2016-08-18T10:35:10 | 2016-08-18T10:35:10 | 65,988,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 767 | java | package io.liveware.sgoodiscordbot;
import net.dv8tion.jda.events.ReadyEvent;
import net.dv8tion.jda.events.message.MessageReceivedEvent;
import net.dv8tion.jda.hooks.ListenerAdapter;
/**
* Created by ChepelevAG on 18.08.2016.
*/
public class BotListener extends ListenerAdapter {
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getMessage().getContent().startsWith(~!) && event.getAuthor().getId() != event.getJDA().getSelfInfo().getId()) {
Main.handleCommand(Main.parser.parse(event.getMessage().getContent().toLowerCase()))
}
}
@Override
public void onReady(ReadyEvent event) {
Main.log("status", "Logged in as: " + event.getJDA().getSelfInfo().getUsername());
}
}
| [
"ChepelevAG@vesco.org"
] | ChepelevAG@vesco.org |
28aaec5bb67b1f4d6720d47f186180f747a77a13 | 32990c839e2f510f15e4f154c3830cc81f6c0a30 | /src/main/java/com/mapabc/signal/dao/vo/signalalarms/SignalAlarmsVo.java | 204d6ba4aa8914a73b4bdee69d4a8fd41c3f9ea7 | [] | no_license | AshesHj/traffic_signal_utcsystem | 3ecb444fb1002fbf2c6c4aba5703702f760be1d5 | c8673925393815620acb044aa2000bdcb7cc8c82 | refs/heads/master | 2020-05-14T14:52:19.088151 | 2019-05-11T02:29:49 | 2019-05-11T02:29:49 | 181,841,513 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 829 | java | package com.mapabc.signal.dao.vo.signalalarms;
import com.mapabc.signal.common.component.BaseSignal;
import lombok.Data;
/**
* @author yinguijin
* @version 1.0
* @Description: [信号机警报信息实体]
* Created on 2019/4/22 17:14
*/
@Data
public class SignalAlarmsVo extends BaseSignal {
//1检测器故障|2时钟故障|3电源故障|4驱动模块故障|
//5信号灯故障|6箱门开启|7方案错误|8绿冲突|9红全熄|10行人红熄
private String alarmId;
//1检测器故障|2时钟故障|3电源故障|4驱动模块故障|
//5信号灯故障|6箱门开启|7方案错误|8绿冲突|9红全熄|10行人红熄
private String alarmDesc;
//告警时间,yyyy-mm-dd hh24:mi:ss
private String alarmTime;
//结束时间,yyyy-mm-dd hh24:mi:ss
private String endTime;
}
| [
"lv_huijin@163.com"
] | lv_huijin@163.com |
d529b25345805fe329e714a309b0393640974d31 | 236b020f8dff5f4b0644a4590b24f5db60b498af | /src/lab5_3/Main.java | b572ed44d57396e6a6eaffddb13ec0af9252a0ed | [] | no_license | OleksandrKvitka/Bohomazov2018-var2- | 49be5c91d7f32fb78ce8d55cb67fe86b5e0220bd | cc6e9d12574e522021ae90f13884439c45ac943c | refs/heads/master | 2022-01-08T07:57:05.072615 | 2019-05-28T20:55:33 | 2019-05-28T20:55:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 542 | java | package lab5_3;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
StringDao inputDao = new StringDaoImpl("src/lab5_3/MainCopy.java");
StringDao outputDao = new StringDaoImpl("src/lab5_3/MainCopyOutput.txt");
SubstringReplacer substringReplacer = new SubstringReplacer();
substringReplacer.setStringToReplace(inputDao.getString());
String result = substringReplacer.replaceWithLongerString("public");
outputDao.setString(result);
}
}
| [
"mihail.lukjanec@gmail.com"
] | mihail.lukjanec@gmail.com |
628a97a21ddcb8e9e3abfe5311ea1660a2a378d5 | 3c50bd0ddcf04dd9385cddf2dc5a2a85cc68d432 | /com.yzd.frame.v1.root/3.2-com.yzd.logging/src/main/java/com/yzd/logging/logbackExt/TraceIdConvert.java | eb584427d2582fa87111458a3e20d026f2851d78 | [] | no_license | yaozd/com.yzd.frame.v1.root | b5d76be92903a498f18c24dfde68bacc331d54c9 | 9e9ad3fd4ecc4b227e017a192ba76cc4d19d32ba | refs/heads/master | 2020-04-05T13:33:23.358151 | 2018-06-29T08:41:40 | 2018-06-29T08:41:40 | 83,413,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 795 | java | package com.yzd.logging.logbackExt;
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import com.yzd.logging.util.MDCUtil;
import com.yzd.logging.util.StringUtils;
import java.util.UUID;
/**
* Created by zd.yao on 2017/5/24.
*/
public class TraceIdConvert extends ClassicConverter {
//定制转换器for logback
//针对
@Override
public String convert(ILoggingEvent event) {
String traceId = null;
traceId=MDCUtil.get(MDCUtil.Type.TRACE_ID);
if (StringUtils.isEmpty(traceId)) {
//”D“:代表人为手动添加的traceId
traceId = "D"+UUID.randomUUID().toString();
MDCUtil.put(MDCUtil.Type.TRACE_ID, traceId);;
}
return traceId;
}
}
| [
"tedijoteamo@163.com"
] | tedijoteamo@163.com |
248fcd63396666baf6a900f48ab7adda4660fedd | bef6b437456682050f47e5650def6af11b517714 | /app/src/main/java/com/maxwell/csafenet/activity/MyProfileActivity.java | 918435da2e9289a1e208a2c3968a0369ebdb8277 | [] | no_license | maxwellandroid/Csafenet | 5e68bd3d48e0d9f66771254a64245b8abb01d241 | b2d760319a3f199aad6acb75a66256dac87ecc61 | refs/heads/master | 2020-06-02T12:51:49.400153 | 2019-06-20T09:41:05 | 2019-06-20T09:41:05 | 191,159,308 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,297 | java | package com.maxwell.csafenet.activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.maxwell.csafenet.R;
import com.maxwell.csafenet.StringConstants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import de.hdodenhof.circleimageview.CircleImageView;
public class MyProfileActivity extends AppCompatActivity {
TextView tv_name,tv_employeeNumber,tv_designation,tv_company,tv_joining_date,tv_mobile_number,tv_email_id;
SharedPreferences preferences;
SharedPreferences.Editor editor;
String s_user_id;
CircleImageView iv_profile;
RelativeLayout layout_progress;
LinearLayout layout_home;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_profile);
tv_name=(TextView)findViewById(R.id.text_name);
tv_employeeNumber=(TextView)findViewById(R.id.text_employee_number);
tv_designation=(TextView)findViewById(R.id.text_designation);
tv_company=(TextView)findViewById(R.id.text_company);
tv_joining_date=(TextView)findViewById(R.id.text_joining_date);
tv_email_id=(TextView)findViewById(R.id.text_email_id);
tv_mobile_number=(TextView)findViewById(R.id.text_mobile);
iv_profile=(CircleImageView)findViewById(R.id.imageProfile);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
s_user_id=preferences.getString(StringConstants.prefEmployeeId,"");
layout_home=(LinearLayout)findViewById(R.id.layout_home) ;
layout_progress=(RelativeLayout)findViewById(R.id.rela_animation) ;
getUser();
}
public void back(View view){
onBackPressed();
}
private void getUser() {
String loading = getString(R.string.loading);
//progressBar.show(loading, false);
// final String url = "https://www.maxwellglobalsoftware.com/tvpromo/api/type_promo.php?lang_id=" + languageId + "&type=1&unique_id=" + uniqId;
final String url = StringConstants.mainUrl+StringConstants.userprofileUrl+StringConstants.inputUserID +"="+s_user_id;
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// getStateMethod(response);
try {
// getAllValue(response);
JSONObject trailerObject=new JSONObject(response);
if (trailerObject.has("view_profile")) {
JSONArray trailers = trailerObject.getJSONArray("view_profile");
for(int i=0;i<trailers.length();i++){
JSONObject jsonObject=trailers.getJSONObject(i);
if(jsonObject.has("fname")){
tv_name.setText(jsonObject.getString("fname"));
}
if(jsonObject.has("employee_no")){
tv_employeeNumber.setText(jsonObject.getString("employee_no"));
}
if(jsonObject.has("designation")){
tv_designation.setText(jsonObject.getString("designation"));
} if(jsonObject.has("company_name")){
tv_company.setText(jsonObject.getString("company_name"));
}if(jsonObject.has("joining_date")){
tv_joining_date.setText(jsonObject.getString("joining_date"));
}if(jsonObject.has("email")){
tv_email_id.setText(jsonObject.getString("email"));
}if(jsonObject.has("mobile_no")){
tv_mobile_number.setText(jsonObject.getString("mobile_no"));
}
if(jsonObject.has("image")){
Glide.with(MyProfileActivity.this)
.load("http://csafenet.com/"+jsonObject.getString("image")) // image url
// .placeholder(R.drawable.placeholder) // any placeholder to load at start
.error(R.drawable.csafenet) // any image in case of error
// .override(200, 200); // resizing
//.apply(new RequestOptions().placeholder(R.drawable.loading))
.into(iv_profile);
}
}
}
layout_progress.setVisibility(View.GONE);
layout_home.setVisibility(View.VISIBLE);
} catch (JSONException e) {
e.printStackTrace();
}
/*getpromo(response);
getMovie(response);
getSerial(response);*/
Log.i("NowFragment", "--->" + response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (Log.isLoggable("getStateValueFromApi", Log.INFO))
Log.i("getStateValueFromApi", "Call to " + url + " failed" + error.toString());
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
}
}
| [
""
] | |
65efeded1720980d6df14990476ff85c1b7ad3e7 | 8be7ed3255b6159ca3fd846cbf797afd535f0a90 | /warcraft/src/com/wwt/warcraft/map/CollisionType.java | 421a78565065c308d081df61767599fb6d99989c | [] | no_license | wwtbuaa/software_engineering | 4fbf3a9ed7c0d10874453aa23d280a69c05594e5 | cd1f04006225e1126a39ad5e05777e0f2a58bb94 | refs/heads/master | 2020-05-29T16:41:13.948608 | 2013-12-28T12:08:07 | 2013-12-28T12:08:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | package com.wwt.warcraft.map;
public class CollisionType extends com.b3dgs.lionengine.game.platform.CollisionType{
public static final int NONE = 0;
public static final int GROUND = 1;
public static final int BORDER = 2;
public static final int WATER = 3;
public static final int TREE = 4;
public CollisionType(String name, int pattern, int min, int max) {
super(name, pattern, min, max);
}
}
| [
"462015315@qq.com"
] | 462015315@qq.com |
7399b91105e2027593bbe3c3fda55e1338f2b85a | 4977972e1e6b67d3dd845514b0afe898484013cd | /src/com/hl_zhaoq/digou/utils/DecimalUtils.java | 96debd8ed2e7d6e8d91f34d2025196df9aa6826d | [] | no_license | huaLongChuangXinYunPos/huaLongDigou | ba785cf6f1d0fcd158eff870a3e421ad8f591662 | 83aee5aed370677f17ad9ae2a26a60358f9ea79e | refs/heads/master | 2021-01-10T10:11:47.887281 | 2016-03-08T06:13:06 | 2016-03-08T06:13:06 | 52,589,448 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 525 | java | package com.hl_zhaoq.digou.utils;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Random;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hl_zhaoq.digou.bean.UserInfo;
public class DecimalUtils {
public static Random random = new Random();
public static DecimalFormat df = new DecimalFormat("0.000");
public static double getRandomDouble() {
double result = random.nextDouble() / 10;
return Double.parseDouble(df.format(result));
}
}
| [
"229457269@qq.com"
] | 229457269@qq.com |
557a2d0970cace83bc333f587211aaa459d21e4e | 66bdfd84193ff3cccc75176969823b4eb9a62d88 | /src/main/java/com/qiu/service/orderServiceImpl.java | c20a0b2ea0531bd107b3e056e36a652bbc584ef5 | [] | no_license | gitqiuzongshuang/school-order | 9e2f12f8e49c8c074a5c2fa1e416e5aae2dbad6a | fa930c13ed0e8587f4c2752b26f1989ac90342a3 | refs/heads/master | 2020-05-09T22:29:31.377669 | 2019-04-18T12:51:13 | 2019-04-18T12:51:13 | 181,473,036 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,969 | java | package com.qiu.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qiu.dao.ordersMapper;
import com.qiu.pojo.orders;
import com.qiu.pojo.ordersExample;
@Service
public class orderServiceImpl implements orderServiceI {
@Autowired
ordersMapper om;
@Override
public int addorder(orders orders) {
// TODO Auto-generated method stub
return om.insertSelective(orders);
}
@Override
public int delorder(int id) {
// TODO Auto-generated method stub
return om.deleteByPrimaryKey(id);
}
@Override
public int modifyorder(orders orders) {
// TODO Auto-generated method stub
return om.updateByPrimaryKeySelective(orders);
}
@Override
public orders getOrderById(Integer id) {
// TODO Auto-generated method stub
return om.selectByPrimaryKey(id);
}
@Override
public orders getOrderByWindow(Integer window) {
// TODO Auto-generated method stub
ordersExample example=new ordersExample();
example.createCriteria().andWindowEqualTo(window);
List<orders> orders=om.selectByExample(example);
if(orders.size()>0) {
return orders.get(0);
}
return null;
}
@Override
public orders getOrderByUser(Integer user) {
// TODO Auto-generated method stub
ordersExample example=new ordersExample();
example.createCriteria().andUserEqualTo(user);
List<orders> orders=om.selectByExample(example);
if(orders.size()>0) {
return orders.get(0);
}
return null;
}
@Override
public int countOrder(ordersExample ordersExample) {
// TODO Auto-generated method stub
return om.countByExample(ordersExample);
}
@Override
public int delOrderByExample(ordersExample ordersExample) {
// TODO Auto-generated method stub
return om.deleteByExample(ordersExample);
}
@Override
public List<orders> showOrder(ordersExample ordersExample) {
// TODO Auto-generated method stub
return om.selectByExample(ordersExample);
}
}
| [
"q641255042@163.com"
] | q641255042@163.com |
bcd1a963afe58b303e76043005dfad48a7048407 | 26a3597eedfba2eb98b47634be63905c2adb377d | /keywords-filter/src/main/java/com/poeny/keywords_filter/model/UpdateCacheResult.java | 6fa17b8453491f9a1d50fd690cb416b3c43e2055 | [] | no_license | hongjinwei/KeywordsFilter | 555dbaabb71c382319226671764116bfa76974d6 | 8b4858477b89b0a167f9ff91f99b00cdb5472a1e | refs/heads/master | 2016-09-05T18:35:14.930456 | 2015-06-25T02:37:55 | 2015-06-25T02:37:55 | 37,583,242 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 901 | java | package com.poeny.keywords_filter.model;
import java.util.HashSet;
import java.util.Set;
public class UpdateCacheResult {
private Set<String> shouldInsert = new HashSet<String>();
private Set<String> shouldDeleted = new HashSet<String>();
public Set<String> getShouldInsert() {
return shouldInsert;
}
public void addShouldInsert(String word) {
this.shouldInsert.add(word);
}
public void addAllShouldInsert(Set<String> words) {
this.shouldInsert.addAll(words);
}
public void addAllShouldDeleted(Set<String> words) {
this.shouldDeleted.addAll(words);
}
public void mergeResult(UpdateCacheResult result) {
this.shouldInsert.addAll(result.getShouldInsert());
this.shouldDeleted.addAll(result.getShouldDeleted());
}
public Set<String> getShouldDeleted() {
return shouldDeleted;
}
public void addShouldDeleted(String word) {
this.shouldDeleted.add(word);
}
}
| [
"hongjinwei222@gmail.com"
] | hongjinwei222@gmail.com |
69f6a5d2be67904addb99af5623846a66ffadbe8 | 98ea2fd468e481937eacdb3447eba497a5d755ad | /src/main/java/com/twilio/sms2fa/application/servlets/ConfirmationsServlet.java | 719f7477c550b01c2274beebbe3fdf8aa8912d8f | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | TwilioDevEd/sms2fa-servlets | 109f4473297d9148197fee448aa82c34c8f7f095 | 16f45f8e6554481ddc28d398e3f80f772b1fe364 | refs/heads/master | 2023-08-08T00:05:51.716583 | 2021-12-30T00:07:14 | 2021-12-30T00:07:14 | 58,226,570 | 2 | 7 | null | 2023-07-28T07:41:52 | 2016-05-06T18:19:00 | Java | UTF-8 | Java | false | false | 1,673 | java | package com.twilio.sms2fa.application.servlets;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.twilio.sms2fa.application.constants.ExternalResource;
import com.twilio.sms2fa.application.constants.InternalResource;
import com.twilio.sms2fa.domain.exception.DomainException;
import com.twilio.sms2fa.domain.model.User;
import com.twilio.sms2fa.domain.service.ConfirmUser;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Singleton
public class ConfirmationsServlet extends HttpServlet {
private ConfirmUser confirmUser;
@Inject
public ConfirmationsServlet(final ConfirmUser confirmUser) {
this.confirmUser = confirmUser;
}
@Override
protected void doPost(final HttpServletRequest request,
final HttpServletResponse response)
throws ServletException, IOException {
try {
String verificationCode = request.getParameter("verification_code");
User user = (User) request.getSession().getAttribute("user");
confirmUser.confirm(user, verificationCode);
request.getSession().setAttribute("authenticated", true);
response.sendRedirect(ExternalResource.SECRETS.getPath());
} catch (DomainException e) {
request.setAttribute("errorMessage", e.getMessage());
request.getRequestDispatcher(InternalResource
.CONFIRMATIONS_NEW_JSP.getPath())
.forward(request, response);
}
}
}
| [
"mosampaio@gmail.com"
] | mosampaio@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.