method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
53345123-c7ab-4101-9208-a076b86efae8
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...
9b98db1a-8465-4aa7-8ed3-7f336edf49d8
3
private static void sort(int[] lotto) { // for (int i = 0; i < lotto.length; i++) { // for (int j = 0; j < i; j++) { // if (lotto[i] < lotto[j]) { // lotto[i] ^= lotto[j]; // lotto[j] ^= lotto[i]; // lotto[i] ^= lotto[j]; // } // } // } for (int i = 0; i < lotto.length - 1; i++) { for (int ...
88059264-9b94-4340-ba66-2ca7371168be
0
@Override public final void testFailure(Failure failure) throws Exception { super.testFailure(failure); selectListener(failure.getDescription()).testFailure(failure); }
b06fc9ff-9c69-40f5-b54d-82996b962077
9
public int maxPoints(Point[] points) { if (points == null) return 0; if (points.length < 2) return points.length; Map<Double, Integer> table = new HashMap<>(); int dup = 1, max = 0; for (int i = 0; i < points.length; i++) { table.clear(); dup = 1; for (int j = 0; j < points.length; j++) { i...
48587d13-30d4-4fb0-9fcb-803f818e9ec9
7
@Override protected void startGame() { notifyNewGame(); discardCards(); shuffle(); community.clear(); doAntes(); doBlinds(); doneFlop = false; doneTurn = false; doneRiver = false; ...
f166b89d-4a61-49c5-8aae-6cb30b0699ce
5
public AlignedAllocation next() { // if duration is over, get next start stop if ((alignment != null && duration <= maxDuration && alignment.startPoint + duration <= intervalsUpperBound) == false) { this.nextStop(); } AlignedAllocation ret = new AlignedAllocation(); ...
abe7bbc1-d0d7-4f8d-b0b3-c552ff06efdb
8
public static void main(String args[]) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); for (int T=parseInt(in.readLine().trim()),t=0;t<T;t++) { if(t>0) sb.append("\n"); in.readLine(); char[] str=in.readLine().trim()....
b49d55c6-0151-4309-b8d1-127627681d13
0
@Override public void mouseExited(MouseEvent e) {}
d6df9f93-fac8-470b-9cd9-9494630b00d3
4
@Override public AbstractComponent parse(String string) throws BookParseException { if (string == null) { throw new BookParseException("String is null"); } try { TextComponent component = (TextComponent) factory .newComponent(EComponentType.CODE_LINE); for (String s : string.split("")) { if (!s...
4486c9ab-68ca-4280-aca5-34550662a38f
7
public static boolean getSortingOrder(String order) throws StreamParserException { order = order.toLowerCase(); switch (order) { case "a": case "asc": case "ascending": return false; case "": case "d": case "desc": case "descending": return true; default: throw new StreamParse...
d970a702-3195-4208-858a-ecc8b653bfde
5
@Override public void actionPerformed(ActionEvent e) { JButton source = (JButton)e.getSource(); if(source.getText().equals("Annuler")){ dispose(); }else{ if(mainPanel.getSelectedComponent().equals(param)){ p.resizeFiguresOnLayer(working_layer, Integer.parseInt(tailleX.getText()), Integer.parseIn...
794389c7-4966-4d0a-8291-abbd19b0a2a6
1
@Override public <T> List<T> queryPage(String sql, Page page, RowMapper<T> rowMapper, int fetchSize, Object... args) { int total = queryCount(sql, args); page.setTotal(total); if (total <= 0) { return new ArrayList<T>(0); } String pageSql = dialect.getPaginationSql(sql, page); LOGGER.info("分页查询操作SQL:"...
3fe77575-6003-4c2c-82b0-17406ec5900d
9
public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); int[] a = new int[n]; int[] o = new int[n]; ...
a0ee76df-b4eb-445e-a434-28fbf7217a88
9
public List<Keyword> getKeywords(Graph graph) { List<Keyword> keywords = new ArrayList<Keyword>(); Map<String, Double> keys = new TreeMap<String, Double>(); for (Node node : graph.values()) { keywords.add(new Keyword(node.getKey(), node.getRank())); } Collections.sor...
88a4f2dd-5126-40f9-b958-77641249350e
2
public void removeBet(Block bet) { Set<Player> betsKeys = bets.keySet(); for(Player key : betsKeys) { if(bets.get(key).contains(bet)) bets.get(key).remove(bet); } }
2e016f36-fc7b-4743-83f1-7db0d24e4ad4
0
public void setDebt(double debt) { this.debt = debt; }
104b9954-db5f-400f-849f-b810adbca395
2
public int getNumeroDePrestamos(Usuarios u){ int numero = 0; PreparedStatement ps; try { ps = mycon.prepareStatement( "SELECT " + "COUNT(Usuarios.nombre) as total " + "FROM " + "Presta...
2ae14bb0-5349-4763-a861-8f628898bb2b
6
public void tableChanged(TableModelEvent e) { /* * int row = e.getFirstRow(); if (modelToView != null) { int[] mToV * = getModelToView(); if (row < mToV.length) { * updateColor(mToV[row], e); } else { updateColor(mToV[row] - 1, * e); } } else { up...
3dc7f9c6-e5ae-4b37-a9cc-dcad5bcdbad6
7
private FloatQueue computeQueue(String expression, byte averageFlag) { FloatQueue q = new FloatQueue(model.getTapeLength()); if (expression.startsWith("\"")) expression = expression.substring(1); if (expression.endsWith("\"")) expression = expression.substring(0, expression.length() - 1); q.setName(expres...
3306876d-36b0-4118-ad22-21d1c954bf25
6
public static void closeStream(Stream self) { { Surrogate testValue000 = Stella_Object.safePrimaryType(self); if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_INPUT_FILE_STREAM)) { { InputFileStream self000 = ((InputFileStream)(self)); InputFileStream.terminateFileInputStreamP(self...
970cd5ae-a68e-43cd-a323-1f39213dee71
9
public String[][] getNColumnDataAraqne(String name, String mgr_ip, String query) { LogDbClient client = null; Vector rowSet = new Vector(); Vector row = null; int colCnt = 0; try { client = DBConnectionManager.getInstance().getQueryClient(mgr_ip); LogCursor cursor = null; try { cursor = client.q...
2fcb7eaa-12aa-4c46-aca1-d3c83317ba72
5
private static boolean[] primeBoolArray(int limit) { boolean[] nums = new boolean[limit]; for (int i = 2; i < nums.length; i++) nums[i] = true; int nextPrime = 2; while (nextPrime < nums.length / 2) { int i = nextPrime; for (; i < nums.length; i += nextPrime) nums[i] = false; nums[nextPrime] = t...
cd47836b-118b-4449-a754-95e5b0f26de4
9
@Override public String toString() { int spos = 0; int max = Math.min(start-1, cs.length()-1); int charCount = 0; for (int i = 0; i < max + 1 && i < 20; i++) { char c = cs.charAt(max-i); if (c == '\r' || (c == '\n' && (max-i-1 < 0 || cs.charAt(max-i-1) != '\r'))) { if (charCount > 0) break; } else...
22d1f0de-88a1-4f2f-8653-187c32a7e549
1
@Override public boolean isBoolean() { return this == TRUE || this == FALSE; }
b19f3665-efcf-414f-a180-bef1615dc96b
4
public static void rectangle(double x, double y, double halfWidth, double halfHeight) { if (halfWidth < 0) throw new IllegalArgumentException("half width must be nonnegative"); if (halfHeight < 0) throw new IllegalArgumentException("half height must be nonnegative"); double xs = scaleX(x); ...
23a79ebb-cf02-49aa-b0fc-7ad7b162d044
8
public void testPieceSetup(){ OthelloPiece[][] test = OthelloBoard.getPieces(); for(int k = 0; k < getP1PiecesX().size(); k++){ if(getM_playerOneColour().equals("Black")){ if(test[getP1PiecesX().get(k)][getP1PiecesY().get(k)].getPieceColour().equals(Piece.OthelloPieceColour.BLACK)){ System.out.println...
4f2ac6b9-1615-46ab-af2c-7531363bb148
8
public static void main(String[] args) { FileReader fr = null; String Folder=Long.toString(System.nanoTime()); try { File A=new File("idents.txt"); fr = new FileReader (A); BufferedReader br = new BufferedReader(fr); String linea; ArrayList<String> ListaFiles=new ArrayList<String>();; while ...
33aea453-527e-4f90-948a-053ac708ffe6
1
public void testMoneyConverter() { System.out.println("** testMoneyConverter **"); final CycFort currUSD = MoneyConverter.lookupCycCurrencyTerm(Currency.getInstance("USD")); final BigDecimal amount = BigDecimal.valueOf(50.25); final CycNaut cycMoney = new CycNaut(currUSD, amount); final Money javaMo...
5fe49959-12a5-4fe7-ac7c-2b7c64db998b
1
private void btnRecommendMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRecommendMousePressed if (Manager.getInstance().getCurrentProfile() == null) { JOptionPane.showMessageDialog(null, "Please load a profile first."); return; } Disc recommendedDisc = FrolfUtil.recommen...
c466fd6c-dd30-4c98-ad7f-b0c14fdca5ca
9
public ArrayList<Move> getPossibleMoves(Loyalty loyalty) { ArrayList<Move> possibleMoves = super.getPossibleMoves(loyalty); ArrayList<Move> realPossibleMoves = new ArrayList<Move>(); for(Move possibleMove : possibleMoves) { boolean possible = true; Game nextGame = new Game(getGame()); Board...
1f9861e1-033b-47ea-9bad-578d86a75af6
9
boolean findTripod(Board board, int colour) { // For each hex that has three or more connecting hexes with same colour, add to queue. PriorityQueue<Hex> queue = new PriorityQueue<Hex>(board.numHexes); PriorityQueue<Hex> visited = new PriorityQueue<Hex>(board.numHexes); int i, j, n, numAd...
5ef05ca6-a3b6-4dd3-b90b-c0190dd16229
9
public static CommandLine bindPosix(Options options, String[] args, Object pojo) throws CLIOptionBindingException { CommandLineParser parser = new PosixParser(); CommandLine cli = null; try { cli = parser.parse(options, args); Class<? extends Object> clazz = pojo.getClass(); Field[] fields = clazz.get...
79609882-1337-49fb-ab8c-4fff98c51e5c
6
public String getWord() { do { boolean currentWordIDisIntList = false; currentWordID = getRandomWordID(); if (passedWordsIdList.size() > 0 && passedWordsIdList.size() != wordList.size()) { for (Integer id : passedWordsIdList) { if (id == cu...
3ba8d958-c73f-412c-9361-75a1840faed8
8
private long updateRewrite(Master master, File f, Location accessLoc, int rewriteCount) { MasterMeta fm = null; if (master.map.containsKey(f.getId())) { fm = master.map.get(f.getId()); } else { fm = new MasterMeta(f); master.map.put(f.getId(), fm); } int cCount = master.clusters.s...
b8a45843-6bed-499e-9633-4f4d60986f1e
0
public String getLastName() { return lastName; }
02f5aac5-b204-4894-b462-a37d5db6e995
5
public void mapCSVData(List<String> parsedCSVData) throws ParseException { Entry newEntry; switch (parsedCSVData.size()) { case 3: newEntry = Entry.createNewEntry(parsedCSVData.get(0), parsedCSVData.get(1), parsedCSVData.get(2), null, null, null, null...
36011949-6374-4dde-bbef-ffc9e92a43e3
3
public List<String> getAllAddresses() { ArrayList<String> addresses = new ArrayList<String>(); for (Map.Entry<String, String> entry : to.entrySet()) addresses.add(entry.getKey()); for (Map.Entry<String, String> entry : cc.entrySet()) addresses.add(entr...
9166c0a0-0c0b-47c6-a51a-6df9e503e80c
9
public boolean isLoop() { return (getSource() != null && getSource() == getTarget()) || (sourceParentView != null && sourceParentView == targetParentView) || (sourceParentView != null && getTarget() != null && getTarget() .getParentView() == sourceParentView) || (targetParentView != null && getSourc...
c43b05e7-5b91-4645-9592-b8c8c715b591
9
public void updateHeight(int l, int r) { if(l > r) {int t = l; l = r; r = t;} for(int i = l; i <= r; i ++) heightOfX[i-left] = 1000; for(int i = 0; i < num; i ++) { if(!isExist[i]) continue; double xl = 1000, xr = 0, y = 1000; for(int j = 0; j < 4; j ++) { xl = blocksPts[i][j].getX() < xl ? block...
2a593fa5-0801-4401-8e97-87c0c8d3bb03
0
@Transient @JsonIgnore public Event getEvent() { return event; }
eee656a5-2882-4a8a-a66c-fcf3b3fda0d2
7
public void parallelRender(int[] raster, int width, int height){ //calculate view frustrum if (!isInitialized) init(); Ray[] rays = cam.generateRays(width, height); int threadCount = 8; TracerThread[] tts = new TracerThread[threadCount]; for (int i = 0; i <threa...
d4d72b65-683c-445d-99cf-58f12cb90a4d
7
public void zoneEventOccurred(String eventZone, int eventType) { if((eventType == ZoneEvents.MOVEMENT || eventType == ZoneEvents.ENTER ) && eventZone.equals("menuBar")){ if(Debug.gui) System.out.println(eventZone); if(triggerShimmyIn()){ mouseInMenuArea = true; } else if(triggerShimmyOut()){ ...
a48e5b9b-a722-44e6-8ffa-f390809e3b3d
5
private ValueWithTimestamp getLocalValue(Column col,long start_ts,long end_ts,boolean hasEnd){ ValueWithTimestamp data=localData.get(col); if(data==null) return null; if(hasEnd){ if(data.timestamp>=start_ts && data.timestamp<=end_ts) return data; return null; }else{ if(data.timestamp>=start_ts) ...
4b4fff96-0389-4fd1-a5d0-d89d783c894e
9
static Line closestPair(ArrayList<Shapes.Point> xPoints, ArrayList<Shapes.Point> yPoints, ArrayList<Shapes.Point> aux, int left, int right, Line s0) { if (left >= right) { return new Line(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE); } int middle = ((right...
4e027cb5-f4c2-4edf-adbd-11e5c85f585c
0
public void setHeading(String heading) { this.heading = heading; }
28b90599-8d21-4c0e-8e63-823f72cb6b17
1
private void compute_pcm_samples1(Obuffer buffer) { final float[] vp = actual_v; //int inc = v_inc; final float[] tmpOut = _tmpOut; int dvp =0; // fat chance of having this loop unroll for( int i=0; i<32; i++) { final float[] dp = d16[i]; float pcm_sample; pcm_sample = (float)(((vp[1 + d...
60ee8547-0d78-4f5b-b04e-21c12400b21d
6
public void move() { // TODO: 根据窗口大小判断 if (x <= 0) moveToRight = true; else if (y >= 400) isAlive = false; else if (x >= 585) moveToRight = false; else if (y <= 25) moveToDown = true; if(moveToDown) y += YSPEED; else y -= YSPEED; if(moveToRight) x += XSPEED; else x -= XSPEED; }
58bd5cb4-b526-4b0e-b926-0ced67c7d808
5
public TemplateModel get(String s) throws TemplateModelException { switch (s) { case "name": return new SimpleScalar(m_name); case "symbol": return new SimpleScalar(m_symbol); case "change": return new SimpleNumber(m_change); ...
dad3d30d-d142-4f0d-969b-292264b37000
8
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); if (movingobjectposition == null) { return par1ItemStack...
d3e2a65b-3ee9-4368-ad5d-628e4ad93815
8
protected void addBlocks(Node node, Automaton automaton, Set locatedStates, Map i2s, Document document) { assert(automaton instanceof TuringMachine); //this code should really be in TMTransducer, but I see why it's here if(node == null) return; if (!node.hasChildNodes()) return; NodeList allNo...
d5916137-b5ba-4600-a599-a7a9ac467277
2
private void inv6ActionPerformed(java.awt.event.ActionEvent evt) { if(!game.getInBattle()) { outputText.setText(game.useItem(5) + "\n" + game.getCurrentRoom().getExitString()); if(game.itemRemoved()) inv6.setText...
196f8a4c-fb72-4f31-bd09-85a646a510f3
2
public static <T> T buscarObjeto( ArrayList<T> lista, Object id) { Iterator<T> iterator = lista.iterator(); T objeto; while (iterator.hasNext()) { objeto = iterator.next(); if (((ObjetoBD) objeto).getId().equals( id)) return objeto; } return null; }
51d5bde6-b5a5-41ae-87db-2b45607650f4
3
public static void messageReceived(Message message) { cbText.add(message); ChatboxInterface chatbox = InterfaceHandler.getChatbox(); if (cbText.size() > 100) { cbText.remove(0); chatbox.setScrollY(chatbox.getScrollY() + 1); } if (chatbox.getScrollY() != 0 ...
4409e3c6-2c13-4205-8534-60f2cdb022fa
3
public int getLightRadius() { int r = 2; if (activeItem != null) { if (activeItem instanceof FurnitureItem) { int rr = ((FurnitureItem) activeItem).furniture.getLightRadius(); if (rr > r) r = rr; } } return r; }
43e1c11a-163a-44c8-a289-a2a69e68ad63
7
public void decreaseRope(int x, int y) { if (ropelength > -1) { ropelength --; } x += 1; y -= 2; switch (ropelength) { case 124: getWorld().removeObject(rope6); ropeman.setLocation(x, y+15); break; case 99: getWorld().removeObject(rope5); ropem...
f49ca60d-fec7-444b-8553-b59eabcf30d6
2
public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (!isOptOut()) { configuration.set("opt-out"...
1a9e7b02-2568-4eca-b105-5bce5d980ab9
5
public static void main(String[] args) { Scanner in = new Scanner(System.in); char grade = in.next().charAt(0); switch (grade) { case 'A': case 'B': case 'C': System.out.println("Passes"); break; case 'D': case 'F': System.out.println("Fail"); break; default: System.out.println("Invalid"); break; } }
638f4ba1-ec3c-4d10-9baa-01867a20a183
3
public void hideGame() { image.setVisible(false); for (Base b : Game.getInstance().getBaseManager().getBases()) { b.setVisible(false); } for(GroupAgent a : Game.getInstance().getAgentManager().getAgents()){ a.setVisible(false); } for(Tower t : Game.getInstance().getTowerManager().getTowers()) { t.s...
0d3d566b-2f28-467e-9024-faca2a6e7555
0
@After public void tearDown() { }
1f96ec6d-a146-4838-a30b-2dfe3c8e3a1a
2
public EuclidsExtended(int input1, int input2) { variables = new Result(input1,input2); // Ensure the input is valid if(input1<=0||input2<=0){ variables.setError(EuclidsExtended.NonPos); } }
1bb93cb5-c125-476d-aba1-d44c090801e5
6
public int load( String filePath ) { XMLConfigParser pars = new XMLConfigParser(); pars.parseDocument("Format"); String file = filePath.substring(filePath.lastIndexOf("\\")); String extension = file.substring(file.indexOf(".") + 1); String fileExtension = null; for ( XM...
168cf215-058b-46b7-9bbf-4ce5397f07ea
1
private String formatLinks(String content) { String buf = ""; int idx = 0; int aStart = 0; int aEnd = -4; while (content.indexOf("<a", idx) != -1) { aStart = content.indexOf("<a", idx); buf += content.substring(aEnd+4, aStart); aEnd = content.indexOf("</a>", aStart); String link = content...
5416797b-e94b-4548-b0d6-c8468ee3301a
5
protected boolean isWriteIgnoredElement(String element, TreePath<String> path, Dependency dependency) { // if (isDebianBuild() && DEBIAN_BUILD_IGNORED_ELEMENTS.contains(element)) { // System.out.println("Build ignored " + element + " " + printPath(path) + " for " + dependency); // } // i...
6caa172b-d076-415c-bfb5-c8dc41c390df
2
private int compareIP(byte[] ip, byte[] beginIp) { for (int i = 0; i < 4; i++) { int r = compareByte(ip[i], beginIp[i]); if (r != 0) return r; } return 0; }
9f00c704-e610-4806-912d-b0be0cbfcf84
0
public SimpleDoubleProperty wrapWidthProperty() { return wrapWidth; }
318a9280-1ce8-448b-bbb8-d468bc72b250
5
@SuppressWarnings("unchecked") @Override public boolean equals(Object obj) { if (obj instanceof Tuple<?,?>) { if(x.equals(((Tuple<X,Y>)obj).x) && y.equals(((Tuple<X,Y>)obj).y)) { return true; } } return false; }
4b6d85a0-1aba-401f-b985-9ab53f8d9b16
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Parameter that = (Parameter) obj; i...
5e2835ae-bb69-49a7-bf08-d7fdf548e93f
1
public long getAddress() { if (addressSize == 4) return normalize($.getInt(this, offset)); else return $.getLong(this, offset); }
a379e948-4896-444e-9f68-acb97d494b04
3
@Override public void run() { System.out.println("The tread number " + numderTread + " started."); while (!stopTread) { int rows = MatrixDouble.getRowsForThreadWithInkrement(); //System.out.println("The tread number " + numderTread + ". Rows = " + rowsA + "."); ...
746fc066-83ac-46b5-a261-49632789fad7
8
public static void main(String[] args) { long startTime = System.currentTimeMillis(); switch (args[0]) { case "1": { General.setParser(new LogicParser()); work = new Checker1(); break; } case "2": { Gener...
f13349d4-6efa-44ff-af18-09969ac2039c
9
public List<TrackData> getTrackDataList_History( List<TrackData> list_track_data, String startDate, String endDate, String vregisteration_num) { try { m_Connection = getDbConnection().getConnection(); m_Statement = m_Connection.createStatement(); String m_Query ...
a2168b2f-6b14-49a5-87e7-334220365ab6
3
private int isDimensionOk(String dimTxt) { int dimension; try { dimension = Integer.parseInt(dimTxt); } catch (NumberFormatException e) { e.printStackTrace(); JOptionPane.showMessageDialog(new Frame(), "Erreur de dimension, format incorrect"); return -1; } if (dimension<4 ||d...
d43eeeb8-b9f0-4512-84c9-13f698e24058
2
public Plateau() { this.cases = new Case[NOMBRE_DE_LIGNES][NOMBRE_DE_COLONNES]; // Creé les objets de type Case du tableau. for (int numeroDeLigne = 0; numeroDeLigne < NOMBRE_DE_LIGNES; numeroDeLigne++) for (int numeroDeColonne = 0; numeroDeColonne < NOMBRE_DE_COLONNES; numeroDeColonne++) this.cases[num...
0ba949a1-7a79-41e4-b60e-29ee031d2efe
7
public static Integer ge(Object o1, Object o2){ if (o1 == null && o2 == null){ return 1; } else if (o1 != null && o2 == null){ return 1; } else if (o1 instanceof Number && o2 instanceof Number){ return ((Number)o1).doubleValue() >=((Number)o2).doubleValue() ? 1 : 0; } return 0; }
fbd944a2-1033-47b0-a9a4-a879cc7d5a50
1
private void setHorLength(int horLength) { if (horLength < 10) throw new IllegalArgumentException("The size of the grid has to be at least 10x10!"); this.horLength = horLength; }
478617a0-32e0-4f6d-b1c7-7ecb5d2e4968
0
public boolean isRemoving() { return this.isRemoving; }
b11bbeca-1e02-4ba2-9d13-6044ea461c4f
7
@Override public void run() { running = true; while (running) { try { switch (fizzBuzzStep) { case FIZZ: { Long value = fizzInputQueue.take(); f...
3c759808-1a48-4a7c-a780-69fb0d6673a5
9
public AbstractPreference createNew(String key) { String type = getProperty(key + KEY_JOIN + TYPE); String scopeType = getProperty(key + KEY_JOIN + SCOPE); if (type == null) { LOGGER.fatal("Unable to load preference for key:" + key); throw new UnsupportedOperationExcept...
314fd82f-3ef2-452f-bd7d-1c081ccc0e72
7
public DrawingToolbar(WhiteboardClientModel model) { this.model = model; this.setFloatable(false); ButtonGroup toolButtons = new ButtonGroup(); boolean first = true; for (Class<? extends DrawingTool> toolClass : new Class[] { Pen.class, Eraser.class }) { ToolSelectio...
690265f3-387c-4dea-b992-68ff84183434
6
public MapObject getObjectNear(int x, int y, double zoom) { Rectangle2D mouse = new Rectangle2D.Double(x - zoom - 1, y - zoom - 1, 2 * zoom + 1, 2 * zoom + 1); Shape shape; for (MapObject obj : objects) { if (obj.getWidth() == 0 && obj.getHeight() == 0) { shape = new...
407a9ba2-d442-4869-af7d-f6ba9f6e60b1
8
private static void browseTranslateRules() { handler.listTranslateRules(); System.out.print("Enter option (new, remove, main, or quit): "); String userInput = readString(); while ((!(userInput.equalsIgnoreCase("quit"))) && (state == CONTEXT_TRANSLATERULES)) { ...
80e13c70-5add-464a-9d01-a22e36c6ff3a
5
private Rule removeDefeater_transformDefeater(Rule origRule) throws TheoryNormalizerException { if (origRule.getRuleType() != RuleType.DEFEATER) return null; List<Literal> origHeadLiterals = origRule.getHeadLiterals(); if (origHeadLiterals.size() > 1) throw new TheoryNormalizerException(getClass(), "rule he...
60d3ccdf-9d1d-43a7-9d19-f0d0d49456e4
7
public void drawTank(Image up,Image down,Image left,Image right,Tank tank){ if( tank.getLastDir()==DirKey.Up ){ gBuffer.drawImage(up, tank.getX(), tank.getY(), null); } else if( tank.getLastDir()==DirKey.Left ){ gBuffer.drawImage(left, tank.getX(), tank.getY(), null); } else if( tank.getLastDir()==DirKe...
f84432e2-ad5c-4511-9482-74945c14324f
2
public void processPdu(CommandResponderEvent event) { String ip; String[] address = event.getPeerAddress().toString().split("/"); ip = address[0]; Iterator<Entry<String, SnmpAgent>> it = snmpAgents.entrySet() .iterator(); while (it.hasNext()) { Map.Entry<String, SnmpAgent> agent = (Map.Entry<String...
34e21b8f-a691-4343-8c29-986cc8396fd0
4
@Override public void initialize(URL location, ResourceBundle resources) { Optional<String> username = getUserLogin(); if (username.isPresent() && username.get().length() != 0) { user = username.get(); } else { // no login = quit System.exit(0); } sound = Sound.getInstance(); codeList = FXColle...
5ecbf5ba-798b-46a1-aa9a-8dbe776ffe88
0
public TransformsType getTransforms() { return transforms; }
9c7cb362-a102-4441-bfad-50fdd6339a87
0
public static int m_bf(final int n, final int c) { return c*n; }
bb68324d-970d-4963-b07a-26c5dabbc44d
4
static void eraseBoard() { for(int i=0;i<place.length;i++)place[i]=place.length-2; for(int i=0;i<pad.length;i++) { for(int l=0;l<pad[i].length;l++) { pad[i][l].delete(); } } for(int i=0;i<but.length;i++) { but[i].delete(); } red.erase(); blue.erase(); console.erase(); res.delete()...
dde52c12-64cf-432f-bcf4-da26e4114f3f
5
private void merge(T[] a, T[] aux, int lo, int mid, int hi) { // i and j is used to point to the currently processing element in the // first and 2nd half respectively int i = lo, j = mid + 1; // Copy a[lo..hi] to aux[lo..hi]. for (int k = lo; k <= hi; k++) aux[k] = a[k]; // Merge back to a[lo..hi]...
ec785a35-49d2-4ea3-95ee-dd81332d224e
5
public boolean renderBlockLadder(Block block, int i, int j, int k) { Tessellator tessellator = Tessellator.instance; int l = block.getBlockTextureFromSide(0); if (this.overrideBlockTexture >= 0) { l = this.overrideBlockTexture; } float f = block.getBlockBrightness(t...
e76e950f-7a68-454f-af6a-5edc61d20b82
4
public String setData(String SQL) { try { if (connOjbect == null){ if (! connectToDB()){ return "Error"; } } String message; Statement st = connOjbect.createStatement(); if (st.execute(SQL)){ message = "OK"; } else{ message = "Error"; } st.close(); return messag...
3aa49900-a5d5-4d55-a756-48074ecaf742
3
@SuppressWarnings("deprecation") public void testCompareTo() { LocalDate test1 = new LocalDate(2005, 6, 2); LocalDate test1a = new LocalDate(2005, 6, 2); assertEquals(0, test1.compareTo(test1a)); assertEquals(0, test1a.compareTo(test1)); assertEquals(0, test1.compareTo(test1)...
3759e4c2-594f-466b-b7b4-f3de6bfa4f01
1
@Override public void mark(int boardPosition, Cell[] cellBoard, int rows, int columns) throws IllegalMark{ //Find the row. int boardPositionRow = boardPosition / columns * columns; //Mark the row. for(int i= boardPositionRow; i < boardPositionRow + columns; i++ ){ ...
c194f929-1a6f-4361-8bb9-c71b529661cb
8
private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset, int options ) { // Lots of error checking and exception throwing if( source == null ){ throw new NullPointerException( "Source array was null." ); } // end if ...
f795a36f-5acf-4afb-84a9-57e94e9b089c
1
public int countClients() { int count = getClients().size(); if (count > size) { count = size; } return count; }
955f7797-e62a-4b45-b9e4-94bbe914b470
2
public static String SHA1(String text) { String Sha1 = ""; String value = text.toUpperCase(); try { MessageDigest md; md = MessageDigest.getInstance("SHA-1"); byte[] sha1hash; md.update(value.getBytes("iso-8859-1"), 0, value.length()); ...
4e4f1a84-0e7b-4c38-9d38-3bd924274287
1
@Test public void testCreatingContactWithoutPhoneNumberShouldFail() { try { new Contact("Bart", "Simpson"); fail("Was expecting an Exception when no phone number is provided."); } catch (IllegalArgumentException iae) { Assert.assertEquals("Please provide a value for Phone Number as it is a non-nullable fi...
b2958755-8b69-4862-993c-5445fdff6ef9
4
public ClassInfo[] loadClassesFromZipFile(final ZipFile zipFile) throws ClassNotFoundException { final ClassInfo[] infos = new ClassInfo[zipFile.size()]; // Examine each entry in the zip file final Enumeration entries = zipFile.entries(); for (int i = 0; entries.hasMoreElements(); i++) { final ZipEntry e...
d1cf6aca-d22b-48b0-b090-3cf08dd03b42
7
@Override public void execute(double t) { Matrix u1 = input1.getInput(); Matrix u2 = input2.getInput(); Matrix u3 = input3.getInput(); double[] y = new double[input1.getDim() + input2.getDim() + input3.getDim()]; if (u1 != null) for (int i = 0; i < input1.getDim(); i++) y[i] = u1.get(i, 0); if ...
a71d3e1c-9929-4acc-9ebd-c42d5f901a55
5
private int percolateDown(int index, E item){ while(((4*index)+1) <= lastIndex){ //Note this is brute force and needs to be optimized int mindex = 4*index+1; int track = (lastIndex - ((4*index)+4)); if(track <0){ //Know track is either -1 -2 -3 track = track + 3; }else{ track = 3; } ...