method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
443b7a2b-fda9-48d4-8a5d-941e842a6fef | 4 | private long getCPtrAddRefServerInfo(ServerInfo element) {
// Whenever adding a reference to the list, I remove it first (if already there.)
// That way we never store more than one reference per actual contained object.
//
for(int intIndex = 0; intIndex < elementList.size(); intIndex++)
{
Object theObject = elementList.get(intIndex);
if ((theObject == null) || !(theObject instanceof ServerInfo))
continue;
ServerInfo tempRef = (ServerInfo)(theObject);
if ((ServerInfo.getCPtr(tempRef) == ServerInfo.getCPtr(element)))
{
elementList.remove(tempRef); // It was already there, so let's remove it before adding (below.)
break;
}
}
// Now we add it...
//
ServerInfo tempLocalRef = element;
elementList.add(tempLocalRef);
return ServerInfo.getCPtr(element);
} // Hope I get away with overloading this for every type. Otherwise, |
de676e04-21f4-4a34-8386-10b27e74442e | 0 | public String getSampleCode() {
return this.sampleCode;
} |
7e59eba2-426f-417e-885d-3aa3a89ff662 | 7 | public boolean xpathEnsure(String xpath) throws ParseException {
try {
//Quick exit for common case
if (xpathSelectElement(xpath) != null) return false;
//Split XPath into dirst step and bit relative to rootElement
final XPath parseTree = XPath.get(xpath);
int stepCount = 0;
for (Enumeration i = parseTree.getSteps(); i.hasMoreElements();) {
i.nextElement();
++stepCount;
}
Enumeration i = parseTree.getSteps();
Step firstStep = (Step) i.nextElement();
Step[] rootElemSteps = new Step[stepCount - 1];
for (int j = 0; j < rootElemSteps.length; ++j)
rootElemSteps[j] = (Step) i.nextElement();
//Create root element if necessary
if (rootElement_ == null) {
Element newRoot = makeMatching(null, firstStep, xpath);
setDocumentElement(newRoot);
} else {
Element expectedRoot = xpathSelectElement("/" + firstStep);
if (expectedRoot == null)
throw new ParseException("Existing root element <" + rootElement_.getTagName()
+ "...> does not match first step \"" + firstStep + "\" of \"" + xpath);
}
if (rootElemSteps.length == 0)
return true;
else
return rootElement_.xpathEnsure(XPath.get(false, rootElemSteps).toString());
} catch (XPathException e) {
throw new ParseException(xpath, e);
}
} |
df46d9fa-f040-4ae9-bcea-d08fd4182171 | 6 | public static Double beersLaw(Double absorbtivity, Double constant, Double concentration)
{
boolean[] nulls = new boolean[3];
nulls[0] = (absorbtivity == null);
nulls[1] = (constant == null);
nulls[2] = (concentration == null);
int nullCount = 0;
for(int k = 0; k < nulls.length; k++)
{
if(nulls[k])
nullCount++;
}
if(nullCount != 1)
return null;
double result = 0;
if(nulls[0])
{
// absorbtivity is unknown
result = constant*concentration;
}
else if(nulls[1])
{
// constant is unknown
result = absorbtivity/concentration;
}
else if(nulls[2])
{
// concentration is unknown
result = absorbtivity/constant;
}
return result;
} |
24f3fbb3-c79b-40f8-a37c-e3750e681483 | 1 | public Serializable fromDOM(Document document)
{
ContextFreePumpingLemma pl = (ContextFreePumpingLemma)PumpingLemmaFactory.createPumpingLemma
(TYPE, document.getElementsByTagName(LEMMA_NAME).item(0).getTextContent());
/*
* Decode m, w, & i.
*/
pl.setM(Integer.parseInt(document.getElementsByTagName(M_NAME).item(0).getTextContent()));
pl.setW(document.getElementsByTagName(W_NAME).item(0).getTextContent());
pl.setI(Integer.parseInt(document.getElementsByTagName(I_NAME).item(0).getTextContent()));
/*
* Decode cases.
*
* Must decode cases before decoding the decomposition, otherwise
* the decomposition will be that of the last case. This is because,
* when add case is called, the pumping lemma chooses the decomposition
* to check if it's legal.
*/
readCases(document, pl);
//Decode the attempts
NodeList attempts = document.getDocumentElement().getElementsByTagName(ATTEMPT);
for(int i = 0; i < attempts.getLength(); i++)
pl.addAttempt(attempts.item(i).getTextContent());
//Decode the first player.
pl.setFirstPlayer(document.getElementsByTagName(FIRST_PLAYER).item(0).getTextContent());
// Decode the decomposition.
int uLength = Integer.parseInt(document.getElementsByTagName(U_NAME).item(0).getTextContent());
int vLength = Integer.parseInt(document.getElementsByTagName(V_NAME).item(0).getTextContent());
int xLength = Integer.parseInt(document.getElementsByTagName(X_NAME).item(0).getTextContent());
int yLength = Integer.parseInt(document.getElementsByTagName(Y_NAME).item(0).getTextContent());
pl.setDecomposition(new int[]{uLength, vLength, xLength, yLength});
//Return!
return pl;
} |
cb022076-1a70-4a7e-8566-e229235a21bf | 5 | protected void update() {
if(this.random.nextFloat() < 0.07F) {
this.xxa = (this.random.nextFloat() - 0.5F) * this.runSpeed;
this.yya = this.random.nextFloat() * this.runSpeed;
}
this.jumping = this.random.nextFloat() < 0.01F;
if(this.random.nextFloat() < 0.04F) {
this.yRotA = (this.random.nextFloat() - 0.5F) * 60.0F;
}
this.mob.yRot += this.yRotA;
this.mob.xRot = (float)this.defaultLookAngle;
if(this.attackTarget != null) {
this.yya = this.runSpeed;
this.jumping = this.random.nextFloat() < 0.04F;
}
boolean var1 = this.mob.isInWater();
boolean var2 = this.mob.isInLava();
if(var1 || var2) {
this.jumping = this.random.nextFloat() < 0.8F;
}
} |
c4eed818-f59d-4e09-be25-a908944c5e41 | 3 | public static String sanitizeWord(String word) {
String result = word;
for (Object obj : bannedWords) {
String badWord = (String) obj;
if (word.contains(badWord)) {
result = "";
// RemoveInstanceOfWord and add all other parts
for (String part : word.split(badWord)) {
result += part + "@#$%&!";
}
}
}
return result;
} |
1b0ce7f0-4ec2-4f81-9fa2-f150f37f6588 | 0 | public String getId() {
return id;
} |
4d33a59e-5018-4b10-931b-93733f405b22 | 9 | public static void main(String[] args) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
ComboPooledDataSource source = new ComboPooledDataSource();
try {
conn = source.getConnection();
ps = conn.prepareStatement("SELECT * FROM users");
rs = ps.executeQuery();
// while(rs.next()){
// System.out.println( rs.getString("name") );
// }
/*获取数据库元数据*/
DatabaseMetaData metadata = (DatabaseMetaData) conn.getMetaData();
/*获取数据连接的url*/
System.out.println(metadata.getURL());
/*获取数据库的主键信息*/
rs = metadata.getPrimaryKeys(null, null, "users");
while(rs.next()){
Short cseq = rs.getShort("KEY_SEQ"); /*所在列的序号*/
String cName = rs.getString("COLUMN_NAME");/*列名*/
System.out.println(cseq+":"+cName);
}
/*获取数据库中所有的表。*/
rs = metadata.getTables(null, null, "%", new String[]{"TABLE"});
while(rs.next()){
String tableName = rs.getString("TABLE_NAME");
System.out.println(tableName);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
if(rs!=null){
try {
rs.close();
} catch (Exception e) {
e.printStackTrace();
}finally{
/* 手动将其引用指向null,java的内存清理机制最终会对其清除 */
rs = null;
}
}
if(ps!=null){
try {
ps.close();
} catch (Exception e) {
e.printStackTrace();
}finally{
/* 手动将其引用指向null,java的内存清理机制最终会对其清除 */
ps = null;
}
}
if(conn!=null){
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}finally{
/* 手动将其引用指向null,java的内存清理机制最终会对其清除 */
conn = null;
}
}
}
} |
df75016f-382d-461d-86a0-6a66c3e65c26 | 5 | public boolean cancelProduction() {
if (isProductionInterfaceOpen()) {
if (isProductionComplete()) {
if (Condition.wait(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return !isProductionInterfaceOpen();
}
})) {
return true;
}
}
if (ctx.widgets.component(WIDGET_PRODUCTION_MAIN, WIDGET_PRODUCTION_CANCEL).interact("Cancel") && Condition.wait(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return !isProductionInterfaceOpen();
}
})) {
ctx.sleep(250);
}
}
return !isProductionInterfaceOpen();
} |
27bbba70-ecbb-4b95-bd9a-e77c38234f4f | 5 | public static StringBuffer fetchData(final String url, final TrayIcon processTrayIcon) {
URL obj = null;
try {
obj = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
URLConnection con = null;
try {
if (ApiProperties.get().getUrl().contains("https")) {
setupConnection();
con = (HttpsURLConnection) obj.openConnection();
} else {
con = (HttpURLConnection) obj.openConnection();
}
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader in;
try {
InputStream inputStream = con.getInputStream();
InputStreamReader inR = new InputStreamReader(inputStream);
in = new BufferedReader(inR);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response;
} catch (IOException e) {
// e.printStackTrace();
processTrayIcon.displayMessage("Connection Error Message", "Could not connect to " + url,
TrayIcon.MessageType.ERROR);
}
return null;
} |
e5e8263d-7076-43d3-b393-ae615a0faceb | 1 | public Object getChild(Object parent, int index) {
Iterator iter = ((TreeElement) parent).getChilds().iterator();
for (int i = 0; i < index; i++)
iter.next();
return iter.next();
} |
c14668c6-51ed-4031-a044-843663de1404 | 7 | private static void Attacking(Graphics2D gg, Base unit, int size, int resize) {
//If the unit disabled MoveAndShoot, then it won't display it's attack range since it can't attack.
if (unit.x != unit.oldx && unit.y != unit.oldy && !unit.MoveAndShoot) {return;}
//TODO: Maybe change this into a list of points like moving instead of playing with a block.
for (int y = unit.y - unit.MaxAtkRange; y <= unit.y + unit.MaxAtkRange; y++) {
for (int x = unit.x - unit.MaxAtkRange; x <= unit.x + unit.MaxAtkRange; x++) {
if (Game.view.Viewable(x,y)) {
if (unit.inrange(x,y)) {
gg.drawImage(Game.img_exts,
(x-Game.view.ViewX())*resize,(y-Game.view.ViewY())*resize,
(x-Game.view.ViewX())*resize+resize,(y-Game.view.ViewY())*resize+resize,
0,0,size,size,null);
}
}
}
}
} |
551aa6b1-e8c9-46d5-a259-c104b57163ff | 2 | public BatchCreatorPanel()
{
this.setBounds(100, 100, 606, 396);
this.listModel = new DefaultListModel<String>();
this.setLayout(new BorderLayout(0, 0));
final JPanel buttonBarPanel = new JPanel();
this.add(buttonBarPanel, BorderLayout.SOUTH);
final JButton btnAddNewFolder = new JButton("Add new Folder");
btnAddNewFolder.setAction(this.addAction);
buttonBarPanel.add(btnAddNewFolder);
final JButton btnSubfolder = new JButton("Subfolder");
btnSubfolder.setAction(this.action_1);
buttonBarPanel.add(btnSubfolder);
final JButton btnRemove = new JButton("Remove");
btnRemove.setAction(this.removeAction);
buttonBarPanel.add(btnRemove);
final JButton btnClear = new JButton("Clear");
btnClear.setAction(this.action);
buttonBarPanel.add(btnClear);
final JButton btnGenerateRsc = new JButton("Generate rsC");
btnGenerateRsc.setAction(this.generateAction);
buttonBarPanel.add(btnGenerateRsc);
this.chkboxOneCollection = new JCheckBox("As one Collection");
buttonBarPanel.add(this.chkboxOneCollection);
this.progressBar = new JProgressBar();
buttonBarPanel.add(this.progressBar);
final JPanel inputPanel = new JPanel();
inputPanel.setBorder(null);
this.add(inputPanel);
inputPanel.setLayout(new BorderLayout(0, 0));
final JScrollPane inputScrollPane = new JScrollPane();
inputPanel.add(inputScrollPane);
this.inputFolderList = new JList<String>(this.listModel);
this.inputFolderList
.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
inputScrollPane.setViewportView(this.inputFolderList);
final JLabel lblNewLabel = new JLabel("Input Folders");
inputPanel.add(lblNewLabel, BorderLayout.NORTH);
final JPanel inputChoosePanel = new JPanel();
this.add(inputChoosePanel, BorderLayout.WEST);
inputChoosePanel.setLayout(new BorderLayout(0, 0));
final JScrollPane folderScrollPane = new JScrollPane();
inputChoosePanel.add(folderScrollPane);
folderScrollPane.setMaximumSize(new Dimension(250, 5000));
this.folderTree = new JTree(new DefaultTreeModel(null));
this.folderTree.setRootVisible(false);
this.folderTree.addKeyListener(new KeyListener()
{
@Override
public void keyPressed(final KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (e.getModifiers() == InputEvent.CTRL_MASK) {
new AddSubfolderAction().actionPerformed(null);
} else {
new ActionAdd().actionPerformed(null);
}
}
}
@Override
public void keyReleased(final KeyEvent e)
{
}
@Override
public void keyTyped(final KeyEvent e)
{
}
});
folderScrollPane.setViewportView(this.folderTree);
final JPanel captionPanel = new JPanel();
inputChoosePanel.add(captionPanel, BorderLayout.NORTH);
captionPanel.setLayout(new BorderLayout(0, 0));
final JLabel lblChooseInputFolders = new JLabel("Choose input folders");
captionPanel.add(lblChooseInputFolders, BorderLayout.NORTH);
this.driveBox = new JComboBox(File.listRoots());
captionPanel.add(this.driveBox);
this.driveBox.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(final ActionEvent arg0)
{
BatchCreatorPanel.this.folderTree.setModel(new FolderTreeModel(
new FileWrapper((File) BatchCreatorPanel.this.driveBox
.getModel().getSelectedItem())));
}
});
this.folderTree.setModel(new FolderTreeModel(new FileWrapper(
(File) this.driveBox.getModel().getSelectedItem())));
} |
297471e2-1bb5-4161-963f-8a38e0f1fe56 | 7 | public boolean validMove(Move move)
{
//For place move
if(move.IsPlaceMove)
{
if(!correctRowColSize(move)) return false;
if(isJumpMove(move)) return false;
if(placeMove(move))return true;
else return false;
}
//For Jump Moves
else
{
if(!correctRowColSize(move)) return false;
if(!isJumpMove(move)) return false;
if(checkJumpMove(move)) return true;
else return false;
}
} |
1015727c-640a-4b9e-b851-0614a3b26865 | 2 | public VoidParameter(String name_, String desc_) {
name = name_;
description = desc_;
if (Configuration.head == null)
Configuration.head = this;
if (Configuration.tail != null)
Configuration.tail.next = this;
Configuration.tail = this;
} |
d9d80dbc-76a7-404d-9931-ddbd3cc6a11f | 7 | public static String GetRootApplicationPath()
{
if (s_root_application_path != null)
{
return s_root_application_path;
}
String os = System.getProperty("os.name").toLowerCase();
String path = "";
if (os.indexOf("win") >= 0)
{
path = "C:\\Users\\Public\\weathervane\\";
}
else if (os.indexOf("mac") >= 0 || os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os.indexOf("aix") >= 0) // is mac or windows
{
path = "/Users/dillonl/Documents/weathervane/";
}
File path_file = new File(path);
if (!path_file.exists())
{
path_file.mkdirs();
}
return path;
} |
16844258-886f-403d-8cd0-a6be58a2f165 | 5 | private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed
String searchNum = txtSearchPartNo.getText();
if (searchNum != null && searchNum.length() > 0) {
for (int i = 0; i < this.partNums.length; i++) {
if (searchNum.equalsIgnoreCase(partNums[i])) {
foundIndex = i;
break;
}
}
if (foundIndex == NOT_FOUND) {
//Not the Responsibility of this class
JOptionPane.showMessageDialog(this,
"Part Number not found. Please try again.",
"Not Found", JOptionPane.WARNING_MESSAGE);
} else {
txtCurProdNo.setText(partNums[foundIndex]);
txtCurDesc.setText(partDescs[foundIndex]);
txtCurPrice.setText("" + partPrices[foundIndex]);
}
} else {
//Not the Responsibility of this class
JOptionPane.showMessageDialog(this,
"Please enter a Part No. to search",
"Entry Missing", JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_btnSearchActionPerformed |
6b8707ba-3352-43d2-b023-a771429607d7 | 0 | final protected void dropChildren() {
children=null;
} |
a01e09db-986d-4dc3-8cc4-64d1032f7eb0 | 4 | private boolean askForSave() {
if (changed) {
int answer = JOptionPane.showConfirmDialog(frmDictionaryEditor, Localization.getInstance().get("messageSaveBeforeQuit"), Localization.getInstance().get("messageSaveBeforeQuitTitle"), JOptionPane.YES_NO_CANCEL_OPTION);
switch (answer) {
case JOptionPane.YES_OPTION:
boolean saved = save();
return saved;
case JOptionPane.NO_OPTION:
return true;
case JOptionPane.CANCEL_OPTION:
return false;
}
}
return true;
} |
b36c4189-9378-4b6e-811d-96384b851692 | 2 | private void createCachedMap() {
Graphics2D cachedTileImageGraphics = (Graphics2D) cachedTileImage.createGraphics();
// Start x, y from 0, and draw the total amount of visible tiles.
// But add the current viewport's x,y tiles to it and draw that tile
// instead.
for (int x = 0, y = 0, xPos = -cameraOffsetFromTileX; x < totalVisibleTilesWidth; x++, xPos += tileSizeWidth, y = 0) {
for (int yPos = -cameraOffsetFromTileY; y < totalVisibleTilesHeight; y++, yPos += tileSizeHeight) {
cachedTileImageGraphics.drawImage(tiles[x + currentVisibleTileX][y + currentVisibleTileY].image,
xPos,
yPos,
null);
}
}
cachedTileImageGraphics.dispose();
} |
962780af-8679-4818-b2e3-6748d152f383 | 5 | public Ship(eShipType type) {
this.type = type;
switch (type) {
case aircraftcarrier:
size = 5;
break;
case battleship:
size = 4;
break;
case destroyer:
size = 3;
break;
case submarine:
size = 3;
break;
case patrolboat:
size = 2;
break;
default:
size = 0;
}
fields = new ArrayList<>();
} |
6f0d4cb7-e174-4273-9a0e-ff5ffd1ca116 | 5 | public boolean transaction(Transaction trans) {
Connection conn = null;
try {
conn = ds.getConnection();
conn.setAutoCommit(false);
trans.trans(conn);
conn.commit();
return true;
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
if (null != conn) {
try {
conn.rollback();
} catch (SQLException e) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, e);
}
}
return false;
} finally {
if (null != conn) {
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
} |
87e75148-a90f-4ac3-afed-359e03b92968 | 4 | @SuppressWarnings("unused")
public void writeAVI() {
/*
* JMF Code no longer functioned for writing AVIs. Commented out and
* code below was written to use a different AVI writing library. BJD:
* 11-9-09
*
* JpegImagesToMovie imageToMovie = new JpegImagesToMovie();
* List<String> frameNames = getFrameNames(); Picture p = new
* Picture((String) frameNames.get(0)); if(!outputURL.endsWith(".avi"))
* outputURL = outputURL + ".avi";
* imageToMovie.doItAVI(p.getWidth(),p.getHeight(),
* frameRate,frameNames,outputURL);
*/
// The code below utilizes Werner Randelshofer's AVIOutputStream
// object to write an AVI movie from the list of frames. His code
// is shared under the Creative Commons Attribution License
// (see http://creativecommons.org/licenses/by/3.0/). More
// information about that code can be found in the AVIDemo.jar
// archive in the jars folder or at http://www.randelshofer.ch
List<String> frameNames = this.getFrameNames();
if (!this.outputURL.endsWith(".avi")) {
this.outputURL = this.outputURL + ".avi";
}
try {
Picture p = new Picture(frameNames.get(0));
} catch (ImageFormatException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
// Convert the URL into a filename
String filename = (new URL(this.outputURL)).getFile();
// Setup the output stream
AVIOutputStream AVIout = new AVIOutputStream(new File(filename));
// AVIout.setCompressionQuality(1);
// AVIout.setFrameRate(frameRate);
// (AVIout).setVideoDimension(p.getWidth(), p.getHeight());
// Write each frame
for (int i = 0; i < frameNames.size(); i++) {
// AVIout.writeFrame(new File(frameNames.get(i)));
// TODO Fix this
}
// Close the output stream so the AVI has proper format
AVIout.close();
} catch (Exception e) {
}
} |
fb85b9d1-65e4-493e-be88-319202ead999 | 8 | public Crossing getDestination(Person p) {
Catcher c = (Catcher) p;
Clue clue = process.getClue();
if( clue == null && c.peekNextPathStep() == null ) {
System.out.println(c + " is going to random Crossing...");
c.setPath( pathFinder.getPath(c.getCurr(), process.getGraph().getRandomVertex()) );
} else if( clue != null && !clue.getCrossing().equals( c.getDestination() ) ) {
System.out.println(c + " is going to clue");
c.setPath( pathFinder.getPath(c.getCurr(), clue.getCrossing()) );
}
// if(c.peekNextPathStep() == null) {
// findCrossingInGraph(clue.getCrossing());
// System.out.println(c + " next step: NULL");
// System.out.println("curr: " + c.getCurr());
// System.out.println("clue: " + clue.getCrossing());
// }
if(c.peekNextPathStep() != null)
return c.getNextPathStep();
/* if there's no particular Crossing we want to get to - choose way at random */
System.out.println(c + " is moving randomly...");
Crossing v = c.getCurr();
LinkedList<Vertex> nhood = v.getNeighbours();
if(nhood.size() < 2) {
return (Crossing) nhood.get(0);
}
if(nhood.size() == 2 && c.getPrev() != null) {
nhood.remove(c.getPrev());
return (Crossing) nhood.get(0);
}
//return (Crossing) (nhood.get(nhood.size()>1?1:0));
return (Crossing) (nhood.get(SimulationProgram.randomGenerator.nextInt(nhood.size() - 1)));
} |
8c20c789-27d4-4834-81a5-5ebd6d551cd5 | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Player other = (Player) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
if (this.score != other.score) {
return false;
}
if (this.woodCamp != other.woodCamp) {
return false;
}
return this.woodCarrying == other.woodCarrying;
} |
08a51739-0eda-4068-92fc-8733b2e00b6f | 7 | private void repetirPassKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_repetirPassKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
repetirPass.setText("");
repetirPass.requestFocus();
}
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
ManejoUsuario abm = new ManejoUsuario();
if (Arrays.equals(pass.getPassword(), repetirPass.getPassword())) {
if (!Base.hasConnection()) {
try{ Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://"+ManejoIp.ipServer+"/lubricentro", "tecpro", "tecpro"); }catch(Exception e){ JOptionPane.showMessageDialog(null, "Ocurrió un error, no se realizó la conexión con el servidor, verifique la conexión \n "+e.getMessage(),null,JOptionPane.ERROR_MESSAGE); }
}
boolean res=abm.modificarDatos(user.getText(),String.valueOf(pass.getPassword()));
if(res){
JOptionPane.showMessageDialog(this, "Cambios realizados con éxito", null, JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
else
JOptionPane.showMessageDialog(this, "Ocurrió un error, intente nuevamente", null, JOptionPane.ERROR_MESSAGE);
if (Base.hasConnection()) {
Base.close();
}
}
else{
JOptionPane.showMessageDialog(this, "¡Contraseñas distintas!", null, JOptionPane.ERROR_MESSAGE);
}
} // TODO add your handling code here:
}//GEN-LAST:event_repetirPassKeyPressed |
f07feaf9-be41-4438-bccd-00acbf2c234a | 1 | public static void main(String[] args) {
// TODO Auto-generated method stub
try {
LogUser frame = new LogUser();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
} |
26049224-78ac-4a4b-8b72-4b16f46175d4 | 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(DocumentSelectorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DocumentSelectorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DocumentSelectorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DocumentSelectorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
List<String> list = new ArrayList();
list.add("toto");
list.add("titi");
DocumentSelectorView selector = new DocumentSelectorView(list);
} |
b10446ec-05d7-4500-9f85-de438207c5a7 | 8 | public void decelerate(Vector v2) {
if(x == 0) {
//do nothing
} else if(x > 0) {
if (x - v2.getX() > 0) {
x = x - v2.getX();
} else {
x = 0;
}
} else {
if (x - v2.getX() < 0) {
x = x - v2.getX();
} else {
x = 0;
}
}
if (y == 0) {
//do nothing
} else if(y > 0) {
if (y - v2.getY() > 0) {
y = y - v2.getY();
} else {
y = 0;
}
} else {
if (y - v2.getY() < 0) {
y = y - v2.getY();
} else {
y = 0;
}
}
} |
5991f058-3a22-487d-b9db-2b5d091f12cb | 3 | private void deleteObjects() {
DictionnaireTable data = mcdComponent.getData();
String mess = Utilities
.getLangueMessage("supprimer_objet_selection");
if (mcdComponent.sizeSelection() > 1)
mess = "Voulez-vous vraiment supprimer les "
+ mcdComponent.sizeSelection()
+ " objets sélectionnés ?";
if (JOptionPane.showConfirmDialog(null, mess,
Utilities.getLangueMessage("analysesi"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
for (MCDObjet mcdObjet : mcdComponent.removeObjets())
data.deleteObserver(mcdObjet);
}
} |
197dba83-7823-4da3-8c57-52c63d466ef3 | 6 | private void createCellArray(String mapFile) {
Scanner fileReader;
ArrayList<String> lineList = new ArrayList<>();
try {
fileReader = new Scanner(new File(mapFile));
while (true) {
String line = null;
try {
line = fileReader.nextLine();
} catch (Exception eof) {}
if (line == null) {
break;
}
lineList.add(line);
}
tileHeight = lineList.size();
tileWidth = lineList.get(0).length();
cells = new Cell[tileHeight][tileWidth];
for (int row = 0; row < tileHeight; row++) {
String line = lineList.get(row);
for (int column = 0; column < tileWidth; column++) {
char type = line.charAt(column);
cells[row][column] = new Cell(column, row, type);
}
}
} catch (FileNotFoundException e) {
System.out.println("Maze map file not found");
}
} |
52385e0b-786b-4cc8-a607-6d2cdd8dba27 | 3 | public boolean extractFile(int libraryFK, String destinationDir){
destinationDir = destinationDir.replace("\\", "/") + "/";
FileBean fileBean = getFileBean(libraryFK);
if(fileBean == null) return false;
boolean isSaved = saveFile(libraryFK, Resource.getString("path.temp.zip"));
if(isSaved == false) return false;
String zipFilePath = Resource.getString("path.temp.zip") + fileBean.getName();
/**
* REMOVE THIS LINE!!!!!
*/
//System.err.println("Destination dir for extracting is static");
//destinationDir = Resource.getString("path.temp.unzip") + fileBean.getLibraryFK();
new File(destinationDir).mkdirs();
boolean extracted = Zip.extractFile(zipFilePath, destinationDir);
if(extracted == false) return false;
return true;
} |
c8bafdc1-0968-47d2-9304-fd83d4f99079 | 9 | private int jjMoveStringLiteralDfa8_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(6, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(7, active0);
return 8;
}
switch(curChar)
{
case 71:
return jjMoveStringLiteralDfa9_0(active0, 0x800L);
case 99:
return jjMoveStringLiteralDfa9_0(active0, 0x2000L);
case 107:
if ((active0 & 0x1000L) != 0L)
return jjStartNfaWithStates_0(8, 12, 2);
break;
case 108:
return jjMoveStringLiteralDfa9_0(active0, 0x4000L);
case 110:
return jjMoveStringLiteralDfa9_0(active0, 0x8000L);
case 112:
return jjMoveStringLiteralDfa9_0(active0, 0x100000L);
default :
break;
}
return jjStartNfa_0(7, active0);
} |
71c49372-a4be-42a9-9a88-5c7d4812ee00 | 0 | public void setNeitherNor(boolean isNeitherNor) {
this.isNeitherNor = isNeitherNor;
} |
c5620057-6089-4ace-8a7f-651ced080bbb | 0 | public void addVertex(Land land) {
laenderMap.put(land.getID(), land);
} |
ff57d32a-3d4c-4071-aee1-c4069e39bd28 | 8 | public static void removeRow(int row) {
int modelRow = LibraryPanel.table.convertRowIndexToModel(row);
FileTraverse.list.remove(modelRow);
Object[][] temp1 = new Object[7][modelRow];
Object[][] temp2 = new Object[7][(data[0].length-1) - modelRow];
Object[][] tempEnd = new Object[7][FileTraverse.list.size()];
for (int i = 0; i < temp1.length; i++) {
for (int j = 0; j < temp1[0].length; j++) {
temp1[i][j] = data[i][j];
}
}
int start = modelRow+1;
for (int i = 0; i < temp2.length; i++) {
for (int j = 0; j < temp2[0].length; j++) {
temp2[i][j] = data[i][start+j];
}
}
for (int i = 0; i < temp1.length; i++) {
for (int j = 0; j < temp1[0].length; j++) {
tempEnd[i][j] = temp1[i][j];
}
}
for (int i = 0; i < temp2.length; i++) {
for (int j = 0; j < temp2[0].length; j++) {
tempEnd[i][modelRow+j] = temp2[i][j];
}
}
data = tempEnd;
//LibraryPanel.model.fireTableDataChanged();
} |
f45e2851-9dd9-4226-877d-1532bcdf0833 | 6 | public static void drawPixels(int i, int j, int k, int l, int i1)
{
if(k < topX)
{
i1 -= topX - k;
k = topX;
}
if(j < topY)
{
i -= topY - j;
j = topY;
}
if(k + i1 > bottomX)
i1 = bottomX - k;
if(j + i > bottomY)
i = bottomY - j;
int k1 = width - i1;
int l1 = k + j * width;
for(int i2 = -i; i2 < 0; i2++)
{
for(int j2 = -i1; j2 < 0; j2++)
pixels[l1++] = l;
l1 += k1;
}
} |
bbf4fbb7-a32c-4922-9b64-daa6b886eaec | 9 | final public SimpleNode Start() throws ParseException {
/*@bgen(jjtree) Start */
SimpleNode jjtn000 = new SimpleNode(JJTSTART);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
expression();
jj_consume_token(22);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
{if (true) return jjtn000;}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
throw new Error("Missing return statement in function");
} |
74e7cde7-da9d-4eea-84ee-25794673dc8f | 4 | public void setBounds(float minx, float maxx, float miny, float maxy){
if(maxx < this.maxx) tempMaxx = maxx;
else tempMaxx = maxx;
if(minx > this.minx) tempMinx = minx;
else tempMinx = minx;
if(maxy < this.maxy) tempMaxy = maxy;
else tempMaxy = maxy;
if(miny > this.miny) tempMiny = miny;
else tempMiny = miny;
constrained = true;
} |
4b9cef94-f8db-4bd2-b45d-de32ddc6b292 | 3 | public static void main(String[] args) throws Exception {
Registry reg = LocateRegistry.getRegistry();
MasterServerClientInterface masterServer = (MasterServerClientInterface) reg
.lookup("masterServer");
ReplicaLoc loc = masterServer.read("file2.txt")[0];
ReplicaServerClientInterface repServer = (ReplicaServerClientInterface) reg
.lookup(loc.getName());
WriteMsg msg = null;
for (int i = 0; i < 10; i++) {
if (i % 3 == 0) {
if (msg != null) {
repServer.commit(msg.getTransactionId(), 3);
}
FileContent data = new FileContent("file2.txt");
data.appendData("\n\n");
msg = masterServer.write(data);
data = new FileContent("file2.txt");
data.appendData(i + "===\n");
repServer.write(msg.getTransactionId(), 0, data);
} else {
FileContent data = new FileContent("file2.txt");
data.appendData(i + "===\n");
repServer.write(msg.getTransactionId(), 0, data);
}
Thread.sleep(1000);
}
System.out.println(repServer.commit(msg.getTransactionId(), 3));
} |
60524ece-4417-4d47-a95c-d2ce6eaa3842 | 7 | public static void logicCommandLoop(Module module) {
{ Stella_Object command = null;
Stella_Object result = null;
boolean eofP = false;
boolean exitP = false;
boolean exitcommandP = false;
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, ((module != null) ? module : ((Module)(Stella.$MODULE$.get()))));
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
loop000 : for (;;) {
try {
System.out.println();
Logic.printLogicPrompt();
{ Object [] caller_MV_returnarray = new Object[1];
command = InputStream.readSExpression(Stella.STANDARD_INPUT, caller_MV_returnarray);
eofP = ((boolean)(((BooleanWrapper)(caller_MV_returnarray[0])).wrapperValue));
}
if (eofP) {
System.out.println("End of File encountered. Exiting.");
break loop000;
}
System.out.println();
{ Object [] caller_MV_returnarray = new Object[1];
exitP = Logic.logicCommandLoopExitP(command, caller_MV_returnarray);
exitcommandP = ((boolean)(((BooleanWrapper)(caller_MV_returnarray[0])).wrapperValue));
}
if (exitP) {
break loop000;
}
if (exitcommandP) {
continue loop000;
}
result = Logic.evaluateLogicCommand(command, false);
Logic.printLogicCommandResult(result);
} catch (LogicException le) {
Stella.STANDARD_ERROR.nativeStream.print(">> Error: " + Stella.exceptionMessage(le));
} catch (StellaException e) {
Stella.STANDARD_ERROR.nativeStream.print(">> Internal Error: " + Stella.exceptionMessage(e));
Stella.printExceptionContext(e, Stella.STANDARD_ERROR);
}
}
} finally {
Stella.$CONTEXT$.set(old$Context$000);
Stella.$MODULE$.set(old$Module$000);
}
}
}
} |
d8a08f0c-38b4-4233-8457-2039749b13c8 | 8 | public void step() {
int len = length();
// remove steps that cancel out
for (int i = 0; i < len; ++i) {
switch (at(i)) {
// We don't need this case, because the lower particle performs the same
// check
// case -1:
// if (directInteraction && at(i - 1) == 1) {
// set(i - 1, 0);
// set(i, 0);
// } else if (at(i - 2) == 1) {
// set(i - 2, 0);
// set(i, 0);
// }
//
// break;
case 1:
if (directInteraction && at(i + 1) == -1) {
set(i + 1, 0);
set(i, 0);
} else if (at(i + 2) == -1) {
set(i + 2, 0);
set(i, 0);
}
break;
case 0:
// do nothing
break;
}
}
// perform the resulting steps
// use a new array for that
int[] oldstate = lattice;
lattice = new int[length()];
for (int i = 0; i < len; ++i) {
if (oldstate[i] != 0) {
set(i + oldstate[i], 1);
}
}
randomize();
++time;
} |
aafbd556-4c9d-4a79-9a29-5e26b930161a | 2 | protected boolean isArrayValue(final Value value) {
Type t = ((BasicValue) value).getType();
return t != null
&& ("Lnull;".equals(t.getDescriptor()) || t.getSort() == Type.ARRAY);
} |
93925fac-2524-4ec5-aea0-7428d48204f2 | 7 | public void moveDown(){
switch (polygonPaint) {
case 0:
line.moveDwon();
repaint();
break;
case 1:
curv.moveDwon();
repaint();
break;
case 2:
triangle.moveDwon();
repaint();
break;
case 3:
rectangle.moveDwon();
repaint();
break;
case 4:
cu.moveDwon();
repaint();
break;
case 5:
elipse.moveDwon();
repaint();
break;
case 6:
arc.moveDwon();
repaint();
break;
}
repaint();
} |
f9013d28-1acd-4f1c-b971-cb97d47a3cb2 | 3 | public int lastManStanding() //This function exists because of our 2+ player system.
{
if(CURRENT_PLAYER_AMOUNT == 1)
{
for(int i = 0; i < GameCore.PLAYER_AMOUNT;i++)
{
if(players[i].stillPlaying == true)
{
return i;
}
}
}
return -1;
} |
7c8b1ddd-9214-456b-bd3a-59e120339ff8 | 6 | public boolean getBoolean(int index) throws JSONException {
Object object = this.get(index);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equals(Boolean.TRUE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONArray[" + index + "] is not a boolean.");
} |
84d291af-aea4-4668-aacf-6f9dec391988 | 0 | public int area() {
return height * width;
} |
95f5b837-f74e-4463-acb8-5c9986980e32 | 2 | public static void main(String args[]) throws UserException {
ORB orb = ORB.init((String[]) null, null);
org.omg.CORBA.Object obj = orb.string_to_object(args[0]);
Calculator stub = CalculatorHelper.narrow(obj);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
System.out.println(String.format("%d + %d = %d", i, j, stub.sum(i, j)));
}
}
} |
99c9ea14-9caf-4353-b174-896e0d8a6ddb | 2 | public MultipleChoice(boolean needsAnswer){
choices = new ArrayList<String>();
answers = new ArrayList<String>();
prompt = InputHandler.getString("Enter the prompt for your Multiple Choice question:");
int numChoices = InputHandler.getInt("Enter the number of choices: ");
for (int i=1; i<=numChoices; i++){
choices.add(InputHandler.getString("Enter choice #"+i+":"));
}
if (needsAnswer){
setCorrectAnswer();
}
} |
de38018a-f0dc-427a-a942-29830eac76e5 | 7 | protected Behaviour getNextStep() {
if (verbose) I.sayAbout(actor, "Getting next build step?") ;
if (built.structure.needsUpgrade() && built.structure.goodCondition()) {
final Action upgrades = new Action(
actor, built,
this, "actionUpgrade",
Action.BUILD, "Upgrading "+built
) ;
return upgrades ;
}
if (built.structure.hasWear()) {
final Action building = new Action(
actor, built,
this, "actionBuild",
Action.BUILD, "Assembling "+built
) ;
if (! Spacing.adjacent(actor.origin(), built) || Rand.num() < 0.2f) {
final Tile t = Spacing.pickFreeTileAround(built, actor) ;
if (t == null) {
abortBehaviour() ;
return null ;
}
building.setMoveTarget(t) ;
}
else building.setMoveTarget(actor.origin()) ;
return building ;
}
return null ;
} |
f2b8e5ce-c168-4bc8-89af-c0e8d4da519d | 3 | public Boolean estContent(EnvironnementSegregation univert){
int etrange = 0;
ArrayList<AgentHurbain> bonhomes = univert.voisins(pos_x, pos_y);
for (AgentHurbain bonhomme : bonhomes)
if(bonhomme != null && bonhomme.type!=type)
etrange++;
return !(((float)etrange/(float)bonhomes.size())*100 > 100-confort);
} |
85b86696-097a-4c0c-b1a3-818a1438c81a | 8 | private void compressStream(CompressionStream stream) {
if (benchmark) startTime = System.currentTimeMillis() ;
// Create the Huffman table.
huffmanTable = new HuffmanTable() ;
// Quantize the stream, compute deltas between consecutive elements if
// possible, and histogram the data length distribution.
stream.quantize(huffmanTable) ;
// Compute tags for stream tokens.
huffmanTable.computeTags() ;
// Create the output buffer and assemble the compressed output.
outputBuffer = new CommandStream(stream.getByteCount() / 3) ;
stream.outputCommands(huffmanTable, outputBuffer) ;
// Print any desired info.
if (benchmark) printBench(stream) ;
if (printStream) stream.print() ;
if (printHuffman) huffmanTable.print() ;
// Set up the compressed geometry header object.
cgHeader.bufferType = stream.streamType ;
cgHeader.bufferDataPresent = 0 ;
cgHeader.lowerBound = new Point3d(stream.ncBounds[0]) ;
cgHeader.upperBound = new Point3d(stream.ncBounds[1]) ;
if (stream.vertexNormals)
cgHeader.bufferDataPresent |=
CompressedGeometryHeader.NORMAL_IN_BUFFER ;
if (stream.vertexColor3 || stream.vertexColor4)
cgHeader.bufferDataPresent |=
CompressedGeometryHeader.COLOR_IN_BUFFER ;
if (stream.vertexColor4)
cgHeader.bufferDataPresent |=
CompressedGeometryHeader.ALPHA_IN_BUFFER ;
cgHeader.start = 0 ;
cgHeader.size = outputBuffer.getByteCount() ;
// Clear the huffman table for next use.
huffmanTable.clear() ;
} |
1901ffc1-d256-4b2a-b722-c7c4b60aeedd | 1 | public synchronized boolean isSeed() {
return this.torrent.getPieceCount() > 0 &&
this.getAvailablePieces().cardinality() ==
this.torrent.getPieceCount();
} |
630d349a-d740-4987-9673-7f2af87c5b6f | 3 | public static void writeImage(BufferedImage image, String fileName)
throws IOException
{
if (fileName == null) return;
int offset = fileName.lastIndexOf( "." );
if (offset == -1)
{
String message = "file suffix was not specified";
throw new IOException( message );
}
String type = fileName.substring(offset + 1);
if (types.contains(type))
{
ImageIO.write(image, type, new File( fileName ));
}
else
{
String message = "unknown writer file suffix (" + type + ")";
throw new IOException( message );
}
} |
2a527799-2944-44df-a9b6-dd252c595360 | 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(GTDay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GTDay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GTDay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GTDay.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() {
GTDay gtday = new GTDay();
gtday.setVisible(true);
gtday.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
});
} |
d7e940cd-7a8a-46ed-b3c2-bf9f9699db4e | 9 | public BoardCell pickLocation(HashSet<BoardCell> targets) {
//If the list of targets locations includes a room, select that location unless the player was just in that room.
//If the list does not include a room, or the room was just
//visited, randomly choose from all locations (gives some chance that the player will re-enter the room, but it's not automatic).
if(accusation != null) {
String person = " ", room=" ", weapon=" ";
for(Card c : accusation) {
if(c.getType() == CardType.PERSON)
person = c.getName();
else if(c.getType() == CardType.ROOM)
room = c.getName();
else if (c.getType() == CardType.WEAPON)
weapon = c.getName();
}
makeAccusation(person, room, weapon);
}
ArrayList<BoardCell> possibleWalkways = new ArrayList<BoardCell>();
for (BoardCell target : targets) {
if(target.isDoorway() == true && target.cellInitial() != lastRoomVisited){
//RoomCell room = (RoomCell) target;
//this.setposition(target.getLocation());
lastRoomVisited = target.cellInitial;
return target;
}else if (target.isWalkway()) {
possibleWalkways.add(target);
}
}
Collections.shuffle(possibleWalkways);
return possibleWalkways.get(0);
} |
3df75dbf-081f-4622-a85b-59e97b9c82c5 | 5 | @Override
public void actionENTER() {
if (Fenetre._state == StateFen.Level && _currentBird.getTakeOff() != 0 && !_currentBird.isDestructing()){
// Test s'il existe un oiseau et s'il existe demande a l'oiseau de lacher un oeuf
if (Fenetre._list_birds.size() != 0 && _currentBird.getEggLeft() > 0) {
Fenetre._list_egg.add(_currentBird.lay_egg());
}
}
} |
bf65c232-6f9e-4e3a-b40c-14ef76d14943 | 2 | @Override
public void startElement(String uri, String localName, String qName, Attributes attrs)
throws SAXException {
if (qName.equals("eveapi")) {
getResponse().setVersion(getInt(attrs, "version"));
} else if (qName.equals("error")) {
error = new ApiError();
error.setCode(getInt(attrs, "code"));
getResponse().setError(error);
}
accumulator.setLength(0);
} |
541f363e-605a-4fa0-bdf8-495e506b9707 | 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(TreehouseFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TreehouseFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TreehouseFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TreehouseFrame.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 TreehouseFrame().setVisible(true);
}
});
} |
59fc3d90-3d8b-4a63-915d-aa6f2a5467e5 | 4 | private void launchChat() throws RemoteException {
// get the index of the last message sent to the server so that client
// knows from where they can start printing messages
this.lastDisplayedMsgIndex = stub.getLastMsgIndex();
String userInput = "",
command,
arg,
splitInput[];
// while client has not quit, process their commands
while (!hasQuit) {
command = "";
arg = "";
// read, format and process user input if it is possible
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
userInput = br.readLine().trim();
if (userInput.length() > 0) {
splitInput = userInput.split("\\s+", 2);
command = splitInput[0];
if (splitInput.length > 1)
arg = splitInput[1];
processCommand(command, arg);
}
} catch (IOException e) {
// ignore exception gracefully
}
}
} |
ec7dde42-461b-4f75-996c-e1d0da51698b | 6 | public static boolean freeVariableP(PatternVariable variable, Proposition proposition) {
{ Keyword testValue000 = proposition.kind;
if ((testValue000 == Logic.KWD_FORALL) ||
(testValue000 == Logic.KWD_EXISTS)) {
if (((Vector)(KeyValueList.dynamicSlotValue(proposition.dynamicSlots, Logic.SYM_LOGIC_IO_VARIABLES, null))).memberP(variable)) {
return (false);
}
}
else {
}
}
{ boolean alwaysP000 = true;
{ Stella_Object arg = null;
Vector vector000 = proposition.arguments;
int index000 = 0;
int length000 = vector000.length();
loop000 : for (;index000 < length000; index000 = index000 + 1) {
arg = (vector000.theArray)[index000];
if (Stella_Object.isaP(arg, Logic.SGT_LOGIC_PROPOSITION)) {
if (!PatternVariable.freeVariableP(variable, ((Proposition)(arg)))) {
alwaysP000 = false;
break loop000;
}
}
}
}
{ boolean value000 = alwaysP000;
return (value000);
}
}
} |
e496e947-81bb-4f2f-9257-3caff1f0c9b9 | 8 | public void propertyChange(PropertyChangeEvent evt) {
Object source = evt.getSource();
if (source instanceof JFormattedTextField
&& evt.getPropertyName().equals("value")
&& (((JFormattedTextField) evt.getSource()).getValue() != null)) {
Number newValue = null;
Number value = m_Node.getValue();
JFormattedTextField field = (JFormattedTextField) evt.getSource();
Number fieldValue = (Number) field.getValue();
if (value instanceof Double)
newValue = new Double(NumberNode.roundDouble((fieldValue.doubleValue())));
else if (value instanceof Integer)
newValue = new Integer((fieldValue).intValue());
else if (value instanceof Float)
newValue = new Float(NumberNode.roundFloat((fieldValue.floatValue())));
else if (value instanceof Long)
newValue = new Long((fieldValue).longValue());
else {
try {
throw new NumberClassNotFoundException(value.getClass()
+ " not currently supported.");
} catch (NumberClassNotFoundException e) {
e.printStackTrace();
}
}
field.setValue(newValue);
m_Node.setValue(newValue);
}
} |
855ec37e-756c-4b46-9342-d00ae4cca1d6 | 0 | @GET
@Path("events")
@Produces({MediaType.APPLICATION_JSON })
public List<Event> getEvents(){
System.out.println("Return the events list");
return JpaTest.eventService.getEvents();
} |
18b1edd2-a6e8-443f-9db8-5796d1d59f29 | 1 | private void setRij(int rij) throws IllegalArgumentException {
if (rij <= 0) {
throw new IllegalArgumentException("Rij mag niet onder 0 gaan");
}
this.rij = rij;
} |
6f1e599e-a9a9-4144-8272-ce4ebb20c5be | 2 | public static LuggageFacilityEnumeration fromValue(String v) {
for (LuggageFacilityEnumeration c: LuggageFacilityEnumeration.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
} |
8f3bfd47-2f89-41cc-a916-a0316312b4a4 | 7 | private void handleMPClick(MouseEvent e) {
xIndex = e.getX() / 100;
yIndex = 0;
while ((gameGrid[xIndex][yIndex + 1]).getState() == 0) {
yIndex++;
if (yIndex == Board.numRows - 1) {
break;
}
}
//if the top circle is already filled, do nothing and return
if (yIndex == 0 && gameGrid[xIndex][yIndex].getState() != 0) {
return;
}
//set the selected circle's state to current player's color
if (game.getTurn() == 1) {
gameGrid[xIndex][yIndex].setState(game.getPlayer1Color());
} else if (game.getTurn() == 2) {
gameGrid[xIndex][yIndex].setState(game.getPlayer2Color());
}
display.repaint();
game.incrementMoveCounter();
System.out.println("Move Counter: " + game.getMoveCounter());
IntPair spotOnBoard = new IntPair(xIndex, yIndex);
game.getMovesList().push(spotOnBoard);
//change turns
if (game.getTurn() == 1) {
game.setTurn(2);
//inGameMenuP.setCurrentTurn(player2ColorState);
} else {
game.setTurn(1);
//inGameMenuP.setCurrentTurn(player1ColorState);
}
++drawCounter;
} |
702fe85d-478c-4e96-8b11-e81c87b36abd | 8 | public static void main(String[] args) {
String rssFeed =
"<rss version=\"0.92\">" +
"<channel>" +
" <title>BBC JIRA</title>" +
" <link>https://jira.dev.example.com/secure/IssueNavigator.jspa?reset=true&jqlQuery=assignee+%3D+currentUser%28%29+AND+status+%3D+Open</link>" +
" <description>An XML representation of a search request</description>" +
" <language>en-uk</language> " +
" <build-info>" +
" <version>4.0.2</version>" +
" <build-number>472</build-number>" +
" <build-date>14-02-2010</build-date>" +
" <edition>enterprise</edition>" +
" </build-info>" +
"<item>" +
" <title>[EXAMPLE-80] Time field in Broadcast Information displayed at GMT and not BST</title>" +
" <link>https://jira.example.com/browse/EXAMPLE-80</link>" +
" <project id=\"10650\" key=\"EXAMPLE\">Example Project</project>" +
"</item>" +
"<item>" +
" <title>[EXAMPLE-81] Time field in Broadcast Information displayed at GMT and not BST</title>" +
" <link>https://jira.example.com/browse/EXAMPLE-80</link>" +
" <project id=\"10650\" key=\"EXAMPLE\">Example Project</project>" +
"</item>" +
"<item>" +
" <title>[EXAMPLE-82] Time field in Broadcast Information displayed at GMT and not BST</title>" +
" <link>https://jira.example.com/browse/EXAMPLE-80</link>" +
" <project id=\"10650\" key=\"EXAMPLE\">Example Project</project>" +
"</item>" +
"</channel>" +
"</rss>";
DocumentBuilderFactory builderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = builderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
Document document;
try {
//FileInputStream is = new FileInputStream("data/example_jira_search_rss.xml");
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(rssFeed));
document = builder.parse( is );
Element rootElement = document.getDocumentElement();
String attrValue = rootElement.getAttribute("version");
System.out.println( "This is document version: " + attrValue );
/*
item
title
link
project @key | text()
*/
NodeList nodes = rootElement.getElementsByTagName("item");
for(int i=0; i<nodes.getLength(); i++){
// System.out.println( node.getTextContent() );
Node node = nodes.item(i);
if(node instanceof Element){
Element child = (Element) node;
NodeList titleNodes = child.getElementsByTagName("title");
if (titleNodes.getLength() >= 0) {
String title = titleNodes.item(0).getTextContent();
System.out.println( "title : " + title );
}
NodeList linkNodes = child.getElementsByTagName("link");
if (linkNodes.getLength() >= 0) {
String link = linkNodes.item(0).getTextContent();
System.out.println( "link : " + link );
}
NodeList projectNodes = child.getElementsByTagName("project");
if (projectNodes.getLength() >= 0) {
Element projectNode = (Element) projectNodes.item(0);
String project = projectNode.getTextContent();
String projectKey = projectNode.getAttribute("key");
System.out.println( "project : " + project + " (" + projectKey + ")");
}
}
}
/*
NodeList nodes = rootElement.getChildNodes();
for(int i=0; i<nodes.getLength(); i++){
Node node = nodes.item(i);
if(node instanceof Element){
//a child element to process
//Element child = (Element) node;
//String attribute = child.getAttribute("width");
System.out.println( node.getTextContent() );
}
}
*/
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} |
4dba44e8-7442-443c-a3a2-ecafcbcaae8f | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TailEvent<?> other = TailEvent.class.cast(obj);
if (tailContents == null) {
if (other.tailContents != null)
return false;
} else if (!tailContents.equals(other.tailContents))
return false;
return true;
} |
64bb2b68-22d1-4f7a-922c-d38bcc37ef83 | 8 | public static void resize(int buffer, int newByteSize) {
if (newByteSize < 0) throw new NegativeArraySizeException();
int buffPos = poses[buffer];
int buffLength = lengths[buffer];
lengths[buffer] = newByteSize;
if (buffLength < newByteSize) {
bytes = Arrays.copyOf(bytes, bytes.length + (newByteSize - buffLength));
}
int backLength = 0;
for (int len = buffer + 1; len < lengths.length; ++len) {
backLength += lengths[len];
}
for (int len = buffer + 1; len < poses.length; ++len) {
poses[len] += newByteSize - buffLength;
}
System.arraycopy(bytes, buffPos + buffLength, bytes, buffPos + newByteSize, backLength);
if (buffLength > newByteSize) {
bytes = Arrays.copyOf(bytes, bytes.length + (buffLength - newByteSize));
}
System.out.println(bytes.length + ", " + (buffLength < newByteSize ? newByteSize - buffLength : buffLength - newByteSize));
int length = (buffLength < newByteSize ? newByteSize - buffLength : buffLength - newByteSize);
for (int len = 0; len < length; ++len) {
bytes[buffPos + buffLength+ len] = 0;
}
} |
9a2fb4fc-4b5e-4517-a469-674f2cb49fb2 | 9 | public static void intersection(int x[], int y[]) {
System.out.print("First Array :\t");
for (int element : x) {
System.out.print(element + " ");
}
System.out.print("\nSecond Array :\t");
for (int element : y) {
System.out.print(element + " ");
}
System.out.print("\n");
int len = 0;
for (int i = 0; i < x.length; i++) {
loop: for (int j = 0; j < y.length; j++) {
if (x[i] == y[j]) {
len++;
break loop;
}
}
}
int z[] = new int[len];
for (int i = 0, j = 0; j < y.length; j++) {
loop: for (int k = 0; k < x.length; k++) {
if (y[j] == x[k]) {
z[i] = y[j];
++i;
break loop;
}
}
}
System.out.print("Intersection of the Arrays:\t");
for (int element : z) {
System.out.print(element + " ");
}
System.out.println("\n");
} |
e669576b-a07b-4e8f-9516-6a5b9123e482 | 4 | protected Method getMethod(String name, boolean isStatic) {
try {
Method method = clazz.getDeclaredMethod(name, Map.class);
if (!ConfigurationSerializable.class.isAssignableFrom(method.getReturnType())) {
return null;
}
if (Modifier.isStatic(method.getModifiers()) != isStatic) {
return null;
}
return method;
} catch (NoSuchMethodException ex) {
return null;
} catch (SecurityException ex) {
return null;
}
} |
802ccdac-0d4a-4dc7-9b36-d666d7a9c19f | 6 | private static void validateProperties(Properties properties) {
String portProperty = getProperty(properties, PORT_PROPERTY);
try {
Integer.parseInt(portProperty);
} catch (NumberFormatException e) {
exit("Port is not a number.");
}
String rootProperty = getProperty(properties, ROOT_PROPERTY);
if (!(new File(rootProperty).isDirectory())) {
exit("Root is not a directory.");
}
String maxThreadsProperty = getProperty(properties, MAX_THREADS_PROPERTY);
try {
Integer.parseInt(maxThreadsProperty);
} catch (NumberFormatException e) {
exit("Max threads is not a number.");
}
String smtpName = getProperty(properties, SMTP_NAME_PROPERTY);
try {
InetAddress.getByName(smtpName);
} catch (UnknownHostException e) {
exit("Couldn't resolve the " + SMTP_NAME_PROPERTY + " IP address.");
}
String smtpPort = getProperty(properties, SMTP_PORT_PROPERTY);
try {
Integer.parseInt(smtpPort);
} catch (NumberFormatException e) {
exit(SMTP_PORT_PROPERTY + " is not a number.");
}
String reminderFilePath = getProperty(properties, REMINDER_FILE_PATH_PROPERTY);
checkCanWrite(reminderFilePath);
String taskFilePath = getProperty(properties, TASK_FILE_PATH_PROPERTY);
checkCanWrite(taskFilePath);
String pollFilePath = getProperty(properties, POLL_FILE_PATH_PROPERTY);
checkCanWrite(pollFilePath);
getProperty(properties, DEFAULT_PAGE_PROPERTY);
getProperty(properties, SERVER_NAME_PROPERTY);
getProperty(properties, SMTP_USERNAME_PROPERTY);
getProperty(properties, SMTP_PASSWORD_PROPERTY);
getProperty(properties, SMTP_IS_AUTH_LOGIN_PROPERTY);
String logLevel = getOptionalProperty(properties, LOG_LEVEL_PROPERTY);
if (logLevel != null) {
HelperLogger.logLevel = HelperLogger.LogLevel.valueOf(logLevel.toUpperCase());
} else {
HelperLogger.logLevel = HelperLogger.LogLevel.DEBUG;
}
} |
8cf2c735-6c61-4638-9790-8e13485a2895 | 3 | static private float[] subArray(final float[] array, final int offs, int len)
{
if (offs+len > array.length)
{
len = array.length-offs;
}
if (len < 0)
len = 0;
float[] subarray = new float[len];
for (int i=0; i<len; i++)
{
subarray[i] = array[offs+i];
}
return subarray;
} |
fc60813a-dde4-4b8c-8530-f15d01bb5eac | 8 | protected void modeTwo(MouseEvent e, TicTacToeSubMenu sm, Main m) {
int x1 = sm.getX1();
int y1 = sm.getY1();
int w1 = sm.getW1();
int h1 = sm.getH1();
if (e.getX() > x1 && e.getX() < x1 + w1) {
if (e.getY() > y1 && e.getY() < y1 + h1) {
m.currentMode = m.mode3;
}
}
int x2 = sm.getX2();
int y2 = sm.getY2();
int w2 = sm.getW2();
int h2 = sm.getH2();
if (e.getX() > x2 && e.getX() < x2 + w2) {
if (e.getY() > y2 && e.getY() < y2 + h2) {
m.currentMode = m.mode4;
}
}
} |
3e0edcec-ec1d-44a8-9665-52fe4c3aeaee | 1 | public void visit_dmul(final Instruction inst) {
stackHeight -= 4;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
stackHeight += 2;
} |
8bdfddfd-c18e-45a6-8ad7-69689a853699 | 4 | public void move() {
if (direction==0) {
x++;
} else if (direction==90) {
y--;
} else if (direction==180) {
x--;
} else if (direction==270) {
y++;
}
} |
4f285850-24d8-469f-8f89-03dc5363cb7d | 8 | private void eventsInMind(CounterActionFactory CAF) {
CloudComment cc = CAF.createCloudComment("");
SkinSwitch ss = CAF.createSkinSwitch(0);
@SuppressWarnings("unchecked")
HashMap<Time, String> events = (HashMap<Time, String>) Serializer.deserialize(this, "events.dat");
if (events == null) {
ss.setSkin(Emotion.sleepy.code);
cc.setComment("There's no event I know about.");
ss.trigger();
cc.trigger();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else {
if (events.size() == 0) {
ss.setSkin(Emotion.sleepy.code);
cc.setComment("There's no event I know about.");
ss.trigger();
cc.trigger();
try {
Thread.sleep(3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else {
ss.setSkin(Emotion.facingaway.code);
cc.setComment("Wait a bit, I found some heereee..");
ss.trigger();
cc.trigger();
try {
Thread.sleep(3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
ss.setSkin(Emotion.talking.code);
ss.trigger();
Iterator<Entry<Time, String>> it = events.entrySet().iterator();
while (it.hasNext()) {
Entry<Time, String> one = it.next();
Time evTime = one.getKey();
String evName = one.getValue();
cc.setComment(evName + " at " + evTime.toString());
cc.trigger();
try {
Thread.sleep(3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
cc.setComment("Aaaand that's all.");
ss.setSkin(Emotion.sleepy.code);
cc.trigger();
ss.trigger();
try {
Thread.sleep(3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} |
16d49069-54bd-4f9d-925c-c94b3114fd23 | 4 | public Deck() {
deck = new ArrayList<Card>();
for (int i = 1; i <= NUMBER_OF_CARDS; i++) {
if (i <= CARDS_FIRST_ITR) {
deck.add(new Card(CardType.CLUBS, i));
} else if (i <= CARDS_SECOND_ITR) {
deck.add(new Card(CardType.DIAMONDS, i - CARDS_FIRST_ITR));
} else if (i <= CARDS_THIRD_ITR) {
deck.add(new Card(CardType.HEARTS, i - CARDS_SECOND_ITR));
} else {
deck.add(new Card(CardType.SPADES, i - CARDS_THIRD_ITR));
}
}
} |
4549065a-9f0e-4d39-bd0d-d1c04de01f77 | 4 | public boolean insidePlayingField(float pf_width, float pf_height) {
if(x < 0) {
return false;
}
else if((x + brick.width) > pf_width) {
return false;
}
if(y < Breakout.STATUS_FIELD_HEIGHT) {
return false;
}
else if((y + brick.height) > pf_height) {
return false;
}
return true;
} |
92e83682-c0a9-40e5-8dad-b59198e1eeb3 | 2 | public static boolean is7BitASCII(String str) {
int i;
for(i=0;i<str.length();i++){
if(str.charAt(i)>=0x80) break; // note: change to codePointAt after we switch to java 1.5
}
return (i==str.length());
} |
703f6611-5f09-449c-b5a7-152a069ad59f | 1 | public void connectDb() {
startSQL();
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url, user, password);
st = con.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
} |
679d7e8f-332f-448c-a22a-c1ea717da3f9 | 0 | public boolean isHalted(){
return isHalted;
} |
b5a562ee-ecb7-4be1-b456-dc4eaab1fd9a | 4 | public static void getNum() {
long n = 2 * 3 * 5 * 7 * 11;
while (true) {
long sq = n * n;
int count = 2;
for (int i = 2; i < n; i++) {
if (sq % i == 0) {
count++;
}
}
if (count > 1000) {
System.out.println(n + " " + count);
break;
}
n += 2 * 3 * 5 * 7 * 11;
}
} |
a0987520-8dea-47b9-82be-03fb11f14714 | 5 | private void buildFinalResult()
{
int nrPlayers = profiles.size();
double[] wins = new double[nrPlayers];
double[] loses = new double[nrPlayers];
double[] ties = new double[nrPlayers];
for (int j = 0; j < nrPlayers; j++) {
wins[j] = loses[j] = ties[j] = 0;
}
//sum up all the percentages
for (int i = 0; i < nrOfWorkers; i++) {
SimulationWorkerResult result = workers.get(i).getResult();
for (int j = 0; j < nrPlayers; j++) {
wins[j] += result.getWinPercentage(j);
loses[j] += result.getLosePercentage(j);
ties[j] += result.getTiePercentage(j);
}
}
//average is needed, so... divide
for (int j = 0; j < nrPlayers; j++) {
wins[j] /= nrOfWorkers;
loses[j] /= nrOfWorkers;
ties[j] /= nrOfWorkers;
}
long duration = endTime - startTime;
ResultBuilder resultBuilder = new SimulationFinalResult.ResultBuilder().setGameType(gameType)
.setPlayers(profiles);
//flop is set
if (communityCards[0] != null) {
resultBuilder.setFlop(Arrays.copyOfRange(communityCards, 0, 3));
}
simulationResult = resultBuilder.setTurn(communityCards[3])
.setRiver(communityCards[4])
.setWins(wins)
.setTies(ties)
.setLoses(loses)
.setRounds(nrRounds)
.setThreads(nrOfWorkers)
.setDuration(duration)
.build();
} |
8677e8bf-3563-49e2-a1f9-cef14b8420f5 | 4 | public void guiForOpeningAndCheckingLogFileForXML() {
frmOpeningAndCheckingLogFileForXML.setSize(400, 300);
frmOpeningAndCheckingLogFileForXML
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmOpeningAndCheckingLogFileForXML.setVisible(true);
frmOpeningAndCheckingLogFileForXML
.add(pnlOpeningAndCheckingLogFileForXML);
frmOpeningAndCheckingLogFileForXML.setLocationRelativeTo(null);
frmOpeningAndCheckingLogFileForXML
.setTitle("XML Tool: Checking for XML in log file");
pnlOpeningAndCheckingLogFileForXML.setLayout(null);
pnlOpeningAndCheckingLogFileForXML.setVisible(true);
pnlOpeningAndCheckingLogFileForXML
.add(btnForExecutingWriteOnlyXmlToTxtFileFromLogFile);
pnlOpeningAndCheckingLogFileForXML
.add(btnForCancellingAndMovingBackToMainHomeScreen);
pnlOpeningAndCheckingLogFileForXML.add(btnForSelectingFileForExecuting);
pnlOpeningAndCheckingLogFileForXML.add(txtPathOfFile);
pnlOpeningAndCheckingLogFileForXML
.add(lblOpenAsOpeningAndCheckingLogFileForXML);
pnlOpeningAndCheckingLogFileForXML.add(lblDone);
btnForExecutingWriteOnlyXmlToTxtFileFromLogFile.setBounds(100, 200, 80,
30);
btnForExecutingWriteOnlyXmlToTxtFileFromLogFile.setVisible(false);
btnForCancellingAndMovingBackToMainHomeScreen.setBounds(200, 200, 80,
30);
btnForCancellingAndMovingBackToMainHomeScreen.setVisible(true);
btnForSelectingFileForExecuting.setBounds(300, 75, 80, 30);
btnForSelectingFileForExecuting.setVisible(true);
txtPathOfFile.setBounds(80, 75, 200, 30);
txtPathOfFile.setEditable(false);
lblOpenAsOpeningAndCheckingLogFileForXML.setBounds(10, 75, 80, 30);
/*
* Button Listener for running WriteOnlyXmlToTxtFileFromLogFile() Method
*/
try {
btnForExecutingWriteOnlyXmlToTxtFileFromLogFile
.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
WritingXmlFromLogFileToTxtFile objWritingXmlFromLogFileToTxtFile = new WritingXmlFromLogFileToTxtFile();
objWritingXmlFromLogFileToTxtFile.writeOnlyXmlToTxtFileFromLogFile();
MainHomePageForApplication objMainHomePageForApplication = new MainHomePageForApplication();
frmOpeningAndCheckingLogFileForXML
.setVisible(false);
objMainHomePageForApplication.frmMainHomePage.setVisible(true);
objMainHomePageForApplication.guiForMainHomePage();
flag = true;
objMainHomePageForApplication.btnQueringForXmlDataBasedOnDateinMainHomePage
.setVisible(true);
objMainHomePageForApplication.btnfindingSpecialCharInMainHome.setVisible(true);
}
});
} catch (Exception e) {
e.printStackTrace();
}
try {
btnForSelectingFileForExecuting
.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
SelectingLogFileToReadXml objSelectingLogFileToReadXml = new SelectingLogFileToReadXml();
objSelectingLogFileToReadXml.ReadLogFile();
if (SelectingLogFileToReadXml.fileWithXmlAndGarbageData.exists()) {
btnForExecutingWriteOnlyXmlToTxtFileFromLogFile
.setVisible(true);
txtPathOfFile.setText(SelectingLogFileToReadXml.PathOfFile);
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
/*
* Button listener to cancel selecting a file and moving back to home
* screen
*/
try {
btnForCancellingAndMovingBackToMainHomeScreen
.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
MainHomePageForApplication objMainHomePageForApplication = new MainHomePageForApplication();
objMainHomePageForApplication.frmMainHomePage.setVisible(true);
frmOpeningAndCheckingLogFileForXML
.setVisible(false);
}
});
} catch (Exception e) {
e.printStackTrace();
}
} |
da12a582-2993-4e1a-af7b-ac985a35c0a3 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Login)) {
return false;
}
Login other = (Login) object;
if ((this.userid == null && other.userid != null) || (this.userid != null && !this.userid.equals(other.userid))) {
return false;
}
return true;
} |
723203f3-d1cd-44e2-a5b0-e72e41a056e6 | 9 | public static JPrimitiveType parse(JCodeModel codeModel, String typeName) {
if (typeName.equals("void"))
return codeModel.VOID;
else if (typeName.equals("boolean"))
return codeModel.BOOLEAN;
else if (typeName.equals("byte"))
return codeModel.BYTE;
else if (typeName.equals("short"))
return codeModel.SHORT;
else if (typeName.equals("char"))
return codeModel.CHAR;
else if (typeName.equals("int"))
return codeModel.INT;
else if (typeName.equals("float"))
return codeModel.FLOAT;
else if (typeName.equals("long"))
return codeModel.LONG;
else if (typeName.equals("double"))
return codeModel.DOUBLE;
else
throw new IllegalArgumentException("Not a primitive type: " + typeName);
} |
f2ad6bca-12ce-44ca-a86c-862f3df1bfef | 2 | public boolean deleteItem(int index) {
int itemCount = getItemCount();
// unacceptable index - reject
if (index < 0 || index >= itemCount)
return false;
// delete indexed entry
childItems.remove(index);
// successful delete
return true;
} |
ee19c4dc-62aa-4e3c-9883-a2cac99c4e65 | 2 | public void passEigenValues( double[] eigenValues, double[][] eigenVectors )
{
int l = eigenValues.length;
double power = 0.0;
for ( int i = 0; i < l; ++ i )
power += Math.abs(eigenValues[i]);
power /= 100.0;
SortingEVFilter sevf = new SortingEVFilter(true, true);
sevf.passEigenValues(eigenValues, eigenVectors);
double[] eigenValuesSorted = sevf.getEigenValues();
double[][] eigenVectorsSorted = sevf.getEigenVectors();
double per = 0.0;
int n = 0;
while ( per - this.percentage < 0.0 )
{
per += Math.abs(eigenValuesSorted[n]) / power;
n ++;
}
FirstEVFilter fevf = new FirstEVFilter(n);
fevf.passEigenValues(eigenValuesSorted, eigenVectorsSorted);
this.eigenValues = fevf.getEigenValues();
this.eigenVectors = fevf.getEigenVectors();
} |
92f1db5b-5eba-41fe-a456-37b9dde82b28 | 1 | int get_bowl_score(int[] bowl) {
int ret = 0;
for (int i=0; i<bowl.length; i++)
ret += bowl[i] * pref[i];
return ret;
} |
53c64978-99a3-44b7-ac9c-a728c77caed7 | 4 | @Override
public Iterator<EntityInfo> iterator() {
return new Iterator<EntityInfo>() {
Iterator<EntityInfo> use = inner.iterator();
@Override
public boolean hasNext() {
return use.hasNext();
}
@Override
public EntityInfo next() {
EntityInfo nxt = use.next();
if (attributeFs.pathExists(nxt.getFullPath() + ExtendedSupportFs.hiddenSymLinkMarker))
{
String dest = "";
try {
dest = FileSystemUtils.readWholeText(fileSystem, nxt.getFullPath());
} catch (PathNotFoundException e) {
e.printStackTrace();
} catch (AccessDeniedException e) {
e.printStackTrace();
} catch (NotAFileException e) {
e.printStackTrace();
}
SymbolicLinkInfo symlink = new SymbolicLinkInfo(nxt.getFullPath(), dest);
return symlink;
}
return nxt;
}
@Override
public void remove() {
}
};
} |
8689ace9-52f6-4ffa-a042-32f16fcea258 | 9 | private int readHexDigit() throws PDFParseException {
// read until we hit a non-whitespace character or the
// end of the stream
while (this.buf.remaining() > 0) {
int c = this.buf.get();
// see if we found a useful character
if (!PDFFile.isWhiteSpace((char) c)) {
if (c >= '0' && c <= '9') {
c -= '0';
} else if (c >= 'a' && c <= 'f') {
c -= 'a' - 10;
} else if (c >= 'A' && c <= 'F') {
c -= 'A' - 10;
} else if (c == '>') {
c = -1;
} else {
// unknown character
throw new PDFParseException("Bad character " + c +
"in ASCIIHex decode");
}
// return the useful character
return c;
}
}
// end of stream reached
throw new PDFParseException("Short stream in ASCIIHex decode");
} |
ef2a6806-6f41-43ab-bffd-218fa4d74d64 | 1 | public RepairIssue removeIssue(UUID hostUUID) {
RepairIssue issue = null;
if (unsolvedIssues_.containsKey(hostUUID)) {
issue = unsolvedIssues_.remove(hostUUID);
unsolvedPaths_.remove(issue.failedPeer.path);
}
return issue;
} |
6e7176d7-8d94-4439-ba4a-84e8e9282542 | 0 | public ResponseWrapper getResponseWrapper() {
return responseWrapper;
} |
52288751-ca5c-4329-924a-4405be5e52ba | 0 | @Override
public void execute(VirtualMachine vm) {
super.execute(vm);
((DebuggerVirtualMachine) vm).removeSymbols(levelsOfStackToPop);
} |
bc0822e0-e1b8-499e-94bc-a68ff7cae511 | 9 | public EditInfo getEditInfo(int n) {
if (n == 0) {
return new EditInfo(waveform == WF_DC ? "Voltage"
: "Max Voltage", maxVoltage, -20, 20);
}
if (n == 1) {
EditInfo ei = new EditInfo("Waveform", waveform, -1, -1);
ei.choice = new Choice();
ei.choice.add("D/C");
ei.choice.add("A/C");
ei.choice.add("Square Wave");
ei.choice.add("Triangle");
ei.choice.add("Sawtooth");
ei.choice.add("Pulse");
ei.choice.select(waveform);
return ei;
}
if (waveform == WF_DC) {
return null;
}
if (n == 2) {
return new EditInfo("Frequency (Hz)", frequency, 4, 500);
}
if (n == 3) {
return new EditInfo("DC Offset (V)", bias, -20, 20);
}
if (n == 4) {
return new EditInfo("Phase Offset (degrees)", phaseShift * 180 / pi,
-180, 180).setDimensionless();
}
if (n == 5 && waveform == WF_SQUARE) {
return new EditInfo("Duty Cycle", dutyCycle * 100, 0, 100).
setDimensionless();
}
return null;
} |
f2fe0258-631b-485f-9e46-0c8fddd19dd9 | 6 | public UnitType getBestDefenderType() {
UnitType bestDefender = null;
for (UnitType unitType : getSpecification().getUnitTypeList()) {
if (unitType.getDefence() > 0
&& (bestDefender == null
|| bestDefender.getDefence() < unitType.getDefence())
&& !unitType.hasAbility(Ability.NAVAL_UNIT)
&& unitType.isAvailableTo(getOwner())) {
bestDefender = unitType;
}
}
return bestDefender;
} |
283e261b-d1f8-45d6-af43-a8b16fa5723f | 9 | public CheckResultMessage checkSum5(int i, int j) {
int r1 = get(20, 2);
int c1 = get(21, 2);
int tr1 = get(36, 5);
int tc1 = get(37, 5);
BigDecimal sum = new BigDecimal(0);
if (checkVersion(file).equals("2003")) {
for (File f : Main1.files1) {
try {
in = new FileInputStream(f);
hWorkbook = new HSSFWorkbook(in);
sum = sum.add(getValue(r1 + j, c1 + i, 4));
} catch (Exception e) {
}
}
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
if (0 != getValue(tr1 + j, tc1 + i, 9).compareTo(sum)) {
return error("支付机构单个账户表格sheet1-10的数据之和" +(r1 + j)+ "行"
+ (c1 + i) + "列" + "出错");
}
} catch (Exception e) {
}
} else {
for (File f : Main1.files1) {
try {
in = new FileInputStream(f);
xWorkbook = new XSSFWorkbook(in);
sum = sum.add(getValue1(r1 + j, c1 + i, 3));
} catch (Exception e) {
}
}
try {
in = new FileInputStream(file);
xWorkbook = new XSSFWorkbook(in);
if (0 != getValue1(tr1 + j, tc1 + i, 9).compareTo(sum)) {
return error("支付机构单个账户表格sheet1-10的数据之和"+(r1 + j) + "行"
+ (c1 + i) + "列" + "出错");
}
} catch (Exception e) {
}
}
return pass("支付机构单个账户表格sheet1-10的数据之和"+(r1 + j) + "行"
+ (c1 + i) + "列" + "正确");
} |
51db4447-17fc-46b5-9149-8f92aa6e505a | 5 | public void action(Sac[] tabSacs, RoyaumeDuFeu rdf, JFrame page, Dieu deus) {
this.avancer(1);
int k = 0;
int nb = 0;
int val;
if ("Tyr".equals(deus.getNom())) {
int det1 = de.getCouleur();
int det2 = de.getCouleur();
String[] choix1 = {tabSacs[det1].getCouleur(), tabSacs[det2].getCouleur()};
JOptionPane jop1 = new JOptionPane();
int rang1 = JOptionPane.showOptionDialog(page,
"Quelle couleur du dé choisissez vous?",
"Avantage Tyr",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
choix1,
choix1[0]);
if (rang1 == 0) {
val = det1;
} else {
val = det2;
}
} else {
val = de.getValeur();
}
Sac s = tabSacs[val];
int nbGeantDeFeu = rdf.getlGeantDeFeu().size();
while (k < this.getPuissance() && k < nbGeantDeFeu) {
Iterator it = s.getlPion().iterator();
Pion p;
p = (Pion) it.next();
if (p.toString().compareTo("Geant de feu") == 0) {
rdf.getlGeantDeFeu().remove(0);
s.getlPion().add(new GeantDeFeu());
nb++;
}
k++;
}
JOptionPane.showMessageDialog(page, "Surt a retiré " + nb + " géant de feu du Royaume du feu, il les a mis dans le sac " + s.getCouleur().toLowerCase() + ".", "Effet de Surt", JOptionPane.INFORMATION_MESSAGE);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.