method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
009353e0-3ca2-4cd0-a98f-7b0752844fae
| 9 |
public void process() {
for (OutputVariable outputVariable : outputVariables) {
outputVariable.fuzzyOutput().clear();
}
/*
* BEGIN: Debug information
*/
if (FuzzyLite.debug()) {
Logger logger = FuzzyLite.logger();
for (InputVariable inputVariable : this.inputVariables) {
double inputValue = inputVariable.getInputValue();
if (inputVariable.isEnabled()) {
logger.fine(String.format(
"%s.input = %s\n%s.fuzzy = %s",
inputVariable.getName(), str(inputValue),
inputVariable.getName(), inputVariable.fuzzify(inputValue)));
} else {
logger.fine(String.format(
"%s.enabled = false", inputVariable.getName()));
}
}
}
/*
* END: Debug information
*/
for (RuleBlock ruleBlock : ruleBlocks) {
if (ruleBlock.isEnabled()) {
ruleBlock.activate();
}
}
/*
* BEGIN: Debug information
*/
if (FuzzyLite.debug()) {
Logger logger = FuzzyLite.logger();
for (OutputVariable outputVariable : this.outputVariables) {
if (outputVariable.isEnabled()) {
logger.fine(String.format("%s.default = %s",
outputVariable.getName(), str(outputVariable.getDefaultValue())));
logger.fine(String.format("%s.lockRange = %s",
outputVariable.getName(), String.valueOf(outputVariable.isLockingOutputRange())));
logger.fine(String.format("%s.lockValid = %s",
outputVariable.getName(), String.valueOf(outputVariable.isLockingValidOutput())));
//no locking is ever performed during this debugging block;
double outputValue = outputVariable.defuzzifyNoLocks();
logger.fine(String.format("%s.output = %s",
outputVariable.getName(), str(outputValue)));
logger.fine(String.format("%s.fuzzy = %s",
outputVariable.getName(), outputVariable.fuzzify(outputValue)));
logger.fine(outputVariable.fuzzyOutput().toString());
logger.fine("==========================");
} else {
logger.fine(String.format("%s.enabled = false", outputVariable.getName()));
}
}
}
/*
* END: Debug information
*/
}
|
3cd2678d-6bf8-47ed-9c72-e2558a8fad67
| 2 |
@Override
public void execute(CommandExecutor player, String[] args)
{
try {
player.getServer().Stop();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
|
ffa1944a-8ebf-40e7-b94a-c4d8683aaee1
| 7 |
@Override
public void register() {
// TODO: register new user (which, if successful, also logs them in)
String username=this.getLoginView().getRegisterUsername();
String password1=this.getLoginView().getRegisterPassword();
String password2=this.getLoginView().getRegisterPasswordRepeat();
String usernameError = "The username must be between three and seven characters: letters, digits, _ , and -";
String passwordError = "The password must be five or more characters: letters, digits, _ , and -";
String validCharsRegex = "[0-9]*[A-z]*[_]*[-]*";
if(username.length()<3||username.length()>7){
//username isn't valid
messageView.setMessage(usernameError);
messageView.showModal();
}
else if(!username.matches(validCharsRegex)) {
messageView.setMessage(usernameError);
messageView.showModal();
}
else if (!password1.equals(password2)) {
//passwords don't match
messageView.setMessage("Passwords must match.");
messageView.showModal();
}
else if(!password1.matches(validCharsRegex)) {
messageView.setMessage(passwordError);
messageView.showModal();
}
else if(password1.length() < 5){
//passwords length has to be greater than 4
messageView.setMessage(passwordError);
messageView.showModal();
}
else {
RegisterUserResponse response=this.presenter.register(username, password1);
if(response.isSuccessful()) {
// If register succeeded
getLoginView().closeModal();
loginAction.execute();
} else {
//registration failed
messageView.setMessage(response.getMessage());
messageView.showModal();
}
}
}
|
c7fcef67-618a-41ca-81bc-6df980d21f03
| 8 |
private void displayData() {
if (this.states != null) {
System.out.println("#################################################");
System.out.println("States: " + this.states);
if (this.emissions != null) {
System.out.println("Emissions: " + this.emissions);
if (this.stateProb != null) {
System.out.println("State Transition Probabilities:\n");
for (String state : this.states) {
System.out.println(" " + stateProb.get(state));
}
}
if (this.emissionProb != null) {
System.out.println("Emission Probabilities:\n");
for (String state : this.states) {
System.out.println(" " + emissionProb.get(state));
}
System.out.println();
}
if (this.beginStateProb != null) {
System.out.println("Begin State Probabilities:\n");
System.out.println(this.beginStateProb);
}
if (this.endStateProb != null) {
System.out.println("End State Probabilities:\n");
System.out.println(this.endStateProb);
}
}
System.out.println("#################################################");
}
}
|
7f922f3e-7b2c-46cf-8e0e-7ddbe2811a51
| 8 |
public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
this.plugin = plugin;
this.type = type;
this.announce = announce;
this.file = file;
this.id = id;
this.updateFolder = plugin.getServer().getUpdateFolder();
final File pluginFile = plugin.getDataFolder().getParentFile();
final File updaterFile = new File(pluginFile, "Updater");
final File updaterConfigFile = new File(updaterFile, "config.yml");
this.config.options().header("This configuration file affects all plugins using the Updater system (version 2+ - http://forums.bukkit.org/threads/96681/ )" + '\n'
+ "If you wish to use your API key, read http://wiki.bukkit.org/ServerMods_API and place it below." + '\n'
+ "Some updating systems will not adhere to the disabled value, but these may be turned off in their plugin's configuration.");
this.config.addDefault("api-key", "PUT_API_KEY_HERE");
this.config.addDefault("disable", false);
if (!updaterFile.exists()) {
updaterFile.mkdir();
}
boolean createFile = !updaterConfigFile.exists();
try {
if (createFile) {
updaterConfigFile.createNewFile();
this.config.options().copyDefaults(true);
this.config.save(updaterConfigFile);
} else {
this.config.load(updaterConfigFile);
}
} catch (final Exception e) {
if (createFile) {
plugin.getLogger().severe("The updater could not create configuration at " + updaterFile.getAbsolutePath());
} else {
plugin.getLogger().severe("The updater could not load configuration at " + updaterFile.getAbsolutePath());
}
plugin.getLogger().log(Level.SEVERE, null, e);
}
if (this.config.getBoolean("disable")) {
this.result = UpdateResult.DISABLED;
return;
}
String key = this.config.getString("api-key");
if (key.equalsIgnoreCase("PUT_API_KEY_HERE") || key.equals("")) {
key = null;
}
this.apiKey = key;
try {
this.url = new URL(Updater.HOST + Updater.QUERY + id);
} catch (final MalformedURLException e) {
plugin.getLogger().log(Level.SEVERE, "The project ID provided for updating, " + id + " is invalid.", e);
this.result = UpdateResult.FAIL_BADID;
}
this.thread = new Thread(new UpdateRunnable());
this.thread.start();
}
|
42038a26-b78f-44d1-96e9-5020737129bb
| 7 |
private int getNumberOfNeighbors(int row, int col) {
int neighborCount = 0;
for (int leftIndex = -1; leftIndex < 2; leftIndex++) {
for (int topIndex = -1; topIndex < 2; topIndex++) {
if ((leftIndex == 0) && (topIndex == 0)) continue; // skip own
int neighborRowIndex = row + leftIndex;
int neighborColIndex = col + topIndex;
if (neighborRowIndex < 0) neighborRowIndex = originalBoard.length + neighborRowIndex;
if (neighborColIndex < 0) neighborColIndex = originalBoard[0].length + neighborColIndex;
boolean neighbor = originalBoard[neighborRowIndex % originalBoard.length][neighborColIndex % originalBoard[0].length];
if (neighbor) neighborCount++;
}
}
return neighborCount;
}
|
fa130b15-7454-4726-b119-d46b99bf2f84
| 3 |
public int getGroupMembershipIndexByUsernameAndGroupID(int groupMembershipID, String username){
for(GroupMembership groupMembership : groupMemberships){
if(groupMembershipID == groupMembership.getGroupID() && username.equals(groupMembership.getUsername())) return groupMemberships.indexOf(groupMembership);
}
return -1;
}
|
e3d402de-833b-4fc2-b383-cbb9b33d481f
| 4 |
@Override
public void delete(Key key)
{
if (isEmpty())
return;
for (Node x = first, p = null; x != null; p = x, x = x.next)
if (key.equals(x.key))
{
N--;
if (x == first)
{
x = x.next;
first = x;
}
else
p.next = x.next;
return;
}
}
|
74b7cb8c-65f5-4289-b875-29c8d73309b8
| 9 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ChangeOfValue other = (ChangeOfValue) obj;
if (newValue == null) {
if (other.newValue != null)
return false;
}
else if (!newValue.equals(other.newValue))
return false;
if (timeDelay == null) {
if (other.timeDelay != null)
return false;
}
else if (!timeDelay.equals(other.timeDelay))
return false;
return true;
}
|
f8210964-dffe-4aaa-8e7f-c3f4e113552e
| 3 |
public boolean func_862_a(int var1, int var2, int var3) {
return !this.field_1235_h?false:var1 == this.field_1242_a && var2 == this.field_1241_b && var3 == this.field_1240_c;
}
|
7634936b-c5ce-48b3-a331-c84922f3c579
| 7 |
public static int floodFill(int r, int c) {
int area = 1;
for (int i = 0; i < dir.length; i++)
if (r + dir[i][0] >= 0 && r + dir[i][0] < n && c + dir[i][1] >= 0
&& c + dir[i][1] < m && !used[r + dir[i][0]][c + dir[i][1]]
&& map[r + dir[i][0]][c + dir[i][1]] == '0') {
used[r + dir[i][0]][c + dir[i][1]] = true;
area += floodFill(r + dir[i][0], c + dir[i][1]);
}
return area;
}
|
fdba8609-9de3-4d80-b714-afa26263a930
| 2 |
public Table(int playersNumber, int botsNumber)
{
players = new ArrayList<>();
deck = new Deck();
while (playersNumber-- > 0)
{
addPlayer(new Human("Player " + (playersNumber + 1)));
}
while (botsNumber-- > 0)
{
addPlayer(new Bot("Bot " + (playersNumber + 1)));
}
}
|
821cf16c-745b-44b7-a064-5032cf1d7ad4
| 8 |
public PatternRecord(IXMLElement elt){
if (!elt.getName().equals("pattern"))
throw new RuntimeException("<pattern> node expected, but found "+elt.getName());
Enumeration children = elt.enumerateChildren();
while (children.hasMoreElements()){
IXMLElement e = (IXMLElement)children.nextElement();
if (e.getName().equals("name")){
name = e.getContent();
continue;
}
if (e.getName().equals("description")){
description = e.getContent();
continue;
}
if (e.getName().equals("class")){
className = e.getContent();
continue;
}
if (e.getName().equals("parameters")){
params = e;
continue;
}
}
if (name == null)
throw new RuntimeException("Pattern renderer name was not specified");
if (className == null)
throw new RuntimeException("Pattern renderer class name was not specified");
}
|
f80ceb80-7dde-4765-bd03-017d0d98da30
| 0 |
public static void main(String[] args)
{
int result = sum(new int[] {1,3,3});
System.out.println(result);
int result1 = sum(1,2,3,4);
System.out.println(result1);
}
|
e8ba59e0-dc01-4218-af9d-0b5959e12a86
| 7 |
public static void main(String [] args){
String usage = "java mobilemedia.startMobileMediaClient --hostName <String> --portNum <String> --archName <String>\n";
String hostName=null,portNum=null;
String archName=null;
for(int i=0; i < args.length; i++){
if(args[i].equals("--hostName")){
hostName = args[++i];
}
else if(args[i].equals("--portNum")){
portNum= args[++i];
}
else if(args[i].equals("--archName")){
archName = args[++i];
}
}
if(archName == null || hostName == null || portNum == null){
System.err.println(usage);
System.exit(1);
}
FIFOScheduler sched = new FIFOScheduler(100);
Scaffold s = new Scaffold();
RRobinDispatcher disp = new RRobinDispatcher(sched, 10);
s.dispatcher=disp;
s.scheduler=sched;
BasicC2Topology c2Topology = new BasicC2Topology();
Architecture arch = new Architecture(archName, c2Topology);
arch.scaffold=s;
Component mediaGUIComponent = null;
mediaGUIComponent = new AWTMediaQueryGUI("urn:glide:prism:Client_mediaGUIComponent",System.getProperty("mp3.download.loc"));
mediaGUIComponent.scaffold = s;
//make the connectors now
C2BasicHandler bbc2=new Prism.handler.C2BasicHandler();
Connector QueryConn = new Connector("urn:glide:prism:QueryConn", bbc2);
QueryConn.scaffold =s;
arch.add(mediaGUIComponent);
arch.add(QueryConn);
//let's add the ports
Port QueryConnReplyPort=new Port(PrismConstants.REPLY,QueryConn);
QueryConn.addPort(QueryConnReplyPort);
QueryConn.scaffold = s;
Port mediaGUIRequestPort=new Port(PrismConstants.REQUEST,mediaGUIComponent);
mediaGUIComponent.addPort(mediaGUIRequestPort);
mediaGUIRequestPort.scaffold = s;
ExtensiblePort QueryConnRequestPort = new ExtensiblePort (PrismConstants.REQUEST, QueryConn);
SocketDistribution sd=new SocketDistribution(QueryConnRequestPort);
QueryConnRequestPort.addDistributionModule(sd);
QueryConnRequestPort.scaffold = s;
QueryConn.addPort(QueryConnRequestPort);
arch.add(QueryConnRequestPort);
arch.add(QueryConnReplyPort);
arch.add(mediaGUIRequestPort);
arch.weld(QueryConnReplyPort,mediaGUIRequestPort);
disp.start();
arch.start();
QueryConnRequestPort.connect(hostName, Integer.parseInt(portNum)); //connect the port to the specified host
}
|
cb419638-0f36-4a89-bbe2-f34f539045c1
| 2 |
public int onesCount()
{
int a = bits;
int count = 0;
for(int i = 0 ; i < 32 ; i ++){
if((a & 0x1) == 0x1){
count ++ ;
}
a = a >> 1;
}
return count;
}
|
6379edac-87dc-473f-88e0-8c7ee66fa976
| 6 |
public boolean checkSum(int x, int y, int z) {
if (getSquare(x + y))
if (getSquare(x - y))
if (getSquare(x + z))
if (getSquare(x - z))
if (getSquare(z + y))
if (getSquare(y - z))
return true;
return false;
}
|
190296cb-fdbe-4f1e-95ec-f4f82812205d
| 7 |
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String us = request.getParameter("USUARIO");
String pw = request.getParameter("PASSWORD");
ResultSet res;
AccesoEmpleados empleado = new AccesoEmpleados();
ActualizarEmpleado newempleado = new ActualizarEmpleado();
String usuario = "";
String password ="";
String dni="";
String nombre="";
String apellidos="";
String departamento="";
String sucursal="";
System.out.println("Antes de out.talbas");
out.println("<head>");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
out.println("<title>Acceso</title>");
out.println("</head>");
out.println("<body>");
out.println("<table>");
out.println("<tr>");
out.println("<td>User</td>");
out.println("<td>Password</td>");
out.println("<td>DNI</td>");
out.println("<td>Nombre</td>");
out.println("<td>Apellidos</td>");
out.println("<td>Departamento</td>");
out.println("<td>Sucursal</td>");
out.println("</tr>");
res = empleado.Listar();
if((request.getParameter("USUARIO")!="") && (request.getParameter("PASSWORD")!="")){
res= empleado.Buscar(request.getParameter("USUARIO"),request.getParameter("PASSWORD"));
res = empleado.Listar();
}
if((request.getParameter("USUARIO")=="") && (request.getParameter("PASSWORD")==""))
res= empleado.Listar();
while (res.next()) { //mientras encuentre resultados en la tabla
usuario = res.getString("usuario");
password = res.getString("password");
dni= res.getString("dni");
nombre= res.getString("nombre");
apellidos= res.getString("apellidos");
departamento= res.getString("departamento");
sucursal=res.getString("sucursal");
System.out.println("<td><input type=\"submit\" value=\"Actualizar\" "
+ "onclick= res= empleado.Buscar(request.getParameter(\"USUARIO\"),request.getParameter(\"PASSWORD\"))></td>");
System.out.println(res);
if (usuario.equalsIgnoreCase(request.getParameter("USUARIO"))){
out.println("<form method=\"post\" action=\"SrvActualizar\">");
out.println("<td><input type=\"text\" name=\"USUARIO\""
+ " value=" + res.getString("usuario")+"></td>");
out.println("<td><input type=\"password\" name=\"PASSWORD\""
+ " value=" + res.getString("password")+"></td>");
out.println("<td><input type=\"text\" name=\"DNI\""
+ " value=" + res.getString("dni")+"></td>");
out.println("<td><input type=\"text\" name=\"NOMBRE\""
+ " value=" + res.getString("nombre")+"></td>");
out.println("<td><input type=\"text\" name=\"APELLIDOS\""
+ " value=" + res.getString("apellidos")+"></td>");
out.println("<td><input type=\"text\" name=\"DEPARTAMENTO\""
+ " value=" + res.getString("departamento")+"></td>");
out.println("<td><input type=\"text\" name=\"SUCURSAL\""
+ " value=" + res.getString("sucursal")+"></td>");
out.println("<td><input type=\"submit\" value=\"Actualizar\"></td>");
out.println("</form>");
out.println("<form method=\"post\" action=\"SrvEliminar\">");
out.println("<td><input type=\"text\" name=\"USUARIO\""
+ " value=" + res.getString("usuario")+"></td>");
out.println("<td><input type=\"submit\" value=\"Eliminar\"></td>");
out.println("</form>");
}
else{
out.println("<tr>");
out.println("<td>"+ usuario +"</td>");
out.println("<td>"+ password +"</td>");
out.println("<td>"+ dni +"</td>");
out.println("<td>"+ nombre +"</td>");
out.println("<td>"+ apellidos +"</td>");
out.println("<td>"+ departamento +"</td>");
out.println("<td>"+ sucursal +"</td>");
}
out.println("</tr>");
}
out.println("</table>");
out.println("</body>");
out.println("</html>");
out.close();
} catch (Exception e) {
Logger.getLogger(SrvEmpleados.class.getName()).log(Level.SEVERE, null, e);
}
}
|
cd30a831-7ab2-4106-8893-37027c0cf98a
| 8 |
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DefaultSchema other = (DefaultSchema) obj;
if (this.mappingType != other.mappingType && (this.mappingType == null || !this.mappingType.equals(other.mappingType))) {
return false;
}
if (this.fields != other.fields && (this.fields == null || !this.fields.equals(other.fields))) {
return false;
}
return true;
}
|
9eb88758-b06b-4629-b4ff-c057b9084ce4
| 9 |
private boolean r_mark_suffix_with_optional_U_vowel() {
int v_1;
int v_2;
int v_3;
int v_4;
int v_5;
int v_6;
int v_7;
// (, line 159
// or, line 161
lab0: do {
v_1 = limit - cursor;
lab1: do {
// (, line 160
// (, line 160
// test, line 160
v_2 = limit - cursor;
if (!(in_grouping_b(g_U, 105, 305)))
{
break lab1;
}
cursor = limit - v_2;
// next, line 160
if (cursor <= limit_backward)
{
break lab1;
}
cursor--;
// (, line 160
// test, line 160
v_3 = limit - cursor;
if (!(out_grouping_b(g_vowel, 97, 305)))
{
break lab1;
}
cursor = limit - v_3;
break lab0;
} while (false);
cursor = limit - v_1;
// (, line 162
// (, line 162
// not, line 162
{
v_4 = limit - cursor;
lab2: do {
// (, line 162
// test, line 162
v_5 = limit - cursor;
if (!(in_grouping_b(g_U, 105, 305)))
{
break lab2;
}
cursor = limit - v_5;
return false;
} while (false);
cursor = limit - v_4;
}
// test, line 162
v_6 = limit - cursor;
// (, line 162
// next, line 162
if (cursor <= limit_backward)
{
return false;
}
cursor--;
// (, line 162
// test, line 162
v_7 = limit - cursor;
if (!(out_grouping_b(g_vowel, 97, 305)))
{
return false;
}
cursor = limit - v_7;
cursor = limit - v_6;
} while (false);
return true;
}
|
2c4b50cc-fbcb-4cf6-ac19-57a01348da4e
| 0 |
public static void main(String[] args) {
int x = 5;
double y = 5.332542;
// The old way:
System.out.println("Row 1: [" + x + " " + y + "]");
// The new way:
System.out.format("Row 1: [%d %f]\n", x, y);
// or
System.out.printf("Row 1: [%d %f]\n", x, y);
System.out.println(String.format("Row 1: [%d %f]\n", x, y));
}
|
16b0aa1e-51e3-424b-952c-8a702c51c2e9
| 4 |
public static ConfigurationIcon iconForConfiguration(
Configuration configuration) {
if (configuration instanceof FSAConfiguration)
return new FSAConfigurationIcon(configuration);
else if (configuration instanceof PDAConfiguration)
return new PDAConfigurationIcon(configuration);
else if (configuration instanceof TMConfiguration)
return new TMConfigurationIcon(configuration);
else if(configuration instanceof automata.mealy.MealyConfiguration)
return new MealyConfigurationIcon(configuration);
return null;
}
|
a0525527-c32f-4915-9f9e-cdfbb93d6c07
| 2 |
public void run() {
try {
InputStream in = socket.getInputStream();
// the server socket is the part that listens,
// you listen by calling serverSocket.accept();
// when someone connects to you, the server is returned.
// client initiate connections to server
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
while (!"".equals(line = reader.readLine())) {
System.out.println(line);
}
OutputStream out = socket.getOutputStream();
String response = "<h2>This is the " + counter + "th request</h2>";
out.write("HTTP/1.1 200 OK\n".getBytes());
out.write("Content-Type: text/html; charset=utf-8\n".getBytes());
out.write(("Content-Length: " + response.length() + "\n\n").getBytes());
out.write(response.getBytes());
out.flush();
out.close();
counter++;
} catch (IOException e) {
e.printStackTrace();
}
}
|
7eb0b8dd-ed43-4479-89fe-b2e045c712f7
| 7 |
public void add(T value) {
if (root == null) {
root = new BinaryTree();
root.setValue(value);
amount++;
} else {
BinaryTree node = root;
while (true) {
if (root == null) {
root = new BinaryTree();
root.setValue(value);
amount++;
break;
} else {
if (value.compareTo(root.getValue()) < 0) {
if (root.left != null)
root = root.left;
else {
root.left = new BinaryTree();
root.left.setValue(value);
amount++;
break;
}
} else {
if (value.compareTo(root.getValue()) > 0) {
if (root.right != null)
root = root.right;
else {
root.right = new BinaryTree();
root.right.setValue(value);
amount++;
break;
}
} else {
System.out.println("this value already exist");
break;
}
}
}
}
root = node;
}
}
|
5ce18097-8644-481b-8e27-4a1504d48343
| 5 |
@Override
public void ParseIn(Connection Main, Server Environment)
{
if (Main.Data.LoadingRoom != 0)
{
Room Room = Environment.RoomManager.GetRoom(Main.Data.LoadingRoom);
if (Room == null)
{
return;
}
if (Room.Model == null)
{
Main.SendNotif("Sorry, model data is missing from this room and therefore cannot be loaded.");
Environment.InitPacket(18, Main.ClientMessage);
Environment.EndPacket(Main.Socket, Main.ClientMessage);
Main.Data.LoadingRoom = 0;
return;
}
/*
String Hack = "xxxxxxxxxxxx"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxx000000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxx00000000"
+ (char)13
+ "xxxxxxxxxxxx"
+ (char)13
+ "xxxxxxxxxxxx"
+ (char)13;
Environment.InitPacket(31, Main.ClientMessage);
Environment.Append(Hack, Main.ClientMessage);
Environment.EndPacket(Main.Socket, Main.ClientMessage);
Environment.InitPacket(470, Main.ClientMessage);
Environment.Append(Hack, Main.ClientMessage);
Environment.EndPacket(Main.Socket, Main.ClientMessage);
*/
String HeightMap = "";
String[] Lines = Room.Model.Heightmap.split("\r\n");
for(int i = 0;i<Lines.length;i++)
{
if (Lines[i].equals(""))
{
continue;
}
HeightMap += Lines[i] + "\r";
}
Environment.InitPacket(31, Main.ClientMessage);
Environment.Append(HeightMap, Main.ClientMessage);
Environment.EndPacket(Main.Socket, Main.ClientMessage);
/*
String[] tmpHeightmap = Room.Model.Heightmap.split("\r");
String ToSend = "";
for (int y = 0; y < Room.Model.MapSizeY; y++)
{
if (y > 0)
{
tmpHeightmap[y] = tmpHeightmap[y].substring(1);
}
for (int x = 0; x < Room.Model.MapSizeX; x++)
{
String Square = tmpHeightmap[y].substring(x, x+1).trim().toLowerCase();
if (Room.Model.DoorX == x && Room.Model.DoorY == y)
{
Square = Integer.toString((int)Room.Model.DoorZ);
}
ToSend += Square;
}
ToSend += "\r";
}*/
Environment.InitPacket(470, Main.ClientMessage);
Environment.Append(HeightMap, Main.ClientMessage);
Environment.EndPacket(Main.Socket, Main.ClientMessage);
}
}
|
a0855993-c88f-47da-b927-771cc80d4fa6
| 7 |
public void renderSheet(int xp, int yp, SpriteSheet sheet, boolean fixed) {
if (fixed) {
xp -= xOffset;
yp -= yOffset;
}
for (int y = 0; y < sheet.HEIGHT; y++) {
int ya = y + yp;
for (int x = 0; x < sheet.WIDTH; x++) {
int xa = x + xp;
if (xa < 0 || xa >= width || ya < 0 || ya >= height) continue;
pixels[xa + ya * width] = sheet.pixels[x + y * sheet.WIDTH];
}
}
}
|
0e181ff7-6cb2-4bf9-9b0f-061c2fd5be50
| 7 |
public CobaltFont(String fontPath, String textureName)
{
glyphHeight = 16;
characters = new HashMap<Character, TextureRegion>();
Texture texture = new Texture("res/font/", textureName);
try
{
String file = "";
@SuppressWarnings("resource")
Scanner scanner = new Scanner(new File(rootDirectory + fontPath)).useDelimiter("\\A");
file = scanner.next();
scanner.close();
String[] lines = file.split("\n");
int maxGlyphWidth = 16;
int xRepeat = 16;
int cIndex = 0;
int scale = 1;
for(int i = 0; i < lines.length; i++)
{
if(lines[i].startsWith("#"))
continue;
if(lines[i].startsWith("height"))
glyphHeight = Integer.parseInt(lines[i].split(" ")[1].trim());
else if(lines[i].startsWith("width"))
maxGlyphWidth = Integer.parseInt(lines[i].split(" ")[1].trim());
else if(lines[i].startsWith("xRepeat"))
xRepeat = Integer.parseInt(lines[i].split(" ")[1].trim());
else if(lines[i].startsWith("scale"))
scale = Integer.parseInt(lines[i].split(" ")[1].trim());
else
{
int width = Integer.parseInt(lines[i].trim());
characters.put((char)(cIndex+32), new TextureRegion(texture, (cIndex%xRepeat) * maxGlyphWidth * scale, (int)Math.floor(cIndex/xRepeat) * glyphHeight * scale, width * scale, glyphHeight * scale));
cIndex++;
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
|
ffe163f7-01e5-457a-94dd-81de32d1ec09
| 7 |
private void getBipolarQuestionList() {
titleDLM.removeAllElements();
bipolarQuestionList = bipolarQuestion.getBipolarQuestionList(fileName, publicFileName, counterTeamType);
if (bipolarQuestionList.size() != 0) {
for (int i = 0; i < bipolarQuestionList.size(); i++) {
titleDLM.addElement(bipolarQuestionList.get(i).getTitle());
}
titleJlst.setSelectedIndex(0);
if (!(bipolarQuestionList.get(0).getDescription() == null
|| bipolarQuestionList.get(0).getDescription().equals("null"))) {
descriptionJtxa.setText(bipolarQuestionList.get(0).getDescription());
}
// Exists patent claim
bipolarQuestionCurrent = bipolarQuestionList.get(0);
if (bipolarQuestionCurrent.getBipolarQuestionParent() != null) {
parentContentJlbl.setText(bipolarQuestionCurrent.getBipolarQuestionParent().getTitle()); // Store parent title
parentIdJlbl.setText(bipolarQuestionCurrent.getBipolarQuestionParent().getId()); // Store Parent id
} else {
parentContentJlbl.setText("None");
}
dialogContentJlbl.setText(bipolarQuestionCurrent.getDialogState());
playerContentJlbl.setText(bipolarQuestionCurrent.getName());
if (bipolarQuestionCurrent.getName().equals(userLogin.getName())
&& bipolarQuestionCurrent.getDialogState().equals("Private")) {
editDetailsJbtn.setEnabled(true);
deleteActionJbtn.setEnabled(true);
} else {
editDetailsJbtn.setEnabled(false);
deleteActionJbtn.setEnabled(false);
}
}
}
|
289fc508-2f1a-48a2-9b3e-1ee79fb91c89
| 0 |
public void setTitel(String titel) {
this.titel = titel;
}
|
339122d9-a2c5-435c-bfd2-669e10e66df4
| 6 |
public void run() {
File processedFileDir = new File(Lunar.OUT_DIR + Lunar.ROW_DIR
+ Lunar.PROCESSED_DIR);
try {
while (true) {
File row = ImageStorage.rowFilesPoll();
if (row != null) {
BufferedReader in = new BufferedReader(new FileReader(row));
String line;
StringBuffer stmtBuffer = new StringBuffer();
stmtBuffer
.append("INSERT INTO base_data2(LAT, LON, HEIGHT) VALUES ");
String stmtBuilder = "INSERT INTO base_data2(LAT, LON, HEIGHT) VALUES ";
while ((line = in.readLine()) != null) {
String[] item = line.split(",");
stmtBuffer.append("(");
stmtBuffer.append(item[0]);
stmtBuffer.append(",");
stmtBuffer.append(item[1]);
stmtBuffer.append(",");
stmtBuffer.append(item[2]);
stmtBuffer.append(")");
stmtBuffer.append(",");
if (item[2].matches("null")) {
stmtBuilder += String.format("(%s, %s, null),",
item[0], item[1]);
} else {
stmtBuilder += String.format("(%s, %s, %s),",
item[0], item[1], item[2]);
}
}
in.close();
in = null;
stmtBuffer.delete(stmtBuffer.length() - 1,
stmtBuffer.length());
stmtBuffer.append(";");
stmtBuilder = stmtBuilder.substring(0,
stmtBuilder.length() - 1);
stmtBuilder += ";";
ImageStorage.statementsPut(stmtBuilder);
// Move file
FileUtils.moveFileToDirectory(row, processedFileDir, false);
} else {
break;
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Statements created");
}
|
4065bd9d-824f-47a5-b0ae-be5247c42ec0
| 1 |
@Override
public void show () {
System.out.println(i);
if(i != 1){
System.out.println("|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
universe.generateWorlds(false);
}
i++;
}
|
76fcf8aa-82a0-4901-9b5b-44cda35c9eb1
| 3 |
@Override
@SuppressWarnings("RefusedBequest")
// Not calling superclass is intended, but not optimal. All buffers should in
// my current oppinion be the same buffer Collection. Right now there are some actions that are both added to the AttackData
// class and the placable itself which is weird. Better have them all in one place or?
public void addBuffers(GameAction action) {
if (!getBuffers().contains(action)) {
getBuffers().add(action);
for (GameAction currentGameAction : getGameActions()) {
if (currentGameAction.hasAnAttack())
currentGameAction.getAttackData().addBuffers(action);
}
}
}
|
e6709c4c-4f00-4bce-8a5e-cea783841fa7
| 8 |
public void mouseMoved(MouseEvent e) {
int x = e.getX();
int y = e.getY();
if (state == RESIZE) {
if (rect1.contains(x, y) || rect2.contains(x, y)) {
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
else if (state == ROTATE) {
if (rotCircle1.contains(x, y)) {
particleToBeRotated = true;
handleIndex = 1;
setCursor(rotateCursor1);
}
else if (rotCircle2.contains(x, y)) {
particleToBeRotated = true;
handleIndex = 2;
setCursor(rotateCursor1);
}
else if (rotCircle3.contains(x, y)) {
particleToBeRotated = true;
handleIndex = 3;
setCursor(rotateCursor1);
}
else if (rotCircle4.contains(x, y)) {
particleToBeRotated = true;
handleIndex = 4;
setCursor(rotateCursor1);
}
else {
particleToBeRotated = false;
handleIndex = -1;
setCursor(rotateCursor2);
}
}
}
|
1d34a6bc-e57b-4c44-adc6-b15c35647fbb
| 3 |
@Override
public void run() {
init();
long start = 0;
long elapsed = 0;
long wait = 0;
while(running){
start = System.nanoTime();
update();
render();
renderScreen();
elapsed = System.nanoTime() - start;
wait = targetTime - elapsed / 1000000;
if(wait < 0) wait = 5;
try {
Thread.sleep(wait);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
|
ef6409a3-7dc9-4a65-ad6b-08b877dd3427
| 2 |
public int turretTracker(){
int loop;
for (loop = 0; loop < turretBuilder.size(); loop++){
if (turretBuilder.get(loop).focused){
return loop;
}
}
return -1;
}
|
5e1e9d70-63fd-4a07-88ff-55471c3066b1
| 2 |
@RequestMapping("createAndSaveDept")
@ResponseBody
public String createAndSaveDept(HttpServletRequest request, HttpServletResponse response)
{
String deptName = request.getParameter("deptName");
if (null == deptName || "".equals(deptName))
{
System.out.println("Department Name cannot be NULL!");
return null;
}
Department dept = new Department(deptName);
DepartmentDao.createAndSaveDept(dept);
return null;
}
|
9b133f7f-9cb7-4438-9ab5-20bc8a9dd593
| 1 |
public static void DisplayGreetings(Player color) {
Game.board.Display();
PrintSeparator('_');
if (color.equals(Player.white)){
System.out.println("Congrats!!!!!!!!!! White has Won.");
}
else{
System.out.println("Congrats!!!!!!!!!! Black has Won.");
}
}
|
a56d4e0f-f5ca-49c1-bdff-fdb65ae2a1df
| 9 |
public boolean ParseMobCommand(Mob mob,String command){
boolean found = true;
if (!this.parsePlayerCommand(mob,command)){ // mobs are players.
String token;
StringTokenizer st = new StringTokenizer(command, " ");
if (st.hasMoreTokens()) {
token = st.nextToken();
if (token.matches("pause")) {
token = st.nextToken();
int miliseconds = Integer.parseInt(token);
try {
Thread.sleep(miliseconds);
} catch (InterruptedException ex) {
//add something here to notify the mob's owner
}
} else if (token.equals("cdmove")) {
mob.moveCurrentDirection();
//here for no good reason, but I know I'll be adding commands
} else if (token.equals("attackPlayers")){ // attack any player
// figure this out...where does this belong?
// maybe make the mob automatically do this based on some
// kind of measurement of violence?
//System.out.println(mob.getPlayerName()+" Called start fight.\r\n");
Player victim = mob.getCurrentRoom().getRandomPlayer(mob);
if (victim != null){
this.parsePlayerCommand(mob, "attack " + victim.getPlayerName());
}
} else if (st.hasMoreTokens()){
//if the player is a mob, do this at the end of mob parser.
System.out.println("got here");
Item i;
i = mob.getItemByName(st.nextToken());
if (i != null){
i.use(mob,token,st);
}
} else {
found = false;
}
}
}
return found;
}
|
32395dc5-ced7-4a9b-8818-6bc6db959d5a
| 5 |
@Test
public void testBuildCity() {
VertexLocationRequest location1 = new VertexLocationRequest(0, 0, VertexDirection.NorthWest);
BuildCityRequest request = new BuildCityRequest(0, location1);
ServerModel aGame;
aGame = gamesList.get(1);
int totalCitiesBEFORE = aGame.getMap().getCities().size();
int playerCitiesBEFORE = aGame.getPlayers().get(0).getCities();
try {
aGame = moves.buildCity(request, cookie);
int totalCitiesAFTER = aGame.getMap().getCities().size();
int playerCitiesAFTER = aGame.getPlayers().get(0).getCities();
assertEquals("Total Cities",totalCitiesBEFORE+1,totalCitiesAFTER);
assertEquals("PLayer Cities", playerCitiesBEFORE-1, playerCitiesAFTER);
} catch (InvalidMovesRequest e) {
System.out.println(e.getMessage());
} catch (ClientModelException e) {
System.out.println(e.getMessage());
}
boolean builtCity = false;
for (City city : aGame.getMap().getCities()) {
if (city.getLocation().getHexLoc().getX() == 0 && city.getLocation().getHexLoc().getY() == 0) {
builtCity = true;
break;
}
}
assertEquals(builtCity, true);
}
|
1b0e9031-102f-4443-a445-9a8a3176ef82
| 3 |
public static void main(String[] args) throws InterruptedException {
new LoaderManager(LoaderManager.ServerAPI.StandAlone, null);//todo
a = new Date();
System.out.println("Starting... Running checks on every Service");
IsMinecraftDown.checkAllStatus();
while (!IsMinecraftDown.getThreads().isEmpty())
for (Thread t : IsMinecraftDown.getThreads().keySet()){
t.join();//wait till one of the threads is done, while loop will check if others are
break;
}
System.out.println((new Date().getTime() - a.getTime()) + "ms\n");
for (Status status : IsMinecraftDown.getAllCurrentStatus())
status.printStatus();
System.out.println(IsMinecraftDown.getFormatedStatus());
}
|
364fb804-912b-4bbc-91ca-a814d738d0d7
| 6 |
@Override
public PlayerAction chooseAction(State state, IPlayer player) throws Exception {
lastAction = new PlayerAction();
lastAction.oldStake = player.getCurrentBet();
// minimum raise
double payToCall = state.getBiggestRaise() - player.getCurrentBet();
double handStrength = 0;
if (state.getStage() == STAGE.PREFLOP) {
handStrength = preFlop.get(state.getPlayersNotFolded() - 2).getStrength(player.getHoleCards());
} else {
// the only difference between HandStrengthStrategy and ImprovedHandStrengthStrategy is this line
// here the function simulateHandWithSharedCardsAndRandom is called, which makes several rollouts for FLOP and TURN
handStrength = new Rollout().simulateHandWithSharedCardsAndRandom(player.getHoleCards(), state.getSharedCards(), state.getPlayersNotFolded(), iterationsOfRollout);
}
// int willingToPay = (int) Math.exp((aggressivity.ordinal() + lambda) * handStrength);
// int willingToPay = (int) (500.0 * (aggressivity.ordinal() + 1) * handStrength);
// int willingToPay = (int) (Math.tanh(handStrength*2) * 500.0 * (aggressivity.ordinal() + 1));
// the amount to pay is calculated with an exp-function
int willingToPay = (int) (Math.exp((handStrength * 3) - 3) * 100.0 * (aggressivity.ordinal() + 1));
if (willingToPay > Integer.MAX_VALUE || willingToPay < 0) {
willingToPay = Integer.MAX_VALUE;
}
lastPotOdd = payToCall / (payToCall + state.getPot());
int minimumRaise = Math.max(state.getBiggestRaise(), state.getBigBlindSize());
//the pod odd has influence on the decision whether to fold or to stay in the game
if (willingToPay < payToCall * lastPotOdd) {
lastAction.action = ACTION.FOLD;
}
// the number of raises has influence on the decision whether to call or to raise
else if (Math.max(willingToPay, minimumRaise) < payToCall * (1.0 / (1.0 + state.getNumberOfRaises())) || minimumRaise >= willingToPay) {
lastAction.action = ACTION.CALL;
lastAction.toPay = state.getBiggestRaise() - player.getCurrentBet();
} else {
lastAction.action = ACTION.RAISE;
lastAction.toPay = Math.max(willingToPay, minimumRaise);
}
lastHandStrength = handStrength;
return lastAction;
}
|
9f7283f5-b7e9-47be-8be5-c14afa8505ce
| 3 |
public static final int task1() {
int sum = 0;
for (int i = 0; i < 1000; i++) {
if ((i % 3 == 0) || (i % 5 == 0)) {
sum += i;
}
}
return sum;
}
|
449ac690-4e35-4c3d-82db-fc6bdd330988
| 4 |
public XMLConfiguration get(QcRequest request)
throws QcException, Exception
{
XMLConfiguration xmlData = null;
log.debug("Requested Url :" + request.getURL());
//Open HTTP connection to the url
HttpURLConnection conn = (HttpURLConnection) new URL(request.getURL()).openConnection();
conn.setRequestMethod("GET");
long opStartTime = System.currentTimeMillis();
//Add header properties.
Properties headerProps = request.getDefaultHeaderProperties();
for(String propName : headerProps.stringPropertyNames()) {
conn.setRequestProperty(propName, headerProps.getProperty(propName));
}
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
xmlData = new XMLConfiguration();
xmlData.load(conn.getInputStream());
} else {
QcException qcException = new QcException("Response code :"
+ conn.getResponseCode() + ", Error message :"
+ QcUtil.readData(conn.getErrorStream()));
if (conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
log.warn(qcException.getMessage());
throw new NotFound();
} else {
throw qcException;
}
}
long opEndTime = System.currentTimeMillis();
log.debug("Time taken to process QC request: {} secs",
(opEndTime - opStartTime) / 1000);
if (log.isTraceEnabled()) {
log.trace("GET Response XML data :\n"
+ ConfigurationUtils.toString(xmlData));
}
return xmlData;
}
|
db6dbcec-c6a5-47e7-a675-7e5fc7b0f9de
| 6 |
protected void doHurt(int damage, int attackDir) {
if (hurtTime > 0 || invulnerableTime > 0) return;
Sound.playerHurt.play();
//level.add(new TextParticle("" + damage, x, y, Color.get(-1, 504, 504, 504)));
health -= damage;
if (attackDir == 0) yKnockback = +6;
if (attackDir == 1) yKnockback = -6;
if (attackDir == 2) xKnockback = -6;
if (attackDir == 3) xKnockback = +6;
hurtTime = 10;
invulnerableTime = 30;
}
|
61960fc2-c9eb-4dc8-99a9-4118d65bc294
| 3 |
public void lisaaJonoonLaskutoimitus(Laskutoimitus lisattava) throws IllegalArgumentException, IllegalStateException {
if (lisattava == null) {
throw new IllegalArgumentException();
}
if (seuraavaArvollinen == null) {
throw new IllegalStateException();
}
if (this.eiSisallaLaskutoimituksia()) {
this.asetaEnsimmainen(lisattava);
return;
}
viimeinen.setTakajasen(seuraavaArvollinen);
seuraavaArvollinen = null;
lisattava.setEtujasen(viimeinen);
viimeinen = lisattava;
}
|
991f30f9-cbf4-40fe-8aab-537f20aca696
| 8 |
public void putAll( Map<? extends Double, ? extends Short> map ) {
Iterator<? extends Entry<? extends Double,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
|
90746ed0-9dbf-4192-826b-99ddb344c826
| 2 |
public static void update(Level lvl,long gametime){
Statistique.gametime = gametime;
if(Avatar.isDead)
Statistique.numberOfDeath++;
if(lvl.isCompleted())
Statistique.currentLvl++;
}
|
0c1ba5fa-b76d-4a14-a633-4f763fccfc98
| 3 |
@Override
public boolean propertyEquals(String key, Object test_value) {
if (propertyExists(key)) {
Object value = getProperty(key);
if (value != null) {
return value.equals(test_value);
} else {
if (test_value == null) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
|
4694784f-ad9d-4269-be6f-9adb057adc89
| 8 |
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
input.useLocale(Locale.US);
System.out.println("Inserire la lunghezza dei due cateti : ");
double cateto1 = input.nextDouble();
double cateto2 = input.nextDouble();
input.close();
double ipotenusa = Math.sqrt(Math.pow(cateto1,2)+Math.pow(cateto2,2));
double area = (cateto1 * cateto2)/2;
double perimeter = cateto1+cateto2+ipotenusa;
double angle1 = Math.toDegrees(Math.asin(cateto2/ipotenusa));
double angle2 = Math.toDegrees(Math.asin(cateto1/ipotenusa));
//frasi che devono avere la stessa lunghezza;
String frase1 ="Ipotenusa: ";
String frase2 ="Perimetro:";
String frase3 ="Area:";
String frase4 ="Angolo1:";
String frase5 ="Angolo2:";
while(frase1.length()>frase2.length() || frase1.length()>frase3.length() || frase1.length()>frase4.length() || frase1.length()>frase5.length())
{
if (frase1.length()>frase2.length())
{
frase2+=" ";
}
else if(frase1.length()>frase3.length())
{
frase3+=" ";
}
else if(frase1.length()>frase4.length())
{
frase4+=" ";
}
else if(frase1.length()>frase5.length())
{
frase5+=" ";
}
}
//stampa i valori incolonnati
System.out.printf(Locale.US,frase1+"%10.2f cm\n",ipotenusa);
System.out.printf(Locale.US,frase2+"%10.2f cm\n",perimeter);
System.out.printf(Locale.US,frase3+"%10.2f cm2\n",area);
System.out.printf(Locale.US,frase4+"%10.2f°\n",angle1);
System.out.printf(Locale.US,frase5+"%10.2f°\n",angle2);
}
|
ff87bd40-3ca7-4277-b79b-951cc6e43959
| 2 |
public int getMDef(){
int value = 0;
for (Armor armor : armorList) {
if(armor != null) value += armor.getStats().getmDef();
}
return value;
}
|
e32c2cca-6ae3-4b74-8fd4-5f9041b64711
| 1 |
public boolean validChosenItemIndex() {
return getChosenItemIndex() >= 0 && getChosenItemIndex() < items.size();
}
|
8c89b371-bcf3-4140-ae17-abfd1737ea10
| 2 |
public void start() {
this.stop = false;
this.forceStop = false;
if (this.thread == null || !this.thread.isAlive()) {
this.thread = new Thread(this);
this.thread.setName("bt-announce");
this.thread.start();
}
}
|
80be57a4-9acc-4bf4-b56b-28a5c039e019
| 5 |
protected void rnt(TouchFrame frame) {
float cx = getWidth() * 0.5f;
float cy = getHeight() * 0.5f;
float tx1 = frame.getLocalX();
float ty1 = frame.getLocalY();
float tx0 = frame.getLastLocalX();
float ty0 = frame.getLastLocalY();
float r = (float)Math.sqrt((tx0 - cx) * (tx0 - cx) + (ty0 - cy) * (ty0 - cy));
float radius = Math.max(cx, cy) * 0.65f;
if (rotatable && r > radius) {
double a0 = Math.atan2(cx - tx0, cy - ty0);
double a1 = Math.atan2(cx - tx1, cy - ty1);
double da = (a0 - a1);
if (da > Math.PI) {
da -= Math.PI * 2;
} else if (da < -Math.PI) {
da += Math.PI * 2;
}
this.tform.rotate(da * 0.3, tx1, ty1);
this.vr = (float)da;
} else {
this.vr = 0;
}
if (movable) {
translateInWorld(frame.getDeltaX(), frame.getDeltaY());
this.vx = tframe.getDeltaX();
this.vy = tframe.getDeltaY();
}
}
|
69b79b1a-ec30-439a-b714-7f166bda8cfa
| 5 |
public void printTopologyOrder(Graph<T> g) throws EdgeVerticeNotFound{
DFSSearch(g);
ArrayList<Integer> result=new ArrayList<Integer>();
ArrayList<Integer> newInput=new ArrayList<Integer>();
for(int i:clock2){
newInput.add(i);
}
while(result.size()!=clock2.length){
int max=0;
int maxIndex=-1;
for(int i=0;i<newInput.size();i++){
if(newInput.get(i)>max){
max=newInput.get(i);
maxIndex=i;
}
}
result.add(maxIndex);
newInput.set(maxIndex, 0);
}
for(int i:result){
System.out.println(g.vertices.get(i).getStartVertice());
}
}
|
2c56d15e-8771-4aad-af08-5847e75e2262
| 2 |
public void initMaze() {
for (int i = 0; i < newRun.BOARD_MAX; i++) {
for (int j = 0; j < newRun.BOARD_MAX; j++) {
board[i][j].setBorder(findBorder(j, i, true));
}
}
}
|
78ec07d6-8068-48a4-99ce-2a8a620bbc48
| 0 |
public static GeneralValidator isGreaterThanEqualsTo() {
return GREATER_THAN_EQUALS_TO_VALIDATOR;
}
|
2aa6eb4a-f6ca-466f-900f-7953551c3966
| 7 |
@Override
public void run() {
mainLoop:
while (true) {
// update running status
for (int i = 0; i < maxClients; i++) {
handshaked[i] = listeners[i].handshakesFinished();
running[i] = listeners[i].clientRunning();
success[i] = listeners[i].success();
}
boolean tmp = true;
// check running status
int succ = 0;
for (int i = 0; i < maxClients; i++) {
if (running[i]) {
tmp = true;
break;
} else {
tmp = false;
if(success[i]){
succ++;
}
}
}
if (!tmp) {
// Everything finished running
elapsed = System.currentTimeMillis() - start;
System.out.println("Sent " + maxPackets * maxClients + " packets in " + elapsed + "ms");
System.out.println("Connections: " + succ + " succeeded, " + (maxClients-succ) + " failed.");
break;
}
try {
Thread.sleep(5);
} catch (InterruptedException ie) {
}
}
}
|
a93a74ad-699c-4193-9dbe-ec337208ea55
| 4 |
public SchachbrettFeld getKoenigPosition(boolean farbe) // figurFarbe ist true für schwarz
{
SchachbrettFeld feld = null;
for (SchachbrettFeld f : this.felder) {
if (f.figur != null && f.figur.getClass().getSimpleName().equals("Koenig") && f.figur.figurFarbe == farbe) {
feld = f;
}
}
return feld; // sollte nie zurück geliefert werden. Irgendwo muss der König ja stehen
}
|
550b6876-62a7-4c6b-8faf-5adf4f5292f8
| 5 |
private Document initDocument(String responseContent, Document document, boolean namespaceAware) {
if(document == null) {
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(namespaceAware);
final DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new ByteArrayInputStream(responseContent.getBytes("UTF8")));
} catch (UnsupportedEncodingException e) {
throw new AzotException(e);
} catch (ParserConfigurationException e) {
throw new AzotException(e);
} catch (SAXException e) {
throw new AzotException(e);
} catch (IOException e) {
throw new AzotException(e);
}
}
return document;
}
|
e1e3b0f4-1060-41d0-9054-bc5262176b38
| 1 |
public boolean buttonDown(int button) {
return poll[button - 1] == MouseState.ONCE
|| poll[button - 1] == MouseState.PRESSED;
}
|
17d9f4be-1315-45ec-8771-71ef2bc45c46
| 9 |
void playSound(boolean capturing) {
if (tile != null) {
if (tile instanceof Bear)
AUDIO_BEAR.play();
else if (tile instanceof Duck)
AUDIO_DUCK.play();
else if (tile instanceof Fox)
AUDIO_FOX.play();
else if (tile instanceof Hunter) {
if (capturing)
AUDIO_RIFLE.play();
else
AUDIO_WALK.play();
}
else if (tile instanceof Lumberjack && !capturing)
AUDIO_WALK.play();
else if (tile instanceof Pheasant)
AUDIO_PHEASANT.play();
}
}
|
e5b59ef1-cf81-4de5-8232-6edead79ee0d
| 6 |
private void DisableOther(CommandSender sender, String[] args) {
if (args.length < 2 && extraauth.DB.Contains(args[1])) {
send(sender, extraauth.Lang._("Command.NoPlayer"));
return;
}
final PreUnregistrationEvent event = new PreUnregistrationEvent(
new PlayerInformation(args[1]));
extraauth.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
extraauth
.getServer()
.getPluginManager()
.callEvent(
new UnregistrationFailedEvent(new PlayerInformation(args[1]),
FailedReason.CANCELED));
send(sender, extraauth.Lang._("Command.Disable.Event.Failed"));
} else if (!extraauth.DB.Contains(args[1])
&& extraauth.DB.Get(args[1]) != null) {
extraauth
.getServer()
.getPluginManager()
.callEvent(
new UnregistrationFailedEvent(new PlayerInformation(args[1]),
FailedReason.NOT_REGISTERED));
send(sender,
extraauth.Lang._("Command.Disable.NotRegistered.Other.Failed"));
} else if (extraauth.DB.Remove(args[1], false) == FailedReason.SUCCESSFULL) {
extraauth.getServer().getPluginManager()
.callEvent(new UnregistrationSuccessfullEvent(args[1]));
send(sender, extraauth.Lang._("Command.Disable.Other.Success"));
} else {
extraauth
.getServer()
.getPluginManager()
.callEvent(
new UnregistrationFailedEvent(new PlayerInformation(args[1]),
FailedReason.UNKNOWN));
send(sender, extraauth.Lang._("Command.Disable.Unknown.Failed"));
}
}
|
c8be08cc-6bd5-473b-a1dd-41d2d768636d
| 6 |
private void trSort (final int ISA, final int n, final int depth) {
final int[] SA = this.SA;
int first = 0, last;
int t;
if (-n < SA[0]) {
TRBudget budget = new TRBudget (n, trLog (n) * 2 / 3 + 1);
do {
if ((t = SA[first]) < 0) {
first -= t;
}
else {
last = SA[ISA + t] + 1;
if (1 < (last - first)) {
trIntroSort (ISA, ISA + depth, ISA + n, first, last, budget, n);
if (budget.chance == 0) {
/* Switch to Larsson-Sadakane sorting algorithm. */
if (0 < first) {
SA[0] = -first;
}
lsSort (ISA, n, depth);
break;
}
}
first = last;
}
} while (first < n);
}
}
|
6899874d-58f1-4783-b5a2-b3e27b9d7017
| 4 |
public static void main(String[] args) {
// TODO Auto-generated method stub
//程序自带数组
int[] systemArray = {23,12,14,2,5,7,46,130,25,3};
int sy[] = new int[10];
//System.out.println(sy.length +" " +systemArray.length);
System.out.println("请选择待排序数组的产生类型");
System.out.println("1.程序自定义数据2.随机产生3.用户输入4.退出");
Scanner scanner=new Scanner(System.in);
int inputFlag=scanner.nextInt();
System.out.println("选择升序还是降序,降序为0,升序是1");
int sortKind=scanner.nextInt();
System.out.println("选择排序算法1.冒泡排序2.选择排序3.插入排序4.希尔排序\n5.快速排序6.归并排序7.堆排序");
int chooseflag=scanner.nextInt();
while(inputFlag!=3){
switch (inputFlag) {
case 1:
System.out.println("自定义数组长度为10\n数组内容为{23,12,14,2,5,7,46,130,25,3}");
chooseSort(chooseflag, systemArray, sortKind);
break;
case 2:
System.out.println("请输入您希望排序的数组,空格隔开,回车是确定");
break;
case 3:
System.out.println("请输入您希望排序的数组,空格隔开,回车是确定");
break;
default:
System.out.println("您选择了退出");
break;
}
inputFlag=scanner.nextInt();
}
System.out.println("程序退出");
scanner.close();
}
|
b28527b5-f8a4-4bf2-a5aa-5db02863c74a
| 7 |
private String updateTask(String taskName, String newName, String startTime,
String endTime) {
backUp();
ArrayList<Task> found = searchKeyword(taskName);
for(int i = 0; i < found.size(); i++){
resetTaskKeyword(found.get(i));
}
if (!(found.get(0).getTaskName().equalsIgnoreCase("searchFound"))){
return NO_MATCHES_FOUND;
}
found.remove(0);
if (found.size() > 1){
return MULTIPLE_MATCHES_FOUND;
}
Task temp = found.get(0);
if (newName != null){
temp.setTaskName(newName);
}
if (startTime != null){
temp.setStartTime(startTime);
}
if (endTime != null){
temp.setEndTime(endTime);
}
writeBack();
shouldRefresh=true;
if(temp.isValidTime()){
return UPDATE_TASK_SUCCESS;
} else{
return UPDATE_TASK_SUCCESS_WARNING;
}
}
|
eb26a80d-06ec-4c9a-8ec1-c790865da862
| 8 |
@Override
public void update(Observable o, Object arg) {
if (presenter.getState().getStatus().equals("Discarding")){
initDiscardValues();
if(totalResources>=7 && !hasDiscarded) { // !hasDiscarded = issue 209 fix
discardView.showModal();
updateResourceValues();
}
else if(totalResources<7 || hasDiscarded){
waitView.showModal();
}
}
else {
if(waitView.isModalShowing()) {
waitView.closeModal();
}
if(this.getDiscardView().isModalShowing() && presenter.getState().getStatus().toLowerCase().equals("robbing")) {
this.getDiscardView().closeModal();
}
//issue 209 fix
hasDiscarded = false;
}
}
|
21c2c21d-c643-44c6-8d61-2da0025be010
| 8 |
public static void dcopy_f77 (int n, double dx[], int incx, double
dy[], int incy) {
double dtemp;
int i,ix,iy,m;
if (n <= 0) return;
if ((incx == 1) && (incy == 1)) {
// both increments equal to 1
m = n%7;
for (i = 1; i <= m; i++) {
dy[i] = dx[i];
}
for (i = m+1; i <= n; i += 7) {
dy[i] = dx[i];
dy[i+1] = dx[i+1];
dy[i+2] = dx[i+2];
dy[i+3] = dx[i+3];
dy[i+4] = dx[i+4];
dy[i+5] = dx[i+5];
dy[i+6] = dx[i+6];
}
return;
} else {
// at least one increment not equal to 1
ix = 1;
iy = 1;
if (incx < 0) ix = (-n+1)*incx + 1;
if (incy < 0) iy = (-n+1)*incy + 1;
for (i = 1; i <= n; i++) {
dy[iy] = dx[ix];
ix += incx;
iy += incy;
}
return;
}
}
|
bf6d4129-2b8a-4dd1-a7b9-e5937a9dc767
| 2 |
private void setValues(boolean config) {
if (!config) {
return;
}
try
{
mConfig.addDefault("MySQL.Hostname", "localhost");
mConfig.addDefault("MySQL.Username", "root");
mConfig.addDefault("MySQL.Password", "password");
mConfig.addDefault("MySQL.Database", "paintballpvp");
mConfig.addDefault("Server", "Thor");
List<String> messages = new ArrayList<String>();
messages.add("Type <AQUA>/join<GRAY> to play a game.");
messages.add("View your stats at <AQUA>hyperpvp.us/profile/{name}");
messages.add("Use <AQUA>/report<GRAY> to report a misbehaving player.");
messages.add("Our website is <AQUA>hyperpvp.us");
messages.add("Visit our forum <AQUA>hyperpvp.us/forum");
mConfig.addDefault("Broadcast.Prefix", "<GRAY>[<AQUA><BOLD><ITALIC>TIP<RESET><GRAY>] ");
mConfig.addDefault("Broadcast.Messages", messages);
mConfig.options().copyDefaults(true);
mConfig.save(this.mFile);
} catch (Exception e) {
e.printStackTrace();
}
}
|
7d20a76d-de04-4f0b-8671-f76522f65ada
| 2 |
public void setDAO(String daoLine) {
if (daoLine.equals("Mock")) {
dao = new MockDAO();
}
else if (daoLine.equals("MySQL")) {
dao = new MySQLDAO();
}
}
|
4ca19910-a7d2-4893-937b-59d1fc5e1ce0
| 6 |
public String getTipoPago(String tipo){
if (tipo.equals("Efectivo")){
return "E";
} else if (tipo.equals("Vale")){
return "V";
} else if(tipo.equals("Voucher")){
return "O";
} else if(tipo.equals("Cuenta de Cobro")){
return "C";
} else if(tipo.equals("Prorrateo")){
return "P";
} else if(tipo.equals("Cargo a Fondo")){
return "F";
}
return "N";
}
|
290bcbf5-a40a-422c-9fe3-1d50984a849a
| 9 |
protected SortKeyDefinition[] makeSortKeys() throws XPathException {
// handle sort keys if any
int numberOfSortKeys = 0;
AxisIterator kids = iterateAxis(Axis.CHILD);
while (true) {
Item child = kids.next();
if (child == null) {
break;
}
if (child instanceof XSLSort) {
((XSLSort)child).compile(getExecutable());
if (numberOfSortKeys != 0 && ((XSLSort)child).getStable() != null) {
compileError("stable attribute may appear only on the first xsl:sort element", "XTSE1017");
}
numberOfSortKeys++;
}
}
if (numberOfSortKeys > 0) {
SortKeyDefinition[] keys = new SortKeyDefinition[numberOfSortKeys];
kids = iterateAxis(Axis.CHILD);
int k = 0;
while (true) {
NodeInfo child = (NodeInfo)kids.next();
if (child == null) {
break;
}
if (child instanceof XSLSort) {
keys[k++] = ((XSLSort)child).getSortKeyDefinition().simplify(makeExpressionVisitor());
}
}
return keys;
} else {
return null;
}
}
|
52d07cea-cf0e-4a94-add2-30a6f9e64bb3
| 1 |
public void testConstructor_ObjectStringEx2() throws Throwable {
try {
new YearMonthDay("T10:20:30.040+14:00");
fail();
} catch (IllegalArgumentException ex) {
// expected
}
}
|
65455ce5-6806-4b88-bb19-37c83800e1a8
| 8 |
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += " " + tokenImage[tok.kind];
retval += " \"";
retval += add_escapes(tok.image);
retval += " \"";
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected.toString();
return retval;
}
|
3216496d-1891-49a9-9f0a-abb3a0178c11
| 2 |
public static void main(String[] args) {
JPopupMenu jp = new JPopupMenu();
jp.add(new JMenuItem("Menu 1"));
JFrame frame = new JFrame("Hello There");
FileSystemView fsv = new SingleRootFileSystemView(new File("C:/Watcher"));
//new File DirectoryRestrictedFileSystemView(new File("C:\\"));
JFileChooser chooser= new JFileChooser("Choose File To Share");
//chooser.setCurrentDirectory(new File("C:/Watcher"));
chooser.setMultiSelectionEnabled(true);
//chooser.setControlButtonsAreShown(false);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setApproveButtonText("Share Files");
chooser.setFileSystemView(fsv);
chooser.updateUI();
chooser.setComponentPopupMenu(jp);
chooser.setCurrentDirectory(new File("C:/Watcher"));
int choice = chooser.showOpenDialog(frame);
if (choice != JFileChooser.APPROVE_OPTION) return;
File[] chosenFile = chooser.getSelectedFiles();
for(File f:chosenFile) {
System.out.println("The name of the files is " + f.getName());
}
JButton fileChooseButton = new JButton("Choose File");
fileChooseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}});
frame.add(fileChooseButton);
frame.setVisible(true);
//.addActionListener( new ActionListener() {
// public void actionPerformed(ActionEvent e){
// File chooser code goes here usually
// }
// });
}
|
ca626ec4-0bad-4518-98aa-5e7fe776941e
| 0 |
public void die(){
}
|
fcdd2e17-11ae-437c-8fda-6b0653221a29
| 6 |
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (mDragDockable != null && mDragInsertIndex >= 0) {
Insets insets = getInsets();
int count = getComponentCount();
int x;
if (mDragInsertIndex < count) {
Component child = getComponent(mDragInsertIndex);
if (child instanceof DockTab) {
x = child.getX() - GAP;
} else if (mDragInsertIndex > 0) {
child = getComponent(mDragInsertIndex - 1);
x = child.getX() + child.getWidth();
} else {
x = insets.left;
}
} else {
if (count > 0) {
Component child = getComponent(count - 1);
x = child.getX() + child.getWidth() + GAP / 2;
} else {
x = insets.left;
}
}
g.setColor(DockColors.DROP_AREA_OUTER_BORDER);
g.drawLine(x, insets.top, x, getHeight() - (insets.top + insets.bottom));
g.drawLine(x + 3, insets.top, x + 3, getHeight() - (insets.top + insets.bottom));
g.setColor(DockColors.DROP_AREA_INNER_BORDER);
g.drawLine(x + 1, insets.top, x + 1, getHeight() - (insets.top + insets.bottom));
g.drawLine(x + 2, insets.top, x + 2, getHeight() - (insets.top + insets.bottom));
}
}
|
c2ec09fa-5a1c-4c58-b1c3-69b833a60d1f
| 3 |
private void pickCustomColor() {
Color c = JColorChooser.showDialog(SwingUtilities.getAncestorOfClass(Dialog.class, this), "Select Color", lastSelection != null ? ((ColorValue) lastSelection).color : null);
if (c != null) {
setSelectedColor(c);
} else if (lastSelection != null) {
setSelectedItem(lastSelection);
}
}
|
c0f65f1f-fec3-4066-ac91-f1c26a45e0a6
| 0 |
public void setAccountId(String accountId) {
this.accountId = accountId;
}
|
1d3c942b-06b4-4970-bb21-93d4a0d8182b
| 4 |
@Override
public String execute(SessionRequestContent request) throws ServletLogicException {
String page = (String)request.getSessionAttribute(JSP_PAGE);
if (page == null) {
page = ConfigurationManager.getProperty("path.page.index");
request.setSessionAttribute(JSP_PAGE, page);
}
String leng = request.getParameter(JSP_LENG);
Locale locale = LocaleManager.getLocale(leng);
if (locale != null) {
request.setSessionAttribute(JSP_LOCALE, locale);
}
Integer idUser = (Integer) request.getSessionAttribute(JSP_ID_USER);
if (idUser == null) {
return page;
}
Criteria criteria = new Criteria();
Locale currLocale = (Locale)(request.getSessionAttribute(JSP_LOCALE));
criteria.addParam(DAO_USER_LANGUAGE, currLocale.getLanguage());
criteria.addParam(DAO_ID_USER, idUser);
criteria.addParam(DAO_ROLE_NAME, request.getSessionAttribute(JSP_ROLE_TYPE));
try {
AbstractLogic userLogic = LogicFactory.getInctance(LogicType.USERLOGIC);
userLogic.doRedactEntity(criteria);
} catch (TechnicalException | LogicException ex) {
request.setAttribute("errorReason", ex.getMessage());
request.setAttribute("errorSaveData", "message.errorSaveData");
request.setSessionAttribute(JSP_PAGE, page);
}
return page;
}
|
2567aca8-4692-44f5-9da8-896eeb3f5ff5
| 9 |
void assignPrefixes() {
for (Map.Entry<String, Map<String, PrefixUsage>> entry : namespacePrefixUsageMap.entrySet()) {
String ns = entry.getKey();
if (!ns.equals("") && !ns.equals(WellKnownNamespaces.XML)) {
Map<String, PrefixUsage> prefixUsageMap = entry.getValue();
if (prefixUsageMap != null) {
Map.Entry<String, PrefixUsage> best = null;
for (Map.Entry<String, PrefixUsage> tem : prefixUsageMap.entrySet()) {
if ((best == null
|| (tem.getValue()).count > (best.getValue()).count)
&& prefixOk(tem.getKey(), ns))
best = tem;
}
if (best != null)
usePrefix(best.getKey(), ns);
}
}
}
}
|
2d3869ed-8a90-4cc7-a889-620a5290bc22
| 3 |
public static String readString(ByteBuffer buffer)
{
// Check that the buffer contains a short with the length of the string
if (buffer.remaining() < 2) {
return null;
}
// The first 2 bytes is the string length.
int stringLength = buffer.getShort();
// Check that the buffer contains the entire string.
if (buffer.remaining() < stringLength) {
return null;
}
// Grab the entire string as an array of bytes
char[] chars = new char[stringLength];
for (int i = 0; i < stringLength; i++) {
chars[i] = (char)buffer.get();
}
return new String(chars);
}
|
17b32e9d-f238-4c9a-88cf-c2c7c60edd2e
| 0 |
public void setRandCode(String randCode) {
this.randCode = randCode;
}
|
1ce4fcf0-31ee-47ca-b47b-b7f536b1fa5b
| 1 |
public static void setLogLevel(int logLevel) {
logLevel = logLevelEquivalents.get(logLevel) == null ? 4 : logLevelEquivalents.get(logLevel);
org.apache.log4j.Logger.getRootLogger().setLevel(Level.toLevel(logLevel));
}
|
42ea32b0-120b-40ae-8a47-912017af0a1f
| 6 |
public void sql_change_acct_info(int choice) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Statement s = GUI.con.createStatement();
if(choice == 1)
{
s.executeUpdate ("UPDATE all_users SET Hierarchy = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
else if(choice == 2)
{
s.executeUpdate ("UPDATE all_users SET First_Name = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
else if(choice == 3)
{
s.executeUpdate ("UPDATE all_users SET Last_Name = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
else if(choice == 4)
{
s.executeUpdate ("UPDATE all_users SET User_Name = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
else if(choice == 5)
{
s.executeUpdate ("UPDATE all_users SET Pass_Word = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
else if(choice == 6)
{
s.executeUpdate ("UPDATE all_users SET G_Name = \'"+change_input.getText()+"\' WHERE Last_Name = \'" + lname_input.getText() + "\' AND First_Name = \'" + fname_input.getText() + "\';");
}
s.close();
}
|
081639ad-9be1-4396-85b4-766c03fbf9da
| 3 |
private static Move BackwardRightForWhite(int r, int c, Board board){
Move backwardRight = null;
if(r>=1 && c<Board.cols-1 &&
board.cell[r-1][c+1] == CellEntry.empty
)
{
backwardRight = new Move(r,c,r-1,c+1);
}
return backwardRight;
}
|
14416ab6-dbbe-482e-aa7f-d72263a0d0a8
| 4 |
@Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
// Controls for player 1
if(keyCode == KeyEvent.VK_W) {
GameMaster.player.moveUp = false;
}
if(keyCode == KeyEvent.VK_S) {
GameMaster.player.moveDown = false;
}
// Controls for player 2
if(keyCode == KeyEvent.VK_UP) {
GameMaster.ai.moveUp = false;
}
if(keyCode == KeyEvent.VK_DOWN) {
GameMaster.ai.moveDown = false;
}
}
|
6af982c6-d100-42d7-a113-9b9ea9cff5a3
| 0 |
public void setTaille(int taille) {
this.taille = taille;
}
|
c444dfef-1ef0-447f-9265-6bfc7ce94fd6
| 4 |
public int getNextIncompleteIndex(int row, int col)
{
boolean notFound = true ;
int len = translations.size() ;
int t = row ;
int back = -1 ;
while ( (t < len) && notFound)
{
TMultiLanguageEntry dummy = (TMultiLanguageEntry) translations.get(t) ;
String str = dummy.getTranslationOnly(col) ;
if (str == null)
{
notFound = false ;
back = t ;
}
else if (str.length() < 1)
{
notFound = false ;
back = t ;
}
else
{
t++ ;
}
}
return back ;
}
|
c7e762d0-e460-4979-b17a-65a682caae3f
| 0 |
public void testByteFloatConvert() {
byte[] data = ByteUtils.floatToByte(1.23f);
float f = ByteUtils.byte2Float(data);
assertEquals(1.23f, f, 0);
}
|
19326004-2d8e-4c18-952b-ef3124d1cf7a
| 2 |
public static void soloDecimales(JTextField Texto)
{
Texto.addKeyListener(new KeyAdapter()
{
@Override
public void keyTyped(KeyEvent e)
{
char c = e.getKeyChar();
if(!Character.isDigit(c) && Character.isLetter(c))
{
e.consume();
Toolkit.getDefaultToolkit().beep();
}
}
});
}
|
86095436-e56d-4b51-96dc-5786a28bcc70
| 7 |
public void mouseMoved(MouseEvent e) {
if (searchPage == null || head2tail || peaks1 == null) {
return;
}
// ポップアップが表示されている場合
if ((selectPopup != null && selectPopup.isVisible())
|| contextPopup != null && contextPopup.isVisible()) {
return;
}
cursorPoint = e.getPoint();
PeakPanel.this.repaint();
}
|
89405a0a-5d7f-4fc2-ae79-732255304201
| 9 |
private Map splitFilename(String filename, PodCastFileNameFormat format, Map parentProps)
{
Map returnValues = new HashMap();
//Allow access to parent props in messages.
returnValues.putAll(parentProps);
returnValues.put(PodCastFileProperties.FILE_VALID, Boolean.TRUE);
//If there are no fields configured, just return them
if(format.getFields().isEmpty()) return returnValues;
//Otherwise, lets get all the parts we have to!
if(format.isDelimited())
{
m_logger.info("Using delimited format");
//Split it on the character and get the parts.
String[] parts = filename.split(format.getSplitCharacter());
//put all the values in the map
List fields = format.getFields();
Iterator it = fields.iterator();
while(it.hasNext())
{
PodCastFileNameField fnf = (PodCastFileNameField) it.next();
if(fnf.getMappedValue() != null)
{
m_logger.info("splitFilename: Setting key["+fnf.getMappedName()+"] value["+fnf.getMappedValue()+"]");
returnValues.put(fnf.getMappedName(), fnf.getMappedValue());
}
else
{
m_logger.info("splitFilename: Setting key["+fnf.getMappedName()+"] value["+parts[fnf.getPosition()]+"]");
returnValues.put(fnf.getMappedName(), parts[fnf.getPosition()]);
}
}
}
else
{
//Substring the filename positions.
List fields = format.getFields();
Iterator it = fields.iterator();
while(it.hasNext())
{
PodCastFileNameField fnf = (PodCastFileNameField) it.next();
m_logger.info("Setting key["+fnf.getMappedName()+"] value["+filename.substring(fnf.getStartpos(),fnf.getEndpos())+"]");
returnValues.put(fnf.getMappedName(), filename.substring(fnf.getStartpos(),fnf.getEndpos()));
}
}
//Go through each format, and if mapped, then look up the right value
Iterator mappedValuesIterator = format.getFields().iterator();
while(mappedValuesIterator.hasNext())
{
PodCastFileNameField fnf = (PodCastFileNameField) mappedValuesIterator.next();
if(fnf.getValueMap() != null)
{
m_logger.info("Using a map to get value for ["+fnf.getMappedName()+"]");
//Take the value, and use it as a key in the map.
returnValues.put(fnf.getMappedName(),
fnf.getValueMap().get(returnValues.get(fnf.getMappedName())));
}
}
//Now get the suffix and get the specific message for that,
//setting the mime type and message
//Make it case-insensitive
String messageAndMime;
if( returnValues.get(PodCastFileProperties.FILE_SUFFIX) != null &&
format.getFormatMessages().containsKey( ((String)returnValues.get(PodCastFileProperties.FILE_SUFFIX)).toLowerCase() ) )
{
m_logger.info("File Suffix ["+returnValues.get(PodCastFileProperties.FILE_SUFFIX)+"] found");
messageAndMime = (String)format.getFormatMessages().get(returnValues.get(PodCastFileProperties.FILE_SUFFIX));
}
else
{
//This is an unsupported file type, so we ignore
m_logger.warn("Ignoring Unsupported File Type ["+filename+"]");
returnValues.put(PodCastFileProperties.FILE_VALID, Boolean.FALSE);
returnValues.put(PodCastFileProperties.INVALID_REASON, PodCastConstants.FILE_NOT_SUPPORTED);
return returnValues;
}
String[] parts = messageAndMime.split("~");
//Set the mime type
returnValues.put(PodCastFileProperties.FILE_MIME_TYPE, parts[1]);
//Set the desc
String desc = parts[0];
desc = PodCastUtils.replaceParameters(desc, returnValues);
returnValues.put(PodCastFileProperties.FILE_TITLE, desc);
//Finally return
return returnValues;
}
|
94d9824c-d8bc-482c-86bb-7e4bcea09843
| 1 |
@Override
protected void keyboardFocusLost() {
if (state != null) {
state.keyboardFocusLost();
}
}
|
60ce7575-07bc-4fd5-a71a-29da2981c094
| 3 |
private List<Edge> getEdgesTriees() {
ArrayList<Edge> edgesTriees = new ArrayList<>();
Integer p;
for (int i = 0; i < vertex.length; i++) {
for (int j = 0; j < vertex.length; j++) {
p = this.edges[i][j];
if (p != null) {
edgesTriees.add(new Edge(i, j, p));
}
}
}
Collections.sort(edgesTriees);
return edgesTriees;
}
|
44521d06-b99c-4c2b-9108-755b7fadbd10
| 9 |
public static void test2(){
try
{
InputStream returnStream = null;
HttpsURLConnection conn = null;
int connectTimeout=15000;
int readTimeout=30000;
String requestMethod="GET";
String charEncode="utf-8";
String url="https://localhost:8443/ssl/index.jsp?username=10";
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStore", "G:/temp/cert/20140428/tomcat.keystore");
System.setProperty("javax.net.ssl.keyStorePassword","password");
System.setProperty("javax.net.ssl.keyStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", "G:/temp/cert/20140428/tomcat.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
URL serverUrl = new URL(null, url, new sun.net.www.protocol.https.Handler());
conn = (HttpsURLConnection) serverUrl.openConnection();
if (connectTimeout != -1) {
conn.setConnectTimeout(connectTimeout);
}
if (readTimeout != -1) {
conn.setReadTimeout(readTimeout);
}
conn.setRequestMethod(requestMethod);
conn.setDoOutput(true);
conn.connect();
conn.getOutputStream().write("jxgacsr".getBytes(charEncode));
if (conn.getResponseCode() != 200) {
returnStream = conn.getErrorStream();
} else {
returnStream = conn.getInputStream();
}
String returnString = "";
if (returnStream != null) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(returnStream, "UTF-8"));
StringBuffer buffer = new StringBuffer();
String line = "";
while((line = br.readLine()) != null) {
buffer.append(line);
}
returnString = buffer.toString();
System.out.println("返回:==》"+returnString);
} catch(IOException e) {
e.printStackTrace();
}
}
}
catch (UnknownHostException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
|
2306c6b1-8473-4e17-b233-2300333f4d5f
| 0 |
public void setId(Integer id) {
this.id = id;
}
|
46f9f424-3584-44a1-9085-6a8626d49df3
| 0 |
public Pyramid4(int side)
{
setSide(side);
base = DimensionalTrasform.scale(side, base);
coloredEx = new ArrayList<Excel>();
setColoredExes();
}
|
ac49aca2-60a0-4e45-8b5e-a93a45926179
| 0 |
@Override
public PermissionType getType() {
return PermissionType.GROUP;
}
|
66af6556-a64d-4cad-8df9-c033b3d64ee9
| 9 |
public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
final ChatColor yellow = ChatColor.YELLOW;
final ChatColor red = ChatColor.RED;
final ArrayList<Player> cMagic = CrazyFeet.CrazyMagic;
if(args.length < 1) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(player.hasPermission("CrazyFeet.crazymagic")) {
if(cMagic.contains(player)) {
cMagic.remove(player);
player.sendMessage(yellow+"The tingling sensation fades away..");
return true;
} else {
cMagic.add(player);
player.sendMessage(yellow+"You feel a tingling sensation in your feet!");
return true;
}
} else {
player.sendMessage(red+"No permission");
return true;
}
} else {
sender.sendMessage(red+"You must be an ingame player to do this!");
return true;
}
} else if(args.length == 1) {
if(sender.hasPermission("CrazyFeet.crazymagicother")) {
if(Bukkit.getServer().getPlayer(args[0]) != null) {
Player targ = Bukkit.getServer().getPlayer(args[0]);
if(cMagic.contains(targ)) {
cMagic.remove(targ);
targ.sendMessage(yellow+sender.getName()+" has disabled your CrazyMagic!");
sender.sendMessage(yellow+targ.getDisplayName()+"'s CrazyMagic has been disabled!");
return true;
} else {
cMagic.add(targ);
targ.sendMessage(yellow+sender.getName()+" has given you CrazyMagic!");
sender.sendMessage(yellow+targ.getDisplayName()+" has been given CrazyMagic!");
return true;
}
} else {
sender.sendMessage(red+"The player "+yellow+args[0]+red+" is either offline or does not exist!");
return true;
}
} else {
sender.sendMessage(red+"You do not have permission to toggle CrazyMagic on others.");
return true;
}
} else if(args.length > 1) {
sender.sendMessage(red+"Incorrect usage. Use /crazyfeet for help!");
return true;
}
return false;
}
|
19d4f201-7d96-4ecb-bd9f-9662561cd1a7
| 2 |
private void startNextTrial() {
gui.showCursor();
if (!currentTrialGroup.isEmpty()) {
if (experimentPhase == PHASE_XP) {
globalTrialNb++;
}
currentTrial = currentTrialGroup.remove(0);
showPreTrialBlankScreen();
} else {
//all trials have been shown, ask participant to complete the pattern he memorized
showPatternReproduction();
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.