method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
3dbf338d-0921-499a-a4eb-b13e05808b1a | 6 | public static boolean isIdentical(Node root1,Node root2)
{
if(root1!=null&& root2!=null)
{
if(root1.data==root2.data)
{
return isIdentical(root1.left, root2.left)&&isIdentical(root1.right, root2.right);
}
else
{
return false;
}
}
else if(root1==null&&root2==null)
{
return true;
... |
30aba8b5-5a3e-4348-a0d7-5ac9673fcd5b | 7 | public AgentSearchView(SingleFrameApplication app) {
super(app);
initComponents();
// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout... |
8420995c-092a-4906-88b8-502791cc80cf | 3 | public void draw() {
if(titleMenu != null) {
titleMenu.draw();
}
if(!gameMenu.isEmpty()) {
for(int x = 0; x<gameMenu.size(); x++)
gameMenu.get(x).draw();
}
} |
26a3f404-d8bb-4318-8b45-ab7952e8eeca | 9 | int insertKeyRehash(byte val, int index, int hash, byte state) {
// compute the double hash
final int length = _set.length;
int probe = 1 + (hash % (length - 2));
final int loopIndex = index;
int firstRemoved = -1;
/**
* Look u... |
cd338662-70c7-4fae-a14a-0c9e956fb681 | 8 | protected final int _itemIndexEquals_(final Object key, final int hash) {
final int index = this._itemIndexCompare_(key, hash);
if (index < 0) return index;
final CompactDataArray data = this._items_;
final Object[] array = data.array();
final int from = data.startIndex();
if (this._itemEquals_(key, hash, a... |
6ae876e5-de67-468f-8d6e-17d10c975894 | 3 | public String getArgs() {
if (blocktext.getText().equals(""))
blocksize.disable();
else {
blocksize.enable();
blocksize.setArgument(blocktext.getText());
}
if (reqtext.getText().equals(""))
reqsize.disable();
else {
reqsize.enable();
reqsize.setArgument(reqtext.getText());
}
if (runtext.... |
8a134f6c-4ff9-4dab-86f1-0f9b0c35b019 | 4 | public List<String> find(String input) {
List<String> result = new ArrayList<String>();
// sub-strings of length greater than max word length in dictionary are guaranteed not
// to be found. So don't produce them as it is very costly.
List<List<Character>> charLists = Combination.combina... |
0f7d3287-d9fa-4ef1-9101-c97c79c70186 | 4 | public synchronized void gridletMove(int gridletId, int userId, int destId, boolean ack)
{
// cancels the Gridlet
ResGridlet rgl = cancel(gridletId, userId);
// if the Gridlet is not found
if (rgl == null)
{
System.out.println(super.resName_ +
... |
a3195752-356a-4385-9f74-322ccb5c2a67 | 3 | public Item getItem(String itemName){
boolean done = false;
int i = 0;
while(!done){
Item current = items.get(i);
if(current.getName().equalsIgnoreCase(itemName)){
return current;
}
i++;
if(i >= items.size()){
... |
9229cb91-1adc-4a28-bc08-4dc482452e12 | 3 | public static char[] readFileToCharArray(String filename)
{
char[] result;
StringBuffer currentSequence = new StringBuffer();
try
{
FileReader fr = new FileReader(filename);
BufferedReader buffreader = new BufferedReader(fr);
int counter=0;
... |
8824eb50-f807-4a85-923d-55a1236a8d2d | 5 | public int lengthOfLongestSubstring(String s) {
int len = s.length();
int [] letters = new int[26];
for (int i = 0;i<26;i++){
letters[i] = -1;
}
int length = 0;
int maxlength = 0;
for (int i=0;i<len;i++){
int num = s.charAt(i)-'a';
... |
2353588e-6da8-4cb9-b4af-2ddd5be2b1f6 | 3 | private void setBoardSize(int rows, int cols) {
PentominosPanel oldPanel = panel;
oldPanel.terminate();
panel = new PentominosPanel(rows,cols,false);
JMenuBar bar = panel.getMenuBar(!runningAsApplet,oldPanel);
bar.add(makeSizeMenu());
setJMenuBar(bar);
setContentPane(panel);
... |
10d5299d-fa58-4fa0-a53d-3625b1e092bd | 5 | public Layer3Decoder(Bitstream stream, Header header, SynthesisFilter filter1, SynthesisFilter filter2,
Decoder player) {
this.stream = stream;
this.header = header;
this.filter1 = filter1;
this.filter2 = filter2;
this.player = player;
channels = (header.mode(... |
817c12c6-90a3-40b2-a5dc-fe4241dc03b7 | 6 | public Waiter(TileMap tm, int startingAction, String s){
super(tm);
moveSpeed = .1;
maxSpeed = .3;
fallSpeed = 0;
maxFallSpeed = 0;
width = 30;
height = 34;
cwidth = 30;
cheight = 34;
health = maxHealth = 1;
damage = 1;
invincible = false;
if(s.equals("right")){
facingRight = tr... |
c851e027-fe33-4322-9fcb-395c930109e8 | 3 | public final synchronized String readWordSaceOnly(){
this.inputType = false;
String word="";
if(!this.testFullLineT) this.enterLine();
if(this.fullLine.equals("")){
word="";
}else
{
w... |
c8cbe407-8ced-4811-9a73-39e915b02d0f | 1 | public void updateSubTypes() {
if (!isVoid())
subExpressions[0].setType(type);
} |
46e9e521-1a73-4a16-b6a1-3a66cf27bbe3 | 3 | public static void main(String[] argv) {
if (argv.length != 1) {
System.out.print("server or client?\n");
return;
}
if (argv[0].equals("s")) {
Server s = new Server();
s.run();
} else if (argv[0].equals("c")) {
Client c = new Client();
c.run();
}
} |
9c3dc002-c143-45d7-82d0-81b706870f13 | 9 | final char[] optimizedCurrentTokenSource3() {
//try to return the same char[] build only once
char[] src = this.source;
int start = this.startPosition;
char c0, c1=src[start+1], c2;
int hash = (((c0=src[start])<< 6) + (c2=src[start+2])) % TableSize;
// int hash = ((c0 << 12) + (c1<< 6) + c2) % TableSize;
char[][... |
5856744c-f6e4-4f6b-b698-71297245e36e | 7 | public String[][] sortBest(String array[][], int member, int direction)
{
// sortLog.log("--------------------------");
int arrayLength = getArrayLength(array);
DataRow list[] = new DataRow[arrayLength];
DataRow dr2;
DataRow dr1;
DataRow parser = new DataRow();
... |
e0ca5631-d861-44d7-b8e0-ec76cddc809b | 1 | public boolean Decrement()
{
//set the status flag of offboarding a passanger
boolean status = false;
//ensure there are passengers on the bus
if ((passengersOnBoard - 1) >= 0)
{
//decrement passenger onboard
passengersOnBoard -= 1;
... |
f618fd5f-cee9-4d7f-9303-9885a4bb3b6d | 3 | public Canvas(final WordlePainter painter) {
setPreferredSize(new Dimension(800, 600));
this.painter = painter;
final MouseAdapter mouse = new MouseAdapter() {
private boolean drag;
private int startx;
private int starty;
private double origX;
private double origY;
... |
986fa621-53ca-4bc8-ba82-958bc9bfcff1 | 1 | @Override
protected boolean removeEldestEntry(Map.Entry<K, BufferedImage> eldest) {
if (super.removeEldestEntry(eldest)) {
eldest.getValue().flush();
return true;
}
return false;
} |
3818783b-f818-44f5-a7ca-707cb3ff3040 | 3 | @Override
public int compareTo(final RawData o) {
int ret;
if (this.getTime() == null) {
ret = 1;
} else if (o == null || o.getTime() == null) {
ret = -1;
} else {
ret = this.getTime().compareTo(o.getTime());
}
return ret;
} |
5c24c1f4-9fe2-44b1-8fd1-4d5c81bba97f | 5 | public void update(){
//Get reference to sprite manager
SpriteManager manager = (SpriteManager)Engine.currentInstance.getManager(Engine.Managers.SPRITEMANAGER);
//Get number of frames that passed
double exactDF = manager.getDeltaFrames();
if(exactDF >= 1){
int dF = 0;
dF = (int) Math.floor(exactDF);... |
6da12ee2-21d2-42b0-b741-885237cef09c | 5 | private static void wrap(String line, int width, String indent,
StringBuilder sb) {
if (line.length() <= width) {
// no wrapping
sb.append(line).append('\n');
return;
}
boolean first = true;
int start = 0;
... |
95e0289d-7bcc-454b-b080-5cd7865e76de | 4 | public FieldInfo findField(String name, String typeSig) {
if ((status & FIELDS) == 0)
loadInfo(FIELDS);
for (int i = 0; i < fields.length; i++)
if (fields[i].getName().equals(name)
&& fields[i].getType().equals(typeSig))
return fields[i];
return null;
} |
026fdf59-d20e-48ef-aeaa-6af9c1d66891 | 5 | @Override
public void execute() {
Vars.status = "HuntingNode";
if (!Vars.butterflai.isOnScreen()) {
Walking.walk(Vars.butterflai);
} else if (Vars.butterflai.validate() && Vars.butterflai.interact("Catch")) {
Timer t = new Timer(1000);
while (t.isRunning() && Players.getLocal().getInteracting() == null)... |
16412c67-1d64-4a20-876f-2b5d1fdd1e2f | 3 | public static int dfs(char[][] grid) {
int count = 0;
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[i].length; j++) {
if ('1' == grid[i][j]) {
count = count + 1;
cdfs(grid, i, j);
}
}
}
return count;
} |
7980de3b-d895-4e9b-82b6-88ba3f0c52ca | 5 | @SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Edge)) {
return false;
}
Edge<V, E> o = (Edge<V, E>) obj;
return sou... |
e29cd0ea-fff9-46db-a9ed-b6ff8182d40e | 0 | @Test
public void testVersionOfJar()
{
Date now = new Date();
Version v = Version.ofJar(org.slf4j.Logger.class);
Assert.assertEquals("1.6.1", v.getVersion());
Assert.assertEquals("slf4j-api", v.getTitle());
Assert.assertTrue(v.getModifiedDate().before(now));
... |
91cc1e75-a5ce-493e-87d6-89212fd81d42 | 5 | public SQLite(Logger log, String prefix, String name, String location) {
super(log,prefix,"[SQLite] ");
this.name = name;
this.location = location;
File folder = new File(this.location);
if (this.name.contains("/") ||
this.name.contains("\\") ||
this.name.endsWith(".db")) {
this.writeError("The dat... |
09c47420-4398-4d85-a1c4-bc27cb8c49e9 | 4 | public void run() {
while (keepGoing) {
if (this.runDFS) {
this.maze.searchPath = this.dfs.search(this.maze.searchPath,
this.maze.size);
}
else if (this.runBFS) {
this.maze.searchPath = this.bfs.search(this.maze.searchP... |
3289b15a-fbfe-487f-93aa-e4f0b37a67c6 | 8 | private void makeSuggestion(Player suggester){
cluedo.board.Room physicalRoom = suggester.getRoom();
if (physicalRoom == null){
// player is not in a room
Dialogs.showMustBeInRoomWarning();
}
Game.Room room = physicalRoom.getName();
MurderHypothesis suggestion = selectSuggestion(room);
if (suggesti... |
2098f9f8-5211-4bda-8ff5-13e028758322 | 5 | public SpaceRegion build(Node node) {
SpaceRegion region = (SpaceRegion) super.build(node);
GroupSector masterSector = new GroupSector(region);
SpatialDivisionBuilder builder;
NodeList nodeLst;
nodeLst = node.getChildNodes();
for (int s = 0; s < nodeLst.getLength(); s++) {
Node fstNode = nodeLst.it... |
0c3ba9be-4533-4fa2-9a25-080dff72f9ef | 8 | protected void writeMethodInfo(PrintWriter out) {
out.println("<pre>");
Method[] methods = interfaceCls.getMethods();
for(int i=0;i<methods.length;i++) {
out.print("public ");
Class returnType = methods[i].getReturnType();
if(returnType.isArray()) {
... |
acee2444-43d7-4bc0-96de-113c3a824aa3 | 9 | private void jButton29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton29ActionPerformed
String serverID = "ALL";
String nymID = "ALL";
try {
if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
serverID = ((... |
14748de9-a20c-44e4-aca1-a7471345f44b | 2 | private Component getTopPanel() {
Container panel = makeTitlePanel();
if (!Desktop.isDesktopSupported()) {
return panel;
}
JLabel icon = new JLabel();
icon.setIcon(
new ImageIcon(
Utils.class.getResource("/com/blazemeter/jmete... |
898f8a9b-23d2-4543-bc3b-30387bc7b6de | 9 | private void drawFractalPolarBruteForce(int image_size) {
double size = fractal.getSize();
double xcenter = fractal.getXCenter();
double ycenter = fractal.getYCenter();
/*double start;
double end = Math.log(size);
int pixel_percent = image_size * image_size / 100;
... |
9dd224f4-2b63-48dc-9c77-cc5ecb4da78e | 9 | public static Object getListener(Object bag, int index)
{
if (index == 0) {
if (bag == null)
return null;
if (!(bag instanceof Object[]))
return bag;
Object[] array = (Object[])bag;
// bag has at least 2 elements if it is array
... |
ef6e3d6b-8fb3-4475-9a72-c968f8c123df | 1 | private void deleteSong() {
try {
int id;
System.out.println("Enter id: ");
id = Keyboard.readInt();
BESong aSong = new BESong(id);
BLLSong ds = new BLLSong();
ds.deleteSong(aSong);
} catch (Exception ex) {
System.ou... |
d4917b11-ba99-4fe3-9429-d17a207f0493 | 8 | public Image idleImages(int i)
{
Image temp = null;
switch(i)
{
case 1:
temp = new ImageIcon("src/images/idle_north.png").getImage();
break;
case 2:
temp = new ImageIcon("src/images/idle_north_east.png").getImage();
break;
case 3... |
39a1124a-b5fd-444a-a38c-a9598bb20a1d | 3 | public static void close(){
try
{
rs.close();
} catch (SQLException e)
{
logger.fatal(e);
e.printStackTrace();
}
try
{
stmt.close();
} catch (SQLException e)
{
logger.fatal(e);
e.printStackTrace();
}
try
{
conn.close();
} catch (SQLException e)
{
logger.f... |
de626f22-ca27-4ba2-8576-add60a7de3af | 1 | public static void saveJMX() {
Save save = new Save();
try {
save.doAction(new ActionEvent(new Object(), ActionEvent.ACTION_PERFORMED, ActionNames.SAVE_ALL_AS));
} catch (IllegalUserActionException iuae) {
BmLog.error("Can not save file," + iuae.getMessage());
}
... |
9af176d5-9a2d-4692-ad0b-bbc8cc991485 | 4 | public static void main(String[] args) {
if (DEBUGGING) {
// Display the command line args.
System.out.println("Starting with args:");
for (int i = 0; i < args.length; i++) {
System.out.println(i + ":" + args[i]);
}
}
try{
/... |
2c4b8ed3-34e1-4acd-a67a-cb8ac156e558 | 3 | public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.err.println(
"Usage: java ReliableUdpClient <destination host> <destination port> <string message>");
System.exit(1);
}
//server name
String serverName = a... |
ec9b42b1-d34a-416e-8427-60b8dfd4f744 | 6 | private Paikka getTokaKohdePaikka(int millainenPari) {
if (millainenPari == 1) {
if (this.ekaKohdePaikka.getMiehenAvecinPaikka() != null);
return this.ekaKohdePaikka.getMiehenAvecinPaikka();
} else if (millainenPari == 2) {
if (this.ekaKohdePaikka.getNaisenAvecinPaikk... |
6ffd030c-659a-4e18-a320-b8a270adb4ff | 3 | public static int binarySearch(int key, int[] list){
int low = 0;
int high = list.length - 1;
int middle = 0;
while(low <= high){
middle = low + (high - low)/2;
if(key < list[middle]) high = middle - 1;
else if(key > list[middle]) low = middle + 1;
else return middle;
}
return low*(-1);
} |
ee891392-454a-4928-bc9d-9f382ad99473 | 2 | static void test(int testval, int target) {
if(testval > target)
result = +1;
else if(testval < target)
result = -1;
else
result = 0; // Match
} |
1a22b0f3-d735-4726-9449-9ed080f223bc | 1 | private void processMoveFromDeck() {
//Can assume did click on the deck.
final Queue<Card> deck = game.getDeck();
if (!deck.isEmpty()) {
activeMove = new CardMove(game);
}
} |
89325bab-ed9a-4a45-819a-6d77f7e120e7 | 6 | @Override
public void setValues(Sprite target, int tweenType, float[] newValues) {
switch (tweenType) {
case POS_XY: target.setPosition(newValues[0], newValues[1]); break;
case CPOS_XY: target.setPosition(newValues[0] - target.getWidth()/2, newValues[1] - target.getHeight()/2); break... |
7eec8a2f-8177-42b4-8306-6ea194f5bc17 | 9 | public static void main(String[] args) {
//Check whether usage needs to be printed or not.
if (args.length != 3 && args.length != 4) {
printInfo();
return;
}
//Set arguments (files, direction, GZIP)
String inarg = args[0];
String dirarg = args[1];
String outarg = args[2];
boolean topng = dirarg.e... |
c7f1fb07-5211-461f-a286-052c084ac4cb | 4 | public static boolean checkIsKilled(Integer i, Integer j) {
Point curPoint = new Point(i, j);
for (Ship ship : ships) {
for (Point point : ship.getPosition()) {
if (point.equals(curPoint)) {
if (ship.isKilled()) {
ships.remove(ship);
myBattleField.remove(ship);
return true;
} el... |
afc2ee68-6e11-4927-8a2d-b957e173607a | 6 | public static void fillPre(int size) {
pre = new String[size + 1];
Arrays.fill(pre, "-1");
String str = "";
int three;
for (int a = 0; a <= 224; a++)
for (int b = a; b <= 224 && (a * a + b * b) <= LIM; b++)
for (int c = b; c <= 224 && (a * a + b * b + c * c) <= LIM; c++) {
three = a * a + b * b + ... |
c843754f-867b-408d-983b-fd0c95d5cbe8 | 0 | @Override
public void setOnLinkFoundListener(OnLinkFoundListener listener)
{
_onLinkFoundListener = listener;
} |
d1097047-f171-439c-a9f9-bc53a482b5b0 | 0 | public static SSLSocketFactory getSsf() {
return ssf;
} |
99003fa3-0f55-461d-a543-748d82105e96 | 8 | @Test
public void testForceFieldStartsTurnedOff() throws InvalidActionException {
game.moveAction(Direction.LEFTUP);
game.endTurnAction();
game.moveAction(Direction.DOWN);
game.endTurnAction();
game.useItemAction(0);
// ForceField is nog niet actief
boolean forceFieldFound = false;
boolean forceF... |
5d5ebcb9-14e8-46a5-a9de-06ef73c7e95a | 7 | protected void update(String mToUpdateTaskDesc, Task userUpdate) {
for (int i = 0; i < mLocalMem.size(); i++) {
if (mToUpdateTaskDesc.equals(mLocalMem.get(i).getDescription())) {
if (userUpdate.getDescription() != null) {
mLocalMem.get(i)
.setDescription(userUpdate.getDescription());
}
if... |
50e4158a-9791-4319-bb84-b18dde9bca95 | 1 | public boolean EliminarArea(Area p){
if (p!=null) {
cx.Eliminar(p);
return true;
}else {
return false;
}
} |
c55943cf-29ad-4d7d-a90c-8120432574eb | 1 | public static void swap(Pair<?> p) { swapHelper(p); } |
512a6126-c235-41c7-a812-00d4ebb05e4c | 1 | public void keyEnterPressed() {
HUD hud = null;
for (int i = (huds.size() - 1); i >= 0; i--) {
hud = huds.get(i);
hud.keyEnterPressed();
}
} |
8fbc5cc2-5118-4b71-b4bd-a6cf33ac6504 | 9 | private static boolean assertLegal(Grid g, Shape s, Point pos, Shape overShape, Point overPos) {
if (g == null) { return false; }
Point[] points = overShape.getCoords();
boolean isOverlap = false;
coords = s.getCoords();
for (Point p : coords) {
if (overPos != null) {
isOverlap = false;
for (... |
d45bf5fd-611b-4188-8b57-b8732d275985 | 1 | public ExceptionTable copy(ConstPool newCp, Map classnames) {
ExceptionTable et = new ExceptionTable(newCp);
ConstPool srcCp = constPool;
int len = size();
for (int i = 0; i < len; ++i) {
ExceptionTableEntry e = (ExceptionTableEntry)entries.get(i);
int type = srcC... |
c6974e34-b7b2-47c0-bb10-83cbcc3e0e58 | 8 | public String statement() {
double totalAmount = 0;
int frequentRenterPoints = 0;
String result = "Rental Record for " + getName() + "\n";
for (Rental each: _rentals) {
double thisAmount = 0;
//determine amounts for each line
switch (each.getMovie().... |
1565c27c-4b79-494c-8ea4-eb1e7d254384 | 5 | public void setBipartiteGraphSpacing(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2, double vertexSpacing,
double groupSpacing)
{
if (numVerticesGroup1 < 0 || numVerticesGroup2 < 0)
{
throw new IllegalArgumentException();
}
mxGraph graph = aGraph.getGraph();
double group1StartY =... |
ceb24b4e-431b-4847-93eb-ea340742e5eb | 1 | @Override
public Response buy(BuyRequest credits) throws IOException {
if(currentUser != null) {
proxyCli.changeCredits(currentUser, credits.getCredits());
return new BuyResponse(currentUser.getCredits());
}
return new MessageResponse("You have to login first to perform this action!");
} |
c8b62301-9e4b-429b-b7b1-2790734b6ab7 | 3 | @After
public void teardown()
{
try{
if(connection!=null && !connection.isClosed())
{
drop.executeUpdate("Drop table Client");
connection.close();
connection = null;
}}
catch(Exception ex)
{
ex.printStackTrace();
}
} |
b301426d-d248-464f-8fdc-2b68798a6ce5 | 0 | public String getPersistenceType() {
return persistenceSettings.getPersistenceType();
} |
748cd344-633a-41b4-be0f-51b2b3168acf | 1 | int getInt() {
try {
String[] students = {"Benjamin", "Joe"};
System.out.println(students[5].toString());
} catch (Exception e) {
System.out.println("ArrayIndexOutOfBounds exception thrown...");
return 10;
} finally {
return 20;
... |
4a5b4835-f0ba-436e-811d-d7f652c8348d | 7 | public boolean isEntityAt (int x, int y)
{
List<Entity> notColliding = new ArrayList<Entity>();
for (Entity entity : entities) {
if (entity instanceof EntityParticle) continue;
if (!entity.isColliding()) notColliding.add(entity);
}
Chunk chunk = chunkhandler.g... |
210b7bca-4c9b-4c3a-b89c-9817c38c3d22 | 7 | private void findIndexUsageForSingle(TablePairActivity tablePair) {
for (Query query : queries) {
List<String> queryRelations = query.getRelations();
Set<QueryFilter> queryFilters = query.getSelections();
String tableA = tablePair.getNameOfTableA();
if (tablePair.isSingle() && queryRelations.contains(ta... |
d0a16957-02c0-4a3b-a0c1-811804796494 | 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://down... |
78206c87-a7cf-463f-b060-4084b7808769 | 4 | @Override
public void setDouble(long i, double value)
{
if (value != 0.0 && value != 1.0) {
throw new IllegalArgumentException("The value has to be 0 or 1.");
}
if (ptr != 0) {
Utilities.UNSAFE.putByte(ptr + i, (byte) value);
} else {
if (isCon... |
57adee47-32f6-4886-8ecc-bf9722dfd7ca | 7 | public String getHtml(WikiContext context) throws ChildContainerException {
try {
if (context.getAction().equals("confirm")) {
startTask();
sendRedirect(context, context.getPath());
return "Unreachable code";
}
boolean showBuff... |
beb0560b-30fc-4725-ad80-67c2b56eb5da | 6 | @Override
public boolean equals(final Object obj) {
if(!(obj instanceof ImmutableMap)) return false;
final ImmutableMap<?, ?> other = (ImmutableMap<?, ?>) obj;
return root.size == other.root.size && root.equals(other.root);
} |
2f4ac597-c1ff-4fb7-9432-eb967dcf7fd8 | 2 | public static String getName(Categorias cat){
String sql="SELECT * FROM categorias WHERE idcategorias = '"+cat.getId()+"' ";
if(!BD.getInstance().sqlSelect(sql)){
return null;
}
if(!BD.getInstance().sqlFetch()){
return null;
}
return BD.ge... |
34134b63-6aeb-428a-a24f-0b98403bd46b | 1 | @Override
public void prepare(String query) throws SQLException {
checkCon();
// check if we need to prepare again and reset data from old statements
if(this.last_prepare.equals(query)) return;
this.values.clear();
this.stmt = this.con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
this.las... |
d1f802f0-65a6-4b5b-8205-a0cfb7a78100 | 8 | public void update()
{
// This section ensures that we have the right children, without constantly removing/adding them,
// which causes user-unfriendly behaviors (unselection etc)
{
Set<Component> text_area_components = new HashSet<Component>();
if(text_area == null)// FIXME: Why does this happen? I... |
50ece4df-2bf3-409a-81eb-2196cea66b24 | 4 | @Override
public void update() {
super.update();
//Get current time and set elapsed time
double currentTime = System.currentTimeMillis();
elapsedTime += (currentTime - previousTime) / 1000.0;
previousTime = currentTime;
//Check if bursting
if(bursting){
//Bursting, check if it's time to shoot
i... |
6578e9f4-7529-40a6-9918-39abf804fa08 | 1 | public JSONArray optJSONArray(String key) {
Object o = this.opt(key);
return o instanceof JSONArray ? (JSONArray) o : null;
} |
0775bd8b-655a-40aa-801b-a883d9b0c4f1 | 6 | public static String findLongestCommonSubstring(String s1, String s2) {
int [][] lcs = new int[s1.length()+1][s2.length()+1];
int max = 0;
String result = null;
//setting the base case, matching anything with empty string will result into 0 length common substring
for( int i=0; ... |
55bb01e2-0dd1-4fb0-9161-e066d5b6e210 | 4 | public int jump(int[] A) {
int[] minJump = new int[A.length];
Arrays.fill(minJump, Integer.MAX_VALUE);
minJump[0] = 0;
int currentMax = 0;
for (int i = 0; i < A.length; i++) {
for (int j = currentMax + 1; j <= i + A[i]; j++) {
if (j > A.length - 1)
... |
87b81ce9-2ca8-402b-9e2f-4dbfdc8b90de | 0 | @Override
public String getName() {
return NAME;
} |
aa1a463d-ccb5-46ef-8e5d-a70092b4f33c | 5 | public void save(MenuItem selectedItem) {
if (selectedItem.getText().equalsIgnoreCase("Save")) {
//check if logged in...
Website2EbookmakerApplication app = ((Website2EbookmakerApplication)MainLayout.this.getApplication());
if (((Account) app.getUser()).isGuest()) {
app.login();
MainLa... |
8c53acaa-fcdb-481d-9273-31d4df132cbf | 7 | @Override
public String toString() {
String strColor = (this.color == COLOR_WHITE ? "white" : "black");
String strType = "unknown";
switch (this.type) {
case TYPE_BISHOP: strType = "B"; break;
case TYPE_KING: strType = "K"; break;
case TYPE_KNIGHT: ... |
52b9c9ae-1b23-43d2-a914-9ede010bb782 | 1 | public List<Game> getAllGames() {
List<Game> games = null;
try {
games = (List<Game>) deserializeXMLToObject("Games.xml");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return games;
} |
78959ad4-474c-47a8-91b2-8f2966d66f98 | 3 | private void prepareDatabase(String driver, String url, String username, String password, String isolation) {
//Setup the data source
DataSourceConfig ds = new DataSourceConfig();
ds.setDriver(driver);
ds.setUrl(replaceDatabaseString(url));
ds.setUsername(username);
... |
99142e51-8c77-493d-bb3b-9b81d54f5fd1 | 2 | @Override
public boolean update(Object item) {
conn = new SQLconnect().getConnection();
String sqlcommand = "UPDATE `eventnodes` SET `description`='%s' WHERE `owner`='%s';";
if(item instanceof Eventnode)
{
Eventnode newitem = new Eventnode();
newitem = (Eventnode)item;
try {
String sql... |
a1b28e99-b6a5-478d-9d7e-3371a147deb0 | 8 | public static String[][] QueryAccess(String Query){
Connection conn = null;
Statement sqlStatement = null;
int ColCount = 0;
String DBRValue = "";
String[][] RowCol = null;
try{
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=myDB.mdb;";
conn = DriverMa... |
0aa2fd66-3109-43e8-a6fa-e495d65d1d7b | 1 | private LinkedHashMap<Integer, Persona> deTablaAMapPersonas() {
LinkedHashMap<Integer, Persona> personas = new LinkedHashMap<>();
Persona p;
for (int i = 0; i < jTable.getRowCount(); i++) {
p = new Persona(
Integer.parseInt(jTable.getModel().getValueAt(i, Constant... |
a3c58e5f-5203-4c98-906b-ad3dfe345f89 | 2 | public static StopPointTypeEnumeration fromValue(String v) {
for (StopPointTypeEnumeration c: StopPointTypeEnumeration.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
} |
124e5135-d499-4938-a749-c7d2523d4447 | 0 | public int getMsgLength() {
return MsgLength;
} |
2369ae15-f7c7-44ee-9ad9-99a927ab519a | 3 | @Override
public String toString() {
return String.format("Top Three Downloads:\n1. %s %s\n2. %s %s\n3. %s %s",file1,file1.equals("") ? "":downloads1,file2,file2.equals("") ? "":downloads2,file3,file3.equals("") ? "":downloads3);
} |
cc5e09f0-0f09-4feb-bea2-e6682425f9ca | 7 | private int getReduced2AfterReduce(ItemPair p, NonTerminal n) {
IdShareableHashSet<NonTerminal> reduced2 = getReduced2(p);
if (n.usedInRejectFilter || n.rejectedLiterals != null) {
IdShareableHashSet<NonTerminal> newReduced = new IdShareableHashSet<NonTerminal>();
if (reduced2 != null) {
newReduced.addAll... |
8b2cec25-0c1a-43a6-8820-994b6b2b2304 | 2 | private void rateLimit() {
try {
int delay = UPDATE_RATE - (int) (System.currentTimeMillis() - lastUpdate);
if (delay > 0)
Thread.sleep(delay);
lastUpdate = System.currentTimeMillis();
} catch (InterruptedException e) {
// someone interru... |
21df5ae8-41e8-403c-aceb-90743155d9ef | 9 | public String formatResults(String fileName) throws IOException {
BufferedReader reader = new BufferedReader (new FileReader(fileName));
String line;
String result = "";
float userTime = 0;
float systemTime = 0;
int bddNodes = 0;
String formatted = "";
try{
while((line = reader.readLine())!=null) {
... |
967e5ab3-ed08-4fdc-a909-ed5302ba5f3e | 3 | public void checkCollision() {
int posx = schlange.get(0).getPosx();
int posy = schlange.get(0).getPosy();
int diff = 0;
for (int i = 2; i < schlange.size(); i++) {
diff += Math.abs(posx - schlange.get(i).getPosx());
diff += Math.abs(posy - schlange.get(i).getPosy());
if (diff < 9) {
setStart(false... |
b80c2029-1fb2-47d4-b452-8bef98e1bfb6 | 8 | public Customize(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(350, 10);
this.setResizable(false);
this.setLocation(500, 300);
this.setVisible(true);
CustomKeys customKeys = new CustomKeys();
this.addKeyListener(customKeys);
while(customKeys.keysPressed < 7){
switch(customKeys.... |
404c5a95-4b48-44e8-bfed-e71fa8a0c175 | 9 | protected void flushSpi() throws BackingStoreException
{
final File file = FilePreferencesFactory.getPreferencesFile();
synchronized (file) {
Properties p = new Properties();
try {
StringBuilder sb = new StringBuilder();
getPath(sb);
String path = sb.toString();
if (file.exists()) {
p.l... |
d304eff7-472a-4cdf-b98a-4af8ce126926 | 5 | public void actionPerformed(ActionEvent actionEvent){
String actionCommand = actionEvent.getActionCommand();
if(actionCommand.equals("New Class")) {
//if new class button selected then pass to
//diagram panel to complete
this.diagramPanel.addClass();
} else if(actionCommand.equals("Add Link")){
//i... |
88e080e8-86b7-4533-843a-ab8c2599235d | 9 | public void testIsEmpty(PrintWriter oo) {
oo.print("testing isEmpty\n"+
"");
if ( ! ((getScruSet(1)).isEmpty())) {
throw new AboraAssertionException("failed isEmpty test");
}
if ( ! ( ! (getScruSet(2)).isEmpty())) {
throw new AboraAssertionException("failed isEmpty test");
}
if ( ! ( ! (getScruSet(3)).isEmpty... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.