method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
55f4e244-3562-4478-8f81-0b5917905c43
1
private int evalState(State s) { int score = evalStateSide(s, "red") - evalStateSide(s, "blue"); return (me == "red")?score:-score; }
58553b8a-6373-4cbe-aac2-81933b7691b6
3
public String Encrypt(String text) { BigInteger m = new BigInteger(this.pkcs1pad2(text.getBytes(), this.GetBlockSize())); if (m.equals(Zero)) { return null; } BigInteger c = this.DoPublic(m); if (c.equals(Zero)) { return null; } String result = c.toString(16); if ((result.length...
e56f4c16-7f4d-4c39-83ba-32715411877b
1
public void append(String msg) { if (win==true){textarea.append(msg+"\n");} else{System.out.println(msg);} }
aa664808-d49a-4bf1-a97b-e0cf29480825
9
private String tellLoca(String lineName) { String direct = "{"; switch (lineName) { case "line one" : direct = direct + "turn left from canteen main entrance, and use the farrest stairs to go up"; break; case "line two" : direct = direct + "turn left from canteen main entrance, and use the nearer stairs...
a3afdd59-7cc3-4ddd-b887-d3d4cbfb7198
7
public static void main(String[] args) { int[] chainLength = new int[1000000]; for (int i = 0; i < chainLength.length; i++) chainLength[i] = 0; chainLength[1] = 1; long next; for (int i = 2; i < chainLength.length; i++) { next = i; int length = 0; while (next != 1 && next >= i) { if (next % ...
7e7621cc-e1f6-48e9-b8c4-f002b670c434
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 ...
70b4c533-10fe-4930-be69-192180adbe22
2
public static boolean checkAuth(byte [] authenticatorclient,String account,String password,String timestamp) { try { String clientstr =Hex.rhex(authenticatorclient); String serverstr = Hex.rhex(GenerateAuthenticatorClient(account, password,timestamp)); if (clientstr.equals(serverstr)){ return true; ...
f627e49e-aeec-4fd2-93a7-46727b0ded04
2
public StringSplitter(String text, String match) { this.matchLength = match.length(); this.text = text; this.match = match; if ((text == null) || (text.equals(""))) { hasMore = false; } }
f53dbb8a-0c17-4c6b-a3f3-57401617e7bf
8
private static void polthierAndRumpf(Component4D component, Map<Integer, Point3D> newPoints, Date date) { Map<Integer, List<Point3D>> pointTubes = component.getPointTubes(); LinkedList<Date> timesteps = component.getTimesteps(); timesteps.add(date); Iterator<Integer> it = newPoints.keySet().iterator(); ...
cc0d4fb4-114a-47b9-9392-fa13706f620b
0
@Override public void addQuestAnswer(String answ) { }
2a5d4628-d279-44dc-a5d1-2d127920f131
6
private static void printResultByLv(Scanner scan){ while (true) { System.out.println(); System.out.println("Please choose a level:"); System.out .println("--------------------------------------------------------------------------------"); //Print all levels by order from LEVEL enumeration. int i =...
9ce7000e-a1c6-4329-a6c6-4ecc3c2157e9
0
public SetModeSpinningUp(){ super(Color.SPINNING_UP); }
ac2eb8d8-a1aa-4cf3-8c0a-836d326c95e5
4
public Player(TileMap tm) { super(tm); width = 30; height = 30; cwidth = 20; cheight = 20; moveSpeed = 0.3; maxSpeed = 1.6; stopSpeed = 0.4; fallSpeed = 0.15; maxFallSpeed = 4.0; jumpStart = -4.8; stopJumpSpeed = 0.3; facingRight = true; health = maxHealth = 5; fire = maxFire = 2500; ...
6ae51f1c-fd63-468e-a5d2-e965de51b1b4
6
@Override public List<Centre_coworking> cercaAvancada(String nom, boolean banys, boolean cafe, boolean internet, boolean salaReunions, String poblacio) { Session session = sessionfactory.getCurrentSession(); Criteria criteria = session.createCriteria(Centre_coworking.class); List<Centre_coworking> centrelist; ...
a20fabc1-10d6-474e-91b9-28dec0988558
9
public boolean yesOrNot() { boolean returning; int countOnes = 0; int countZeros = 0; if (Configuration.isDebugMode()) { System.out.println("Evaluate true/false value"); } if ((subDimension.getHeight() != 0) && (subDimension.getWidth() != 0)) { f...
20293927-154c-4778-9d87-27ac8945fc48
6
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed try { //cargo Parametros del Reporte generarTabla(); Map parametros = new HashMap(); parametros.put("name_empresa", r_con.getRazon_social()...
c7bbc360-4eed-4db3-b1cd-29635358540a
2
public boolean contensDependente(String nomeDependente){ for(String d: dependentes){ if( d.equalsIgnoreCase(nomeDependente) ){ return true; } } return false; }
e7c133f0-a4c4-47c5-b091-586aaeda8585
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Tag other = (Tag) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (val...
f98b3a3d-5d46-43f2-bc8e-7475e9131ec5
5
public ArithmeticResult comuteFunctionCall(String funcName, ArrayList<ArithmeticResult> argumentList, Block codeBlock) { // Predefined func if (funcName.equals("InputNum")) { codeBlock.putInputFuncCode(); return new ArithmeticResult(new SSAVar(Instruction.getPC())); } else if (funcName.equals("OutputNum"...
f4207e41-40ff-43ce-b424-05b2e2b8b31b
0
protected void extractPack(String in, String out) throws Exception { File f = new File(in); FileOutputStream fostream = new FileOutputStream(out); JarOutputStream jostream = new JarOutputStream(fostream); Pack200.Unpacker unpacker = Pack200.newUnpacker(); unpacker.unpack(f, jostream...
c16ceeb2-735a-40ed-a362-99853a55fb1d
8
private ActionListener acaoCBOrdenacao() { ActionListener action = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int indice = cbOrdenacao.getSelectedIndex(); ArrayList<Atracao> lstOrdenada; switch (indice) ...
95b576d4-df6d-43df-a697-b3946cc54e91
0
public FrameCreateAlgo(){ super("Create algo..."); initialize(); }
5df3f8dc-0d44-4f9a-a5d8-7d1985a76684
8
private void init() { if (defaultRadioButtonBackground == null) defaultRadioButtonBackground = getBackground(); if (defaultRadioButtonForeground == null) defaultRadioButtonForeground = getForeground(); popupMouseListener = new PopupMouseListener(this); addMouseListener(popupMouseListener); setOpaque(fal...
1de4fce0-d15c-486a-bb77-e6a36d69be51
1
public void streamFile(File file, DataOutputStream outStream) throws IOException { System.out.println("FILE STREAMING"); long fileSize = file.length(); long completed = 0; int step = 150000; outStream.flush(); System.out.println("FILE STREAMING2"); ...
a2bfaf55-94ee-4aaf-8cab-eb2fb76c782d
6
public void render(Graphics g) { g.drawImage(Draw.bg, 0, 0, null); // if (time>100){ // WordsYo(msg, g, 160 , 140 - (int) (Math.abs(Math.sin(time * 0.05) * // 10))); // } int xs = 0; int ys = msg.length + 3; for (int y = 0; y < msg.length; y++) { int s = msg[y].length(); if (s > xs) xs = s; ...
f68a3eec-c919-4321-82cb-34f962533e67
5
static final void method1971(int i, String string, boolean bool, int i_11_) { anInt9942++; Class59_Sub1_Sub1.method556(false); Class341.method2681(9864); Class348_Sub22.method2959(-1); Class348_Sub23.method2965(string, i_11_, bool, i ^ i); Class348_Sub24.method2994(2); VarpHandler.method1311(5139, Class348_...
b2f3d035-045d-4388-8d43-efb3e94bb2a8
6
public static boolean checkEntry(int[][] M,int i,int j){ boolean valid = false; int[][] indexes = new int[4][2]; indexes[0][0] = i-1; indexes[0][1] = j; indexes[1][0] = i; indexes[1][1] = j+1; indexes[2][0] = i+1; indexes[2][1] = j; indexes[3][0] = i; indexes[3][1] = j-1; for(int[] index:indexes){...
e7e7f982-3f11-4d0a-bf7e-c6c94a644774
2
public void createIndex() throws IOException { validate(); String tweet = null; TweetProcessor tweetProcessor = new TweetProcessor(indexFolder, dumpFile); BufferedReader dumpReader = new BufferedReader(new FileReader(dumpFile)); while((tweet = dumpReader.readLine()) != null)...
53421f95-2bc3-409d-8369-17145f90d56d
0
public void markCompletelyDirty(JComponent c) { // do nothing }
b03f537f-e99d-4cc9-85d5-66e2dd232dc9
9
private PMap<Object, Object> addPrimitive(Class<?> bClass, PMap<Object, Object> map) { if (bClass == Integer.class) { map = map.plus(Integer.TYPE, bClass); } if (bClass == Long.class) { map = map.plus(Long.TYPE, bClass); } if (bClass == Byte.class) { ...
8d5350a4-c0a0-4d10-b213-a211916134e4
8
protected void internalUpdate(Widget widget, Object element, String[] properties) { boolean needsRefilter = false; if (properties != null) { for (int i = 0; i < properties.length; ++i) { needsRefilter = needsRefilter(element, properties[i]); if (needsRefilter) { break; } } } if (needsR...
cf009959-fdf2-4f9c-9b47-8286296d2aa3
5
@Override public ResultMessage insertCollectionOrPaymentPO(CollectionOrPaymentPO receipt) throws RemoteException { // TODO Auto-generated method stub boolean isGet = false ; int i = -1 ; if(receipt.getNumber().substring(0,3).equals("SKD") ) i = 1 ; for(TransferListItemPO theItem:receipt.ge...
dd65055a-2ecf-4608-a1ba-a075d36bf1cf
5
@Override public void run() { console.displayMessage("Server thread started"); try { console.displayMessage("Starting..."); while (true) { for (int i = 0; i < clients.size(); i++) { NetworkMessage tmp = clients.get(i).readMessage(); if (tmp != null) { manageMessage(clients.get(i).getID(),...
2660bf9c-35ba-4cd2-a236-3a6c0ebf4665
1
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "GeoObject": geoObject = new GeoObject(); break; } }
1eecf513-71ef-43e7-b288-b404e73be885
8
public void normalTarget(){ JFrame frame = new JFrame("Normal Mode"); frame.setVisible(true); frame.setSize(500,500); frame.setBackground(color); panel = new JPanel(); panel.setBackground(color); final JButton first = new JButton(); first.setBackground(Color.WHITE); first.setLocation(50+ran...
a61ea1af-6a39-40c9-acab-317ecd48d0d9
4
public int getGreen(int x, int y) { int value = 0; if ((x >= 0) && (y >= 0) && (x < im.getWidth()) && (y < im.getHeight())) { value = ((im.getRGB(x, y) >> 8) & 255); } return value; }
ed34527d-5fef-487a-bf8e-cdcba99ad90b
2
public void separateAlpha(int[] buffer, int len) { for (int i = 0; i < len; i++) { if ((buffer[i] & 0xff000000) != 0) { buffer[i] = buffer[i] & 0xff000000 | Math.min((buffer[i] >>> 16 & 0xff) * 255 / (buffer[i] >>> 24), 255) << 16 | Math.min((buffer[i] >>> 8 & 0xff) * 255 / (buffer[i] >>> 24), 255)...
ead1cd11-fc09-4c0e-8edc-e0f4add8d13c
7
public List<GrouponResponse> getOffers(RequestBean request, int requiredNoOfOffers) throws InvalidRequestParametersException, CitysearchException { validate(request); Properties properties = PropertiesLoader.getAPIProperties(); StringBuilder urlStringBuilder = new StringBuilder( ...
ba1aaf58-9dc3-4821-bb2b-d17d24585be7
5
int getContentX (int columnIndex) { int minX = parent.getCellPadding (); if (columnIndex == 0) { Rectangle checkboxBounds = getCheckboxBounds (); if (checkboxBounds != null) { minX += checkboxBounds.width + CTable.MARGIN_IMAGE; } } if (parent.columns.length == 0) return minX - parent.horizontalOffset; /* ...
9d527df4-5838-4d4a-aa35-6a4bf38d0028
0
protected void initialize() {}
e4644dc4-9250-4092-986b-1a5456cde368
7
@Override public synchronized Message process(ClientState state, Message request) { // Read in the Request if (!parseMessage(request)) { //return failure return null; } //Check for missing or invalid parameters if (myQuestion.equals("")) //missing question return writeFailureResponse("No question...
18a63435-a0e8-4d8b-82e8-32ad668dcaec
9
private String makeUnicodeCharactersEscaped(String str) { StringBuilder b = new StringBuilder(); for (char c : str.toCharArray()) { if ((1024 <= c && c <= 1279) || (1280 <= c && c <= 1327) || (11744 <= c && c <= 11775) || (42560 <= c && c <= 42655)) { b.append("\\u").append(...
dd4e1b67-2f8a-4c17-ae0d-00e74a0181b0
4
public void removePoller(PollItem item_) { PollItem item = item_; Iterator<SPoller> it = pollers.iterator(); while (it.hasNext()) { SPoller p = it.next(); if (item.equals(p.item)) { it.remove(); dirty = true; } } ...
5494b8e4-f4cb-472a-8818-6de68bfee4b9
8
public final int partitionByName(int lb, int ub) { Product pivotElement = allProducts[lb]; // store the left most value as the pivot element int max = logicalSize; int left = lb, right = ub; // store left and right as the unchanging values of lb and ub respectively. This is used for the final move of this metho...
a9c412e4-237e-4c98-9e7f-9c2994af062b
5
public void initialise(World world) throws PatternFormatException { String[] cellParts = cells.split(" "); for (int i=0;i<cellParts.length;i++) { char[] currCells = cellParts[i].toCharArray(); for (int j=0;j<currCells.length;j++) { if (currCells[j] != '1' && currCells[j] != '0') ...
2a315fc6-9119-491d-8f80-b660deeeffa0
3
public Category getById(int id) throws SQLException { Session session = null; Category cat = null; try { session = HibernateUtil.getSessionFactory().openSession(); cat = (Category) session.load(Category.class, id); } catch (Exception e) { JOptionPane.showMessa...
f98b9122-ed6a-40e0-9293-49c934b27204
9
public int execute(Instruction inst) { this.inst = inst; InstructionType type = inst.get_type(); int format = inst.get_format(); switch (format) { case 0: if (r_format()) return result; break; case 1: if (memory_format()) return result; break; case 2: if (memory_format()) ret...
d822f13e-24c2-40a9-a240-fc82ffb11f55
4
@Override public boolean doSmall() { if (!script.houseTask.isInHouse()) { if (locationAttribute.getSmallRandom(ctx).matrix(ctx).reachable()) { script.housePortal.enterPortal(); } else { ctx.movement.findPath(locationAttribute.getSmallRandom(ctx)).traverse(); } if (Condition.wait(new Callable<Bo...
3bc72d22-cedd-4031-88f9-78ca631c9476
1
synchronized void notifyListeners(Key key, boolean pressed) { HashSet<OnToggleListener> tmpList = (HashSet<OnToggleListener>) onToggleListeners.clone(); for (OnToggleListener listener : tmpList) { listener.onToggle(key, pressed); } }
4ad8b796-8798-43b8-b0cf-f366de0298a9
0
private Assert() { super(); }
4b63a74d-51bc-4c3b-b9ee-d02a909f0e45
1
public String getCodigoLinea(int index){ if (index > 0) { return lineas.get(index-1).getcIata(); } return ""; }
f2d358f8-85a5-431b-b81c-fbecd278e302
4
public boolean isPermitted(String command, String subcommand) { if (player == null) { return true; } if (plugin.getPluginManager().getPermissions() != null) { if (subcommand != null) { return plugin.getPluginManager().getPermissions().has(player, "XcraftGate." + command + "." + subcommand); ...
b2c70020-d16f-4326-8224-9c9e56ac2913
7
private static void loadCurio() { try { FileInputStream fstream = new FileInputStream("curio.conf"); InputStreamReader in = new InputStreamReader(fstream, "UTF-8"); BufferedReader br = new BufferedReader(in); String strLine; while ((strLine = br.readLine()) != null) { String[] info = strLine.split(...
bb58bad0-d2c2-4de5-a1d5-19ed6bef0ee2
7
private void resolveImports(ModuleManager moduleManager) { autoImportModules(moduleManager); for (Import importEntry : this.imports) { ModuleDefinition dependencyModule = null; if (moduleManager != null) { dependencyModule = moduleManager.getModule(importEntry.getName()); } ...
62220324-2974-454b-a0f2-5a193c50e141
4
@Override public void deserialize(Buffer buf) { name = buf.readString(); worldX = buf.readShort(); if (worldX < -255 || worldX > 255) throw new RuntimeException("Forbidden value on worldX = " + worldX + ", it doesn't respect the following condition : worldX < -255 || worldX > 255...
d8fad20a-730e-4ed5-9bf7-f68b3ca2066b
5
public boolean hasCycle(ListNode head) { ListNode fast = head; ListNode slow = head; if (head == null) return false; if (head.next == null) return false; while (fast.next != null && fast.next.next != null) { slow = slow.next; fast = fast.next.next; if (slow == fast) return true; } ...
0d4f00ef-8b45-4f43-bc90-2964f05cadf4
6
private static void SLDouble(Player P) { ShippingLines SL = (ShippingLines)Game.fields.get(P.Position); int Owner = SL.Owner; if (Owner != Game.players.indexOf(P)) { if ((Game.players.get(Owner)).InPrison == false) { int cnt = ...
2bee0992-2e3f-4ee4-bd79-60d818653f58
1
@Test public void insertTest() { for (int i = 1; i < 10; i++) { int[] inserts = initializeRandomTable(10000 * ((int) Math.pow(2, i) / 4)); printTime(testPriorityQueueInserts(inserts)); printTime(testBinaryHeapInserts(inserts)); } }
d43c3d5b-a982-49f5-9523-29a8a4ffdb9b
0
@Before public void init() { parkBoy = new ParkBoy(); parkBoy.handlePark(new Park(this.FIRST_PARK_SIZE)); parkBoy.handlePark(new Park(this.SECOND_PARK_SIZE)); }
c7a99b72-57e2-4d9a-ba45-ca087400044a
1
public void testConstructor_RD_RI5() throws Throwable { DateTime dt = new DateTime(TEST_TIME_NOW); Duration dur = new Duration(-1); try { new Interval(dur, dt); fail(); } catch (IllegalArgumentException ex) {} }
83f40cfd-778c-48c5-95af-8c5a92d0db28
5
private boolean searchSubMenu(String searchString) { final String resultFormatString = "%s. [%s] Name: %s"; if (searchString.matches("\\s*\\v*")) { return true; } int resultIndex = 1; String type = "Book"; for(Book li : library.s...
c5c315ca-59a7-49f2-83bc-27e7de4ab7d8
1
public List<JAXBElement<ReferenceType>> getDataReferenceOrKeyReference() { if (dataReferenceOrKeyReference == null) { dataReferenceOrKeyReference = new ArrayList<JAXBElement<ReferenceType>>(); } return this.dataReferenceOrKeyReference; }
b314a1db-6ac7-4e67-87d1-14f77aa5481e
7
public static void main(String[] args) { // TODO Auto-generated method stub func = ScoreFunctionFactory.getScoreFunction(mode); int suffix = 0; if (ROOTDIR.equals("/home/graveendran/Downloads/DUC")) { suffix = 1; } if (mode == ScoreFunctionFactory.Mode.KLSUM) { ((KLSumPlusScoreFunction) func) ...
717766a1-8bf8-42df-add2-6d096b1da905
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); setEnabled(false); addActionListener(this); Outliner.documents.addTreeSelectionListener(this); Outliner.documents.addDocumentRepositoryListener(this); }
27f8cd85-e6b3-4bc2-8bb8-68d57dcace12
5
public static ArrayList<Staff> getAll() { try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Staff> staffList = new ArrayList<Staff>();...
e97561da-e62a-454d-b48b-3cf2a47d2825
3
private void save(prRegion pr) { File f = new File(plugin.getDataFolder(), "saves/" +pr.getWorld() + "/" + pr.getName()+".fr"); if (!f.exists()) { f.getParentFile().mkdirs(); try { f.createNewFile(); } catch (Exception e) {} } try { GZIPOutputStream gzipo = new GZIPOutputStream(new FileOutputStr...
05300b9c-48fd-4362-a236-00933e5d3d39
7
public Flags() throws IOException { System.out.print("Do you want to override the global flags for this module?"); if (askBoolean()) { System.out.println("Give the global overriding compiler flags"); System.out.print("Leave blank and hit return to skip this option"); global_override_compiler_flags = ask...
0375362d-bde4-4205-ac8a-b75867a945e8
2
public void start() { LOGGER.info("Starting MaintenanceServer version " + SOFTWARE_VERSION); long start = System.currentTimeMillis(); if (((Boolean) this.options.valueOf(USE_CONFIG))) { this.propertyHandler = new PropertyHandler(new File(getRoot(), "maintenance-server.properties"));...
e224061b-3790-43eb-a356-8a2238a093e3
5
public void moveEntity(Entity entity, int xEnd, int yEnd) throws Exception{ if(!containedEntities.contains(entity)){ throw new Exception("The entity: "+entity.toString()+" is not located on this map."); } if(gameMap[entity.getXTileCoordinate()][entity.getYTileCoordinate()] != entity){ throw new Exception("...
b414eda4-585d-4000-aa5c-8150c9488465
8
public Number multiplyNumbers(Number a, Number b) throws NumberClassNotFoundException { Number product = null; if (a instanceof Double && b instanceof Double) { product = new Double(roundDouble(a.doubleValue() * b.doubleValue())); } else if (a instanceof Integer && b instanceof In...
48ac2d4a-9bc3-47d6-a0d5-9ff33a54ed9d
3
private void _drawRect(Graphics2D g2, int x, int w, Color hiCol, Color mdCol, Color loCol) { Dimension d = getSize(); // Divide height into quarters int h = (int) d.getHeight(); int th = h / 4; GradientPaint p1; GradientPaint p2; ButtonModel model = getModel(); // Paint shaded area if (!model.isEn...
e25d2009-d9c9-46fb-9d14-ca8b55df4c86
0
public void setRatingId(int ratingId) { this.ratingId = ratingId; }
613c7028-8923-47a5-9002-604ba868b367
5
public static boolean isActive(Block block) { if (!isApplicable(block)) return false; TileEntityBeacon beacon = (TileEntityBeacon) ((CraftWorld) block .getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ()); Field active = null; try { active = TileEntityBeacon.class.getDeclar...
8d394497-9321-48c5-a43c-2f527646c2ee
8
private void adjustScale(double v, double theta) { int i = 0; while (i < _launchVelocity.length && theta > _launchAngle[i]) i++; if (i == 0) i = 1; double temp = v / _launchVelocity[i-1]; // avoid setting velocity to NaN ...
4ce35ffa-3314-4f44-ac94-919b0360fa6f
4
public static boolean gameOver(Board board){ if (board.whoWon() != null) { System.out.println("\n" + board.whoWon() + " won the game!"); System.out.println("Wining move: " + board.getWinningMove()); System.out.println(board); Integer winCount = gamesT...
761bdb76-4b9b-4e00-b5f5-97b79d7d3026
6
public int pointToSymbol(int midCount) { int low = 0; int high = TOTAL_INDEX; while (true) { // binary search returns when it finds result int mid = (high+low)/2; if (_count[mid] > midCount) { if (high == mid) --high; else high = mid; } else if (_count[mid+1] > midCount) { return (mid==EO...
f50a5ac4-685f-4497-a601-0781b2208099
5
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (event.getBlock().getState() instanceof Sign) { Sign sign = (Sign) event.getBlock().getState(); if (sign.getLine(1).startsWith("Game ") && sign.getLine(2).cont...
b19f0d40-d568-4cd2-894b-18750705d627
7
@Override public void mouseEntered(MouseEvent e) { if(e.getSource().equals(btnStation) || e.getSource().equals(btnSortCentreEntrance) || e.getSource().equals(btnSortCentreExit) || e.getSource().equals(btnJunctionPoint) || e.getSource().equals(btnConveyor)) { if(!m_currentlyAdding) ...
61620d23-315a-4321-8394-e20c00e6de23
6
private void generatePowerFailures() { for (int x = 0; x < grid.width; x++) { for (int y = 0; y < grid.height; y++) { if (Math.random() * 100 <= CHANCE) { // Generate the Primary PowerFailure final Position primaryPos = new Position(x, y); if (grid.validPosition(primaryPos)) { final ...
1c5535c4-982e-4e45-81b6-b1aa4fa465aa
2
private void buildHorizontalRoads() { // Add Horizontal Roads _horizontalRoads = new VehicleAcceptor[_gridDimensions.getRow()][_gridDimensions.getColumn()+1]; //[row][column] for (int i=0; i<_gridDimensions.getRow(); i++) { for (int j=0; j<=_gridDimensions.getColumn(); j++) { VehicleAcceptor l ...
a2b85c32-470e-4c64-be20-9f40927db779
1
public void removeAllRows(){ int rowCount= getRowCount(); System.out.println(rowCount); for(int i = rowCount - 1; i >=0; i--) { removeRow(i); } }
536539eb-10dd-46ca-92ac-5886deb878dc
1
private void evaluateOperator() throws BinaryOperatorException { BinaryOperator operator = expressionStack.operatorStack.pop(); if (2 > expressionStack.operandStack.size()) { throw new BinaryOperatorException("binary operator wasn't calculated"); } BigDecimal operandFirst = e...
024236bb-ee68-4992-9c1f-1e2f961586b6
7
private void closeSelectedSpecifications() { List<SpecificationDocument> selectedSpecifications = selectedSpecifications(); if (selectedSpecifications.isEmpty()) { return; } boolean hasEditedDocuments = hasEditedDocuments(selectedSpecifications); ...
2facade6-a0bb-4f08-8d38-7e9850cff9d0
4
private void setOrder(String sortField, String sortOrder, Criteria criteria) { if (sortOrder.equalsIgnoreCase("ASC") && sortField != null) { criteria.addOrder(Order.asc(sortField)); } else if (sortOrder.equalsIgnoreCase("DESC") && sortField != null) { criteria.addOrder(Order.desc(sortField)); } }
a936ddf5-3a28-4f78-b9cf-abacb816c056
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++){ StringTokenizer st=new StringTokenizer(in.readLine()); int N=parseInt(st.nextToken());...
c8d58980-f568-429e-a4a1-a5aecc08e24a
1
public IntegerStack copy() { IntegerStack res=new IntegerStack(data.length); res.count=count; for(int i=0;i<count;i++) res.data[i]=data[i]; // in most cases actually empty stacks are cloned in JEL // System.arraycopy(data,0,res.data,0,count); return res; };
9ecf51ce-54b8-48f6-af49-ccb8c3fc40e4
7
protected @Override Module retrieveModule(final String locator, final long version) throws StorageException { assert (locator != null): "Supplied locator is null"; assert (version >= -1): "Invalid revision number supplied"; try { final RandomAccessFile file = FileAccessManager.getFile(l2p(locator)); try { ...
1c8f8773-c79f-47d7-9424-696b5c800bdf
3
public Fish(Vector2f position, FishType type, int animationDelay) throws SlickException { this.position = position; this.type = type; this.delay = animationDelay; this.animation.add(new Image("res/fish/regular.png")); this.animation.add(new Image("res/fish/regular1.png")); this.animation.add(new Image("r...
ad341416-6a74-4344-b092-c91c0d3e83f6
1
public void testPlus_Months() { Months test2 = Months.months(2); Months test3 = Months.months(3); Months result = test2.plus(test3); assertEquals(2, test2.getMonths()); assertEquals(3, test3.getMonths()); assertEquals(5, result.getMonths()); assertEquals(...
27163a6c-d5bf-41da-8f58-58482f2fa279
8
public void actionPerformed(ActionEvent e) { if (e.getSource() == buttonOk) { wavelength = (int) Double.parseDouble(textWavelength.getText()); loadExistingValues(); updateConsole(); } if (e.getSource() == buttonNext) { power[i] = Double.parseDouble(textPower.getText().replaceAll(" ", "").replaceAll("...
18c91250-0daa-435b-a05d-7910aac47322
4
public void newdrain() // this makes it so when the player activates a new prayer if the new drain rate is faster it uses that one ;) { int OldDrain = PrayerDrain; if(NewDrain > OldDrain && Noprayer == false) { PrayerDrain = OldDrain; } else if(NewDrain <= OldDrain || Noprayer == true) { PrayerDrain = NewDrain; } }
eda72940-4be2-460a-b4ce-fdc0537a4d0a
7
public static String completexpath_class(String tableid, String search, String linkname, int columnnumber,String controltype) throws Exception { ArrayList object = new ArrayList(); int rows = getNoOfRowsInGrid_class(tableid); int stringincrementer = 0; for (int i = 1; i < rows; i++) { String temp = conf...
c311958d-98ab-48b1-a61c-2067e58a9a56
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Address other = (Address) obj; if (!Objects.equals(this.street, other.street)) { return false...
5d9b6c61-2250-404e-ab29-3ac6799cf8f9
8
public ArrayList<Interval> insert(ArrayList<Interval> intervals, Interval newInterval) { // Start typing your Java solution below // DO NOT write main() function ArrayList<Interval> res = new ArrayList<Interval>(); int n = intervals.size(); int i = 0; // 第一步,找到左端点 while (i < n && intervals.get(i).end <...
6cb49895-aea9-4d8f-b848-23ac8c096f6c
5
@Override public void extract() throws XMLStreamException, FileNotFoundException { FileInfo terc = this.bfis.get(Parser.Types.TERC.toString()); this.factory = XMLInputFactory.newInstance(); this.readerRaw = factory.createXMLStreamReader(new BufferedInputStream(new FileInputStream(...
60f4cd4d-5df4-4556-b7be-76b01dbc8232
0
public ConvertPane(Grammar grammar, Automaton automaton, Map productionsToTransitions, Environment env) { this.grammar = grammar; this.automaton = automaton; this.setLayout(new BorderLayout()); JSplitPane split = SplitPaneFactory.createSplit(env, true, .4, null, null); this.add(split, BorderLayout.CEN...
afb234f4-146d-46c8-b2b0-38775f3b6e5a
2
private static boolean hasOptionPrefix(String arg) { return arg.startsWith("-") || Platform.isWindows() && arg.startsWith("/"); //$NON-NLS-1$ //$NON-NLS-2$ }
668fbc5a-4299-4b9f-8e07-6de60168f197
2
private void compileShader() { glLinkProgram(resource.getProgram()); if (glGetProgram(resource.getProgram(), GL_LINK_STATUS) == 0) { Util.err(fileName + ": " + glGetShaderInfoLog(resource.getProgram(), 1024)); System.exit(1); } glValidateProgram(resource.getProg...
e816a15a-e4ee-4ce1-889d-b64c63c09079
3
public void disconnect() { if(serialPort != null && serialPort.isOpened() ) { try { serialPort.setDTR(false); serialPort.setRTS(false); serialPort.removeEventListener(); serialPort.closePort(); } catch (Exception e) { publish(Messages.SerialWorker_6); explainSerialPortException(e);...
5dfaf675-e4f0-4082-8cf6-cfdefd15b7a1
1
public static boolean getMouseDown( int mouseButton ) { return getMouse( mouseButton ) && !lastMouse[mouseButton]; }