method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1d675b36-3028-446a-a440-d7a46c820cf9
9
private void BtGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtGravarActionPerformed if (camposobrigatoriospreenchidos()) { if (JOptionPane.showConfirmDialog(null, "Tem certeza que deseja realmente Gravar os dados deste funcionário?", "Confirmar", JOptionPane.YES_NO_OPTION...
d52742ff-a094-4491-8ab5-dfdbbf30706d
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target=mob; if(mob.isInCombat()) { mob.tell(L("You can't meditate while in combat!")); return false; } if(!CMLib.flags().isSitting(mob)) { mob.tell(L("You must be in a sitt...
6bd1456c-6d7d-47be-8101-1fa2b9f99e17
0
public void setName(String name) { Name = name; }
5934b736-e29a-41cf-b9f5-e176f4de6304
5
private void getSaisie(boolean decrypt) { ISaisie s=new Saisie(this.menu,decrypt,this); while(s.estEnCours() && !this.stop) { try { Thread.sleep(100); } catch (InterruptedException e) { } } s.masquer(); if(!this.stop) { this.key=s.getKey(); this.m=s.getMessage(); this.typeCode=s.getTypeC...
c5af21e7-bee8-433c-b880-8d79438be146
3
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((endDate == null) ? 0 : endDate.hashCode()); result = prime * result + ((startDate == null) ? 0 : startDate.hashCode()); result = prime * result + ((carType == null) ? 0 : carType.hashCode()); return resu...
4651dde8-4caa-448d-a883-e9d5b103fa1d
4
public void Show() { System.out.print("["); for (int i = 0; i < _ListaDeObjetos.size(); i++) { if(_ListaDeObjetos.get(i) != null) { System.out.print(_ListaDeObjetos.get(i).getNombre()); if(i + 1 < _ListaDeObjetos.size()) ...
9bd45c0d-255b-472e-8249-d50078ee29c7
7
private boolean unzip() { URL url = null; try { url = new URL(src); } catch (MalformedURLException e) { e.printStackTrace(); return false; } if (EventQueue.isDispatchThread()) page.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (Zipper.sharedInstance().getProcessMonitor() == nul...
ad37f9a7-b642-4aef-832e-5ec5d6208a3a
2
private void moveAllAnimals() { for (int i = 0; i < animalFactory.getQuantityOfVictims(); i++) { animalFactory.getVictim(i).move(); } for (int i = 0; i < animalFactory.getQuantityOfPredator(); i++) { animalFactory.getPredator(i).move(); } }
241f1354-82bb-486a-8dfd-66753dda5164
2
public void buildMatrix() { this.getSize().setWidth(this.RowCells * this.CellSize.getWidth()); this.getSize().setHeight(this.Rows * this.CellSize.getHeight()); this.Matrix.clear(); int row = 0; int z = 0; for(int i = 0; i < Cells; i++) { this.Matr...
2f82e4a6-2f05-4701-ac8b-e3ce483570e5
2
public Button(String text) { this.text = text; setBounds(0, 0, text != null ? Text.getDefault().getWidth(text) : 1, text != null ? Text.getDefault().getHeight(text) : 1); addMouseListener(new DefaultButtonAdapter()); }
65eac4a7-9018-42f0-b1c0-eae0dd8f15d2
0
public static void collapseToParent(JoeTree tree) { TextKeyListener.collapseToParent(tree.getEditingNode()); return; }
d9f3ab6a-1c3e-499b-9da6-2d70e80900f1
7
private int countMatadors() { // If it's a null game, we don't have multipliers, skip this. if(this.gameType.getGameType() == GameTypeOptions.GameType.Null) return 0; // Create our trump card list. List<Card> trumpList = new ArrayList<Card>(); trumpList.add(new Card(Card.CARD_SUIT.CLUBS, Card.FACE_VALUE...
c7766825-b382-4839-8bf4-a2b4bd5de8c4
9
@Override // #TODO: Bug when clicking, sometimes requires a double click? public void mouseClicked(MouseEvent e) { GridLabel g = (GridLabel) e.getSource(); if(currentlyClickedLabel != null && g == currentlyClickedLabel) // Clicked the same button, deselect { g.setBackground(Color.LIGHT_GRAY); GameWindow.r...
3cb7e063-0290-489e-bc54-bf0edd61aae4
4
public static void makeAMove(HanoiGame game, int pileA, int pileB) { int sizeTopPileA = game.getCurrentSituation().get(pileA).seeLast() .getSize(); int sizeTopPileB = game.getCurrentSituation().get(pileB).seeLast() .getSize(); if (sizeTopPileA != 0 && (sizeTopPileB == 0 || sizeTopPileA < sizeTopPileB)...
4360cdaf-5726-495c-9b30-107a915b053e
4
public void die() { Deer prev = null; Deer curr = null; // remove this deer from the linked list of deer if (head == this) head = head.next; else { prev = head; curr = prev.next; while (curr != null && curr != this) { prev = curr; curr = prev...
8423f26d-cee7-4d83-89e4-dbd736cf4ab3
0
public String toString() { return name; }
1380f18b-1eaa-430a-a6f7-575158eb9699
0
@Override public PermissionType getType() { return PermissionType.USER; }
8a30ab3c-f8f5-4453-adac-30f2b1c884d3
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...
cf265de6-feaf-4474-abff-6222e0106c9e
9
public int getProbableDirectionCode(final String theDir) { if(theDir.length()==0) return -1; final String upDir=theDir.toUpperCase(); for (final Object[] element : DIRECTIONS_FULL_CHART) { if((element[0].toString().equals(upDir)) &&(((Integer)element[1]).intValue()<NUM_DIRECTIONS())) return ((Inte...
1699cc1b-b6ad-45e4-9ad5-7cd5d40a43ab
7
@Override public void unInvoke() { if(canBeUninvoked()) { if(affected instanceof MOB) { final MOB mob=(MOB)affected; if((buildingI!=null)&&(!aborted)) { if(messedUp) { if(activity == CraftingActivity.LEARNING) commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",...
6b24ab7a-409a-4dcc-aa04-dad251925f5c
3
public T get(int i){ T dato = null; if(i >= 0){ Integer contador = 0; Nodo<T> nodoQ = this.inicio; while(nodoQ != null){ if(i == contador){ dato = nodoQ.getInfo(); break; }else{ nodoQ = nodoQ.getLiga(); contador++; } } return dato; }else{ return dato; } ...
97d9c4b4-5a4b-472b-ace3-ca07a0cc9aca
5
@Override public int getAge() { String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); /* save all arguments into an array */ Object[] args = new Object[0]; Class<?>[] argsType = new Class<?>[0]; int ret = 0; try { ret = (Integer)super.invokeMethod(methodName, args, argsType);...
66afeba1-3bfe-47b3-8bf7-aef6fe3a0e90
0
private final void capLinePath() { g.draw(linePath); // Dump the path to the graphics... linePath.reset(); // Clear the path... linePath.moveTo((float) currentTurtle.position.getX(), (float) currentTurtle.position.getY()); // We've started anew! }
af416922-402d-4cd7-ae09-e3ec05c45e17
7
private void GoToRestaurant() { state = AgentState.WaitingInRestaurant; print("Doing GoToRestaurant"); switch(name) { case "0.00": money = 0.00; break; case "5.00": money = 5.00; break; case "10.00": money = 10.00; break; case "15.00": money = 15.00; break; case "20....
ff0f36b0-7f59-4251-80ab-fc2b28d91bcb
9
private boolean checkHorizontal(Cell origin) { int count = 1; Cell next = null; Position pos = origin.getPosition(); // Count coins to the left if (pos.getCol() > 0) { // First cell to the left next = getCell(pos, 0, -1); // Continue left until the cell is empty or placed by another player ...
ac861925-b9c8-45bb-ba43-a255c6ab794d
3
@Override public void mouseEntered(int mx, int m, GUIComponent component) { if (component instanceof CardComponent && component.belongsTo(playersComponent) && ((CardComponent) component).getAssociatedPlayer() instanceof HumanPlayer) { setHoverCardComponent((CardComponent)component); } ...
6a9d11b4-1d73-4524-b179-9c7106896671
7
public void renderTile(int xPos, int yPos, Tile tile) { xPos -= xOffset; yPos -= yOffset; for(int y = 0; y < tile.sprite.size; y++){ int ya = y + yPos; for(int x = 0; x < tile.sprite.size; x++) { int xa = x + xPos; if(xa < -tile.sprite.size || xa >= width || ya < 0 || ya > width) break; if(xa < ...
02f21cdf-fc2c-463b-8aa5-c612aeaac998
3
@Override public boolean onMouseDown(int mX, int mY, int button) { if(super.onMouseDown(mX, mY, button)) { return true; } for(ShopItemButton sib : itemSlots) { if(sib.onMouseDown(mX, mY, button)) { return true; } } ...
fee5eed2-b49c-4ad6-89a3-211233a358e3
3
static public boolean deleteDirectory(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete(); } } } return (path.delete()); }
2df85475-c926-49c5-b87b-3cd33e8eb027
6
public static void main(String a[]) throws SocketException, IOException { String hostName = new String(""); int port = 6000; String team = new String("Krislet3"); String prototype = "Krislet"; try { // First look for parameters for( int c = 0 ; c < a.length ; c += 2 ) { if( a[c].compare...
d7a15f3a-c46e-428b-b777-aff52278082a
5
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
b23716e3-0772-4f1d-af0d-30aac0a5b049
9
public int getTeamPointsObtained(PlayerModel player, PlayerModel partner) { int combinedBid = player.getNumBid() + partner.getNumBid(); int combinedTricks = player.getNumTricks() + partner.getNumTricks(); boolean BurntMellow1 = player.isBurntMellow(); boolean BurntMellow2 = partner.isBurntMellow(); int sco...
1d469cb2-702d-4cf1-9739-58cac4a9c28c
7
private void jButtonUpdateFornecedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUpdateFornecedorActionPerformed // UPDATE FORNECEDOR -> DEPOIS DE EDITAR String nome = jTextFieldNomeFornecedor.getText(); String morada = jTextFieldMoradaFornecedor.getText(); S...
3105ae43-9ca6-4c06-a6a7-e0a20c49dc0e
1
public static ArrayList<Point> reverseArray(ArrayList<Point> array) { ArrayList<Point> newarray = new ArrayList<Point>(); for (int c = array.size() - 1; c >= 0; c--) { newarray.add(array.get(c)); } return newarray; }
52623a89-20bc-49a0-a799-890bc4f0b20d
6
private static final int method3963(int i, Class251 class251) { if (i != 594) return 7; if (class251 == Class135_Sub2.aClass251_4835) return 1; if (class251 != Class239_Sub18.aClass251_6030) { if (class251 != Class348_Sub40_Sub38.aClass251_9477) { if (Class57.aClass251_1051 == class251) return 4...
9094f3bd-7f75-4643-a335-904fcfad50bd
1
private void runHideZigZag(int array[][]) { convolution = zigZag.getHideZigZagArray(array, SIZE); for (int i = 0; i < STEP * STEP; i++) { arrayForZigZag[position++] = convolution[i]; } }
f79d8057-c935-4b58-b350-d02c748080cc
0
public final int getN() { return n; }
dbbb46ed-15be-4474-ad59-d873e2f112e6
3
public String getSortConfig() { StringBuilder buffer = new StringBuilder(); int count = mColumns.size(); boolean hasSort = false; buffer.append('S'); buffer.append(CONFIG_VERSION); buffer.append('\t'); buffer.append(count); for (int i = 0; i < count; i++) { Column column = getColumnAtIndex(i); in...
1015be0b-973c-4f5c-bb65-13dd00c1a21d
2
@Override public void in() throws Exception { if (data == null) { throw new ComponentException("Not connected: " + toString()); } Object val = data.getFieldValue(); // fire only if there is a listener if (ens.shouldFire()) { DataflowEvent e = new Dataf...
e6b7d734-be2f-4981-a985-8591969f682b
3
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this); if ((clipboardContent != null) && (clipboardContent.isDataFlavorSupported(DataFlavor.stri...
194ffd74-b8bb-4544-a672-4ffae9c81959
0
@Override public void windowDeiconified(WindowEvent arg0) { }
4309311c-b657-4103-a552-519fb5f1d030
0
@Id @Column(name = "PRP_MOA_CONSEC") public Integer getPrpMoaConsec() { return prpMoaConsec; }
467e9963-0b1f-491a-80ec-2f51328b0015
6
public static String getALError(int err) { switch (err) { case AL_NO_ERROR: return "AL_NO_ERROR"; case AL_INVALID_NAME: return "AL_INVALID_NAME"; case AL_INVALID_ENUM: return "AL_INVALID_ENUM"; case AL_INVALID_VALUE:...
113ee77c-5402-4219-a0c6-be783ce5f89c
8
public void sendAssignment(File file, String assignment, String course, String vfykey) throws IOException { if (!open) { try { connect(); } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnrecoverableKeyException e) { // TODO Auto-generated...
6cc2b490-418f-4832-8534-3df3b4f3e85d
6
@Override public void analyze(){ try { for(int i=0; i<numFiles; i++){ File f = files.get(i); InputStream traingInputStrem = new BufferedInputStream(new FileInputStream(f.getPath())); trainSequencer.setSequence(traingInputStrem); Sequence trainSequence = trainSequencer.getSequence(); Tr...
d92eede2-b2f7-45aa-9b3a-64aa655f735d
4
public static void displayStudent(int mode) { if (FileReadService.sList.isEmpty()) { System.out.println("There is no Students !"); } else { System.out.println("Which student do you want to choose ?"); int i; for (i = 0; i < FileReadService.sList.size(); i++) { System.out.print(i + ":(" + FileR...
108cfb7d-7025-486f-bd30-8d1bb59b9134
7
public static double getMetric(Evaluation eval, int metric_index) { switch (metric_index) { case METRIC_ACCURACY: return eval.pctCorrect(); case METRIC_RMSE: return 1.0 - eval.rootMeanSquaredError(); case METRIC_ROC: return eval.areaUnderROC(1); //TODO - is 1 right? case METRIC_PRECISION:...
2abfd2ee-bbde-4bf3-8d9f-55893921a6a3
0
public void setDocumentInfo (DocumentInfo someDocInfo) { docInfo = someDocInfo; }
a0cccbd2-dee1-41d6-811f-d8bff8cabb60
0
@Override protected int processHeader (byte[] header) { // TBD //if (Outliner.DEBUG) // System.out.println ("\tStan_Debug:\tPdbSPReaderWriter:processHeader"); } return SUCCESS ; } // end protected method processRecord
1cca4485-e113-4e17-a1ef-8cedfca55a98
1
@Override public String toString() { return (e.getAttributeValue("name") != null ? e .getAttributeValue("name") : e.getName()); }
a86abeb1-82b3-42f4-a8f8-aec80c202724
1
public void stopAllSounds() { for (Clip sound : managingSounds) { sound.stop(); } }
08c7c86f-e5b3-4dd1-a104-5b06b58de503
4
* @return - Position on the board to drop piece */ public Point makeAIMove(ConnectFourBoard board) { Random r = new Random(); int maximum = 0; ArrayList<Point> m_MaxChoice = new ArrayList<Point>(); int arrayPosition; /** Set maximum to be the maximum chain ...
5d376dc1-2fad-46ff-818c-b4705cdce878
9
@Override // Buscar todos los alojamientos disponibles public int seleccionarUsuarios(JTable pTable){ Connection conn = null; PreparedStatement stmt; ResultSet rs; try{ conn = SQLServerDAOFactory.createConnection(); stmt = con...
2bf519a0-2f67-4224-989a-e10c36304227
9
public void run() { while(isWriter) { int i; int j; synchronized(this) { if(buffIndex == writeIndex) try { wait(); } catch(InterruptedException _ex) { } if(!isWriter) return; j = writeIndex; if(buffIndex >= writeIndex) i = buffIndex - writeIndex; ...
81d483fb-5023-48d6-8973-cc2b8d8d4162
4
private void setBoard(String board){ boolean test = false; if (test || m_test) { System.out.println("Drawing :: setBoard() BEGIN"); } gameBoardGraphics.SetBoard(board); if (test || m_test) System.out.println("Drawing::setBoard() - END"); }
a98ca663-fbc3-4f1c-b04c-f4f4946d7b96
8
public Token getNextToken() { if (m_characterIterator == null) { return ExceptionHandler.getInstance().throwException(Exception.NO_INPUT_STREAM, ExceptionStrength.STRONG); } else { while (m_characterIterator.hasNext()) { if (CharacterUtilities.isWhitespace(m_characterIterator.peek())) { m_characterIt...
17bb1629-0b28-4335-8fec-b8cc06adc1ec
4
@Override public Event next() { String input = null; try { input = br.readLine(); } catch (IOException e) { e.printStackTrace(); } //alters state if(input == null || input.equals("")){ return new DefaultState(as); } if(input.equalsIgnoreCase("add")){ return new AuctionCreateState(name, ...
7f4302f0-310a-46e5-9491-2d7e30628c02
6
public static String getIpClient() throws UnknownHostException, SocketException { String interfaceRede = "wlan0"; String meuIp = null; Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface ...
da087912-dbdf-4631-a632-a9e4d37cc43a
7
public Point[][] getPointArray(int x, int y){ Point[][] res = new Point[WORD_LENGTH][(int)Math.pow(8,WORD_LENGTH)]; res[0][0] = points[x][y]; for (int i = 0; i < WORD_LENGTH-1; i++){ for (int j = 0; j < (int)Math.pow(8,i); j++){ for (int l = 0; l < 8; l++){ ...
f6a3e7a6-2289-4e9e-9318-fae9ed61d1ed
5
public static void createProfessor() { System.out.println("=== Creation of a professor ==="); System.out.print("Give a name: "); String name = ""; while (name.equals("")) { Scanner scName = new Scanner(System.in); name = scName.nextLine(); } System.out.print("Give a first name: "); String forename =...
c3edfd73-1e9f-4200-a3b7-9f1ad50ebc7a
8
@Override protected void execute(CommandSender sender, String Command, List<String> list) { this.init(sender); if (Command.equals("creategp")) { if (this.getGP(list.get(0)) != null) { this.reply("Es gibt bereits einen GlobalPrice mit der ID"); return; } if (list.get(1).matches("\\d*")) { this...
5afad748-0282-4303-bcf8-8c746d0bd926
6
public void setMoodleNoteField(String nodeName,String content) { if (nodeName.equals("clientnoteid")) if (!content.isEmpty() && content!=null) setClientNoteId(content); if (nodeName.equals("noteid")) setNoteId(Integer.parseInt(content)); if (getNoteId()==-1) if (nodeName.equals("errorMes...
4c296a2b-956d-4903-b260-999397eee55f
5
public Set<LinkDigest> addAllLinks(final Set<LinkDigest> all) { for (Block block : mBlocks) { all.addAll(block.getDigests()); } if (all.contains(LinkDigest.NULL_DIGEST)) { throw new RuntimeException("Assertion Failure: NULL_DIGEST in blocks"); } for (Roo...
a00e0821-2aa2-40ac-952b-7f77ad8e726a
1
public static long readLong() { long x = 0; for (int i = 0; i < 8; i++) { char c = readChar(); x <<= 8; x |= c; } return x; }
5f94bfec-4c86-4f52-8961-ef7a6e15c4d0
6
public static void createFile(String content, String urlPath) { /* ָurl */ String[] elems = divUrl(urlPath); StringBuffer path = new StringBuffer(); File file = null; for (int i = 1; i < elems.length; i++) { if (i != elems.length - 1) ...
1e9975be-65de-4361-86b1-3ec597691174
1
public void addAll(String[][] L) { data = new String[L.length][4]; for (int i = 0; i < data.length; i++) { data[i][0] = L[i][0]; data[i][1] = L[i][1]; data[i][2] = L[i][2]; data[i][3] = L[i][3]; } }
82e8b242-22a8-4158-ac47-c495ecd56633
9
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); // if it is the Logout button if (o == logout) { client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, "")); return; } // if it the who is in button if (o == whoIsIn) { client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""...
1825be74-3d28-49a0-8970-aed111b7a683
8
@Override public ValidationResult validate(Game game) { int allowedQuestionsCount = getQuestionsCount(); int allowedAnswersCount = getAnswersCount(); int allowedCorrectAnswersCount = getCorrectAnswersCount(); List<Question> questions = game.getQuestions(); if (questions == n...
663e1c09-bdff-48b7-86c0-2d3bacfcae4b
5
public void run() { Map<String, Term> solution; // Variable X = new Variable("X"); // Query q2 = new Query("child_of(joe,ralf)"); System.err.println("child_of(joe,ralf) is " + (q2.hasSolution() ? "provable" : "not provable")); new Query("sleep(?)", new Term[] { new org.jpl7.Integer(delay) }).hasSolution(); ...
8016053d-f85b-43d6-867a-cc2f7b2cee56
7
@Override protected void mutate(Individual indiv) { Sudoku sudoku = (Sudoku)indiv; Sudoku best = null; Random r = new Random(); for(int i=0; i<numOfTries; i++){ //choose a row int row = r.nextInt(9); //choose 2 cols int c1= r.nextInt(9); int c2 = r.nextInt(9); if(c1==c2 || sudoku.r...
fd62a056-b366-46e7-ba15-66cf59211529
2
private String scanString(String listData) { StringBuilder cadenafinal = new StringBuilder(); Scanner innerScan = new Scanner(listData); boolean firstPass = true; while (innerScan.hasNext()) { if (firstPass) { cadenafinal.append(" ").app...
6104e239-8e94-445f-a1b6-8f7f81617a8c
8
public static MilkyWay getMilkyWay(List<String> filePathList) throws IOException { MilkyWay milkyWay = new MilkyWay(); int i = 0; Double ngp = Math.toRadians(27.4); for (String filePath : filePathList) { List<Coord> dataSet = new LinkedList<>(); try ( ...
0b683167-3d22-4481-a66b-dac1f6546c8e
6
public static List<String> getStructures(CyNetwork network, CyIdentifiable id) { String pdbColumn = getPDBColumnName(network); if (pdbColumn == null || pdbColumn.length() == 0) return null; if (!network.getRow(id).isSet(pdbColumn)) return null; List<String> columnListString = null; if (network.getDefa...
2ae47c5a-84c0-4cfd-ab36-8d17ebcff708
8
@Override public Auction[] search(String criteria) { Predicate<Auction> cp = null; ArrayList<Auction> theSearch = new ArrayList<Auction>(); Stack<Predicate<Auction>> predicateStack = new Stack<Predicate<Auction>>(); Stack<String> operatorStack = new Stack<String>(); Predicate<Auction> firstSearchString...
adf0fa5a-d7ea-4e44-9198-5ef9f2dc8c84
2
public Format getFormat() throws SQLException { if (format == null && formatNumber > 0) format = GetFormats.create().getFormat(formatNumber); return format; }
c6ea869e-f5f9-41bc-b8f1-a2fa300f7c1b
7
public static void main (String[] args) { Wordsmith wordsmith = new Wordsmith(); // Choosing the number of topics is tricky. Trial and error is not a bad way necessarily... // Too few topics and it will be more summarization, but not capture a lot of the nuances. // Too many topics, and they can become...
b8124115-edb4-4351-9f3c-050e6470ad37
1
@Override public void fixSubtree(String footpath, String subtreePrefix, RepairIssue[] issues) { Host[] failedHosts = new Host[issues.length]; for (int i = 0; i < issues.length; i++) { failedHosts[i] = Deserializer.deserializeHost(issues[i].failedPeer); } delegate_.fixSubt...
695e42ef-029e-416f-95bc-2d43cfa0f4ae
8
public void run() { if (DEBUG) log("Now running TaskEdit Command"); if (taskViewsToUpdate != null) { if (DEBUG) log("currentState completed? " + currentState.isCompleted()); if (DEBUG) log("newState completed? " + newState.isCompleted()); if (DEBUG) log("Update currentState to newState")...
bccb656a-d987-40ce-9a7d-d73940fb51e2
2
public void setHLevel(int hLevel) { if(hLevel > 0 && hLevel < 6) { this.hLevel = hLevel; } else { System.err.println("hLevel invalid"); this.hLevel = 5; } }
eb0c799b-015e-4a34-8ec4-41aece51a690
1
private URL encodeurl(URL raw) throws IOException { /* * This is "kinda" ugly. It is, actually, how the Java documentation * recommend that it be done, though... */ try { return (new URL(new URI(raw.getProtocol(), raw.getHost(), raw.getPath(), raw.getRef()).toASCIIString())); } catch (URI...
2fdc39a3-c1ed-4dac-90ef-88a5c2b25c06
3
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!plugin.hasPerm(sender, "warp", false)) { sender.sendMessage(ChatColor.YELLOW + "You do not have permission to use /" + label); return true; } if (args.length == 0) return false; Player player =...
1abfbd73-f27a-422a-ab7a-40e2c2b49004
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...
7f7a9115-96a2-42db-ab97-126db6f04efc
3
public boolean isMenuKey() { switch(keyCode) { case VK_SHIFT: case VK_CONTROL: case VK_ALT: return true; } return false; }
ae48122e-0391-47a1-89b1-7c204d293382
0
public void setItemNumber(String itemNumber) { this.itemNumber = itemNumber; }
4a529093-364a-4ebe-b352-c0f2c59af9cd
5
public String performAddition(String tal1, String tal2) { StringBuilder sBuilder = new StringBuilder(); int lenght = tal1.length(); tal2 = matchLenght(lenght, tal2); int carry = 0; int i = 0; if(tal2.length() > lenght) { lenght = tal2.length(); tal1 = matchLenght(lenght, tal1); } // Reverse ...
87e30404-5096-440e-9660-05eded55be18
0
@Test public void getVertexSetNeigourhoodTest(){ VertexSet s = new VertexSet(); s.addVertex(city_graph.getCity(6)); VertexSet v = city_graph.getVertexSetNeighbourhood(s); assertTrue(!v.containsID(6)); }
a5d5b501-be16-4a3f-b027-3d84638265c3
4
public float move(float amtXIn, float amtYIn) { if (amtXIn != 0.0f && amtYIn != 0.0f) { throw new IllegalArgumentException( "Can only move in 1 dimension per call"); } structure.remove(this); double amtX = (double) amtXIn; double amtY = (double) amtYIn; CollisionComponent c = (CollisionComponent) g...
45d1996a-9d10-4b85-a7e7-461472d2bc39
7
public Vector<Block> selectBlocks(Vector<Block> originalPopulation) { Vector<Block> fitBlocks = new Vector<Block>(); //first, calculate the sum of e^(fitness of each of the blocks) double fitnessSum = 0.0; for(Block b : originalPopulation) { fitnessSum += Math.exp(b.getFitness()); } //second figure out...
4f9a298b-4d48-44ba-a78e-6d0ecf19ba8a
1
public void guardarDatos(){ try { FileOutputStream fileOut = new FileOutputStream("usuario.ser",true); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(this); out.close(); fileOut.close(); System.out.println("datos guardados en usuario.ser"); }catch (IOException i) { ...
645f4f08-329b-437a-a409-a9f9a2457943
5
public void setState(int state) { this.state=state; // Change the status label if (state==1) theApp.setStatusLabel("Start Tone Hunt"); else if (state==2) theApp.setStatusLabel("Sync Hunt"); else if (state==3) theApp.setStatusLabel("Sync Found"); else if (state==4) theApp.setStatusLabel("Decoding"); else i...
33f3470b-4b4c-4ec5-8f4d-2973c93b5278
6
public void draw(Graphics2D g) { g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); g.drawImage(board, 0, 123, null); synchronized(model) { if (model.done()) { if (model.hasWon(model.CROSSES)) { drawMessage(1, g); } if (model.hasWon(model.CIRCLES)) { drawMessage(3, g); } } else { dr...
4bf008b5-7486-4be2-b00a-a624a407bbc9
0
public String getURLString() { return assembleURL( this.host, this.port, this.userInfo, this.authority, this.protocol, this.path_list, this.query_list, this.fragment ); }
4ad4c67b-0ca8-420a-8de1-72aaaee9046b
2
public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); HTTPTokener x = new HTTPTokener(string); String token; token = x.nextToken(); if (token.toUpperCase().startsWith("HTTP")) { // Response jo.p...
62e505a9-3927-4293-96ef-dd3723b9a4c7
5
public ServerReply getReply(HttpPost post) { ServerReply reply = null; HttpClient client = this.getClient(); try { log.finest(String.format("[%s] Executing POST.", post.getURI())); HttpResponse resp = client.execute(post); try { HttpEntity entity = resp.getEntity(); if(resp.get...
2a9ee275-42bb-465f-8ed2-35657a4707ca
8
@SuppressWarnings("resource") public void loadPak(File file, boolean spawnPlayer){ pakFile = file; String thisfile = "properties"; try { ZipFile zipFile = new ZipFile(file); ZipEntry zipEntry = zipFile.getEntry(thisfile); InputStream in = zipFile.getInputStream(zipEntry); BufferedReader input = new B...
91368417-9bca-4899-8423-b1e949724210
4
@Override public Usuario salvar(Usuario entidade) throws ValidacaoException { if (entidade == null) { throw new IllegalArgumentException("'usuario' não pode ser nulo"); } for (Usuario usuario : obterTodos()) { if (usuario.getUsuarioId() == entidade.getUsuarioId()) {...
1deb746e-5fb1-4017-8cb4-9268ad7655ea
6
public static final String getHomeDir() { String homeDir = null; try { String os = System.getProperty("os.name").toLowerCase(); try { if (os.startsWith("windows")) { // JRE prior to 1.5 cannot reliably determine USERPROFILE. // Return user.home and hope it's right. ...
5aa2cdb8-035d-41e2-b81a-52933f987038
3
public static long kthFac(int k, int n) { long res = 1; long limit = n; for (long i = 2; i <= limit; i++) { res *= i; if (i == limit && k > 0) { k--; limit = res; } } return res; }
ed387905-fffd-4086-8241-cbd465cec654
6
public static void setTerrain(int direction) { switch(direction) { case 1: tiley--; break; case 2: tiley++; break; case 3: tilex++; break; case 4: tilex--; break; } for(int i = 0; i<80; i++) { for(int j = 0; j<60; j++) { ...
e471d50c-97d5-40a2-8083-b072300aa627
8
public static void main(final String[] args) { //check useage if(args.length < 1) { System.out.println("UTF8 Validator version: " + VERSION); System.out.println("Useage: utf8validate [options] <file>"); System.out.println(""); System.out.println("...