method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0ff07606-3e02-4ddf-b455-ed68fd1f6484
0
public void setPrice(String price) { this.price = price; }
5ce1ca05-ff8b-47fa-8797-27eb47f042d0
6
@Override public ArrayList<User> findByName(String Name) { ArrayList userList = new ArrayList(); try { connection = getConnection(); ptmt = connection.prepareStatement(QUERY_SELECT + " WHERE Name =?;"); ptmt.setString(1, Name); resultSet = ptmt.execute...
049f2a26-9280-452d-8484-5d56bc046a5e
8
private static List<HouseAd> buildHouseAds(Document document, String path, String dartTrackUrl) { List<HouseAd> hads = null; if (document != null && document.hasRootElement()) { Element rootElement = document.getRootElement(); List<Element> children = rootElement.getChildren("ad"); if (children != null ...
fbd69cf7-5b68-4060-af79-312849f02448
7
public ArrayList<TicketVO> selectQuery(HashMap<String, String[]> requestMap) { ArrayList<TicketVO> ticketList = new ArrayList<TicketVO>(); PreparedStatement ps = null; ResultSet rs = null; try { this.getConnection(); // build SQL query ticketBuild = new TicketBuilder(requestMap); String ticketQu...
afe59913-0d9b-4361-84e6-ad59b3c7cee6
4
@Override public void draw(int x, int y) { glColor4f(1f, 1f, 1f, 1f); //TODO fix this, it's due to a quirk in the drawing code that offsets the draw by one x = x - Standards.TILE_SIZE; y = y - Standards.TILE_SIZE; Boot.getTexHandler().bindTexture("zed"); float rotation = this.getOrientation() * 90; fl...
a0e0cf24-5631-4691-b0fd-7fa6f6385539
3
public static String trimTrailingCharacter(String str, char trailingCharacter) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) { sb.deleteCharAt(sb.length() - 1); ...
57f434b7-0e8a-40fa-9ab0-1c8f871ba598
5
@Override public void update(KeyEvent keyEvent) { //System.out.println(event.getKeyCode()); if (keyEvent.getKeyCode() == 37) { setDir(Direction.LEFT); } if (keyEvent.getKeyCode() == 39) { setDir(Direction.RIGHT); } if (keyEvent.getKeyCode() == 38) { setDir(Direction.UP); } if (keyEvent...
c85b4bd7-d92c-4193-806b-68c0f4fa2c68
6
private Set<Piece> captured(int team, Location location) { Set<Piece> ret = new HashSet<Piece>(); if (actorAt(location) != null) { return ret; } for(int[] delta : ADJACENT) { Set<Piece> swath = new HashSet<Piece>(); Location scan = location; while(true) { scan = scan.add(delta[0],delta[1]); if (!...
bff67291-827e-4708-b9ea-28a1b9fef6a8
5
public void run() { this.init(); Graphics screenGraphics = this.screen.getGraphics(); long lastTimer = System.currentTimeMillis(); long fpsWait = (long) (1.0 / 60 * 1000); main : while (this.running) { this.renderStart = System.nanoTime(); // Update the game this.tick(); // Update sc...
3422a8f4-0552-4d41-8c70-07427ea59db1
4
protected void applyMove(int turnNumber, Move move) throws InvalidMoveException { if (move.column >= GameConstants.NUM_COLUMNS || move.column < 0) { throw new InvalidMoveException(); } int column = move.column; //--Start in the bottom-most row int row = GameConstants.NUM_ROWS - 1; Piece moveLocat...
1e8c476d-54d2-4a50-8a62-6a468cf32a57
2
public String getSimpleCode(){ String str = condition.getSimpleCode() + this.printLineNumber(true) + "goto := " + this.labelFalse + " if " + condition.place + " == false \n"; String trueCode = truePart.getCode(); str += (trueCode == "" ? "" : trueCode ) + this.printLineNumber(true...
d5bd3d8c-9244-4174-a604-27e5d761df0f
8
public Stance getStanceFromTension(Tension tension) { int value = tension.getValue(); switch (this) { case WAR: // Cease fire if tension decreases if (value <= Tension.Level.CONTENT.getLimit()-Tension.DELTA) { return Stance.CEASE_FIRE; ...
b1661374-a3b0-4bc4-8f93-3b1df3c59e8f
4
@Override public boolean isSolid(final int pX, final int pY) { if(0 <= pX && pX < mBitsBlock.length && 0 <= pY && pY < mBitsBlock[0].length) return mBitsBlock[pX][pY]; else return false; }
b3406d3e-c270-45bd-8fa4-31f2de9a75c4
7
public static Class downsize(Class c) { if (c.equals(Year.class)) { return Quarter.class; } else if (c.equals(Quarter.class)) { return Month.class; } else if (c.equals(Month.class)) { return Day.class; } else if (c.equals(Day.cl...
84399d85-5ca4-4924-a5ca-3097e7ed26aa
1
private Object toValue(String name, double[] vals) { Object orig = parameter.get(name); if (orig.toString().indexOf('{') > -1) { // this is an array (hopefully 1dim) return Conversions.convert(vals, String.class); } else { return Double...
b5603f8d-6e08-45d4-9534-209349dca016
8
public static <T extends Comparable<T>> BasicNode<T> searchNodeWithValue( BasicNode<T> root, T valueToSearch) { if (null == root || null == valueToSearch) { throw new IllegalArgumentException("Root or value to be inserted can not be null."); } if (root.getValue().equals(valueToSearch)) { ...
552242de-2199-448b-acfe-98f6fab3a24b
9
private void calculator(int score){ int sh1=0; int sh2=20; int nums[]={score,0,0}; int sval=0; //int rem=score-(sh2*2); if(score>60){ System.out.println("if(score>60)\n"); int val=score; while((sh1*3+sh2*2)!=score...
5240087c-b0c1-49ff-a368-274f4770e217
9
public String printHTML(String html) { html += "<b>Statistics</b><br><table>"; html += "<tr><td></td>"; if(mean != null){ html += "<th>Mean</th>"; } if(sd != null){ html += "<th>Std.Dev</th>"; } if(percentiles != null){ for(int ...
7dee451e-5075-427e-bd82-5eb136719614
7
@Override public void keyPressed(KeyEvent event) { if (isLoading) { return; } int key = event.getKeyCode(); switch (key) { case KeyEvent.VK_DOWN: if (selectedIndex < components.size() - 1) { selec...
53fb9cd8-82d0-46e7-b06e-498f6a59c2d0
4
@SuppressWarnings("unchecked") public CodeMapT<T> set(final int index, final T value) { final int i0 = index >>> 24; T[][] map1; if (i0 != 0) { if (map == null) map = (T[][][]) new Object[MAX_INDEX_ZERO][][]; map1 = map[i0]; if (map1 == null) map1 = map[i0] = (T[][]) new Object[MAX_INDEX_ONE][...
b9c0f396-270b-4f45-bd70-24da8968b9c1
4
@Override public void onFrame() { for (Unit unit : self.getUnits()) { if (unit.getType().isWorker() && unit.isIdle() && unit.isCompleted()) { resourceManager.giveWorker(unit); } } }
1cfa9efd-5ed5-43c1-b711-93cf0391cefe
8
@Override public int getQuestRoomIndex(String roomID) { final int[] num={1}; int x=-1; synchronized(questState) { if(questState.worldObjects!=null) x=getQuestThingIndex(PreservedQuestObject.getPOIter(questState.worldObjects),roomID,CMClass.CMObjectType.LOCALE,num); if((x<0)&&(questState.roomGroup!=n...
163425e2-620f-4ab0-979f-797e1efd305c
6
public boolean isBestEffort() { if(mProperties != null) { for(Property prop : mProperties) { if(prop instanceof NonFunctionalRequirementsProperty) { if(!((NonFunctionalRequirementsProperty) prop).isBE()) { return false; } } else if(prop instanceof OrderedProperty) { if(((OrderedPr...
46d61605-c823-4f86-81d4-8d34b993d3d6
8
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int[] nm = readInts(line); n = nm[0]; m = nm[1]...
2ee2c7b6-54bf-4788-9ec9-178458bc3581
3
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String nom = ""; String password = ""; if (request.getParameter("user") != null){ nom = request.getParameter("user"); } if (request.getParameter("password") != null){ passw...
dba8c26f-1352-4681-ab71-9b993b5af62d
7
public static void LIS(Integer[] mArray){ //This will implement the Longest Increasing Subsequence algorithm using //Dynamic Programming in O(n^2) time int[] sizes = new int[mArray.length]; String[] paths = new String[mArray.length]; //First we init both sizes and paths for(int i = 0; i < mArray.length; i...
50560b39-39d1-46f2-b10c-88708bde23fe
7
public int[][] getUsedAttributes(){ int[][] usedAttributes = new int[m_numClasses][]; //first extract coefficients double[][] coefficients = getCoefficients(); for (int j = 0; j < m_numClasses; j++){ //boolean array indicating if attribute used boolean[] attributes = new boolean[m_numericDataH...
8a4b5774-1b89-4f56-8911-f9740749ea90
2
public static void writeCurrentErrors(ErrorLogs errorLogs, String errorFileOutputName){ int errorSize = errorLogs.getErrorMsgs().size(); System.out.println("writing current Errors"); try { PrintWriter error_writer = new PrintWriter(errorFileOutputName); for (int i = 0; i < errorSize; i++) { error_write...
8cfa0410-dbd6-4d61-8c2c-d4d8480df953
9
private Node<K, V> floorAll( V value ) { if( value == null ) { return null; } Node<K, V> node = mAllRoot; Node<K, V> ret = null; if( mValueComparator != null ) { Comparator<? super V> comp = mValueComparator; while( node != null ) { int c = com...
0c4b49e6-2f44-45c2-95f5-47ba6b1e9549
0
protected void setManagerFirewallId(int managerFirewallId) { this.managerFirewallId = managerFirewallId; }
befa0820-0a16-44bf-957d-cc57345978ca
5
@Override public void run() { if(listenSocket == null) { if(!setupTCPListener()) { System.err.println("TCP listen socket not started."); return; } } running = true; //set running flag try { while(running) { Socket clientSocket = listenSocket.accept(); ...
1fb43f04-a5e5-4355-b371-83bb7ede27f8
2
private void getStripImages(String line) { StringTokenizer tokens = new StringTokenizer(line); if (tokens.countTokens() != 3) { EIError.debugMsg("Wrong no. of arguments for ", EIError.ErrorLevel.Error); } else { tokens.nextToken(); // skip command label ...
0528ceaf-329a-442b-9e07-1b779add585c
1
@RequestMapping(value = "/create/employee", method = RequestMethod.POST) public ModelAndView createUser(@ModelAttribute("employee") Employee employee) { ModelAndView modelAndView = new ModelAndView(); boolean flag = employeeDao.createUser(employee); if (flag) { modelAndView.setViewName("hrdepartment"); mod...
6e15c646-b1e6-417c-955a-0a59c6e0fa2a
6
public double evaluateMod(NodeArgument[] params, HashMap<NodeVariable, MessageQ> modifierTable) { if (modifierTable.isEmpty()){ return this.evaluate(params); } if(debug>=3){ System.out.println("Table non empty, there are "+modifierTable.keySet().size()+" keys"); ...
6fddf999-835b-4aed-8d5e-6489fd1a902c
7
public byte[] encrypt(byte[] text, String key){ // System.out.println("encrypting"); byte[] textEncrypted = null; try{ //keygenerator.init(bits); // 192 and bits bits may not be available byte[] keyPadded = new byte[bits / 8]; for(int i = 0; i < bits / 8 && i < key.length(); i++){ keyPadded[i] = ...
e5e848e2-12b1-4e55-b6d2-b6b029a94152
7
private void DestroyByID(int identity) { //Creating the 'Deleted' variable boolean objectDeleted = false; //Looking through the standard game objects for (int num = 0; num < game.AL_GameObjects.size() && objectDeleted == false; num++) { if (game.AL_GameObjects.get(num).intObjectID == identity) {...
f7e5f2c3-7e1e-452b-80c5-c1f43c627855
1
public String toString() { try { return this.toJSON().toString(4); } catch (JSONException e) { return "Error"; } }
c651f2a3-6d48-4356-8315-a7dd7ad6ee5e
4
private void initComponent() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 536, 430); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); ...
8fbdbbf3-b1cc-4d7b-8f79-c9d45118fa8b
0
public double get() { return _rate; }
f13efbc4-d40c-4c2d-a1e4-f444214e6a04
4
private String determine(){ if(msg.asunto().matches(sales) && msg.asunto().matches(info)) return "ambos"; else if(msg.asunto().matches(sales)) return "sales"; else if(msg.asunto().matches(info)) return "info"; else return null; }
66c80c82-4b5b-4f81-a0ea-9b82280a103c
6
public ArrayList<AntBrain> runTournament(GUI gui) { int numCompetitors = antBrains.size(); scores = new int[numCompetitors]; //can init scores[] now that we know how many brains there are for (World wo : worlds) { wo.checkValidForTournament(); } int gameCounter = 0;...
1c37163e-4ac9-480d-8eec-7df7f2580f8c
5
public void instanstiateAllClasses() { if (classes.size() == 0) { if (debug) { System.out.println("You have to call loadAllClasses() first!"); } return; } for (Class<BaseSorter> c : classes) { try { sorters.add((BaseSorter) c.newInstance()); } catch (InstantiationException e) { e.printS...
9937b1f9-21d4-41ea-b5a0-28a33d7fa1ea
0
static boolean patroonVerjaardag(String invoer) { return invoer.matches("[0-9]{2}-[0-9]{2}-[0-9]{4}"); }
9a158fa1-fd51-4a2f-aa7d-c3d5848de86b
6
public void convert() { this.biResult = null; if ((ResultWidth == 0) || (ResultHeight == 0)) return; if ((this.biLeftImage == null) || (this.biRightImage == null)) return; if ((this.biLeftImage.getWidth() != this.biRightImage.getWidth()) || (this.biLeftImage.getHeight() != this.biRightImage.getHeight())) ...
b08afaac-d280-4cfb-a1a2-ccc2b0f4834c
8
public Result start() { startTimeMillis = System.currentTimeMillis(); do { for(int i=0;i<iterations;i++) { if(super.forceStop) return null; Chromosome newS = new Chromosome(s); Mutation.mutate(newS, super.mutationType); float rand = -1f + (float) Math.pow(Math.E, ((newS.getFitness()/3f)-(s.getFit...
f866c080-5d6a-4754-ab3e-61cabc9e22e7
1
public void doNumericsAndDates() { try { final String mapping = ConsoleMenu.getString("Mapping ", NumericsAndDates.getDefaultMapping()); final String data = ConsoleMenu.getString("Data ", NumericsAndDates.getDefaultDataFile()); NumericsAndDates.call(mapping, data); ...
b53ad796-fff1-48da-99a1-33066c52e0f2
1
@Override public int getSize() { if(FW == null) { return 0; } return FW.getObjectNames().size(); }
5acc303e-b2a4-4a62-b5ee-c93fa531cf21
5
private double standardMoment(int n) { if (n < 0) throw new IllegalArgumentException(); if (n == 0) return 1.0; if (n == 1) return 0.0; if (n == 2) return 1.0; makeValid(); double sigma = stdDev(); double sigmaN = sigma; for (int i = 1; i < n; i++) sigmaN *= sigma; return centralMoments[n] / sigmaN; ...
a913a325-b31f-4dc1-b90c-21b1199d59e4
2
Modelo buscarModelo(String nome) { for (PecaModelo m : modelos) { if (m.getModelo().getNome().compareToIgnoreCase(nome) == 0) { return m.getModelo(); } } return null; }
681d4186-e454-434a-94be-040a093585ac
5
public String[] resnames() { List<String> names = new ArrayList<String>(); ResDrawable dw = getattr(ResDrawable.class); Resource res; if (dw != null) { res = dw.res.get(); if (res != null) { names.add(res.name); } } else { ...
5a3b0597-4438-44ef-b1a7-67a5953f469d
9
private void patternPane(Graphics g, int ystart, int yend) { int cssize = 3+2+2+3 +1; int widthChars = width/4; int widthChannels = (widthChars-4)/cssize; int heightChars = (yend-ystart)/6; g.setColor(Color.BLACK); int offscol = 0; int xoffsrow = heightChars/2; int offsrow = patrow-xoffsrow; /...
c5c21a1d-319b-4cd3-bf73-9a74e2d1c53d
1
public AnnotationVisitor visitArray(final String name) { ++size; if (named) { bv.putShort(cw.newUTF8(name)); } // write tag, and reserve space for array size bv.put12('[', 0); return new AnnotationWriter(cw, false, bv, bv, bv.length - 2); }
1a0fbc1e-47f8-4e20-a0c6-81d660c2d937
3
public String readVarIntString(DataInputStream stream, int maxLength) throws Exception { int length = Varint.readVarInt(stream); if (length > maxLength * 4) throw new Exception("The received encoded string buffer length is longer than maximum allowed (" + length + " > " + maxLength * 4 + ")"); if (length < 0) ...
27dca2a2-8042-4931-bba1-74807806a083
9
private void fall(Level level, int x, int y, int z) { if (!Minecraft.isSinglePlayer) { return; } int yOffset = y; while (true) { int yCheckPos = yOffset - 1; int nextTile; LiquidType liquidType; if (!((nextTile = level.getTile(...
83e7fcfe-380b-4445-b5de-2b2c2d761fa3
5
private void setupMaps() { // this.layermap = new int[this.cellsoffset]; this.arraymap = new int[this.cellsoffset]; this.indeg = new int[this.cellsoffset]; this.outdeg = new int[this.cellsoffset]; // // for (int i = 0; i < this.cellsoffset; i++) { ...
e5ffc522-483c-4f94-9960-4bb77fead581
2
protected void loadConfiguration() { File configFile = new File(CONFIG_FILE); configuration = new Configuration(); try { configuration.load(configFile); } catch (IOException e) { e.printStackTrace(); } File xmlConfigFile = new File(CONFIG_FILE_XML...
05653b88-12f5-4dd1-ba27-d10c9f98bce2
6
public void fermerConnexion() { // Fermeture du jeu de résultats, si nécessaire. try { if (rs != null) rs.close(); } catch (Exception e) {} // Rien à faire. // Fermeture de la requête préparée, si nécessaire. try { if (this.ps != null) this.ps.close(); } catch (Exception e) {} // Rien à ...
b0b0ae66-d38e-48e9-b87f-cf58e9d682df
6
public boolean yInInterval(int t, int b) { int ty = this.higherVertex().centerX(); int by = this.lowerVertex().centerX(); if(ty > t && ty < b) return true; if(by > t && by < b) return true; if(ty < t && by > b) return true; return false; }
d57d1e0b-7bd5-4dfa-b2aa-3c6d52ed3fc7
1
public Card(CardType type) { this.type = type; try { bgImage = ImageIO.read(new File("img/parchment.png")); } catch (IOException e) { } setBgImage(type); }
1a75b5c1-ffe7-4e4b-9a84-4ff6d3223452
2
@Override public void clockIn(String nick) { if (userExists(nick)) { if (!timeOut.containsKey(nick)) { timeOut.put(nick, new Date()); } else { timeOut.get(nick).setTime(new Date().getTime()); } } }
c4b42c51-c67f-40b2-9c25-e2ab7d50066b
0
public void windowIconified(WindowEvent e) { isIdle=true; }
0c4a6909-e21a-41c0-aa17-127f0b522d80
8
private static String escapeJSON(String text) { StringBuilder builder = new StringBuilder(); builder.append('"'); for (int index = 0; index < text.length(); index++) { char chr = text.charAt(index); switch (chr) { case '"': case '\\': ...
0b3d27c7-90cb-466b-a1cc-f0bc785396e4
9
@Override protected String doInBackground () { Benchmark.start("LoginWorker"); try { if (LaunchFrame.canUseAuthlib) { try { LoginResponse resp = AuthlibHelper.authenticateWithAuthlib(username, password, mojangData, selectedProfile); ...
05434cb6-0fd8-4d9f-879c-da64f37c031b
6
public void run() { int numbytes; StringBuilder total_data = new StringBuilder(); BufferedInputStream sockin = null; try { sockin = new BufferedInputStream(client_sock.getInputStream()); } catch (IOException e) { MsgDumperCmnDef.WriteErrorFormatSyslog(__FUNC__(), __LINE__(), "Error occurs, due...
644ea158-918c-4929-83f0-c2127f087a98
1
@Override protected String[][] doInBackground() throws Exception { System.out.println("TEST 1"); while(true) { System.out.println("Test"); players = remote.getConnectedPlayers(); publish(players); return players; } }
52c51d20-5c03-447e-90fa-af5223bd2bc3
8
public static void main( String[] args ) { System.out.println( "NanoHTTPD 1.0 (c) 2001 Jarno Elonen\n" + "(Command line options: [port] [--licence])\n" ); // Show licence if requested int lopt = -1; for ( int i=0; i<args.length; ++i ) if ( args[i].toLowerCase().endsWith( "licence" )) { lopt = i;...
4bb7201b-74ac-4de2-a50b-a411d755aa59
3
void assignOLSWeights( double[][] A ) { edge e; e = depthFirstTraverse(null); while (null != e) { if ( e.head.leaf() || e.tail.leaf()) e.OLSext(A); else e.OLSint(A); e = depthFirstTraverse(e); } }
839ee54a-3fdb-4041-a3f7-45f8ea33272f
7
public ChoixArtefact(java.awt.Frame parent, boolean modal, HashMap<Integer, Artefact> liste) { super(parent, modal); indexDieux = new int[6]; initComponents(); ChoixArtefact.liste = liste; for (int i = 0; i < liste.size(); i++) { if ("Hel".equals(liste.get(i).getEnnem...
0b29e5e0-b49b-4bc0-9350-711eaff6714c
4
public boolean moveMade(Coordinate move) throws InterruptedException { boolean test = false; if (test || m_test) { System.out.println("Controls :: moveMade() BEGIN"); } getGameWindow().moveMade(move); if (test || m_test) { System.out.println("Controls :: moveMade() END")...
bd9d2fef-7423-44f4-acee-e6160f3e0860
9
static boolean matchA(String str, String pat, String matches[]) { int i = 0; // move through str int j = 0; // move through matches int pos = 0; // move through pat while (pos < pat.length() && j < matches.length) { char p = pat.charAt(pos); if (p ...
ed4d59c2-cad0-432f-ae86-83153af8f86c
0
@Override public void documentAdded(DocumentRepositoryEvent e) {}
d85c922f-cd55-48dc-8906-e7348d3ed332
3
private ChatEvent formatChatMessage(ChatEvent chatEvent) { String deltaTime = ""; String timeStamp = ""; String nick = chatEvent.getFrom().getDisplayName(); if (enableTimeStamp) timeStamp = new SimpleDateFormat("hh:mm:ss").format(new Date()) + Config.SEP; if (enableDeltaTime) deltaTime = chatEvent.getD...
ad481e00-ceb8-421f-aa32-9e06732b66fd
0
public static String stripControlCharacters(String s) { return s.replaceAll("\\p{Cntrl}","?"); }
792415f5-3a12-4263-b0bf-9d148c8fe007
0
public GenericFlooder(int numThreads, String target) { this.numThreads = numThreads; this.target = target; tracker = new StatsTracker(target); }
d97757e0-135f-46a4-a394-49439109a918
7
private static ArrayList<Configuration> sautRecursif(Configuration conf, byte[] triplet, byte typeSauteFirst, boolean noirEnPlayer){ ArrayList<Configuration> listeConf = new ArrayList<Configuration>(); byte caseDebut = triplet[0]; byte typeSaute = triplet[1]; byte caseFin = triplet[2]; byte newTurttle...
83910615-9665-4da0-9505-4955e95af0ff
1
@SuppressWarnings("serial") public ErrorGui(java.awt.Frame parent) { super(parent, "Haven error!", true); setMinimumSize(new Dimension(300, 100)); setResizable(false); add(new JPanel() {{ setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(new JLabel("An error has occurred!")); add(status = new...
9096d073-c81d-4d73-b5ec-c99206560789
7
private boolean preconditionsOK(Player player) { boolean res = false; // CHECK 1 if(!player.isOnline()) // this may happen because "player" reference may be delivered by a scheduler { return false; } // CHECK 2 if(!player.isOp()) //if player is op, he does not nee...
23950c7c-786f-442c-99fe-e1cd87aba8ca
2
public int getSelectedFontSize() { int fontSize = 1; String fontSizeString = getFontSizeTextField().getText(); while (true) { try { fontSize = Integer.parseInt(fontSizeString); break; } catch (NumberForma...
aaad2d82-9c21-4149-8213-83035637d2ca
8
private static void addFilter_p(String className,String label,int type) { LogFilter filter= new LogFilter(); filter.className=className; // get the name of caller class try { throw new Exception(""); } catch( Exception e ) { StackTraceElement tr = e.getStackTrace()[2]; if(className==null || classNa...
5ba37bad-4d01-4d4a-b799-631b940677c6
6
public synchronized void overlay(int id, int frame, int olid, boolean prs, Indir<Resource> resid, Message sdt) { Gob g = getgob(id, frame); if (g == null) return; Gob.Overlay ol = g.findol(olid); if (resid != null) { if (ol == null) { g.ols.add(ol ...
c4b72309-b9ef-4763-b614-d2556238518d
4
@SuppressWarnings("unchecked") @Override public int compareTo(KeyValue<A, B> o) { int cmp = 0; if (key instanceof Comparable) { cmp = ((Comparable) key).compareTo(o.key); if (cmp != 0) return cmp; } if (value instanceof Comparable) { cmp = ((Comparable) value).compareTo(o.value); if (cmp != 0) r...
78857836-165f-411e-b04d-5b84d3ecdb4c
9
public static Slot FIND_SLOT(String name, List slots, boolean useParametricTypeP, boolean useTypeP) { if (useTypeP && ((slots.length() == 1) && (XmlObjects.SLOT_BASE_AND_PARAMETER_TYPE(((Slot)(slots.first())), new Object[1]) == XmlObjects.SGT_XML_OBJECTS_XMLObject))) { return (((Slot)(slots.f...
e97d4cdb-b426-4857-8ae8-d6d3042a14b5
7
private void disconnect() { try { if (sInput != null) sInput.close(); } catch (Exception e) { } // not much else I can do try { if (sOutput != null) sOutput.close(); } catch (Exception e) { } // not much else I can do try { if (socket != null) socket.close(); } catch (Exception e) {...
bf0b9125-0ca6-4638-8746-06ff7ef1d39a
0
public void clear() { this.map.clear(); }
b0a2e44f-d778-4201-895a-3b7b2d63676a
9
public void paintChildren(Graphics g) { g.setColor(Color.WHITE); g.fillRect(0, 0, getWidth(), getHeight()); if (a.getDataModel().getMode().equals(Anim9or.DRAW_MODE)) { for (int i=0;i<a.getDataModel().getCurveList2().size();i++) { g.setColor(a.getDataModel().getCurveList2().get(i).getColor()); for (i...
51f46c0a-0304-490f-a012-5793ea437453
9
@Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub MainView main = MainView.getMain(); HouseModel m = main.getMaison(); MemoryAction hg= new MemoryAction(); ModificationView.getCaracView(); musicController = MainView.getMusicController(); RepresentationView vie...
872fcc3a-53b9-486c-bc05-47154b76e2d9
6
static boolean isBoolean( String var ) { if( var.equalsIgnoreCase("true") || var.equalsIgnoreCase("false") || var.equals("1") || var.equals("0") || var.matches("^[tT].*$") || var.matches("^[fF].*$") ) { return true; } return false; }
be192f79-759c-4de9-8f80-81b80f9a319b
2
public static int[] nearNeighbour(int[] pixs, int iw, int ih, int ow, int oh, float p) { int[] opix = new int[ow * oh]; for (int i = 0; i < oh; i++) { int u = (int) (i / p); for (int j = 0; j < ow; j++) { int v = (int) (j / p); int a = pixs[u * iw + v]; opix[i * ow + j] = a; } } return opi...
61e6e388-b749-4a0a-aa7c-1230a03239af
4
private void updateJoystick(int i) { FloatBuffer newAxes = glfwGetJoystickAxes(i); ByteBuffer newButtons = glfwGetJoystickButtons(i); if (newAxes != null) { joystickAxes[i] = newAxes; } else if (joystickAxes[i] == null) { joystickAxes[i] = createDefaultJoystickAxes(); } if (newButtons != null) { ...
83de6aa0-05a2-47b3-905e-201295cb3f5e
4
public void render(Screen screen) { if (!level.getTile(x, y - 1).isWall()) { sprites.rotate(Math.PI / 2 * 0, true); screen.draw(sprites, x, 0, y, this); } if (!level.getTile(x + 1, y).isWall()) { sprites.rotate(Math.PI / 2 * 1, true); screen.draw(s...
6921261e-9595-4a06-a6d3-412e8e02aa48
7
private void displayDungeon(AsciiPanel term, int left, int top) { for (int i = 0; i < screenW; i++) { for (int j = 0; j < screenH; j++) { int dx = i + left; int dy = j + top; term.write(dungeon.glyph(dx, dy), i, j, dungeon.color(dx, dy)); ...
674826f0-b58d-4632-9dbf-722285c929bb
3
public void removeSimpleCreature() { synchronized (simpleCreatures) { List<SimpleCreature> sC = Collections .synchronizedList(simpleCreatures); for (Iterator<SimpleCreature> it = sC.iterator(); it.hasNext();) { SimpleCreature c = it.next(); if (c.getClass() == SimpleCreature.class) { if (c.isAli...
207dd403-4eba-4818-90ef-a6b2b2377d02
0
public void setUlica(String ulica) { this.ulica = ulica; }
e446304e-8102-42f3-8e2f-d9238343ea3b
9
private void search(int posI, int posJ, int minI, int maxI, int minJ, int maxJ, boolean pionAdverse) { for (int i = minI; i <= maxI; i++) { for (int j = minJ; j <= maxJ; j++) { if (posI + i < 0 || posI + i >= Plateau.PLATEAU_HEIGHT || posJ + j < 0 || posJ + j >= Plateau.PLATEAU_WIDTH) continue;...
fd5b7b73-17ce-4417-b8be-63bba1c230b0
9
private void initialize() { setup = new GeneralSetup(); frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); comboColumnsStart = new JComboBox(); comboColumnsStart.setBounds(121, 68, 159, 24); fr...
2f6e5550-e496-4262-99bf-a7f11fac7783
3
private void print(int[][] array) { for (int[] is : array) { for (int i : is) { if (i == 0) { System.out.print(" "); } else { System.out.print(i); } } System.out.println(); } }
6a5e8c20-2b6e-4595-b90e-5523a3c5041f
7
private void layoutMacStyle(Container c) { int spacing = getHorSpacing(); int h = getHeight(); // assumes all buttons have the same dimensions these dimensions include the borders int buttonHeight = h - getVerSpacing() - 1; int buttonWidth = buttonHeight; ...
49e5c537-cb74-4147-ad28-b280c9a1180b
3
public static void main(String [] args){ //create 3 hero int numberOfHero = 3; ArrayList<HeroSlot> heroies = new ArrayList<HeroSlot>(); for(int i = 0 ; i < numberOfHero ; i++){ heroies.add(new MainMenuHeroSlot()); } for(HeroSlot heroslot : heroies){ System.out.println(heroslot.toString()); } ...
c655620b-d763-43a6-94f5-d2a8f5d2c54a
4
public void moveEnemiesDialogs(){ // Move enemies into place, and handle the dialogs // If the box isn't drawn if(drawBox == false){ // start moving the initial 3 enemies for(int i = 0; i<initials.size(); i++){ // if all of the enemies are...
900bca08-fb81-478f-ab49-604f11145056
1
public static Sound loadSound(String fileName) { Sound sound = new Sound(); try { AudioInputStream ais = AudioSystem.getAudioInputStream(Sound.class.getResource(fileName)); Clip clip = AudioSystem.getClip(); clip.open(ais); sound.clip = clip; } catch (Exception e) { System.out.println(e); } ...