method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
03d4b8ad-0f8c-4624-a13b-26de9b57d029
5
public String toString(){ String res = new String(); if(msg != null) res += msg; if(codErr != null) res += !res.isEmpty() ? " - " + codErr : codErr; if(sourceException != null) res += !res.isEmpty() ? "\n" + sourceException : sourceException; return res; }
bbe488c7-372e-43a6-873a-e9b1c5de9e04
8
public ArrayList<File> indexSearch(String searchPath, String searchKey) { ArrayList<File> matches = new ArrayList<File>(); for(File searchSubject : indexFiles(searchPath)) { if(searchSubject.isDirectory()) { for(File searchSubjectSub : indexSearch(searchSubject.getAbsolutePath(), searchKey)) ...
4126ac6e-5da5-4d69-990b-c5a7b6dba627
5
private void playlistEditMenu() { System.out.println(" Edit Menu "); System.out.println("1. |Create a playlist |"); System.out.println("2. |Add song to a playlist |"); System.out.println("3. |Delete a playlist |"); System.out...
0e4d8c6b-5dbd-4222-959f-9b74424910b7
1
public CtClass getType() throws NotFoundException { int type = etable.catchType(index); if (type == 0) return null; else { ConstPool cp = getConstPool(); String name = cp.getClassInfo(type); return thisClass.getClassPool().getCtClass(name); ...
ddef6420-38a3-4592-a580-bae6e594988d
7
public void draw(Graphics2D g, Player player) { int Px = player.getScreenXpos()/32; //get row number int Py = (player.getScreenYpos()/32); int arroundX = 16; int arroundY = 10; int someX = Px-arroundX; int someXMax = Px+arroundX; int someY = Py-arroundY; int someYMax = Py+arroundY; for(int row ...
71fa30db-0382-4eb1-941b-cb008f3c47f3
1
@Override public Object promptForAnswer() { HashMap<Integer, Integer> userAnswer = new HashMap<Integer, Integer>(); for (int i=1; i<=col1Choices.size(); i++){ int choice = InputHandler.getInt("Which item in column 2 matches item "+i+" from column 1?"); userAnswer.put(i, choice); } return userAnswer; }
5aa94b30-44b0-49d1-bcc3-0294dd3dd2fc
9
public String nextToken() throws JSONException { char c; char q; StringBuffer sb = new StringBuffer(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); ...
3735d3c2-4b82-48ed-829b-36697c97528b
2
public static SignalAspect fromOrdinal(int ordinal) { if (ordinal < 0 || ordinal >= VALUES.length) return SignalAspect.RED; return VALUES[ordinal]; }
998382cd-29e5-4801-8b1a-0998d4a4d8f4
6
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Player player = (Player) table.getValueAt(row, PlayersTable.PLAYER_COLUMN); NationType nationType = ((Nation) table.getValueAt(row, PlayersTable.NATION_COL...
0bc75e48-cdb2-4f03-8ca7-54cdfe94437a
1
public void add(UnitsValue<?> other) { mValue += mUnits.convert(other.mUnits, other.mValue); }
0fb4adfe-04f7-42eb-9cf4-4f5f463c26be
7
*/ public boolean processAtSampling(final String line) { if (line == null) { return false; } final Matcher matcherBegin = this.patternBegin.matcher(line); final Matcher matcherEnd = this.patternEnd.matcher(line); final Matcher matcherCri...
e5936540-aee9-4948-b94c-77800f95ec53
3
public void randTestQual(int numTests, int lenMask, long seed) { Random rand = new Random(seed); for( int t = 0; t < numTests; t++ ) { String seq = "", qual = ""; int len = (rand.nextInt() & lenMask) + 10; // Randomly select sequence length seq = randSeq(len, rand); // Create a random sequence qual = r...
38b4ca38-32cb-448a-928e-543694337db7
5
@Override public void setPosition( float x, float y, float z ) { super.setPosition( x, y, z ); // Make sure OpenAL information has been created if( sourcePosition == null ) resetALInformation(); else positionChanged(); // put the ...
37e22ffa-cb94-4604-afbd-9c29f5206c29
4
public void remove(T data) throws Exception { Node<T> currNode; Node<T> prevNode; if (head == null) { throw new ListEmptyException(); } else { // find the node with the data in it // adjust the links so the Node is removed from the chain of Nodes currNode = head; prevNode = head; while (currNo...
254a9f6c-8bc6-4a5b-9b33-0fda39a819a0
0
public void Init(ContentManager manager) { initBlocks(manager.getBlockManager()); initPackets(manager.getPacketManager()); }
bd0263d2-b318-4490-9215-68f32d829df4
0
public void actionPerformed(ActionEvent event) { frame.close(); }
f5232ec3-6c7b-490e-8e51-1e6266bdd0ef
8
private final void remove(int[] cursorArray) { if (cursorArray[1] < cursorArray[2]) { if (this.head > this.tail) { copy(); } final int length = length(); System.arraycopy(this.content[this.cIdx], this.head, this.content[this.cIdxNext], StringBuilder.PATTERN_SIZE, cursorArray[1]); System.a...
354db7d8-4fe7-4239-85a6-6bad7a16d1d2
6
@EventHandler public void PlayerBlindness(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getPlayerConfig().getDouble("Player.Blind...
99dd6fcb-8c17-4418-ae1c-9fd845d4142f
4
public boolean checkRow(int row) { int i = 0, j = 0, count = 0; for(i = 1; i < 10; i++) { count = 0; for(j = 0; j < 9; j++) { if(i == Integer.parseInt(entries[row][j].getText()) ) { count++; } if( count >= 2) { System.out.println("checkRow() returned false at i: " + row + ...
d5066c3a-ec45-45cd-ae87-9ef69b503cba
0
@Override public String getVersion() { return("*"); }
975008ad-b503-49cb-adf5-b8bbad0e2964
4
private synchronized void dequeue(PacketScheduler sched) { Packet np = sched.deque(); // process ping() packet if (np instanceof InfoPacket) { ((InfoPacket) np).addExitTime( GridSim.clock() ); } if (super.reportWriter_ != null) { super.write("dequeui...
19a4e763-f075-415f-8f18-2282db551d9d
2
protected void touchedBy(Entity entity) { if (entity instanceof Player && pushTime == 0) { pushDir = ((Player) entity).dir; pushTime = 10; } }
a3dce455-2d40-4684-ba3e-25d19c3115ba
5
public String readPidFromFile(String targetDirectory) throws IOException { // PID to return String pid = ""; // Buffered Reader BufferedReader br = null; File pidFile = new File(targetDirectory + PID_FILE_NAME); if (pidFile.exists()) { try { // Setup buffered reader br = new BufferedReader(...
b534f934-2d39-4afa-8c3a-7b8cbd097f17
7
private static void Optimize(DiffData data) { int startPos, endPos; startPos = 0; while (startPos < data.Length) { while ((startPos < data.Length) && (data.modified[startPos] == false)) startPos++; endPos = startPos; while ((endPos < data.Length) && (data.modified[en...
5617dd60-08b5-4a53-9464-9bff3882bc29
7
public void generateUpdatedEntries() { _modifiedEntries.clear(); HashSet<String> newEntries = new HashSet<String>(); for (int i = 0; i < 5; i++) { OrderEntry orderEntry = null; int action = _random.nextInt(100); if (_orderEntries.size() == 0 || ...
3316e48a-5846-4b13-b86a-f5bd6bceb56f
7
protected void updatePeProvisioning() { //Log.printLine("dans updatePeProvisioning"); getPeMap().clear(); for (Pe pe : getPeList()) { pe.getPeProvisioner().deallocateMipsForAllVms(); } Iterator<Pe> peIterator = getPeList().iterator(); Pe pe = peIterator.next(); PeProvisioner peProvisione...
b48b8089-e45f-4fd4-af00-90dee33ddc47
2
public static String checkLevels(double level) { String message = ""; if (level < 0.0) { message = " below acceptable range."; } if (level > 1.0) { message = " above acceptable range."; } return message; }
6e328cfc-e92d-4c19-b3db-3faf58950139
9
public static void main(String[] args) { try { FitnessCalc1 FitnessFunc; String testfile = "C:\\Users\\Vincent\\Documents\\GitHub\\Exercises\\testFiles\\A"; /*Initialisation*/ FitnessFunc = new DCS(); Algorithm.setMaximization(true); Algor...
aa22b4f3-1f19-4849-914d-508a4fa2438e
2
public OrgaEinheit getOrgaEinheitvonBezeichnung(String bezeichnung){ OrgaEinheit rueckgabe = null; try { ResultSet resultSet = db.executeQueryStatement("SELECT * FROM OrgaEinheiten WHERE OrgaEinheitBez = '" + bezeichnung + "'"); if(resultSet.next()) rueckgabe = new OrgaEinheit(resultSet, db, this); re...
6f7e61ec-30a7-4a97-a77f-53952574d7cf
8
void fill( Point a, Point b, Point c, Point a0, Point b0, Point c0 ) { int x0 = (int)Math.floor( Util.minX(a, b, c) ), x1 = (int)Math.ceil( Util.maxX(a, b, c) ); int y0 = (int)Math.floor( Util.minY(a, b, c) ), y1 = (int)Math.ceil( Util.maxY(a, b, c) ); x0 = Math.max(x0, 0); x1 = Math.min(x1, width - 1 ); y0 = ...
02e1fb7f-5a5b-43a4-97f8-66c54f4ca7d4
8
protected OgexTrack toTrack( DataStructure ds, Map<BaseStructure, Object> index ) { OgexTrack result = new OgexTrack(); BaseStructure target = ds.getProperty("target"); Object resolved = index.get(target); if( resolved == null ) { // Need to figure out what it is and create...
eff8b1cd-dcdd-47c4-b65e-91e3ce6c6954
5
private static String xmlTrim(String text) { int start = -1, end = text.length(); while (start < text.length() && isWhitespace(text.charAt(++start))); while (end > -1 && isWhitespace(text.charAt(--end))); if (end != -1) { return text.substring(st...
74d18914-d2dc-40bd-98d0-75bb4aa9709f
6
public void handleInput() { if (Keys.isPressed(Keys.ESCAPE)) gsm.setPaused(true); if (player.getHealth() == 0) return; player.setUp(Keys.keyState[Keys.UP]); player.setDown(Keys.keyState[Keys.DOWN]); player.setLeft(Keys.keyState[Keys.LEFT] || Keys.keyState[Keys.A]); player.setRight(Keys.keyState[Keys.R...
d8401e37-5d71-4687-8f2a-11da13184dca
6
public ArrayList<Integer> readGold(ID tid) { ArrayList<Integer> gtags = null; BufferedReader br = null; String line; try { gtags = new ArrayList<Integer>(); br = new BufferedReader(new FileReader(gold)); while ((line = br.readLine()) != null) { ...
a4d30ce7-79bf-4e0b-9460-d67ebff6ce65
7
public boolean nodesWithSum(int sum, treeNode root) { int[] newArray = new int[this.nodeCount]; addToArray(this.root, newArray, 0); int indexClosetLarger = newArray.length; int lowIndex = 0; int matchIndex = -1; int matchCount = 0; // find the closet number larger than sum for (int i = 0; i < newArray....
4d1dc311-85f2-44b8-92ff-4d2f72543ba9
6
@Override public T build(Map<Class<?>, ClassBuilder<?>> how) { Constructor<?>[] constructors = underConstruction.getConstructors(); Constructor<?> constructorElegido = this.elegirConstructor(constructors); if(constructorElegido != null){ try { return (T)constructorElegido.newInstance(this.getObjects...
f2d2005a-b44d-48f6-bcf0-09dde7f4ec9b
4
public void Draw(Graphics2D g2d, Point mousePosition) { //draws according to Framework canvas size //g2d.drawImage(backgroundImg, 0, 0, Framework.frameWidth, Framework.frameHeight, null); //draw moving bg??????? movingBg.Draw(g2d); // Draws the course objects for (int ...
5d95798d-71b7-473c-a46c-2e541d683da9
6
public static Cons translateLoomPartitions(Stella_Object partitions, boolean exhaustiveP, Symbol parentconcept) { { Cons axioms = Stella.NIL; Cons partitionList = Stella.NIL; if (!Stella_Object.consP(partitions)) { partitions = Cons.consList(Cons.cons(partitions, Stella.NIL)); } if ...
0dd5ec93-82a1-47a1-bd01-3bb46be63b31
7
@EventHandler public void WitherInvisibility(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Wither.In...
7e34fa8e-44b7-470d-b834-b2db1661c970
3
private void makeRGBTexture(GL2 gl, BufferedImage img, int target) { /* Setup a BufferedImage suitable for OpenGL */ WritableRaster raster = Raster.createInterleavedRaster (DataBuffer.TYPE_BYTE, img.getWidth(), img.getHeight(), 4, null); ...
ff975395-acfb-4b34-a1ad-9cc05d03e726
3
private synchronized void processInputs() { int code; try { // Careful: the read*() methods are blocking! code = hmi.dataIn.readInt(); Command command = Command.values()[code]; if (command == Command.IN_SET_MODE) { int imode = hmi.dataIn.readInt(); hmi.mode = Mode.values()[imode]; } else if...
d6a39e03-788b-4e03-9ce9-8affb140abd7
8
@Override public void storeComment(Comment comment) { ResultSet rs = null; int ID = comment.getID(); if (ID > 0) { // update editComment(comment); } else { // insert try { // this.iComment = connection.prepareStatement("INSERT INTO comment (aut...
3234b061-1700-468f-8413-d5ad030018e5
4
private Comparator<? super TSource> createComparatorChain() { final List<Comparator<TSource>> comparators = new LinkedList<Comparator<TSource>>(); SortableList<TSource> s = this; do { comparators.add(0, s.comparator); } while ((s = s.parent) != null); return new Comparator<TSource>() { @Override p...
dbf1be33-9221-4872-a90a-dcbf7be00921
4
private MouseMotionListener mouseMotionListener(){ return new MouseMotionAdapter() { @Override public void mouseDragged( MouseEvent e ) { if( !moving ){ if( mousePressedPoint != null ){ initMove( mousePressedPoint.x, mousePressedPoint.y ); } } if( moving ){ for( MoveableCapabili...
c3ae0563-a6bd-4698-bea2-08a76dee86bf
0
@Override public void restoreCurrentToDefault() { copyHashMap(def,cur); }
91950226-22ac-4ef5-8461-6375899af548
0
public String expression(String expression){ this.expression = expression; return this.expression; }
d2f3f12a-2a40-43a5-8457-1760fcbe1132
7
@Override protected void setup(Context context) { this.conf = context.getConfiguration(); // get cube identifier from hadoop conf try { initCubeIdentifierFromHadoopConf(); } catch (CubeIdentifierNotSetException e) { e.printStackTrace(); // TODO ex...
01f89635-aa60-4a5b-9186-5a0ce4d3e1d0
6
public boolean isVertexInArea(Point p1, Point p2) { double[] posX = { p1.getX(), p2.getX() }; double[] posY = { p1.getY(), p2.getY() }; if (posX[0] > posX[1]) { swapCoords(posX); } if (posY[0] > posY[1]) { swapCoords(posY); } if (getCenterX() >= posX[0] && getCenterX() <= posX[1] && getCenterY()...
ac2aca0b-6cc2-4e91-97d5-4fc9541c8ad5
0
@Override public void finishOutline () {}
1d21e649-f208-4ec5-ba12-bf48b46e373c
3
public PlantManager(World world, Object3D ground, float range) { plants=new Plant[MAX_PLANTS]; positions=new SimpleVector[MAX_PLANTS]; for (int i=0; i<MAX_PLANTS; i++) { Plant plant=new Plant(); plants[i]=plant; boolean ok=false; do { float xpos=(float)(...
c265e403-c7a8-4dae-9701-860a022770a3
4
public void kick(String message, Object... args) { if (left) return; PacketKick kick = new PacketKick(this); kick.message = message; kick.args = args; if(properties.containsKey("translation")) { Translation t = (Translation)properties.get("translation"); System.out.println(t.translate("client.kicked...
8cd0db0f-4d9f-44df-83f2-38444acc4c2c
4
@Override public void parse(CommandInvocation invocation, List<ParsedParameter> params, List<Parameter> suggestions) { String token = invocation.currentToken(); for (String name : getNames()) { if (name.equalsIgnoreCase(token)) { invocation.consume...
298d39a9-48d3-4429-b461-bec507f2c62f
3
@Override protected String makeString(String t, boolean structured) { String n = ""; //new line String tt = ""; //tabulators //create new stuff, if structured if(structured){ n = "\n"; tt = t+"\t"; } //temp storage StringBuilder arrsb = new StringBuilder(); //trick to h...
7c30d005-5de1-4bb0-aa8c-07a47b334adc
4
@Override public void run() { while (true) { Point p; try { p = toLoad.take(); }catch (InterruptedException e) { e.printStackTrace(); continue; } try { Main.getLoadedWorld().addChunk(load(p)); }catch (NullPointerException e) { try { Thread.sleep(10); } catch (Inte...
9687a6ac-879f-459d-a115-c3e98841450c
0
public static void print(Object s) { System.out.print(s); }
58643004-663c-4583-8993-90c6db4b0b9a
3
@Override public String process(String content) throws ProcessorException { // TODO Auto-generated method stub pipeline = new SimpleAuthenticationPipeline(); context = new AuthenticateContext(); pipeline.setBasic(new LoginEntryValve()); pipeline.addValve(new FlushValve()); pipeline.addValve(new EncodeValve...
e09f4a3f-a7ca-4c34-ba5f-a52401704d34
2
public void bind() { SocketAddress address; if (ip.isEmpty()) { address = new InetSocketAddress(this.port); } else { address = new InetSocketAddress(this.ip, this.port); } ChannelFuture future = this.bootstrap.bind(address); Channel channel = futu...
60cbf132-6aed-4f6c-9067-9ed0626f4cf4
0
@SuppressWarnings("deprecation") public void stop(){ downloadThread.stop(); }
3adf4a0a-3d45-45fa-a9b6-33fa00b5081d
1
public void addVertex(UndirectedNode vertex) { if (!this.vertices.contains(vertex)) { this.vertices.add(vertex); } }
67e48e11-0598-4147-9039-e10251bc39e9
3
public void writeWsFrameLength(byte type, int length) throws IOException { writeRawByte(type); // Encode length. int b1 = length >>> 28 & 0x7F; int b2 = length >>> 14 & 0x7F; int b3 = length >>> 7 & 0x7F; int b4 = length & 0x7F; if (b1 == 0) { if (b2 == 0) { if (b3 == 0) { writeRawByte(b4); ...
9749724d-1c6d-4f9d-8c70-8ae2bba4af3f
2
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = ConfigurationManager.getProperty("path.page.countries"); String prevPage = (String) request.getSessionAttribute(JSP_PAGE); resaveParamsShowCountry(request); formCountryList(re...
20d42295-a95a-4410-8b64-63fcbe5378c7
5
@Override public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: System.out.println("Stop JUMP"); break; case KeyEvent.VK_DOWN: currentSprite = anim.getImage(); robot.setDucking(false); break; case KeyEvent.VK_LEFT: robot.setMovingLeft(false); robot.stop(); ...
81828e19-24eb-4730-901e-ad2558b93fb7
2
public int getSize() { return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1; }
a4849cae-f97c-499e-9683-c36d6b4c4cd2
4
public WorldInfo loadWorldInfo() { File var1 = new File(this.saveDirectory, "level.dat"); NBTTagCompound var2; NBTTagCompound var3; if(var1.exists()) { try { var2 = CompressedStreamTools.loadGzippedCompoundFromOutputStream(new FileInputStream(var1)); var3 = var2....
3fcdfe88-2c54-4ae0-8774-5ed9ba533033
8
public Player play() throws GameEndedUnexpectedlyException { Player turn = null; WinResult gameState = WinResult.None; //The game loop. Halts when the game has ended while(gameState == WinResult.None) { //Determine whose turn it is if (turn == player1) { turn = player2; } else { t...
7f83ecf1-7bb0-4bcf-8e10-24f1a4d0f365
8
public static void main(String[] args) throws IOException { for (int i = 2; i < 1000000; i++) if (!primos[i]) for (int j = i + i; j < 1000000; j += i) primos[j] = true; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while(true){ int n = Integer.parseInt(in.readLine().tr...
6cba5efd-b2e0-40e7-99d6-534cebe50869
4
@Override public boolean grown() { final FarmingDefinition definition = definition(); if (definition.containsAction("Empty") || definition.containsAction("Take-tomato")) { return true; } final int bits = bits(); return bits == NORMAL_STAGE[2] || bits == SUPER_STAGE[2] || bits == TOMATO_STAGE[2]; }
1f60bf86-cf83-46bf-a5bf-fbb8061b1a58
3
public cancelService(int route) { database.openBusDatabase(); Calendar cal = Calendar.getInstance(); route_id = route; timing_point += cal.get(Calendar.HOUR_OF_DAY) * 60; timing_point += cal.get(Calendar.MINUTE); startDate = (Calendar)cal.clone(); if(startDate.get(Calendar.DAY_OF_WEEK) > ...
749e93ae-cbfe-474a-9ff7-cb092a39c998
7
public void mouseWheelMoved(MouseWheelEvent e) { MapView mapView = (MapView) e.getSource(); ControllerAdapter mController = (ControllerAdapter) mapView.getModel() .getModeController(); if (mController.isBlocked()) { return; // block the scroll during edit (PN) ...
a35aecf9-f258-4348-ac03-f7c12a21ec68
2
private static boolean checkElementDiscovered(String element) { for (int x = 0; x <= elementsDiscovered.length -1; x++) { //goes through the elementsDiscovered int elementInt = elementNumber(element); //and checks if the int of the element passed if (elementInt == elementsDiscovered[x]){ //through matches any i...
cd3e5df3-1c96-4864-a8ce-df7a2a776508
3
@Test public void test_solvable_matrix_size_3_solve() throws ImpossibleSolutionException,UnsquaredMatrixException, ElementOutOfRangeException{ int height=3; int width=3; float[][] matrix; float[] resultVector; float[][] knownMatrix = new f...
e23109ed-f45b-461b-832e-83da4ec83e42
6
public String getLyricsSnippet(String artistName,String songName){ if (artistName.equals(null) || artistName.equals("") || songName.equals(null) || songName.equals("")) return null; String url = buildUrl(artistName,songName); try { Document document = reader.read(url); // XMLUtil.writeToFile(document, art...
82699e84-bff1-4edc-af52-dc879e1712a1
2
public GedcomObjectFactory findFactoryForTag(String tag) { if (tag.equalsIgnoreCase("DATE")) return dateFactory; else if (tag.equalsIgnoreCase("PLAC")) return placeFactory; else return null; }
1d5aae56-7368-449a-8518-6e9ff9919ad2
9
@EventHandler public void onPlayerDeathEvent(PlayerDeathEvent event) { Player player = (Player) event.getEntity(); if (!player.hasPermission("trophyheads.drop")) { return; } if (randomGenerator.nextInt(100) >= DROP_CHANCES.get(EntityType.PLAYER.toString())) { ...
29810106-f9ad-4da4-aaa7-72d458b229ed
5
protected void decodeAttribute(mxCodec dec, Node attr, Object obj) { String name = attr.getNodeName(); if (!name.equalsIgnoreCase("as") && !name.equalsIgnoreCase("id")) { Object value = attr.getNodeValue(); String fieldname = getFieldName(name); if (isReference(obj, fieldname, value, false)) { ...
7846a1ba-192a-4b44-b0a8-6ee4a206593f
6
public void dequeueSound( String filename ) { if( !toStream ) { errorMessage( "Method 'dequeueSound' may only be used for " + "streaming and MIDI sources." ); return; } if( filename == null || filename.equals( "" ) ) { ...
21aa1558-34e4-4360-9b7b-79973a8c926a
4
private void closeDB(){ try { if(rs!=null){ rs.close(); } if(ps!=null){ ps.close(); } if(conn!=null){ conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
a7da799d-7044-4073-8acc-0d5939278316
2
private static ResCache makeglobal() { ResCache ret; if ((ret = JnlpCache.create()) != null) return (ret); if ((ret = FileCache.foruser()) != null) return (ret); return (null); }
8797e0be-f79e-4571-b033-954b29acfb4e
2
public static void loadAllAchievements() { String statement = new String("SELECT * FROM " + DBTable + " WHERE type = ?"); PreparedStatement stmt; try { stmt = DBConnection.con.prepareStatement(statement); stmt.setInt(1, HIGHSCORE_TYPE); ResultSet rs = stmt.executeQuery(); while (rs.next()) { HighS...
1befae6b-6cfa-4a42-b30a-2046faecf6e6
2
public ArrayList<Fish> reproduceWithFish(Fish f) { Random generator = new Random(); ArrayList<Fish> babies = new ArrayList<Fish>(); double num = generator.nextDouble(); if (num <= .01) { int num1 = generator.nextInt(2); for (int x = 0; x <= num1; x++) { ...
7923af32-e7d6-4f98-a7ce-8ccfe1d58f31
1
@Test public void testGetSquareContent() { board.removeAllPawns(); Pawn pawn1 = new Pawn('a', 2, 2, board); board.addPawn(pawn1); if (board.getSquareContent(2, 2) != null) { assertEquals('a', board.getSquareContent(2, 2).getLetter()); } else { fail(); ...
a7c0e7d5-fcc8-4244-9ff2-1d2b255fdd77
7
public void input() { System.out.println("Available choices are score, flag, reveal, board, save, help, and exit"); String inputString = input.next().trim().toLowerCase(); if (inputString.equals("score")) { score(); } else if (inputString.equals("flag")) { System.out.println("Where to flag?\nplease i...
e8279fca-cac9-487a-9f35-f2ff0ac34b96
7
private static int findMatch(String s, String p) { if (s == null || p == null) return -1; int m = s.length(); int n = p.length(); if (m < n) return -1; for (int i = 0; i <= (m - n); i++) { // (M - N) steps int j = 0; while(j < n && s.charAt(i + j) == p.charAt(j)) { // at most N steps j++; ...
806ec4f6-1a4e-4d5b-90c3-be1605ffde4a
0
public BounceFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setTitle("Bounce"); comp = new BallComponent(); add(comp, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); addButton(buttonPanel, "Start", new ActionListener() { public void actionPerforme...
d8c3f493-f08a-44f0-9360-d8b6772912ee
9
public static String getBaseURI(NodeInfo node) { String xmlBase = node.getAttributeValue(StandardNames.XML_BASE); if (xmlBase != null) { URI baseURI; try { baseURI = new URI(xmlBase); if (!baseURI.isAbsolute()) { NodeInfo parent...
eb636f3b-9374-408b-973c-3d9286d2b6b7
2
public void display(){ int index = 0; while(index<SIZE) { if (elements[index] != null) { LinkedNode node = (LinkedNode) elements[index]; node.display(); } index++; } }
76108288-73ab-4d73-b2ad-7a708d660f2f
9
@Test public void testPingSocket() { LOGGER.log(Level.INFO, "----- STARTING TEST testPingSocket -----"); String client_hash = ""; String client_hash2 = ""; server1.setUseDisconnectedSockets(true); Server server3 = null; try { server3 = new Server(game, por...
93b7661c-8642-4a85-b9a5-b75b1b74a8b8
0
public String toString() { return "STATE: " + myState.toString() + " COLOR: " + myColor; }
a70630cd-075a-4924-85e8-3161c1269a63
8
public void DBDeleteAreaAndRooms(Area A) { if(A==null) return; if(!A.isSavable()) return; if(Log.debugChannelOn()&&(CMSecurity.isDebugging(CMSecurity.DbgFlag.CMAREA)||CMSecurity.isDebugging(CMSecurity.DbgFlag.DBROOMS))) Log.debugOut("RoomLoader","Destroying area "+A.name()); A.setAreaState(Area.State....
6e61abea-9fea-4c91-8ade-b243acb5028e
9
void drawEllipse(int color, int sz, int xc, int yc, int a, int b) { /* e(x,y) = b^2*x^2 + a^2*y^2 - a^2*b^2 */ int x = 0, y = b; long a2 = (long)a*a; long b2 = (long)b*b; long crit1 = -(a2/4 + a%2 + b2); long crit2 = -(b2/4 + b%2 + a2); long crit3 = -(b2/...
660728ea-e4e2-4727-936a-5af6d6a86c71
1
public boolean EliminarTrata(Trata p){ if (p!=null) { cx.Eliminar(p); return true; }else { return false; } }
c670a533-38b2-4f81-bfe7-60584231f1f0
4
@Override public String newProgrammesThisWeek() throws WhatsNewServiceException { List<BroadCastProgramme> programmeList = iProgrammesThisWeekService.programmesThisWeek(); List<Programme> newProgrammes = new ArrayList<Programme>(); if (programmeList != null) { for (BroadCastProgramme broadCastProgramme : ...
38841994-18f6-4bca-be78-dca23bbe4dc8
8
public void checkType(Symtab st) { exp1.setScope(scope); exp1.checkType(st); exp2.setScope(scope); exp2.checkType(st); exp1Type = exp1.getType(st); exp2Type = exp2.getType(st); if (!exp1Type.equals("int") && !exp1Type.equals("decimal") && !exp1Type.equals("String") && !exp1Type.equals("message")) M...
ea66ad07-76a4-4ccf-95d9-e8cd796b0cca
3
public ArrayList<String> getDimensionsFromPoints(ArrayList<ClusterPoint> p) { ArrayList<String> pointDimensionValues = new ArrayList<String>(); for(int i = 0; i < p.size(); i++) { for(int j = 0; j < dimensionCount; j++) { try { pointDimensionValues.add(Double.toString(p.get(i).getValueAtDimension(j)));...
f88503c5-ce34-4133-b26f-3db9aceee0e8
8
public void cullConnections() throws SQLException { int availableCount = 0; for (IMySQLConnection conn : conns) { if(conn.isAvailable()) { ++availableCount; } } double check = ((double)availableCount) / ((double)conns.size()); if((conns.size() > 10) && (availableCount > 5) && (check > 0.3)) ...
0968cfaa-68b2-418d-9758-71471c6eed7b
3
private void createDropWidget(Composite parent) { parent.setLayout(new FormLayout()); Combo combo = new Combo(parent, SWT.READ_ONLY); combo.setItems(new String[] {"Toggle Button", "Radio Button", "Checkbox", "Canvas", "Label", "List", "Table", "Tree", "Text", "StyledText", "Combo"}); combo.select(LABEL); dropContr...
da17c63d-5c21-4506-ad8e-ac363a2a2abb
9
public SampleBuilder<P> blanks2blanks(Map<BlankBuilder<?>, BlankBuilder<?>> blanks2blanks) { verifyMutable(); if (this.blanks2blanks == null) { this.blanks2blanks = new HashMap<BlankBuilder<?>, BlankBuilder<?>>(); } if (blanks2blanks != null) { for (Map.Entry<BlankBuilder<?>, BlankBuilder<?>> e : blanks2...
8be605a1-58dc-43d6-9dcf-ea0247f688f2
1
private boolean jj_3_52() { if (jj_3R_70()) return true; return false; }
6d53f85d-ceb6-4d1a-87a7-48c5f9178e80
2
@Transient public List<LabelValue> getRoleList() { List<LabelValue> userRoles = new ArrayList<LabelValue>(); if (this.roles != null) { for (Role role : roles) { // convert the user's roles to LabelValue Objects userRoles.add(new LabelValue(role.getName(),...
f067f862-3c67-43d6-8568-b7a3925ccbaf
4
public static double LinkedListFromArrayBench(int number) { LinkedListFromArray ll = new LinkedListFromArray(); long addLastTime = System.currentTimeMillis(); for (int i = 0; i < number; i++) { ll.addLast("" + Math.random()); } addLastTime = System.currentTimeMillis() - addLastTime; ll = new LinkedLis...