method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
991e9206-ea84-4a93-8aec-39c4ab1701b6
| 0
|
@Test
public void compareHands_HighCardHandsHaveSameCards_HandsAreEqual() {
Hand p1 = Hand.HighCard(Rank.King, Rank.Jack, Rank.Nine, Rank.Six, Rank.Five);
Hand p2 = Hand.HighCard(Rank.King, Rank.Jack, Rank.Nine, Rank.Six, Rank.Five);
assertTrue(p1.compareTo(p2) == 0);
}
|
55132457-4d4c-4992-83e4-d291bf2b3e79
| 4
|
private void btnExportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarActionPerformed
String NombreArchivo = tfNombreArchivo.getText();
if(!NombreArchivo.equals("")){
//ORIGEN Y GRUPO NO DEBEN ESTAR VACIOS
if(selectOrigen.getSelectedIndex()!=0 || selectGrupo.getSelectedIndex()!=0){
try {
String origen = (String) selectOrigen.getSelectedItem();
String grupo = (String) selectGrupo.getSelectedItem();
ExportaTXT exportaTXT = ExportaTXT.getInstance();
exportaTXT.setParametros("origen-grupo", NombreArchivo, origen, grupo);
VistaLoading vistaLoading = new VistaLoading(null, true);
vistaLoading.setProceso(VistaLoading.EXPORTA);
vistaLoading.setLocationRelativeTo(null);
vistaLoading.setVisible(true);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException e) {
JOptionPane.showMessageDialog(this, "ERROR: " + e + ".", "Error", JOptionPane.ERROR_MESSAGE);
}
}else{
JOptionPane.showMessageDialog(null, "Debes seleccionas un origen y/o grupo.", "Error", JOptionPane.WARNING_MESSAGE);
}
}else{
JOptionPane.showMessageDialog(this, "Escribe el nombre para el archivo de salida", "Problemas.", JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_btnExportarActionPerformed
|
43bd3e00-2b92-4a8c-a2aa-86c8b9505c63
| 6
|
private static Vector3i loadTexture(String fileName, int minFilter, int magFilter)
{
String path = "res" + File.separator + "textures" + File.separator + fileName;
try
{
System.out.println("Loading Texture: " + fileName);
BufferedImage bimg = null;
try{
bimg = ImageIO.read(new FileInputStream(new File(path)));
}
catch(IOException e)
{
e.printStackTrace();
System.err.println("Unable to load texture:" + path);
System.exit(1);
}
int width = bimg.getWidth();
int height = bimg.getHeight();
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
int textureID = glGenTextures();
int[] pixels = new int[width * height * 4];
bimg.getRGB(0, 0, width, height, pixels, 0, width);
ByteBuffer buffer = Util.createByteBuffer(pixels.length);
for(int y = 0; y < height; y++)
{
for(int x = 0; x < width; x++)
{
int pixel = pixels[y * width + x];
buffer.put((byte) ((pixel >> 16) & 0xFF));
buffer.put((byte) ((pixel >> 8) & 0xFF));
buffer.put((byte) (pixel & 0xFF));
buffer.put((byte) ((pixel >> 24) & 0xFF));
}
}
buffer.flip();
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
if(minFilter == GL_LINEAR_MIPMAP_LINEAR || minFilter == GL_LINEAR_MIPMAP_NEAREST)
glGenerateMipmap(GL_TEXTURE_2D);
return new Vector3i(textureID, width, height);
}
catch(Exception e)
{
e.printStackTrace();
System.exit(1);
}
return new Vector3i(0, 1, 1);
}
|
d4bded43-c4ae-4f36-8eb9-c1b898bd4c5f
| 9
|
public void renderSprite(int xp, int yp, int scale, int color, Sprite sprite){
int size = sprite.size;
for(int y = 0; y < size * scale; y++){
int ya = y + yp;
for(int x = 0; x < size * scale; x++){
int xa = x + xp;
if(xa < 0 || ya < 0 || xa >= width || ya >= height) continue;
int col = sprite.pixels[(x / scale) + (y / scale) * size];
if(col != 0xffff00ff && col != 0xff7f007f){
if(color != -1) col = blend(col, color, 0.5f);
pixels[xa + ya * width] = col;
}
}
}
}
|
d7677fa0-badf-417e-9059-7b035bd38fd3
| 9
|
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Ensemble other = (Ensemble) obj;
if (members == null) {
if (other.members != null)
return false;
} else if (!members.equals(other.members))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
|
81a5e325-fbe3-4455-bef8-f0ce824648f0
| 3
|
public boolean isDone()
{
//Iterate through the list of restrictions
//Check to see if it's empty
if(restrictions.size() > 0)
{
boolean allRestrictionsDone = true;
for(int i=0; i<restrictions.size(); i++)
{
if(!restrictions.get(i).done)
allRestrictionsDone= false;
}
//If even a single restriction has yet to be completed, the event still is not complete.
return allRestrictionsDone;
}
else //If we have no restrictions, it can obviously be executed
return true;
}
|
6ad5fa30-cb51-4e3f-ac8e-45d6e67aaed1
| 0
|
public void SetDirection(char newDirection)
{
this.direction = newDirection;
}
|
9ae34278-22d7-49e2-8c8f-46e8175dda5a
| 4
|
public void calcFine(){
int total = 0;
int minOver = minutesParked - minutesPuchased;
int hour = minOver / 60;
int partOfHour = minOver % 60;
boolean firstTime = true;
if(hour > 0){
total += 25;
--hour;
firstTime = false;
}else{
total = 25;
}
while(hour > 0){
total += 10;
--hour;
}
if(!firstTime && partOfHour > 0)
total+=10;
fine = total;
}
|
bfc73eb7-9253-4341-80e9-9f3241bfe506
| 3
|
public static void loadFont(String key, String ref) {
if(fonts.get(ref) == null) {
if(fonts.isEmpty())
fonts.put("DEFAULT", new GameFont(ref));
if(!key.matches("DEFAULT")) {
fonts.put(key, new GameFont(ref));
}
}
}
|
51e8b1b5-604c-47a5-aa7e-533e8b804132
| 7
|
public static String toUTF8(String str){
if(str == null){
return null;
}
StringBuffer sb = new StringBuffer();
for (int i=0; i< str.length(); i++) {
char c = str.charAt(i);
if(c >= 0 && c <= 256){
sb.append(c);
}
else{
try{
byte[] b = Character.toString(c).getBytes("UTF-8");
for (int j = 0; j < b.length; j++) {
int k = b[j];
if(k<0){
k = k + 256;
}
sb.append("%" + Integer.toHexString(k).toUpperCase());
}
}
catch (Exception e) {
System.out.println(e);
}
}
}
return sb.toString();
}
|
19a2e6fe-61d3-49d6-96aa-5b7e1cc27309
| 5
|
@Override
public void move() {
updateCounter = (updateCounter + 1) % (rotationSpeedLimiter - speedOfRotation);
if(!isOnScreen)
return;
y += speed;
if(y >= SpaceWarrior.HEIGHT) {
isOnScreen = false;
}
if(updateCounter % 10 == 0) {
if(currentImage == 7)
y += (height * 0.2);
currentImage = (currentImage+1) % 8;
}
if(explosionItr == 15)
isOnScreen = false;
}
|
2bbc0c40-cd58-4c39-b342-74e43e52328d
| 2
|
@Override
public void run() {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
if (this.plugin.getNCDatabase().hasHIV(player.getName())) {
EffectFactory.getInstance().applyHivEffect(player);
player.sendMessage("You have HIV.");
}
}
}
|
93f48025-2677-49be-835d-75d434080df3
| 2
|
public V get(Object key) {
CachedValue<V> val = cache.get((K)key);
if (val == null) {
return null;
}
if (val.isExpired()) {
cache.remove((K)key);
return null;
}
return val.get();
}
|
99aa8fc6-a1fa-4162-aa2f-1ffe8b4feb47
| 0
|
public CheckResultMessage checkTotal4(int i){
return checkReport1.checkTotal4(i);
}
|
c98f1a94-fecc-4abd-85c2-16e235b8ab76
| 0
|
@Override
public void handleProgressNotification(ProgressNotification pn) {
loading.update(pn.getProgress());
}
|
875f4c10-fd71-4e89-aeaf-9136bdf413ed
| 3
|
public void stopPlaying()
{
try {
if(stream != null)
{
lg.logD("AudioPlayer: Try to stop the audio player with the stream: "+stream.name);
}
mainGui.setTitleForAudioPlayer(stream.name ,"",false);
outStream.write("stop\n");
outStream.flush();
if(stream != null)
{
lg.logD("AudioPlayer: Audio Player with stream: "+stream.name + "has been stopped");
}
} catch (IOException e) {
lg.logE("Error while stopping playback of mplayer: "+e.getMessage());
}
}
|
e668bdec-35dc-4f89-8246-b2faabcbcaed
| 9
|
public int getValue(){
if(this.v_code.charAt(0) == 'A') return 1;
if(this.v_code.charAt(0) == '2') return 2;
if(this.v_code.charAt(0) == '3') return 3;
if(this.v_code.charAt(0) == '4') return 4;
if(this.v_code.charAt(0) == '5') return 5;
if(this.v_code.charAt(0) == '6') return 6;
if(this.v_code.charAt(0) == '7') return 7;
if(this.v_code.charAt(0) == '8') return 8;
if(this.v_code.charAt(0) == '9') return 9;
else return 10;
}
|
f9d583b9-9a4c-4122-90ea-8fff10c9198e
| 5
|
public static void sort(int[] source) {
int len = source.length;
if (len == 0 || len == 1) {
System.out.println("\nEmpty or only one element!");
return;
}
for (int i = 0; i < source.length - 1; i++) {
int minIndex = i;
for (int j = i + 1; j < source.length; j++) {
if (source[j] < source[minIndex]) {
minIndex = j;
}
}
int temp = source[minIndex];
source[minIndex] = source[i];
source[i] = temp;
}
}
|
7ddf4f88-9283-4b07-b146-15a7fb478412
| 6
|
public static void main(String args[]) {
/*
* 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(ModificarEstudiante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ModificarEstudiante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ModificarEstudiante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ModificarEstudiante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ModificarEstudiante().setVisible(true);
}
});
}
|
5232a8f8-cf61-4f3e-9a64-181548fb4f0e
| 3
|
public static void main(String[] args)
{
String filename = args[0];
String delim = args[1];
StringGraph sg = new StringGraph(filename, delim);
System.out.println(filename + " : Key in your Query");
Graph G = sg.G();
while (StdIn.hasNextLine())
{
String s = StdIn.readLine();
if (sg.contains(s))
for (int w : G.adj(sg.index(s)))
System.out.println(" " + sg.name(w));
else
System.out.println("Not found in database");
}
}
|
b31664d4-c0c7-4588-9d65-69093c4bf304
| 6
|
public String getTamanhoIntuitivo() {
final int KB = 1024;
final int MB = 1024 * 1024;
final int GB = 1024 * 1024 * 1024;
String str = new String();
double tam = tamanho;
if(tamanho < KB) {
str = Long.toString(tamanho) + " bytes";
}
else if(tamanho >= KB && tamanho < MB) {
str = String.format("%.3f KB", tam / KB);
}
else if(tamanho >= MB && tamanho < GB) {
str = String.format("%.3f MB", tam / MB);
}
else if(tamanho >= GB) {
str = String.format("%.3f GB", tam / GB);
}
return str;
}
|
8b051108-ec8a-4f40-9e78-336f5efef275
| 6
|
public static void main(String[] args) {
final String[] strings = {"7 6 5 9 8 4 3 2 1 0",
"3 2 1 0 4 5 6 7 8 9", "2 3 1 5 0 6 7 4 8 9", "0 1 2 4 3 6 5 9 8 7", "0 1 2 4 5 6 7 9 3 8"};
for (String string : strings) {
final String[] split = string.split(" ");
int[] outSeq = new int[split.length];
int i = 0;
for (String s : split) {
outSeq[i++] = Integer.parseInt(s);
}
Stack<Integer> stack = new Stack<>();
int inSeq = -1;
boolean result = true;
for (int os : outSeq) {
if (os > inSeq) {
while (os > inSeq + 1) {
stack.push(++inSeq);
}
} else {
final Integer pop = stack.pop();
if (pop != os)
result = false;
break;
}
}
System.out.println(result);
}
}
|
4aec3f29-473f-4e8e-bb5d-2714eca85199
| 2
|
@Override
public double escapeTime(Complex point, Complex seed) {
// Keep iterating until either n is reached or divergence is found
int i = 0;
while (point.modulusSquared() < escapeSquared && i < iterations) {
// Z(i+1) = (|ReZ(i)| * i|ImZ(i)|) + c
double newReal = Math.abs(point.real());
double newIm = Math.abs(point.imaginary());
Complex d = new Complex(newReal, newIm);
point = d.square().add(seed);
i++;
}
return normalise(point, i);
}
|
6fcc2eac-8dd5-47ea-afb1-f4ded4306e11
| 0
|
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
|
877bbb65-c550-454d-8d45-487446e1fc3e
| 5
|
public static void main(String[] args) {
if (args.length < 2){
System.out.println("need two args - letter and filename");
}
String letter = args[0];
String filename = args[1];
BukvoReader r = new BukvoReader(letter);
List<Word> result = r.doRead(filename);
System.out.println("size " + result.size());
for (Word s : result) {
System.out.println(s);
}
List<Word> sorted = new ArrayList<>();
for (Word s : result) {
sorted.add(s);
}
Collections.sort(sorted);
for (int i = 0; i < result.size(); ++i) {
if (!result.get(i).equals(sorted.get(i))) {
System.out.println(MessageFormat.format("mismatch {0}!={1} line {2}",
result.get(i), sorted.get(i), i));
break;
}
}
System.out.println("Done");
}
|
0fbce869-f21e-45bf-8f1e-d4de23f3ad66
| 5
|
public static DynamicArray<String> generateSmoother(int size) {
DynamicArray<String> array = new DynamicArray();
for (int i = 0; i < size; i++) {
String line = "";
int l = 0;
for (int j = 0; j < size; j++) {
if (j < i + 4) {
line += "x ";
} else if (l < 3) {
if (l == 1) {
line += "x ";
} else {
line += r.nextInt(10) + 1 + " ";
}
l++;
} else {
line += "x ";
}
}
array.insert(line);
}
return array;
}
|
3aa2ec9c-4d62-4a15-98a8-c5704ab97e4c
| 9
|
public static double phi(double z)///phi(z), see [3] P439
{
if(z<=0 || z>1)
return -1;
if(z<0.5)
return -1*phi(1-z);
for(int i=1;i<normalTable.length;i++){
if(normalTable[i-1]<=z && z<=normalTable[i]){
double n1 = 0.1*((int)(i-1)/10)+0.01*((int)(i-1)%10);
double n2 = n1 + 0.01;
if(i+1<normalTable.length && normalTable[i] == normalTable[i+1] && z == normalTable[i]){
return n2+0.005;
}else{
return n1+(n2-n1)*(z-normalTable[i-1])/(normalTable[i]-normalTable[i-1]);
}
}
}
return -1;
}
|
0837b0b3-3c43-4873-aaad-3705194ce69a
| 6
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Boolean) {
setSelected(((Boolean)value).booleanValue());
if(column == 3) {
if(PigeonSDK.Mouse1TileID == Integer.parseInt(table.getValueAt(row, 2).toString())) {
setSelected(true);
}
}
if(column == 4) {
if(PigeonSDK.Mouse2TileID == Integer.parseInt(table.getValueAt(row, 2).toString())) {
setSelected(true);
}
}
setEnabled(table.isCellEditable(row, column));
if (isSelected) {
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
} else {
return null;
}
return this;
}
|
9d03ca3c-fb70-4676-9d5d-dfcf9967596d
| 1
|
public Player createPlayer(int hp, int level, String name)
{
Player newPlayer = new Player(playerCanvas);
Sprite newSprite = new Sprite();
URL spriteURL = null;
try
{
spriteURL = this.getClass().getClassLoader().getResource("sprites/sprite_fr1.png");
newSprite._setSpriteImage(spriteURL);
}
catch(NullPointerException np)
{
np.printStackTrace();
}
newPlayer._setSprite(newSprite);
// Set different player stats
newPlayer._setName(name);
newPlayer._setHp(hp);
newPlayer._setLevel(level);
newPlayer._setSpeedX(2);
newPlayer._setSpeedY(2);
return newPlayer;
}
|
3a760724-5fda-428d-800a-d383ddd81a62
| 2
|
private static Device getDefaultDevice ()
throws IOException
{
Vector devices = getDevices ();
switch (devices.size ()) {
case 1:
return (Device) devices.elementAt (0);
case 0:
System.err.println ("no de FX2 devices");
break;
default:
System.err.println ("which FX2 device?");
listDevices (devices);
break;
}
return null;
}
|
46c63a80-05c9-44fc-baf5-8dbdb23c0e7b
| 9
|
public boolean replaceSubExpression(Expression original, Expression replacement) {
boolean found = false;
if (select == original) {
select = replacement;
found = true;
}
for (int i = 0; i < sortKeyDefinitions.length; i++) {
if (sortKeyDefinitions[i].getSortKey() == original) {
sortKeyDefinitions[i].setSortKey(replacement);
found = true;
}
if (sortKeyDefinitions[i].getOrder() == original) {
sortKeyDefinitions[i].setOrder(replacement);
found = true;
}
if (sortKeyDefinitions[i].getCaseOrder() == original) {
sortKeyDefinitions[i].setCaseOrder(replacement);
found = true;
}
if (sortKeyDefinitions[i].getDataTypeExpression() == original) {
sortKeyDefinitions[i].setDataTypeExpression(replacement);
found = true;
}
if (sortKeyDefinitions[i].getLanguage() == original) {
sortKeyDefinitions[i].setLanguage(replacement);
found = true;
}
if (sortKeyDefinitions[i].collationName == original) {
sortKeyDefinitions[i].collationName = replacement;
found = true;
}
if (sortKeyDefinitions[i].stable == original) {
sortKeyDefinitions[i].stable = replacement;
found = true;
}
}
return found;
}
|
9067d0d9-9743-41b2-b5ae-d4fdc6dea86a
| 2
|
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean isFocused, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, isFocused, row, column);
if (!isSelected && !isFocused) {
cell.setBackground(Color.white);
}
return cell;
}
|
cc8006e4-a41f-421e-838e-916830b09003
| 2
|
public void setProperty(String name, String value)
{
if(!new File(PROP_FILE).exists())
{
PROP_FILE = "/usr/share/tomcat7/.jenkins/jobs/PlagiatsJaeger/workspace/WebContent/WEB-INF/classes/config.properties";
}
Properties prop = new Properties();
try
{
prop.load(new FileInputStream(PROP_FILE));
// set the properties value
prop.setProperty(name, value);
// save properties to project root folder
prop.store(new FileOutputStream(PROP_FILE), null);
}
catch (IOException e)
{
_logger.fatal(e.getMessage(), e);
e.printStackTrace();
}
}
|
e4311ad9-2c7b-40d8-9586-dc41dfa1b936
| 7
|
protected String getChannelsValue(final HTTPRequest httpReq, final String index)
{
final String name=httpReq.getUrlParameter("CHANNEL_"+index+"_NAME");
final String mask=httpReq.getUrlParameter("CHANNEL_"+index+"_MASK");
final String colors=httpReq.getUrlParameter("CHANNEL_"+index+"_COLORS");
if((name!=null)&&(name.trim().length()>0)
&&(!name.trim().equalsIgnoreCase("auction")))
{
final StringBuilder str=new StringBuilder("");
str.append(name.trim().replace(',',' ').toUpperCase()).append(" ");
if(colors.trim().length()>0)
str.append(colors.trim().replace(',',' ').toUpperCase()).append(" ");
String flagid="";
for(int i=0;httpReq.isUrlParameter("CHANNEL_"+index+"_FLAG_"+flagid);flagid=""+(++i))
{
final String flagName=httpReq.getUrlParameter("CHANNEL_"+index+"_FLAG_"+flagid);
final ChannelsLibrary.ChannelFlag flag=(ChannelsLibrary.ChannelFlag)CMath.s_valueOf(ChannelsLibrary.ChannelFlag.values(), flagName);
if(flag != null)
str.append(flag.name()).append(" ");
}
if(mask.trim().length()>0)
str.append(mask.trim().replace(',',' ')).append(" ");
str.setLength(str.length()-1);
return str.toString();
}
return null;
}
|
b42dcca9-dce0-4562-bd6d-e361327f7414
| 1
|
private void createSong() {
try {
String title;
String artist;
String categoryId;
String filename;
System.out.println("Enter title: ");
title = Keyboard.readString();
System.out.println("Enter artist: ");
artist = Keyboard.readString();
System.out.println("Enter category: ");
categoryId = Keyboard.readString();
System.out.println("Enter file name: ");
filename = Keyboard.readString();
BESong aSong = new BESong(0, title, artist, categoryId, filename);
BLLSong ds = new BLLSong();
ds.createSong(aSong);
} catch (Exception ex) {
System.out.println("Could not insert song - " + ex.getMessage());
}
}
|
8bb4cab3-df59-4455-b217-7a0a52291438
| 8
|
public static void main(String[] args) {
//Initialize objects
Random randObj = new Random();
//Initialize constants
final double side = 6;
//Initialize radius and number of trials with command-line arguments
double radius = Integer.parseInt(args[0]);
int trials = Integer.parseInt(args[1]);
//Choose linear or random mode
String mode = args[2];
//Initialize variable for storing data
int frequency[] = new int[1000];
double maximumAngle = 0;
int maximumBounceTimes = 0;
System.out.println("Running...");
//Linear mode
if (mode.equalsIgnoreCase("systematic")) {
for (double angleMultiplier = 0 ; angleMultiplier < 2.0 ; angleMultiplier = angleMultiplier + (2.0 / trials)) {
//Initialize discs
Disc disc1 = new Disc(new Vector(side / 2 , -side * Math.sqrt(3) / 6) , radius);
Disc disc2 = new Disc(new Vector(-side / 2 , -side * Math.sqrt(3) / 6) , radius);
Disc disc3 = new Disc(new Vector(0 , side * Math.sqrt(3) / 3) , radius);
//Initialize the particle
double angle = Math.PI * angleMultiplier;
Particle particle = new Particle(new Vector(0 , 0) , new Vector(Math.cos(angle) , Math.sin(angle)));
//Calculation starts
int bounceTimes = Bounce.Bounce(disc1 , disc2 , disc3 , particle);
//Add data to storing variables
if (bounceTimes > maximumBounceTimes) {
maximumBounceTimes = bounceTimes;
maximumAngle = angle;
}
frequency[bounceTimes]++;
}
}
//Random mode
else if (mode.equalsIgnoreCase("random"))
{
for (int i = 0 ; i < trials ; i++) {
//Initialize discs
Disc disc1 = new Disc(new Vector(side / 2 , -side * Math.sqrt(3) / 6) , radius);
Disc disc2 = new Disc(new Vector(-side / 2 , -side * Math.sqrt(3) / 6) , radius);
Disc disc3 = new Disc(new Vector(0 , side * Math.sqrt(3) / 3) , radius);
//Initialize the particle
double randomMultiplier = randObj.nextDouble() + randObj.nextDouble();
double angle = Math.PI * randomMultiplier;
Particle particle = new Particle(new Vector(0 , 0) , new Vector(Math.cos(angle) , Math.sin(angle)));
//Calculation starts
int bounceTimes = Bounce.Bounce(disc1 , disc2 , disc3 , particle);
//Add data to storing variables
if (bounceTimes > maximumBounceTimes) {
maximumBounceTimes = bounceTimes;
maximumAngle = angle;
}
frequency[bounceTimes]++;
}
}
else
System.exit(0);
//Report
int totalFrequency = 0;
System.out.println("For discs with r=" + radius + " and " + trials + " trials in " + mode + " mode:");
for (int i = 0 ; i < 1000 ; i++) {
totalFrequency = totalFrequency + i * frequency[i];
if (frequency[i] != 0)
System.out.println(i + " bounces repeats " + frequency[i] + " times.");
}
System.out.println("Average frequency is: " + (totalFrequency / (double)trials));
System.out.println("Maximum angle for most bounces is " + maximumAngle);
}
|
2240d7c0-379a-4c4e-96ae-3351edbded86
| 5
|
@Override
public void keyPressed(int i, char c) {
if (i == Input.KEY_DOWN){
selection++;
} else if (i == Input.KEY_UP){
selection--;
} else if (i == Input.KEY_ENTER) {
MenuButton.buttonAction(selection, container, menu);
}
if (selection < 1){
selection = 5;
} else if (selection > 5){
selection = 1;
}
}
|
8146d073-6214-4a17-9bcb-65f3621927f8
| 7
|
public void stateChanged(ChangeEvent e) {
final JSlider source = (JSlider)e.getSource();
if (e.getSource() == sliderLaser1 && ready) {
valueSliderLaser1 = (int)source.getValue();
labelSliderLaser1.setText("Power L1 : " + valueSliderLaser1 + " %");
process.laserManu(valueSliderLaser1, 1);
labelTotalPower.setText("Current total power : " + round(calculation.computePower(sliderLaser1.getValue(), sliderLaser2.getValue()), 3) + " mW");
}
if (e.getSource() == sliderLaser2 && ready) {
valueSliderLaser2 = (int)source.getValue();
labelSliderLaser2.setText("Power L2 : " + valueSliderLaser2 + " %");
process.laserManu(valueSliderLaser2, 2);
labelTotalPower.setText("Current total power : " + round(calculation.computePower(sliderLaser1.getValue(), sliderLaser2.getValue()), 3) + " mW");
}
if (calculation.computePower(valueSliderLaser1,valueSliderLaser2) > 250 && calculation.computePower(valueSliderLaser1,valueSliderLaser2) < 300){
labelIcon.setIcon(new ImageIcon(getClass().getResource("/images/danger.png" )));
labelIcon.setVisible(true);
}
else if (calculation.computePower(valueSliderLaser1,valueSliderLaser2) >= 300){
labelIcon.setIcon(new ImageIcon(getClass().getResource("/images/erreur.png" )));
labelIcon.setVisible(true);
}
else{
labelIcon.setVisible(false);
}
}
|
02fd68f3-9bc7-4f4a-8496-5f48b6f772f6
| 4
|
private void awaitAsyncRollback(Future<?> async) throws ProcessRollbackException {
try {
async.get();
} catch (ExecutionException ex) {
// thread returned an exception
if (ex.getCause() instanceof ProcessRollbackException) {
throw (ProcessRollbackException) ex.getCause();
}
} catch (Exception ex) {
throw new ProcessRollbackException(this, ex);
}
}
|
f2039473-18ad-4c1e-8811-fc34e027bc30
| 4
|
public boolean prompt() {
System.out.print("Would you like to begin a new adventure? <y/n>\n==========================================\n You:");
BufferedReader input =
new BufferedReader( new InputStreamReader(System.in) );
String response = "";
//Reads input. If response is not y or n, ask again.
try {
response = input.readLine();
if ( !response.equals( "y" ) && !response.equals( "n" ) )
return prompt();
else if ( response.equals( "y" ) ) {
return true; }
else
return false;
//loadGame();
}
catch (IOException ioe) {
System.out.println("Error reading input.");
System.exit(1);
}
return false;
}
|
2b25de44-fc7a-4fa4-8959-9290b1d227c0
| 2
|
private void findfocus() {
/* XXX: Might need to check subwidgets recursively */
focused = null;
for (Widget w = lchild; w != null; w = w.prev) {
if (w.autofocus) {
focused = w;
focused.hasfocus = true;
w.gotfocus();
break;
}
}
}
|
bf92017c-6c04-41de-96ac-f2d5ff3ec5b7
| 9
|
public float getRightAngleOrientation() {
float theta = getOrientation();
float pi = (float)Math.PI;
if (theta > 2 * pi) theta -= 2 * pi;
if (theta >= 0 && theta < pi * 0.25) {
return 0;
} else if (theta >= pi * 0.25 && theta < pi * 0.75) {
return pi * 0.5f;
} else if (theta >= pi * 0.75 && theta < pi * 1.25) {
return pi;
} else if (theta >= pi * 1.25 && theta < pi * 1.75) {
return pi * 1.5f;
} else {
return pi * 2;
}
}
|
15c60d88-eaa1-45e3-872f-8b2fc2adbf6b
| 0
|
public String getName() {
return name;
}
|
d20d1e65-1f95-4dd5-aeee-ff97fc434912
| 5
|
@Override
public boolean containsKey(K key) {
if (key == null) {
return false;
}
for (Entry entry : this.array) {
if (entry != null && key.equals(entry.key) && !entry.isDeleted) {
return true;
}
}
return false;
}
|
e929ebe9-ac1b-42b6-9674-b29468676dad
| 8
|
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
OrderItem other = (OrderItem) obj;
if (count != other.count)
return false;
if (id != other.id)
return false;
if (item == null) {
if (other.item != null)
return false;
} else if (!item.equals(other.item))
return false;
return true;
}
|
6d2af663-b04e-4507-904e-735575025a97
| 6
|
private void agregarAnuncio(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agregarAnuncio
cal.add(Calendar.DATE, Integer.parseInt(jComboBox2.getSelectedItem().toString().replace(" días", "")));
boolean nuevo = true;
if (buttonGroup2.getSelection() == jRadioButton4) {
nuevo = false;
}
switch (jComboBox1.getSelectedIndex()) {
case 1:
if (!cargaimagen) {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), 0, Float.parseFloat(jTextField2.getText()), cal.getTime(), nuevo, 1);
} else {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), 0, Float.parseFloat(jTextField2.getText()), cal.getTime(), nuevo, 1, chooser.getSelectedFiles());
}
break;
case 2:
if (!cargaimagen) {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), Float.parseFloat(jTextField2.getText()), 0, cal.getTime(), nuevo, (int) jSpinner1.getValue());
} else {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), Float.parseFloat(jTextField2.getText()), 0, cal.getTime(), nuevo, (int) jSpinner1.getValue(), chooser.getSelectedFiles());
}
break;
default:
if (!cargaimagen) {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), Float.parseFloat(jTextField2.getText()), 0, cal.getTime(), nuevo, 1);
} else {
anuncioservice.agregar(jComboBox3.getSelectedIndex(), (String) jComboBox4.getSelectedItem(), vendedor, jComboBox1.getSelectedIndex(), jTextField1.getText(), jTextArea1.getText(), Float.parseFloat(jTextField2.getText()), 0, cal.getTime(), nuevo, 1, chooser.getSelectedFiles());
}
break;
}
cal.setTime(new Date());
jDialog2.dispose();
JOptionPane.showMessageDialog(this, "Gracias por publicar en Compumundohipermegared");
}//GEN-LAST:event_agregarAnuncio
|
32154197-d3be-44c1-a875-e796f2c8d2a3
| 0
|
public UnrestrictedTreeNode(String text) {
super(text);
this.text = text;
}
|
c534cd20-06fe-4baf-b6cc-3a1a52397fd9
| 7
|
public void actionPerformed(ActionEvent event) {
Object target = event.getSource();
if (target == fJoinButton || target == fDeleteButton || target == fRoomName) {
if (fRoomName.getText().length() > 0) {
setVisible(false);
if (fJoinButton != null)
fMeetingManager.joinRoom(fRoomName.getText(),
fPrivateRoom.isSelected(),
fFetchLog.isSelected());
else
fMeetingManager.deleteRoom(fRoomName.getText(), fPrivateRoom.isSelected());
}
else {
//
// See the comment in setVisible() below. Usually setVisible(false)
// make the popup menu invisible.
//
fRoomHintsPopup.setVisible(false);
}
}
else if (target == fCancelButton) {
setVisible(false);
}
else if (target instanceof JMenuItem) {
JMenuItem item = (JMenuItem) target;
String menuLabel = item.getText();
fRoomName.setText(menuLabel);
}
}
|
204f41d6-7936-4d81-9035-4b90f4cd7f61
| 8
|
public int compare(String o1, String o2)
{
String s1 = (String)o1;
String s2 = (String)o2;
int thisMarker = 0;
int thatMarker = 0;
int s1Length = s1.length();
int s2Length = s2.length();
while (thisMarker < s1Length && thatMarker < s2Length)
{
String thisChunk = getChunk(s1, s1Length, thisMarker);
thisMarker += thisChunk.length();
String thatChunk = getChunk(s2, s2Length, thatMarker);
thatMarker += thatChunk.length();
// If both chunks contain numeric characters, sort them numerically
int result = 0;
if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0)))
{
// Simple chunk comparison by length.
int thisChunkLength = thisChunk.length();
result = thisChunkLength - thatChunk.length();
// If equal, the first different number counts
if (result == 0)
{
for (int i = 0; i < thisChunkLength; i++)
{
result = thisChunk.charAt(i) - thatChunk.charAt(i);
if (result != 0)
{
return result;
}
}
}
} else
{
result = thisChunk.compareTo(thatChunk);
}
if (result != 0)
return result;
}
return s1Length - s2Length;
}
|
64434aed-93e0-4c6f-ae57-c2ec0723d1a6
| 5
|
public static String getTokenName(int tokenType) {
// Get all the fields of the lexical analyser - will be the token type
// variables
Field[] fields = EsperLexer.class.getFields();
// Iterate through the fields
for (Field field : fields) {
if (field.getType() == int.class) {
try {
// If the field matches the token type then that field is
// the token
if (field.getInt(null) == tokenType) {
return field.getName();
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return "UNKNOWN TOKEN";
}
|
797cbc7b-893b-4b1a-9985-eed7c8e29881
| 7
|
public boolean logIn() throws UnknownHostException, IOException {
String message;
String total = "";
@SuppressWarnings("resource")
Scanner us = new Scanner(System.in);
try {
String userInput;
System.out.print("Username: ");
String userSend = us.next();
out.println(userSend);
System.out.print("Password: ");
String passSend = us.next();
out.println(passSend);
String pop = "";
pop = in.readLine();
if (pop.equals("Access Granted")) {
System.out.print("Access Granted\n> ");
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
total = "";
do {
message = in.readLine();
if (message.endsWith(">")) {
total += message + "\n> ";
}
else{
total += message + "\n";
}
} while (!(message.endsWith(">")));
System.out.print(total);
}
return false;
} else if (pop.equals("Access Denied")) {
System.out
.println("Access Denied, Incorrect Username or Password.");
return true;
} else {
System.out.println("Couldn't find Access level... ");
return true;
}
} catch (UnknownHostException e) {
System.err.println("Don't know about host " + hostName);
System.exit(1);
return true;
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to "
+ hostName);
return true;
}
}
|
e00af5c7-a4fa-4ec8-b9e1-6807afe829d3
| 2
|
public ArrayList<String> traerListaDeptos(int codEdif){
conn = Conector.conectorBd();
String sql = "select * from departamento where codedi="+codEdif+"";
try {
pst = conn.prepareStatement(sql);
ArrayList<String> ls = new ArrayList<String>();
rs = pst.executeQuery();
while(rs.next()){
ls.add(String.valueOf(rs.getInt("n_dpto")));
}
return ls;
} catch (Exception e) {
return null;
}
}
|
20cc4887-ff52-4423-a4cb-89bab2416acb
| 3
|
public void setValues(String[] itemInfo) {
if (labels == null) return;
if (values == null)
values = new String[labels.length];
int numItems = Math.min(values.length, itemInfo.length);
for(int i = 0; i < numItems; i++) {
values[i] = itemInfo[i];
}
}
|
c2cbe923-b369-4825-81cc-9d4e319ce94f
| 3
|
public Configuration loadEmbeddedConfig(final String resource) {
final YamlConfiguration config = new YamlConfiguration();
final InputStream defaults = this.getResource(resource);
if (defaults == null) return config;
final InputStreamReader reader = new InputStreamReader(defaults, CustomPlugin.CONFIGURATION_SOURCE);
final StringBuilder builder = new StringBuilder();
final BufferedReader input = new BufferedReader(reader);
try {
try {
String line;
while ((line = input.readLine()) != null)
builder.append(line).append(CustomPlugin.LINE_SEPARATOR);
} finally {
input.close();
}
config.loadFromString(builder.toString());
} catch (final Exception e) {
throw new RuntimeException("Unable to load embedded configuration: " + resource, e);
}
return config;
}
|
f5424490-504f-4e0e-a30e-9ecc8bf17984
| 6
|
@Override
public void mouseEntered(MouseEvent e) {
if(e.getSource()==recordBut){
recordBut.setIcon(recordOverIcon);
}else if(e.getSource()==playBut){
playBut.setIcon(playOverIcon);
}else if(e.getSource()==stopBut){
stopBut.setIcon(stopOverIcon);
}else if(e.getSource()==saveBut){
saveBut.setIcon(saveOverIcon);
}else if(e.getSource()==openBut){
openBut.setIcon(openOverIcon);
}else if(e.getSource()==saveAllBut){
saveAllBut.setIcon(saveOverIcon);
}
}
|
935da9c1-e747-469b-aa1c-c8131956ca6f
| 9
|
private static SpeechNBestList buildSpeechNBestList(List<String> correctSentence, BufferedReader wordReader, BufferedReader scoreReader, Set vocabulary) throws IOException {
List<Double> scoreList = readScores(scoreReader);
List<List<String>> sentenceList = readSentences(wordReader);
List<List<String>> uniqueSentenceList = new ArrayList<List<String>>();
Map<List<String>, Double> sentencesToScores = new HashMap<List<String>, Double>();
List<String> tokenizedCorrectSentence = null;
for (int i = 0; i < sentenceList.size(); i++) {
List<String> sentence = sentenceList.get(i);
if (! inVocabulary(sentence, vocabulary)) // && i < sentenceList.size()-1)
continue;
Double score = scoreList.get(i);
Double bestScoreForSentence = sentencesToScores.get(sentence);
if (!sentencesToScores.containsKey(sentence)) {
uniqueSentenceList.add(sentence);
if (equalsIgnoreSpaces(correctSentence, sentence)) {
if (tokenizedCorrectSentence != null) {
System.out.println("WARNING: SPEECH LATTICE ERROR");
}
tokenizedCorrectSentence = sentence;
}
}
if (bestScoreForSentence == null || score > bestScoreForSentence) {
sentencesToScores.put(sentence, score);
}
}
if (uniqueSentenceList.isEmpty())
return null;
if (tokenizedCorrectSentence == null)
return null;
return new SpeechNBestList(tokenizedCorrectSentence, uniqueSentenceList, sentencesToScores);
}
|
0e04cafc-0a37-4ed4-bee6-d6686b51d1b9
| 0
|
public int getChannelAccess()
{
return channelAccess;
}
|
7bee7e4c-6491-498e-8523-bae35ad9bea5
| 1
|
private boolean checkCardForUnique (String motherLangWord, String translation) throws SQLException {
Connection conn = null;
ResultSet resSet = null;
try {
conn = DriverManager.getConnection(Utils.DB_URL);
PreparedStatement pStat = conn.prepareStatement("SELECT id FROM word WHERE motherlang_word = '"+ motherLangWord +"' " +
"AND foreignlang_word = '"+ translation +"'");
resSet = pStat.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
finally {
conn.close();
return resSet.next();
}
}
|
311561b0-66fe-49f9-b8ae-965e027c58a0
| 0
|
public static void main(String[] args) throws IOException {
loadFromFile();
writeToFile(Scheduler.getUsers().values());
}
|
ede928fe-ff68-4ebe-a77d-89b02b941aee
| 8
|
public void DFS(int[] state, int m, int n) {
if (state[0] == m-1 && state[1] == n-1) {
pathcount++;
return;
} else if (state[0] == m) {
return;
} else if (state[1] == n) {
return;
} else if (state[0] == m-1 && state[1] < n-1) {
int[] nextstate = new int[2];
nextstate[0] = state[0];
nextstate[1] = state[1]+1;
DFS(nextstate, m, n);
} else if (state[0] < m-1 && state[1] == n-1) {
int[] nextstate = new int[2];
nextstate[0] = state[0]+1;
nextstate[1] = state[1];
DFS(nextstate, m, n);
} else {
int[] nextstate = new int[2];
nextstate[0] = state[0];
nextstate[1] = state[1]+1;
DFS(nextstate, m, n);
nextstate = new int[2];
nextstate[0] = state[0]+1;
nextstate[1] = state[1];
DFS(nextstate, m, n);
}
}
|
50085af2-14ae-4cf1-8b97-be4bcbbf7ee9
| 7
|
void readZrlePackedPixels(int tw, int th, int[] palette, int palSize)
throws Exception {
int bppp = ((palSize > 16) ? 8 : ((palSize > 4) ? 4
: ((palSize > 2) ? 2 : 1)));
int ptr = 0;
for (int i = 0; i < th; i++) {
int eol = ptr + tw;
int b = 0;
int nbits = 0;
while (ptr < eol) {
if (nbits == 0) {
b = zrleInStream.readU8();
nbits = 8;
}
nbits -= bppp;
int index = (b >> nbits) & ((1 << bppp) - 1) & 127;
if (bytesPixel == 1) {
zrleTilePixels8[ptr++] = (byte) palette[index];
} else {
zrleTilePixels24[ptr++] = palette[index];
}
}
}
}
|
7717d981-04dd-4533-9c89-3d659326f99e
| 0
|
public GUISignup() {
setResizable(false);
portServer = 2223;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 378, 249);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
txtUserName = new JTextField();
txtUserName.setBounds(146, 63, 136, 20);
contentPane.add(txtUserName);
txtUserName.setColumns(10);
txtPort = new JTextField();
txtPort.setBounds(146, 105, 136, 20);
contentPane.add(txtPort);
txtPort.setColumns(10);
JButton btnSignIn = new JButton("Sign In");
btnSignIn.addActionListener(this);
btnSignIn.setBounds(145, 156, 89, 23);
contentPane.add(btnSignIn);
JLabel lblUserName = new JLabel("User Name");
lblUserName.setBounds(52, 66, 73, 14);
contentPane.add(lblUserName);
JLabel lblPort = new JLabel("Port");
lblPort.setBounds(52, 108, 73, 14);
contentPane.add(lblPort);
JLabel lblIpServer = new JLabel("Ip Server");
lblIpServer.setBounds(52, 14, 84, 14);
contentPane.add(lblIpServer);
txtIPServer = new JTextField();
txtIPServer.setBounds(146, 11, 136, 20);
contentPane.add(txtIPServer);
txtIPServer.setColumns(10);
}
|
5def91b8-db60-4043-82dd-1c9db873b3ac
| 5
|
private void removeDropTransfer(Transfer transfer){
if (dropTypes.length == 1) {
dropTypes = new Transfer[0];
} else {
int index = -1;
for(int i = 0; i < dropTypes.length; i++) {
if (dropTypes[i] == transfer) {
index = i;
break;
}
}
if (index == -1) return;
Transfer[] newTypes = new Transfer[dropTypes.length - 1];
System.arraycopy(dropTypes, 0, newTypes, 0, index);
System.arraycopy(dropTypes, index + 1, newTypes, index, dropTypes.length - index - 1);
dropTypes = newTypes;
}
if (dropTarget != null) {
dropTarget.setTransfer(dropTypes);
}
}
|
d495c49c-4ada-4ca4-99e0-f8e0353d2944
| 3
|
public static void main(String[] args) {
for (String input : Arrays.asList("0", "50", "-10", "1000", "x", null)) {
String output;
try {
Integer out = LIMIT_FIELD.validate(input);
output = out == null ? null : out.toString();
} catch (ValidationException e) {
output = "ERROR: " + e.getMessage();
}
System.out.println("Validation for '" + input + "' = " + output);
}
}
|
1e8d9fd8-d76a-45e6-817f-02b6a29eb802
| 5
|
public void print_resultSet(ResultSet rs){
if (rs != null){
ResultSetMetaData md = null;
int nombreColumns = 0;
try {
md = rs.getMetaData();
nombreColumns = md.getColumnCount();
String[] nomColumns = new String[nombreColumns];
for(int i = 1 ; i < (nombreColumns+1) ; i++){
nomColumns[i-1] = md.getColumnName(i);
}
int i = 1;
while(rs.next()){
System.out.print("DEBUG : Row "+i+" : ");
for(String s : nomColumns){
System.out.print(rs.getString(s)+" ");
}
i++;
System.out.println();
}
rs.beforeFirst();
} catch (SQLException ex) {
Logger.getLogger(Request_MySQL.class.getName())
.log(Level.SEVERE, null, ex);
}
}
}
|
bff7b1ab-e421-4ded-a0f8-f8ca8ff94e76
| 3
|
public PastMeeting getPastMeeting(int id) {
PastMeeting returner = null;
for (int i = 0; i < pastMeetingList.size(); i++) {
if (pastMeetingList.get(i).getID() == id) {
returner = (PastMeeting) pastMeetingList.get(i);
}
}
if (returner == null) {
System.out.println("There is no such past meeting");
return null;
}
System.out.println("");
System.out.println("Meeting: " + returner.getID());
System.out.println((df.format(returner.getDate().getTime())));
System.out.print("Attendees: ");
printContacts(returner.getContacts());
System.out.println("Notes: " + returner.getNotes());
return returner;
}
|
f0a10ba4-50ce-4043-870c-a8236aafe825
| 9
|
public void tick(World w)
{
if(life <= 0)
return;
if(vel.x > this.maxPositiveVX)
{
vel.x = this.maxPositiveVX;
}
if(vel.x < this.maxNegativeVX)
{
vel.x = this.maxNegativeVX;
}
if(vel.y > this.maxPositiveVY)
{
vel.y = this.maxPositiveVY;
}
if(vel.y < this.maxNegativeVY)
{
vel.y = this.maxNegativeVY;
}
vel.x += w.gravity.x*2;
vel.y += w.gravity.y*2;
if(canGo(pos.x+vel.x, pos.y, w))
{
pos.x+=vel.x;
}
else
{
vel.x = vel.x*-.5f;
}
if(canGo(pos.x, pos.y + vel.y / this.gravityEfficient, w))
{
pos.y += vel.y / this.gravityEfficient;
}
else
{
vel.y = 0;
}
if(vel.x > decceleration*2)
{
vel.x -= decceleration*2;
}
else if(vel.x < -decceleration*2)
vel.x+= decceleration*2;
else
vel.x = 0;
life--;
}
|
5dc97df4-2ec9-44c3-b2e6-21bfdccb4192
| 2
|
public void writeMap(String fn) throws IOException {
FileOutputStream fout = new FileOutputStream(fn);
DataOutputStream out = new DataOutputStream(fout);
out.writeInt(_map[0].length-1);
out.writeInt(_map.length-1);
out.writeFloat(_map.length-1);
out.writeFloat(_map[0].length-1);
out.writeFloat(_map.length-1);
out.writeFloat(_map[0].length-1);
for (double[] row: _map)
for (double d: row) {
out.writeFloat((float)d);
}
fout.close();
}
|
44e2b47b-d4cc-4145-8d0f-7715fc25196e
| 1
|
public UserFollowers get(Integer key) {
UserFollowers res = hashMap.get(key);
if (res == null)
missCnt.incrementAndGet();
total.incrementAndGet();
return res;
}
|
bf7769bd-5b9b-45f9-9fa8-ce807a66a527
| 9
|
public String toString()
{
final StringBuilder sql = new StringBuilder(1024);
// first off if there are no entries in the where column list AND
// there is NO additional freeform where clause short circuit the logic
// and just return an empty string since there is nothing to process
if (this.wcv.isEmpty() && (this.freeFormWhereClause.length() == 0))
{
return "";
}
// we know there is a WHERE clause so lets start it off
sql.append(" WHERE ");
// if there is anything in the where column value list process it first
if (!this.wcv.isEmpty())
{
final Iterator<ColumnValue> i = this.wcv.iterator();
ColumnValue cv;
while (i.hasNext())
{
cv = i.next();
if (cv.caseSensitive)
{
sql.append(cv);
}
else
{
sql.append("lower(").append(cv.name).append(")").append(cv.operator);
sql.append(cv.value.toLowerCase());
}
if (i.hasNext())
{
sql.append(" AND ");
}
}
}
// if there was something in the AND there is more in the freeform where clause
// we need the AND otherwise there is only the freefrom clause
if (!this.wcv.isEmpty() && (this.freeFormWhereClause.length() > 0))
{
sql.append(" AND ");
}
// append the freeform where clause if there is anything
if (this.freeFormWhereClause.length() > 0)
{
sql.append(this.freeFormWhereClause.toString());
}
return sql.toString();
}
|
6304d4f7-bdb4-4d59-8a00-dc350a29988c
| 9
|
public String format(String pattern) {
SimpleDateFormat parser;
String buffer;
String temp;
int n;
if(pattern == null) return "Invalid pattern";
if(pattern.charAt(0) == 'B') { // Special case - binary seconds from reference year
int year;
long seconds;
long milli;
long diff;
if(pattern.length() < 5) year = 1966; // Cline Time
else year = Integer.parseInt(pattern.substring(1));
Calendar refYear = Calendar.getInstance(mTimeZone);
refYear.set(year, 1, 1, 0, 0, 0);
Calendar sysYear = Calendar.getInstance(mTimeZone);
sysYear.set(1970, 1, 1, 0, 0, 0);
milli = mDate.getTimeInMillis();
milli -= refYear.getTimeInMillis();
milli += sysYear.getTimeInMillis();
seconds = milli / 1000;
diff = milli - (seconds * 1000);
buffer = Long.toString(seconds);
buffer += ".";
temp = Long.toString(diff);
for(int i = 0; i < 3 - temp.length(); i++) buffer += "0";
n = temp.length();
if(n > 3) n = 3;
buffer += temp.substring(0, n);
} else if((n = pattern.indexOf('T')) != -1) { // Special case - PDS style time
if(pattern.compareTo("T") == 0) { // Fule time format
parser = new SimpleDateFormat("yyyy-MM-dd");
parser.setTimeZone(mTimeZone);
buffer = parser.format(mDate.getTime()) + "T";
parser = new SimpleDateFormat("HH:mm:ss.SSS");
parser.setTimeZone(mTimeZone);
buffer += parser.format(mDate.getTime());
} else { // Treat as two part pattern split by "T"
buffer = "";
temp = pattern.substring(0, n);
if(temp.length() > 0) {
parser = new SimpleDateFormat(pattern.substring(0, n));
parser.setTimeZone(mTimeZone);
buffer += parser.format(mDate.getTime());
}
buffer += "T";
temp = pattern.substring(n+1);
if(temp.length() > 0) {
parser = new SimpleDateFormat(temp);
parser.setTimeZone(mTimeZone);
buffer += parser.format(mDate.getTime());
}
}
} else {
parser = new SimpleDateFormat(pattern);
parser.setTimeZone(mTimeZone);
buffer = parser.format(mDate.getTime());
}
return buffer;
}
|
89b83c65-991a-44bc-8a94-8022861cba98
| 6
|
public final Pino etsiPolku(int alkuX, int alkuY, int loppuX, int loppuY) {
kaymattomatNoodit = new Keko(11);
kaydytNoodit = new LinkedList<T>();
kaymattomatNoodit.lisaa(noodit[alkuX][alkuY]);
valmis = false;
T valittu;
while (!valmis) {
/** Haetaan läpikäymättömistä noodeista lyhimmän matka-arvion omaava */
valittu = (T)lyhinMatkaLapikaymattomissa();
/** Lisätään noodi läpikäytyihin ja poistetaan -käymättömistä */
kaydytNoodit.add(valittu);
kaymattomatNoodit.poistaPienin();
/** Onko piste loppupiste? */
if ((valittu.getxPositio() == loppuX)
&& (valittu.getyPositio() == loppuY)) {
return laskePolku(noodit[alkuX][alkuY], valittu);
}
// Käytään läpi kaikki viereiset Noodit
List<T> viereisetNoodit = getViereinen(valittu);
for (int i = 0; i < viereisetNoodit.size(); i++) {
T valittuViereinen = viereisetNoodit.get(i);
if (!kaymattomatNoodit.sisaltaakoSaman(valittuViereinen)) {
asetaKaymatonNoodi(kaymattomatNoodit, valittuViereinen, valittu, loppuX, loppuY);
} else {
/** Jos matka käsittelyssä olevan Noodin kautta on lyhyempi kuin Noodiin aiemmin tallennettu matka,
aseta käsittelyssä oleva Noodi edeltäjäksi ja päivitä matkaa */
asetaUusiLyhinMatka(valittuViereinen, valittu);
}
}
if (kaymattomatNoodit.onkoTyhja()) {
return new Pino(10);
}
}
return null;
}
|
1b148e15-f547-48b2-8580-59e203d773f3
| 3
|
@Override
public void addWord(String s) {
// Equivalent of rho function
int nbTrailingZeros = Integer.numberOfTrailingZeros(func.hashString(s));
// Consider only words whose hash value begins with more than b zeros.
if (nbTrailingZeros >= b) {
LinkedList<Occurrence> l = strTab.get(nbTrailingZeros);
Occurrence sOcc = new Occurrence(s, 1);
int i = l.indexOf(sOcc);
// If we have already seen the word, increase its number of occurrences.
// Else add the word to the array at the proper position.
if (i == -1) {
l.add(sOcc);
this.nbElements++;
} else
l.get(i).nbOcc++;
}
// If the array has more than 2*k elements stored, remove the elements with less than b
// trailing zeros then increase b, until the array has less than 2*k elements.
while (nbElements >= 2 * k) {
nbElements -= strTab.get(b).size();
strTab.set(b, null);
b++;
}
}
|
9adb8feb-04b3-489e-a724-97488d61ab58
| 8
|
private boolean r_factive() {
int among_var;
// (, line 132
// [, line 133
ket = cursor;
// substring, line 133
among_var = find_among_b(a_7, 2);
if (among_var == 0)
{
return false;
}
// ], line 133
bra = cursor;
// call R1, line 133
if (!r_R1())
{
return false;
}
switch(among_var) {
case 0:
return false;
case 1:
// (, line 134
// call double, line 134
if (!r_double())
{
return false;
}
break;
case 2:
// (, line 135
// call double, line 135
if (!r_double())
{
return false;
}
break;
}
// delete, line 137
slice_del();
// call undouble, line 138
if (!r_undouble())
{
return false;
}
return true;
}
|
83c19a66-2c32-4112-8201-c062b9deaf2b
| 3
|
public void keyPressed(int key, char c){
if(key == Input.KEY_UP){
startMenu.movePointer(Utility.Direction.UP);
}else if(key == Input.KEY_DOWN){
startMenu.movePointer(Utility.Direction.DOWN);
}else if(key == Input.KEY_ENTER){
startMenu.performAction();
}
}
|
86c2a917-152f-4419-8267-7495bf836220
| 4
|
private boolean isConnectedTo(LightTrailPart that) {
final List<LightTrailPart> lightTrailParts = lightTrail.getLightTrailParts();
final int index = lightTrailParts.indexOf(this);
if ((index > 0 && lightTrailParts.get(index - 1).equals(that)) || (index < lightTrailParts.size() - 1 && lightTrailParts.get(index + 1).equals(that)))
return true;
return false;
}
|
79520e6b-65a8-454a-b0d9-f35ba96189dc
| 5
|
public final synchronized void mouseReleased(MouseEvent mouseevent) {
anInt7428++;
int button = getMouseButton(mouseevent);
if ((button & buttonMask ^ 0xffffffff) == -1)
button = buttonMask;
if ((button & 0x1 ^ 0xffffffff) != -1)
addEvent(3, mouseevent.getY(), mouseevent.getX(), mouseevent.getClickCount());
if ((0x4 & button) != 0)
addEvent(5, mouseevent.getY(), mouseevent.getX(),
mouseevent.getClickCount());
if ((0x2 & button) != 0)
addEvent(4, mouseevent.getY(), mouseevent.getX(), mouseevent.getClickCount());
buttonMask &= button ^ 0xffffffff;
if (mouseevent.isPopupTrigger())
mouseevent.consume();
}
|
af45183a-0a31-4a42-8541-41252e970a2d
| 9
|
private static int decodeByte(byte b) {
if (b >= 'A' && b <= 'Z') {
return b - 'A';
} else if (b >= 'a' && b <= 'z') {
return b - 'a' + 26;
} else if (b >= '0' && b <= '9') {
return b - '0' + 52;
} else if (b == '+') {
return 62;
} else if (b == '/') {
return 63;
} else if (b == '=') {
return -2;
} else {
return -1;
}
}
|
aa71ba57-c35b-4a28-84a1-919a000a5ac4
| 8
|
public void put(Telegram telegram) throws InterruptedException {
if(_closed) return;
final int length = telegram.getSize();
if(length <= 0) throw new IllegalArgumentException("Telegrammlänge muss größer 0 sein, ist aber " + length + ": " + telegram);
final byte priority = telegram.getPriority();
synchronized(this) {
if(length > _capacity){
// Telegramm passt nicht in Queue, solange warten bis _size == 0 und dann senden
while(!_closed && _size > 0) {
wait();
}
}
else {
while(!_closed && _size + length > _capacity) {
wait();
}
}
if(_closed) return;
_priorityLists[priority].add(telegram);
_size += length;
notifyAll();
}
}
|
c6611f86-ea90-4d81-9f49-1b336f8a811a
| 8
|
protected void alterneigh(int rad, int i, int b, int g, int r) {
int j, k, lo, hi, a, m;
int[] p;
lo = i - rad;
if (lo < -1)
lo = -1;
hi = i + rad;
if (hi > netsize)
hi = netsize;
j = i + 1;
k = i - 1;
m = 1;
while ((j < hi) || (k > lo)) {
a = radpower[m++];
if (j < hi) {
p = network[j++];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
} catch (Exception e) {
} // prevents 1.3 miscompilation
}
if (k > lo) {
p = network[k--];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
} catch (Exception e) {
}
}
}
}
|
51fbef39-92e9-4745-b9ec-91c835a7eeda
| 2
|
public SignatureVisitor visitInterface() {
if (state != SUPER) {
throw new IllegalStateException();
}
SignatureVisitor v = sv == null ? null : sv.visitInterface();
return new CheckSignatureAdapter(TYPE_SIGNATURE, v);
}
|
2e39b148-cad5-465e-b53f-4d5ba20f7ed8
| 6
|
public static int getPort(String vncServerName) {
int colonPos = vncServerName.lastIndexOf(':');
while (colonPos > 0 && vncServerName.charAt(colonPos - 1) == ':')
colonPos--;
if (colonPos == -1 || colonPos == vncServerName.length() - 1)
return 5900;
if (vncServerName.charAt(colonPos + 1) == ':') {
return Integer.parseInt(vncServerName.substring(colonPos + 2));
}
int port = Integer.parseInt(vncServerName.substring(colonPos + 1));
if (port < 100)
port += 5900;
return port;
}
|
79a33c3b-589b-4893-a3e4-2bd214afce77
| 6
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
config = plugin.getConfig();
if (args.length == 1 ){
if (sender instanceof Player) {
if (sender.hasPermission("darkcommand.bitchslap")){
if (commandLabel.equalsIgnoreCase("bitchslap")){
Player player = (Player) sender;
Player target = (Bukkit.getServer().getPlayer(args[0]));
if (target != null){
config = plugin.getConfig();
Bukkit.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " has bitchslapped " + args[0] + "!");
Damageable dm = Bukkit.getServer().getPlayer(args[0]);
double health = dm.getMaxHealth();
double newhealth = health / 2;
Bukkit.getServer().getPlayer(args[0]).setHealth(newhealth);
if(!(config.getBoolean("logcommands") == false)){
int current = config.getInt("Times.Done.BitchSlapped");
int newint = current + 1;
config.set("Times.Done.BitchSlapped", newint);
plugin.saveConfig();
}
}else{
sender.sendMessage("This person doesn't exist or isn't online!");
}
}
}else{
sender.sendMessage("You don't have permission for this command!");
}
}else{
sender.sendMessage("You must be a player to use this command!");
}
}else{
sender.sendMessage("Usage: /bitchslap <Player_Name>");
}
return true;
}
|
2fcfa530-3c31-4837-812b-bac9939a393a
| 6
|
public static void main(String[] args) {
int op;
do{
System.out.println("1- Agregar plan");
System.out.println("2- Pagar");
System.out.println("3- Editar Email");
System.out.println("4- Agregar Amigo");
System.out.println("5- Ver Plan");
System.out.println("6- Salir");
System.out.println("Escoja Opcion: ");
op = lea.nextInt();
switch(op){
case 1:
agregarPlan();
break;
case 2:
System.out.println("Numero del telefono: ");
pagarPlan(lea.nextInt());
break;
case 3:
System.out.println("Numero del telefono: ");
editarEmail(lea.nextInt());
break;
case 4:
System.out.println("Numero del telefono: ");
agregarAmigo(lea.nextInt());
break;
case 5:
System.out.println("Numero del telefono: ");
verPlan(lea.nextInt());
}
}while(op!=6);
}
|
afffe626-b8fd-4689-a213-6d74f4aded29
| 4
|
public byte getTileID(int x, int y) {
if (x < 0 | x >= getWidth()) {
return LevelTexture.CENTER;
} else if (y < 0) {
return LevelTexture.AIR;
} else if (y >= getHeight()) {
if (tileSet[x][getHeight() - 1] == LevelTexture.AIR) {
return tileSet[x][0];
} else {
return LevelTexture.CENTER;
}
} else {
return tileSet[x][y];
}
}
|
00ead177-010a-41b9-994b-cb04781b4c78
| 5
|
public void createControlPanel(Composite parent) {
super.createControlPanel(parent);
if (nextNumber < 1)
nextNumber = startNumber;
// add selection listener to reset nextNumber after
// the sequence has completed
playItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (nextNumber < 1)
nextNumber = startNumber;
}
});
Composite comp;
GridLayout gridLayout = new GridLayout(2, false);
// create spinner for line width
comp = new Composite(parent, SWT.NONE);
comp.setLayout(gridLayout);
new Label(comp, SWT.CENTER).setText(GraphicsExample
.getResourceString("LineWidth")); //$NON-NLS-1$
lineWidthSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
lineWidthSpinner.setSelection(20);
lineWidthSpinner.setMinimum(1);
lineWidthSpinner.setMaximum(100);
lineWidthSpinner.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (!pauseItem.isEnabled()) {
example.redraw();
}
}
});
// create drop down combo for antialiasing
comp = new Composite(parent, SWT.NONE);
comp.setLayout(gridLayout);
new Label(comp, SWT.CENTER).setText(GraphicsExample
.getResourceString("Antialiasing")); //$NON-NLS-1$
aliasCombo = new Combo(comp, SWT.DROP_DOWN);
aliasCombo.add("DEFAULT");
aliasCombo.add("OFF");
aliasCombo.add("ON");
aliasCombo.select(0);
antialias = aliasValues[0];
aliasCombo.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
antialias = aliasValues[aliasCombo.getSelectionIndex()];
if (!pauseItem.isEnabled()) {
example.redraw();
}
}
});
// create drop down combo for line cap
comp = new Composite(parent, SWT.NONE);
comp.setLayout(gridLayout);
new Label(comp, SWT.CENTER).setText(GraphicsExample
.getResourceString("LineCap")); //$NON-NLS-1$
lineCapCombo = new Combo(comp, SWT.DROP_DOWN);
lineCapCombo.add("FLAT");
lineCapCombo.add("SQUARE");
lineCapCombo.add("ROUND");
lineCapCombo.select(0);
lineCap = capValues[0];
lineCapCombo.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
lineCap = capValues[lineCapCombo.getSelectionIndex()];
if (!pauseItem.isEnabled()) {
example.redraw();
}
}
});
}
|
e1a13662-f605-42f8-b830-9d3b8bfeae49
| 7
|
@SuppressWarnings("unchecked")
public void handle(HttpExchange exchange) throws IOException {
long start = System.currentTimeMillis();
Map<String, Object> params = (Map<String, Object>)exchange.getAttribute("parameters");
Map<String, String[]> headers = (Map<String,String[]>)exchange.getAttribute("headers");
String path = exchange.getRequestURI().getPath();
String result = null;
String method = exchange.getRequestMethod();
int rcode = -1;
byte[] data = null;
OutputStream os = exchange.getResponseBody();
String contentType = "text/plain"; // "application/octet-stream";
log.finest("Operation: " + rootPath);
String opPath = path.substring(rootPath.length());
File f = new File(opPath);
if (f.exists() && f.getAbsolutePath().toLowerCase().endsWith(".py")) {
log.finest("Executing Python: " + f.getAbsolutePath());
Process proc = Runtime.getRuntime().exec("python " + f.getAbsolutePath());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedInputStream bis = new BufferedInputStream(proc.getInputStream());
int read = 0;
boolean init = true;
data = new byte[64000];
while ((read=bis.read(data, 0, 64000))>0) {
baos.write(data, 0, read);
if (init) {
init = false;
String d = new String(data,0,read);
if (d.indexOf("<body>")>=0 || d.indexOf("<BODY>")>=0) {
contentType = "text/html";
} else if (d.indexOf("<?xml ")>=0) {
contentType = "text/xml";
}
}
}
bis.close();
bis = null;
data = null;
data = baos.toByteArray();
exchange.getResponseHeaders().set("Content-Type", contentType);
exchange.sendResponseHeaders(200, data.length);
os.write(data,0, data.length);
data = null;
baos = null;
}
os.close();
os = null;
long end = System.currentTimeMillis();
System.out.println((new Date()).toLocaleString() + "|Py|" + path + "|" + rcode + "|" + (end-start) + "ms");
System.out.flush();
}
|
6f947901-e7d1-4052-ae05-454e34e5c890
| 1
|
public Integer[] nextIntArray() throws Exception {
String[] line = reader.readLine().trim().split(" ");
Integer[] out = new Integer[line.length];
for (int i = 0; i < line.length; i++) {
out[i] = Integer.valueOf(line[i]);
}
return out;
}
|
378a2e8a-5d88-446c-abc3-56e4b3f86d93
| 7
|
public void printAmbiguousTemporalConclusions(Map<Literal, TreeMap<Temporal, Map<ConclusionType, Set<String>>>> conclusions[]) {
if (null == conclusions) return;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < conclusions.length; i++) {
String str = getAmbiguousTemporalConclusionString("ambiguous temporal conclusions (" + (i == 0 ? "definite" : "defeasible")
+ ")", conclusions[i]);
if (null != str && !"".equals(str.trim())) {
if (sb.length() > 0) sb.append(LINE_SEPARATOR);
sb.append(str);
}
}
if (sb.length() > 0) System.out.println(sb.toString());
}
|
61c9fd2e-b90c-457d-9048-85bf551ecb58
| 4
|
public int getTileID(int x, int y){
if(x < 0 || y < 0 || x >= worldWidth || y >= worldHeight) return -1;
return mapData.get((y * worldWidth) + x);
}
|
b2d6009b-20c3-4458-ac94-b82af26089e1
| 1
|
public void visit_dneg(final Instruction inst) {
stackHeight -= 2;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
stackHeight += 2;
}
|
767fcbe7-fcb2-453c-a4eb-85fcd1955231
| 0
|
public Logon(String name, String pwd) {
username = name;
password = pwd;
}
|
c63ad26b-3d3e-4a77-bed2-d1a1ea04e3ab
| 8
|
private void IntervenantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IntervenantsActionPerformed
// TODO add your handling code here:
switch(etat){
case Debut:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
desactiveBouton();
break;
case Debut1:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case UE:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case Intervenant:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case Salle:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case Etudiant:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case Creneau:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
case Batiment:
donner1.frame_Intervenant();
this.donner1.setVisible(true);
this.donner1.setEtat("Intervenant");
this.donner1.desactive_sup_modif();
etat = Etat.Intervenant;
activeBouton();
break;
}
}//GEN-LAST:event_IntervenantsActionPerformed
|
0c335478-3b99-4007-9d7f-dfe4d16a666f
| 1
|
public boolean offer(Position p){
boolean notfull = super.offer(p);
if (notfull){
this.clear();
super.offer(p);
}
return true;
}
|
9c8e9c58-79ac-4cb9-9a3d-c99887138f07
| 8
|
final public Temporal temporalStamp() throws ParseException {
Token startNegation=null, endNegation=null;
Token startTime=null,endTime=null;
Token negInf=null;
jj_consume_token(TEMPORAL_START);
if (jj_2_35(7)) {
if (jj_2_34(7)) {
startNegation = jj_consume_token(MINUS);
} else {
;
}
startTime = jj_consume_token(NUMBER);
} else if (jj_2_36(7)) {
negInf = jj_consume_token(NEG_INF);
} else {
jj_consume_token(-1);
throw new ParseException();
}
if (jj_2_38(7)) {
jj_consume_token(ARGUMENT_SEPARATOR);
if (jj_2_37(7)) {
endNegation = jj_consume_token(MINUS);
} else {
;
}
endTime = jj_consume_token(NUMBER);
} else {
;
}
jj_consume_token(TEMPORAL_END);
Temporal temporal=new Temporal();
if (null==negInf) temporal.setStartTime(getNumericalValue(startNegation,startTime));
// else temporal.setStartTime(Long.MIN_VALUE);
// temporal.setStartTime(Long.parseLong(startTime.image));
if (null!=endTime) {
temporal.setEndTime(getNumericalValue(endNegation,endTime));
// temporal.setEndTime(Long.parseLong(endTime.image));
}
{if (true) return temporal;}
throw new Error("Missing return statement in function");
}
|
0c0ea336-bc52-461f-88a3-d43d7d9c5ccc
| 5
|
public ISOCountry( String id2, String id3, String shortName, String ext )
{
if ( id2 != null )
{
iso = id2.toUpperCase() ; // 2 letter iso
}
else
{
iso = "" ;
}
iso3 = id3 ; // 3 letter iso
name = shortName ;
if ( ext == null )
{
extension = "" ;
}
else
{
extension = ext.trim() ;
}
// some name validations
if ( name == null )
{
name = "" ;
full = "" ;
}
else
{
name = name.trim() ;
full = name + " " + extension ;
int len = name.length() ;
if ( len > 1 )
{
if ( name.charAt( len - 1 ) == ',' )
{
name = name.substring( 0, len - 1 ) ;
full = extension + " " + name ;
}
}
}
}
|
b266a0ee-89c1-4548-9c34-46cf526bdfb9
| 0
|
public static SettingsDialog getInstance()
{
return instance;
}
|
a828632e-fa5d-468a-abb7-d27d7ae5bf5f
| 0
|
public GregorianCalendar getDate() {
return date;
}
|
f4924e6b-7019-43df-8d83-c27e870c3578
| 1
|
public void checkProduction(Production production) {
if (!ProductionChecker.isRestrictedOnLHS(production)){
javax.swing.JOptionPane.showMessageDialog(null,
"Your production is unrestricted on the left hand side.");
throw new IllegalArgumentException(
"The production is unrestricted on the left hand side.");
}
}
|
8a7bb7ed-4d29-42db-9bee-142512e4ba59
| 6
|
@CanReturnNull
public static Command getCommandByName(String commandName)
{
Command toRet = null;
ArrayList<Class<?>> availableCommands = (ArrayList<Class<?>>) ReflectionHelper.getCommandClasses();
for(Class<?> comm:availableCommands)
{
try
{
Command currComm = (Command)comm.newInstance();
if(currComm.getCommandName().equals(commandName))
{
toRet = currComm;
break;
}
}
catch(Exception e)
{
Logger.logException("Problem occured while trying to get command by name", e);
}
}
return toRet;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.