method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a69fbc1d-52fc-4d75-8654-883bfb1b0243
6
private void processAsXML(ByteArrayOutputStream bytes) { ByteArrayInputStream input = new ByteArrayInputStream(bytes.toByteArray()); try { TransformerFactory factory = TransformerFactory.newInstance(); Transformer xformer = factory.newTransformer(); Source source = new StreamSource(input); Document...
0314c12b-c68b-4164-b0d3-7166ea1587fa
6
public void undo(){ Command commande = commandeCourante.commande; commande.undo(); //Actualisation du modèle puis de la vue. if(commande instanceof LirePlanCommand){ zone = ((LirePlanCommand)commande).getZone(); Fenetre.getInstance().actualiserPlan(); ...
4cce219d-cd2c-42a4-a7c5-5b823bfac94a
8
private boolean verfiyeTextField(){ boolean r = true; if (lectureName.isEmpty()){ JOptionPane.showMessageDialog(mainForm, "Lecture text is empty", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (tag.isEmpty()){ JOptionPane.showMessageDialog(mainForm, "Tag t...
ed283155-b174-4e04-845d-78a0ccaebfa5
2
public static String shortName(final Class c) { final String n = c.getName(); final int i = n.lastIndexOf("."); return i == -1 || i == n.length() ? n : n.substring(i+1); }
bf15e7a6-7972-4a1f-9272-a7c97cc296a6
8
public final Level loadOnline(String var1, String var2, int var3) { if(this.progressBar != null) { this.progressBar.setTitle("Loading level"); } try { if(this.progressBar != null) { this.progressBar.setText("Connecting.."); } HttpURLConnection var6; ...
4beb4fff-c9a0-4c51-9394-a0fe5335e6e9
4
public void move() { // Controls wrap around in the x-axis if (x >= fWidth) { double temp = middleX - x; x = -1 * image.getWidth(null); middleX = x + temp; } else if (x <= -image.getWidth(null)) { double temp = ...
8210f3aa-9742-4a37-b037-f87f48e10281
6
public boolean growPumpkins(Player player, String[] args, int radius) { Block playerCenter = player.getLocation().getBlock(); // Get Centrepoint (Player) int pumpkins = 0; for (int x = -radius; x < radius; x++) { for (int y = -radius; y < radius; y++) { for (int z = -radius; z < radiu...
41424252-f126-4b86-804a-fba259fee9ac
5
public void insertarDespuesDeX(T dato, T x){ Nodo<T> nodoQ = this.inicio; Nodo<T> nodoT = null; boolean bandera = true; if(this.inicio == null){ this.inicio = new Nodo<T>(dato); }else{ while(nodoQ.getInfo() != x && bandera){ if(nodoQ.getLiga() != null){ nodoQ = nodoQ.getLiga(); }else{ ...
c68c733a-380e-42dd-94a5-d1d4831b4793
5
public Date nextTimePeriod(){ String c = sdf.format(periodStartDate); int month = Integer.parseInt(c.substring(5,7)); int day = Integer.parseInt(c.substring(8,10)); int year = Integer.parseInt(c.substring(0,4)); if(day == 1){ day = 16; }else{ day = 1; month++; if(month > 12){ month %= 12;...
c8afd305-1492-43a4-a5da-284733d0e0ab
4
private void checkFull(Node node) { for (Node n : node.children) { if (n == null) return; // not full, nothing to do else if (n.full == false) return; // not full, nothing to do } // all children are full, flag and check recursively upwards node.full = true; if (node != root) checkFull(nod...
71c77173-3945-4a1f-8bec-be9d2f5c55f5
7
public static Grandeur getGrandeurFromString(String grandeur) { Grandeur ret; switch (grandeur.toUpperCase()) { case "LONGUEUR": ret = Grandeur.LONGUEUR; break; case "TEMPS": ret = Grandeur.TEMPS; break; ...
fcdd8207-04f3-4ce6-9eee-2aecc0196c01
7
public void piirraRobotti(Pelaaja pelaaja, Graphics g){; Robotti robo=pelaaja.getRobotti(); switch (pelaaja.getMones()){ case 1:g.setColor(Color.blue); break; case 2:g.setColor(Color.red); break; case 3:g.setColor(Color.GREEN); ...
c7f6d9e5-0286-4d8b-91da-340fcf315780
8
public GrahamScan(Point2D[] pts) { // defensive copy int N = pts.length; Point2D[] points = new Point2D[N]; for (int i = 0; i < N; i++) points[i] = pts[i]; // preprocess so that points[0] has lowest y-coordinate; break ties by x-coordinate // points[0] is an...
3746f47e-1aa0-4113-a2b4-24116b498d30
2
public static String getMacBytesAsString(byte[] data, int startOffset) { StringBuilder sb = new StringBuilder(18); for (int i = startOffset; i < startOffset + 6; i++) { byte b = data[i]; if (sb.length() > 0) sb.append(':'); sb.append(String.format("%02x", b)); } return sb.toString(); }
acde7817-97b0-40af-8145-d42484f66b81
3
public static void main(String[] args) { double c1,c2,c3; int exp; double a,b,xr,fa,fb,fxr,error,eact; double eaux=0; Scanner lector = new Scanner(System.in); System.out.println("Dame el coeficiente del termino cuadratico"); c1=lector.nextDouble(); System.out.println("Dame el exponente del termino ...
b01cfd17-6377-4946-ac22-107e2dc8feef
1
public static void clearInventory(InventoryItem[] targetInventory) { for(int i = 0; i<getInventorySize(targetInventory); i++) { targetInventory[i] = Parasite.items.EmptyItem; } }
8b43cc03-bf50-4fbc-8b21-39a1b09ade70
3
public static void killMeIfIGetStuck() { final Thread threadToKill = Thread.currentThread(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(2000); if (threadToKill.getState().equals(State.RUNNA...
6dff2bfb-b6ab-481f-b6b1-6a46c133fafe
8
protected void onGuiEvent(GuiEvent ev) { // ---------------------------------------- command = ev.getType(); if (command == QUIT) { try { home.kill(); for (int i = 0; i < container.length; i++) container[i].kill(); } catch (Exception e) { e.printStackTrac...
17403772-0d8d-40ec-b034-b048e8d1ea55
7
private Token scanTag () { char ch = peek(1); String handle = null; String suffix = null; if (ch == '<') { forward(2); suffix = scanTagUri("tag"); if (peek() != '>') throw new TokenizerException("While scanning a tag, expected '>' but found: " + ch(peek())); forward(); } else if (NULL_BL_T_LINEBR....
81ce3cba-c5a7-4c4c-979a-d0b571551bef
8
@Override protected AcceptStatus accept(final BytesRef term) { if (commonSuffixRef == null || StringHelper.endsWith(term, commonSuffixRef)) { if (runAutomaton.run(term.bytes, term.offset, term.length)) return linear ? AcceptStatus.YES : AcceptStatus.YES_AND_SEEK; else return (linear &&...
24162320-e731-4c30-b1a0-d1afbdcb40f5
8
public static void unifyTypes(Proposition prop, Skolem term1, Stella_Object term2) { { Surrogate type1 = Logic.logicalType(term1); Surrogate type2 = Logic.logicalType(term2); if ((type1 == type2) || (Logic.logicalSubtypeOfP(type1, type2) || Logic.logicalSubtypeOfP(type2, type1))) {...
47c12c3c-8d71-46c0-aad2-45472c8fdf33
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Coordinate that = (Coordinate) o; if (x != that.x) return false; if (y != that.y) return false; return true; }
be1d1a5f-20bb-4833-9190-4368a9652a6c
7
@Override public String getWeaponLimitDesc() { final StringBuffer str=new StringBuffer(""); if((disallowedWeaponClasses(null)!=null)&&(disallowedWeaponClasses(null).size()>0)) { str.append(L("The following weapon types may not be used: ")); for(final Iterator i=disallowedWeaponClasses(null).iterator();i.h...
60aa4454-0dd4-4cd7-9138-70c7ac261259
8
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url; request.setAttribute("active", "manageUsers"); String firstName = request.getParameter("firstName"); String lastName = request.ge...
9ed6487a-4e6b-4d9a-be02-c0fa0fbf6e1f
4
public void go_top() { if(order.length()>0) { if(Idx!=null) { Idx.goTop(); go_recno( Idx.found ? Idx.sRecno : 0 ); } else { Cdx.goTop(); go_recno( Cdx.found ? Cdx.sRecno : 0 ); } } else go_recno(1); }
125b947c-8f5c-4e90-b32d-d173f5053c96
3
private void fixParent(Node parent, Node alipuu, Node p) { // p on poistetun vanhempi if (parent == null) { this.root = alipuu; } else if (parent.left == p) { parent.left = alipuu; } else { parent.right = alipuu; } if (parent != null) {...
0a4198fb-6595-4cef-84de-1e37469dbacb
2
private static void displayConfiguration() { logger.info("Configuration loaded:"); Enumeration<?> e = properties.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); logger.info("\"" + key + "\":\"" + properties.getProperty(key) + "\""); } }
0ae72c46-36f9-4005-b596-67393ed702ab
2
private boolean isLeave(TreeNode node) { if(node.left == null && node.right == null) return true; return false; }
954498ca-9973-46d8-9a59-1368d4abb36d
1
@Test public void setNextFigure() { HashMap<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(KING.getFigureAsString(), 1); FiguresChain figuresChain = new Bishop(figureQuantityMap); FiguresChain figuresChain1 = new Queen(figureQuantityMap); figures...
9c808690-ec11-486c-9509-3908453b9815
3
protected final static String createSignature(String className, Method method) { String signature = className + "." + method.getName() + "("; Class<?> types[] = method.getParameterTypes(); if(types.length > 0) { for(int i = 0; i < types.length - 1; i++) signature += types[i].getName() + ","; signature ...
2aa78094-4e9d-4949-a9a9-cf3a04f39b0d
3
public static void main(String args[]) { Digraph G = null; try { G = new Digraph(new In(args[0])); System.out.println(args[0] + "\n" + G); } catch (Exception e) { System.out.println(e); System.exit(1); } OrderDirectedDFS order = new OrderDirectedDFS(G); System.out.println("Post order o...
11856e0f-2a25-4ee4-9a76-713ef2b04c4f
5
@Override public Class<?> getColumnClass(int columnIndex) { switch(columnIndex){ case 0 : return Integer.class; case 1 : return String.class; case 2 : return Integer.class; case 3 : return Intege...
f2584f92-f5be-4f59-b5cc-3d7b6eda852b
9
public static ArrayList<Device> getDevicesList(String in){ try{ FileInputStream input = new FileInputStream(in); XMLDecoder decoder = new XMLDecoder(input); while(result.size() < 3){ Object obj = decoder.readObject(); int option = getDeviceCode(obj); switch (option) { case 1: if (contain...
9ceb2a58-d767-4853-80b2-446d3b83abaa
3
public QueryDefinition createQuerty(String name, Class<? extends JPanel> panel, Environment env) throws Exception { Node node = null; try { Element queryElem = getOrCreateCollection("queries"); node = Utilities.selectSingleNode(queryElem, "./c:query[@c:name='" + name + "']", this.namespaces); if(node ==...
fbcca847-7e75-4b52-be51-e721be9a5b94
7
private JSONArray readArray(boolean stringy) throws JSONException { JSONArray jsonarray = new JSONArray(); jsonarray.put(stringy ? read(this.stringhuff, this.stringhuffext, this.stringkeep) : readValue()); while (true) { if (probe) { lo...
b7b763a7-9ae9-47b3-84cd-08ab5d5b05d6
1
protected static String processURL(String txt) { int index = txt.indexOf(" "); String url = txt; String label = txt; if (index != -1) { url = txt.substring(0, index); label = txt.substring(index + 1); } return "<a href=\"" + url + "\">" + label + "...
776cf1b6-2612-4e2d-b2f0-dd4156a5c1d3
1
private void mapTasksToFile(List<String> tasks, IFile file) { //first remove existing mappings for this file // List<String> keysToRemove = new ArrayList<String>(); // for (Entry<String, IFile> entry : taskToFileMap.entrySet()) { // if (entry.getValue().equals(file)) { // keysToRemove.add(entry.getKey()); // ...
65f1934f-9682-46ef-bbf8-d3de42f5b3e9
6
public static void printSymbol(Symbol self, PrintableStringWriter stream) { { boolean visibleP = self == Symbol.lookupSymbolInModule(self.symbolName, ((Module)(Stella.$MODULE$.get())), false); Module module = ((Module)(self.homeContext)); if (!visibleP) { if (self.symbolId == -1) { st...
f962ee3d-a150-4fdc-810e-e83633900b12
9
public void paint(Graphics g, TicTacToePlayer playerObj) { Graphics2D g2 = (Graphics2D) g; Font scoreFont = new Font("monospaced", Font.BOLD, 18); Font numberFont = new Font("consolas", Font.PLAIN, 18); Font gameOverFont = new Font("monospaced", Font.BOLD, 25); Color background...
f3122b98-aff7-4c0d-a56a-130dab27f887
5
public Integer[][] paintFill(int x, int y, int color, Integer[][] grid){ if(grid[x][y] == color){ return grid; } else{ grid[x][y] = color; if(x<grid.length-1){ paintFill(x+1, y, color, grid); } if(x>0){ paintFill(x-1, y, color, grid); } if(y>0){ ...
4854d6d6-6db3-4be2-8303-5de4a97765c9
2
public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case CMD_START: game.startGame(); break; case CMD_CONTINUE: game.continueGame(); break; } }
957d23f8-586b-43e8-8cb8-ba7c76d1b7db
8
@Override public void run() { ArrayList<Meld> play, trivialPlay; Boolean playMade; try { startNewGame(); while (!game.isGameOver()) { updateRound(); playMade = false; System.out.println(game.displayGame()); printStatus("Current Hand : " + hand.toString()); if(initi...
f921ff40-b457-46c6-bc63-0ce83d00eb34
1
public void removeAllInferenceListeners() { synchronized (inferenceListeners) { Object[] listenerArray = inferenceListeners.getListenerList(); for (int i = 0, size = listenerArray.length; i < size; i += 2) { inferenceListeners.remove((Class) listenerArray[i], (EventListener) list...
b7beecda-decf-4912-a50c-cec1cb406364
0
protected void onRemoveChannelKey(String channel, String sourceNick, String sourceLogin, String sourceHostname, String key) {}
4afdac29-4f13-452d-818f-281cdecf8b3a
4
private int intTupleToInt(TupleExpression msg) { if (msg.getTupleType().equals("Z")) { return 0; } else if (msg.getTupleType().equals("I") && msg.getElements().size() == 1 && msg.getElements().get(0) instanceof TupleExpression) { return 1 + intTupleToInt((TupleExpression)msg.getElements(...
ca9898b5-d055-47dd-ba30-92d1073024b5
2
public void fillRect(int x, int y, int w, int h, int pix) { assert data instanceof int[]; for (int ry = y; ry < y + h; ry++) for (int rx = x; rx < x + w; rx++) ((int[])data)[ry * width_ + rx] = pix; }
bcded768-399c-4a5c-9df6-30df4a95b276
9
protected final boolean needReload(String shop, int id, int data) { if (cacheTimeout > 0 && data >= 0) { if (id <= 0) { id = data = 0; } if (shop == null) { if (id == 0) { // full db return System.currentTimeMillis() - lastReload > cacheTimeout; } else { // global shop shop = ...
73f93ab7-324f-4627-ae2a-b032bb269bd5
6
public static URL getURL(String link) { if(link == null || link.equals("")) return null; URL url = null; try { url = new URL(link); } catch (MalformedURLException e) { if(!link.startsWith("http://") && !(link.startsWith("https://"))) { link = "...
11debf58-8500-4f7e-9c44-a78e81e57dfa
6
public static void saveGraph(Component apane, JComponent c, String description, String format){ if (apane instanceof EditorPane){ apane = ((EditorPane)apane).getAutomatonPane(); } Image canvasimage = apane.createImage(apane.getWidth(),apane.getHeight()); ...
bcc0afc7-c059-45d5-812d-57089f14ef04
1
public String toString() { try { return this.toJSON().toString(4); } catch (JSONException e) { return "Error"; } }
de595ea4-43db-441a-a572-b900a32f301b
3
private HashMap<String,HashSet<String>> BuildGraph(){ HashMap<String,HashSet<String>> g = new HashMap<String,HashSet<String>>(); for(String str : m_nonterminals){ g.put(str,new HashSet<String>()); } for(Rule cur_rule : m_rules){ if(m_nonterminals.contains(cur_rule...
f305459b-6c23-4f3e-8c9c-971e48039c4f
5
public void setElementConflictConditionToAll(AbstractElement e, Condition c) { if (e == null) throw new NullPointerException("The element is null."); if (c == null) throw new NullPointerException("The condition is null."); RETW(defaultEngineLock, () -> { eleme...
2496bb0f-1ee8-4af2-9325-31d4068ae9c0
9
private static boolean checkAll(int arrIdx, int ch, int charIdx) { int errCnt = 0; for (int j = 0; j < cts.length; j++) { if (j == arrIdx || ct[j].length <= charIdx) continue; int x = (ch ^ ct[j][charIdx]); if (x == 0) continue; if (!((x >= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z'))) { errC...
2a863608-6b0d-4f8a-9249-7fbe5680192d
4
private String readLine() { String line = null; do { if (this.currentThread.isInterrupted()) { this.log.info("MessageReceiver thread is Interrupted"); finishFileReceiverThread(); return null; } try { if (this.inputMessageReceiver.ready()) line = this.inputMessageReceiver.readLine(); ...
597e1215-8907-434d-b9ae-3e80903527cf
6
static protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else ...
8b2858e7-9068-4161-8bf7-aa064963b760
8
final void method3770(int i, Interface11 interface11) { do { try { anInt7598++; if (((OpenGlToolkit) this).aBoolean7815) { method3805(8387, interface11); method3764(-17083, interface11); } else { if (anInt7746 < 0 || anInterface11Array7743[anInt7746] != interface11) throw new Runtime...
0637e854-f193-47cf-bc02-e60a67799497
2
public boolean getLinhaVenda(int id)throws ExceptionGerenteVendas { for (LinhaVenda v : linhas) { if (v.getId()==(id)) { return true; } } throw new ExceptionGerenteVendas("Linha de venda n�o existe!"); }
e035cd9d-d0df-4881-901a-6d2992b1077c
4
public void update(int base, int comp) { if ((base == this.base) && (comp == this.comp)) return; int delta = (this.base > 0) ? base - this.base : 0; if(delta > 0) { UI.instance.cons.out.println("Your "+nm.toUpperCase()+" raised by "+delta+" points"); } this.base = base; this.comp = comp; se...
aa59dda7-af75-4d6a-adf5-4eafc4ed5ed7
6
public static void main( String[] args ) throws LWJGLException { Controllers.create(); Controllers.poll(); for ( int i = 0; i < Controllers.getControllerCount(); i++ ) { controller = Controllers.getController( i ); System.out.println( "(" + i + ") " + control...
9960ae1d-773d-465b-ba81-99b347ab1ff5
3
public static boolean isRedirectCode(int statusCode) { return (statusCode == HttpStatus.SC_MOVED_TEMPORARILY) || (statusCode == HttpStatus.SC_MOVED_PERMANENTLY) || (statusCode == HttpStatus.SC_SEE_OTHER) || (statusCode == HttpStatus.SC_TEMPORARY_REDIRECT); }
fd5c7b1e-d820-4d5a-a376-98bd715b0776
0
public void setComments(List<String> comments) { this.comments = comments; }
024411d4-5973-4cd6-9acf-d06d6cda0a06
1
public boolean equals (Month m) { if (m.getNum()==this.getNum()) return true; else return false; }
cd6d2179-53a5-4870-b5c8-4ead08805ce8
8
@Override public void paintComponent(Graphics g) { super.paintComponent(g); if (screen != null) result = screen.screen; for (int x = 0; x < cellsX; x++) { for (int y = 0; y < cellsY; y++) { switch (result[x][y]) { case 0: g.setColor(Color.BLACK); g.fillRect(x * c...
ac18582f-117d-4302-9140-da3d455a804b
4
public void input(InputRouter.Interaction action) { if (isAlive()) inputAlive(action); else { RespawnMenu.setRespawnOpen(true); switch(action) { case MENU_UP: RespawnMenu.selectionUp(); break; cas...
fc992e8c-0b75-4b94-8d39-f5fe52d5c062
4
public static void diffStuff() { // Get the path of current directory Path currentDir = Paths.get(System.getProperty("user.dir")); // Manipulate the paths to point to specific files. Path pathToFileA = currentDir.resolve("../src/DemoMain.java"); Path pathToFileB = currentDir.resolve("../src/DemoDbManager.ja...
012aef8f-7b73-4310-96c4-6d129582f0a9
2
public static List<Fournisseur> selectFournisseur() throws SQLException { String query = null; List<Fournisseur> fournisseurs = new ArrayList<Fournisseur>(); ResultSet resultat; try { query = "SELECT * from FOURNISSEUR "; PreparedStatement pStatement = (Prepared...
7683a98e-add4-4b2a-b355-a14b0bee5010
3
double purity(String codon, String around) { String pre = around.substring(0, CODONS_SIZE * CODONS_AROUND); String post = around.substring(around.length() - CODONS_SIZE * CODONS_AROUND); if( debug ) Gpr.debug("codon: '" + codon + "'\tAround: '" + around + "'\tpre: '" + pre + "'\tpost: '" + post + "'"); // Coun...
13a33136-97ac-45a5-a6b0-cbcf8614ff28
2
private void fillConceptTable(Bill r, Student s, JTable table) { DefaultTableModel dtm = (DefaultTableModel) table.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { dtm.removeRow(i); } Set<BillLine> billLines = billService.getBillLinesByStudent(r, s); for (BillLine rl : billLines) { Object[] da...
53a90da7-6624-4b2a-b163-1c918a32081b
0
public boolean parkIsNull() { return this.park == null; }
83f39946-7402-413f-a7eb-1c6abeb21a37
6
public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getActionCommand().equals("Cut")) { if (tf != null) { tf.cut(); } else { ta.cut(); } } if (actionEvent.getActionCommand().equals("Copy")) { if (t...
6730a9e6-761c-4f16-8830-8efab385eeca
8
public void SemanticOperationDistribute(int id){ //功能: //根据Id调用对应语义推理模块的处理程序 if(id>=1 && id<100){ reiMainSpace.Process(id); } else if(id>=101 && id<200){ reiImageSpace.Process(id); } else if(id>=201 && id<500){ reiAttributeSpace.Process(id); } else if(id>=1001){ Process(id); } else ...
fa5b2ffa-c641-4111-8e55-f7344286291d
0
public void setPcaSubgru(Integer pcaSubgru) { this.pcaSubgru = pcaSubgru; }
7cb3297a-fce8-4811-a8d5-e41623bccf06
8
public void renderProjectile(int xp, int yp, Projectile p) { xp -= xOffset; yp -= yOffset; for (int y = 0; y < p.getSpriteSize(); y++) { int ya = y + yp; int ys = y; for (int x = 0; x < p.getSpriteSize(); x++) { int xa = x + xp; int xs = x; if (xa < -p.getSpriteSize() || xa >= width || ya < 0...
ee266be6-fb2a-44e3-a518-a36de2a8bd2a
9
@EventHandler public void onSignInteract(PlayerInteractEvent e){ Player player = e.getPlayer(); if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.hasBlock() && e.getClickedBlock().getState() instanceof Sign){ Sign sign = (Sign) e.getClickedBlock().getState(); if(sign.getLine(0).equalsIgnoreCase(ChatColor.D...
768da15f-54c4-4c4d-86e3-4f068b3b21a5
4
public String giveRandomCard() { String nameOfCard = null; int w = random.nextInt(52); if (deck[w].cardValue == 1) { nameOfCard = "A" + deck[w].suit; } else if (deck[w].cardValue == 11) { nameOfCard = "J" + deck[w].suit; } else if (deck[w].cardValue == 12) { nameOfCard = "Q" + deck[w].suit; ...
98351d4b-839d-4a45-a8b0-72802a467ee3
3
private SongLogger() throws LogException { SongLogger.log= Logger.getLogger(SongLogger.class.getName()); FileHandler fh= null; try { fh = new FileHandler("LogSong " + new Date().toString()); SongLogger.log.addHandler(fh); SongLogger.log.setUseParentHandlers(false); } catch (SecurityEx...
e3d3bd6b-bdce-4f90-b4a6-8610cb5ad9ea
2
private static double getDScale(int factor) { if (factor < SCALES.length) { return SCALES[factor]; } else if (factor < 2 * SCALES.length) { return SCALES[factor - SCALES.length] * (double) SCALES[SCALES.length - 1]; } else { throw new IllegalArgumentException("Too high factor"); } }
850f14c4-c7a0-4276-879e-189fad5f7a60
2
public void updateLayerBox() { int j = 0; removeAll(); MainImagePanel mip = MainImagePanel.getInstance(); for (BufferedImage i : mip.getLayers()) { BufferedImage newi = new BufferedImage(LAYER_ICON_SIZE, LAYER_ICON_SIZE, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = newi.createGraphics(); g2d.drawImage...
a87ddf88-c0b1-4e7a-97bd-3265f63190e9
9
@SuppressWarnings("unchecked") public static double mean(Function w, HashSet<Integer> id, boolean inclusion, double threshold, boolean above) { double result = 0.0; int counter = 0; for (Feature f : (LinearFunction<Feature,FeatureVector>) w) { if (((inclusion && id.contains(f.identifier())) || (!inclusion...
91581e48-5cc4-49c2-b37e-1550c10af251
4
public ArrayList<Object> getInfoFromPDB(ArrayList<String> pdbFile) { //empty at beginning ArrayList<Atom> atomList = new ArrayList<Atom>(); CartesianCoord coords; String atomType, pdbResNum; //default double value is 0 double tempFact, meanBFactor, std, totalBFactor=0, totalSquaredBF...
4006cfc2-a589-4d3c-b7bd-1899ba817534
1
@Override public synchronized boolean saveResult(ProgressReporter reporter) throws IOException, InterruptedException { Path p = Paths.get(saveTo, getFSSafeName(getTitle())); Files.createDirectories(p); if (WebDownloader.fetchWebFile(coverUrl, getCoverSavePath(), reporter) != 0) { reporter.report("cover ...
4b0a46fd-1329-4622-a122-4791801ba7bd
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...
a315512e-fc6c-4e1e-a777-2b36767520b4
6
public synchronized void forward(int gameID, String data) { // hier wird der String in seine Einzelteile zerlegt // (Zieladresse, Name, Nachricht) try { StringTokenizer ST = new StringTokenizer(data); String player = ST.nextToken(); String name = ST.nextToken(); String msg = data.sub...
29a37de7-c464-4f4b-b1a0-df5fa8e4ccc5
7
private void loadAvalibleData() { // fill cbKompetens cbKompetens.removeAllItems(); try { ArrayList<String> komptemp = DB.fetchColumn("select kid from kompetensdoman"); ArrayList<Kompetensdoman> komp = new ArrayList<>(); for (String k : komptemp) { ...
ba8bf082-6bff-490f-b327-fd65e6e4b134
7
public MacroCreation() { temp_body = new ArrayList<Code>(1); add(pB, BorderLayout.SOUTH); add(pL, BorderLayout.CENTER); add(mBL, BorderLayout.WEST); add(mN, BorderLayout.NORTH); // When user clicks Save Button mN.ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEv...
f3352634-e3c7-4ed1-9fa9-0ebdf35d8b2d
3
@Override public void stop(boolean success) { if (connection != null) { try { if (success) { connection.commit(); } else { connection.rollback(); } } catch (SQLException e) { System.out.println("Could not end transaction"); e.printStackTrace(); } finally { safeC...
77b44495-4f9e-4e2e-8b29-f82e1b85f530
6
public void subscribeUsersFinished(int type) throws InvalidSubscriptionException, IOException { usersHaveData = 1; String tmp; final int nonce; if (type == FINISHED_DEC_HAND) { tmp = HAVE_MY_HAND; nonce = SigService.HAVE_HAND_NONCE; } else if (type == FINISHED_DEC_COM_CARDS) { tmp = REQUEST_RAW...
7a5d711b-85b9-45da-babb-b456fb2d3144
0
@Override public void run() { plateau1.run(); plateau2.run(); }
a9be9712-fae3-428a-ba36-b2d447856b05
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://downl...
4fe7c955-2feb-4ac3-a06e-c44e28af2dfa
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } BigramModel<T,K> other = (BigramModel<T,K>) obj; if (key == null) { if (other.key != null) { return false; } } els...
33b43ba5-bd7b-4d27-9dbd-fdc827fee8eb
0
public void setStep(int step) { this.step = step; }
f6cf1267-e0c3-42f4-8375-3c042c724160
2
public int[] twoSum(int[] numbers, int target) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); int[] result = new int[2]; int n = numbers.length; for(int i = 0; i< numbers.length; i++ ){ if(map.containsKey(target-numbers[i])){ result...
a2e2c00a-0387-46fc-b2f3-d0d82a5a04e1
7
public static void main (String[] argv){ System.out.println("Starting mapfold controller system"); try{ String workerConfPath = "conf/server_conf.json"; String jobConfPath = "conf/job.json"; if(argv.length > 0){ workerConfPath = argv[0]; }...
e8a4896e-394c-4754-8600-f1f35c4fef8b
1
public void shots(){ if (bullet.isShot()){ Bullet bullet1 = new Bullet(); bullet1.setX(paddle.getX() + (paddle.getWidth() - bullet1.getWidth()) / 2); bullet1.setY(paddle.getY() + (paddle.getHeight() - bullet1.getHeight()) / 2); bulletList.add(bullet1); } }
1abb8c64-07e0-421b-be27-9abed5d8150d
6
public static void validateDirection(Direction direction) throws TechnicalException { if (direction == null) { throw new TechnicalException(MSG_ERR_NULL_ENTITY); } if ( ! isStringValid(direction.getName(), DIRECT_NAME_SIZE)) { throw new TechnicalException(NAME_ERROR_MSG);...
c9f5d4c7-44da-432f-b1f4-84a8f0b7f86c
1
@Override public Object fromMessage(Message message) throws MessageConversionException { try { Map data = converter.toMap(new String(message.getBody(), "UTF-8")); return new MyCustomEventApplicationEvent(this, data); } catch(IOException e) { throw new MessageConve...
cb206728-c809-46e9-a213-accb03a0d0c5
9
private Method findActionMethod(Class<?> type, String methodName) { List<Method> methods = new ArrayList<Method>(); Action detail = null; for (Method method : type.getDeclaredMethods()) { if (!isMethodValid(method, methodName)) { continue; } Ac...
cc4d7d75-a945-434b-b40b-55efc5e45bcd
0
public ParkException(String msg) { super(msg); }
6ad317b3-961f-457d-8641-8560c36d7ad9
5
private void endGame(int i) { isInGamePlay = false; for (Cell[] cellArray : cells) { for (Cell cell : cellArray) { cell.reveal(); } } if (listener != null) { if (i == -1) listener.gameFinished(false); else ...
b374cb57-6db2-47d8-ae5e-9c5d1f4557dd
9
public boolean processXML(File file,Document doc,boolean forceRefresh) throws Exception { Element root=doc.getDocumentElement(); List<FragmentDirective> fragments=new ArrayList<FragmentDirective>(); scanComments(root,fragments); MessageDigest digest=MessageDigest.getInstance("SHA-1"); ...