method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
fcb8b3a8-005c-44d1-885a-a4a1626c86f4
6
public PreparedStatement prepare(String query, String... params) { if (isOpen()) { try { PreparedStatement statement = this.connection.prepareStatement(query); int count = 1; if (params != null) { for (String value : params) { ...
683ae0d8-21a5-428c-953d-7da3573a9e3a
1
private ProxyConnection createNewConnection() throws DaoConnectException{ ProxyConnection conn = null; try { Class.forName(DB_DRIVER); Connection connection = (Connection) DriverManager.getConnection(DB_URL, DB_USER_NAME, DB_PASSWORD); connection.setAutoCommit(false);...
ebf9e573-4c5b-46af-a5a4-9eff7d6c8f29
6
public String getLowOrHighDate(String dateone, String datetwo, boolean highestDate) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = sdf.parse(dateone); Date date2 = sdf.parse(datetwo); if (date1.compareTo(date2) > 0) { if (!highestDate) { return datetwo; } el...
2864799d-d31b-44a5-bdee-ec9248c2db51
4
@Override public void DisableDirection(Direction direction) { this.direction = direction; if(current != direction){ if(current != Direction.None){ if(direction != Direction.None){ if(direction != Direction.All){ this.direction = Direction.All; } } } } current = ...
86462d5a-1dea-4033-9a6b-dfd1bc3cc2d6
1
public double getScore(ArrayList<Object> userAnswers) { double sum = 0; ArrayList<Question> questions = getQuestions(); for (int i = 0; i < questions.size(); i++) { sum += questions.get(i).getScore(userAnswers.get(i)); } return sum; }
eb936019-9b15-44cb-a516-7bf9da6d0dbb
8
public void laTouche() { double phi; double x1, y1, x4, y4, x2 = 0, y2 = 0, x3 = 0, y3 = 0; x1 = extremiteInitiale.getCoordonnees().getX(); y1 = extremiteInitiale.getCoordonnees().getY(); x4 = extremiteTerminale.getCoordonnees().getX(); y4 = extremiteTerminale.getCoordonnees().getY(); // Reconnaissance ...
67aa04c0-fba4-4d60-b82f-9abf2eac8798
5
public static void DBDelete(String[] tCodes){ Connection con = DBase.dbConnection(); PreparedStatement pst =null; try{ for (String tableCodes : tCodes){ String d = "delete from \"ME\"." + tableCodes; pst = con.prepareStatement(d); pst.exe...
1b800991-d6eb-4996-bbc5-d79601f9d061
7
public ListNode addTwoNumbers(ListNode l1, ListNode l2) { int carry = 0; int value = 0; ListNode head; ListNode temp; ListNode node; if (l1 == null || l2 == null) { return null; } value = l1.val + l2.val; head = new ListNode(value % 10); node = head; carry = value / 10; l1 = l1.next; l2 = l...
beac1c07-ac9c-4ab0-8e5b-e8aca5b319b6
4
public void take(Command command){ if (!command.hasSecondWord()){ System.out.println("take what?"); return; } String id = command.getSecondWord(); Item item = currentRoom.getItem(id); if(item != null) { if(item.canBeTaken()){ ...
a046a6b3-91bc-4848-8276-6cd7f8fb3b6c
4
public VSequence readSequence() { VSequence read = null; JFileChooser fileChosser = new JFileChooser(); int option = fileChosser.showOpenDialog(VMainWindow.window); switch (option) { case JFileChooser.APPROVE_OPTION: try { ...
2c357392-6373-4fd8-b27a-b01c5c12805b
2
public static RetailFacilityEnumeration fromValue(String v) { for (RetailFacilityEnumeration c: RetailFacilityEnumeration.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
7f619d14-bad9-4fcc-b4d0-ea968e23906f
2
public void addDconst(double d) { if (d == 0.0 || d == 1.0) addOpcode(14 + (int)d); // dconst_<n> else addLdc2w(d); }
bce767db-d131-459e-b04a-f86ab15a6fc8
5
public BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage)image; } image = new ImageIcon(image).getImage(); boolean hasAlpha = false; BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { i...
5bec54a2-945a-409c-b97e-fdde5d91f802
1
public static void deleteBucket(RestS3Service ss, S3Bucket sb) { try { ss.deleteBucket(sb.getName()); } catch (ServiceException e) { e.printStackTrace(); } }
76bf5dff-0c9f-477c-8f73-04747bc25410
1
public static String getPropertyDefaultAsString(PropertyContainer container, String key) { if (container != null) { Object value = container.getPropertyDefault(key); return convertObjectToString(value); } else { throw new IllegalArgumentException("Provided PropertyContainer was null."); } }
43e443e0-9fb6-4d9b-b4fa-466087382740
8
public void voidVisitAnnotated(Annotated p) { p.leadingCommentsAccept(this); noteContext(p.getContext(), !p.getAttributeAnnotations().isEmpty()); p.attributeAnnotationsAccept(this); List<AnnotationChild> before = (p.mayContainText() ? p.getFollowingElementAnnotations() ...
0c764d4e-8729-4dd1-8718-1fccbcf6061a
7
public void aimMyTank() { for(InfoDetail i : info.getEnemies()) { int n = 0; double x = Math.abs(i.getX() - me.getX()); int result = (int)(Math.toDegrees(Math.acos(x / allDistances.get(n)))); if(me.getX() <= i.getX() && me.getY() <= i.getY()) { ...
a137c97f-ac4d-43a0-b649-f001d30dfede
7
protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer) throws DecoderException { FrameDecoder decoder = null; // REVIEW: allow channel output selection type // (LEFT, RIGHT, BOTH, DOWNMIX) switch (layer) { case 3: if (l3decoder==null) { l3decoder = new LayerIIIDec...
0d915931-4d13-48b1-aa92-45e1b4ebd1c1
4
private void removeAVL(TreeNode startingNode, int searchingKey, int hash) { currentSearchHeight++; if (startingNode == null) { System.out.println("\nKey " + searchingKey + " not found."); return; } else { if (startingNode.key > searchingKey) { removeAVL(startingNode.left, searchingKey, hash); } el...
67a5468a-6877-4895-98a8-f470296edbd9
5
private void computeIndexings() { //Index the images. imageData = new int[width][height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { MultiColor c = new MultiColor(colorCount); for (int i = 0; i < imageCount; i++)...
5cb73e9c-d721-4371-b95f-1e6cc1b295df
5
public void searchBairro() { if (selectBtnSearchCidade == true && this.cidade.getCidade_id() != null) { facesContext = FacesContext.getCurrentInstance(); requestContext = RequestContext.getCurrentInstance(); List<Bairro> listBairro; try { bairro...
4b6c1e10-e602-43d2-bb44-4b5a45d4630a
9
public void launch(String command) throws Exception { // check format if(! this.launchInstancePattern.matcher(command).matches()) { System.out.println("Input format is not correct. " + Utils.FORMAT_COMMAND_LAUNCH_INSTANCE); return; } // RunInstancesRequest request = new RunInstancesRequest(); Strin...
ef27cb91-a1eb-42e4-83bc-ae6837c1f390
2
private static boolean isPrime(long n){ for(long i=2;i<Math.sqrt(n)+1;i++){ if (n%i == 0) return false; } return true; }
735f591a-57f1-46f4-af7d-87d347595517
2
public boolean removeInvalidLinks(){ //go over all the links and remove the ones set to false (set all the values to false) //a boolean to indicate, if something has changed boolean rval = false; edgeIterator.reset(); while(edgeIterator.hasNext()){ Edge edge = edgeIterator.next(); if(edge.valid ==...
08884876-6035-441a-9d68-58d302be13cc
8
public void move() { if(inhibit > 0) { inhibit--; }; boolean can_go_straight = can_go_at(x + dx, y + dy); Random random = new Random(); int r = random.nextInt(17);//(4); //r = 1; boolean has_turned = false; if(r == 0 && inhibit == 0) { has_turned = turn_left_or_right(); } if(!has_turned && !ca...
bf54429c-ee3f-4688-aac2-0cc13245e826
7
@Override public void hurt(Entity entity, int amount) { if (!level.creativeMode) { if (health > 0) { if (ai != null) { ai.hurt(entity, amount); } if (invulnerableTime > invulnerableDuration / 2F) { if (lastHe...
71fc5ba4-2045-4d14-8c19-526dbfced60d
3
public static void main(String[] args) throws InterruptedException { GWCAConnection gwcaConnection = null; try { LOG.info("Executing \"Java GWCAConstants\" (version {})", Version.getVersion()); //TODO: Fill in the PID of the running Guild Wars instance here (so replace the 6500...
f89f1bc5-29a9-4387-a349-bd3e75205611
6
private void addition(int countryCode, int numberToAdd){ if(IPCTrackerKeys.DEBUG_STATUS){ logger.log(CLASS_NAME, "DEBUG: Add"); } switch(countryCode){ case IPCTrackerKeys.CountryCodes.SU: logger.log(CLASS_NAME, "Adding: \"" + numberToAdd + "\" to SU"); int currentTotalSU = Integer.parseInt(lblTot...
ec69f790-bc2e-4133-b7ef-02801b45a185
9
public static int getRankOfSeven(int card_1, int card_2, int card_3, int card_4, int card_5, int card_6, int card_7) { long KEY = deckcardsKey[card_1] + deckcardsKey[card_2] + deckcardsKey[card_3] + deckcardsKey[card_4] + deckcardsKey[card_5] + deckcardsKey[card_6] + deckcardsKey[card_7]; int FLUSH_C...
a21721cb-eb8d-4ab5-ac9f-3cfcbbe0be60
2
public static void solve_equation(Double a, Double b) { Double d = -b/a; if(d.isInfinite() || d.isNaN()) System.out.println("INF"); else System.out.println(d); }
27c3cd82-3035-45ee-9765-6f7fa85594c9
8
@Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } Pair<?, ?> pair = (Pair<?, ?>) other; return Objects.equals(first, pair.first) && ...
bb528f7b-9f03-4121-a746-ef2b6f6bfb3a
6
private static void testKetraDemote(L2PcInstance player) { if (player.isAlliedWithKetra()) { // Drop the alliance (old friends become aggro). player.setAllianceWithVarkaKetra(0); final PcInventory inventory = player.getInventory(); // Drop by 1 the level of that alliance (symbolized by a quest ...
f40c8fb6-ca8b-47b4-bfb3-e9dd23e580db
0
private String readInput() throws IOException { return this.keyboard.readLine(); }
51d8ddaa-9c19-4970-9675-e3661c5c8798
9
int[][] generateTigerMove(Board b){ // fn() tested int[] tigerPositions = new int[3]; int trimLength = 0; tigerPositions = getTigers(b); int generatedTigerMoves[][] = new int[12][2]; for(int i=0,j=0; i<3; i++){ if(b.p[tigerPositions[i]].left != null){ if(isThisMoveValidForTiger(Integer.p...
b79a1c20-15f3-4bf8-b140-fbd79568ab76
5
private Tuple<String, Integer> getOptionalParameters(String[] args, int i) { if(i >= args.length) { // no args left return new Tuple<String,Integer>("", new Integer(i)); } if(!args[i].startsWith("(")) { // does not start with a '(' => no optional parameter. return new Tuple<String,Integer>("", new Int...
4ea30301-d5ef-4a44-bd91-a81c916a75ba
9
private void setBailout() { if(backup_orbit != null && orbit) { System.arraycopy(((DataBufferInt)backup_orbit.getRaster().getDataBuffer()).getData(), 0, ((DataBufferInt)image.getRaster().getDataBuffer()).getData(), 0, image_size * image_size); } main_panel.repaint(); String...
73fbf95e-6fa5-4495-b2f6-f36d916bbede
4
private void createGUI() { this.setLayout(null); playButton = new JButton(play); playButton.setOpaque(false); playButton.setBorderPainted(false); playButton.setContentAreaFilled(false); playButton.setBorder(null); playButton.setRolloverIcon(play_selected); ...
a854af60-0f8d-4471-84ee-694ad4640ed4
7
public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); count = new TreeMap<String, ArrayList<String>>(); words = new TreeSet<String>(); for(String line; (line = in.readLine())!=null; ){ if( ...
f37c30a2-133f-40b1-bcc1-17d98b39e562
4
void createListenersGroup () { listenersGroup = new Group (tabFolderPage, SWT.NONE); listenersGroup.setLayout (new GridLayout (4, false)); listenersGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1)); listenersGroup.setText (ControlExample.getResourceString ("Listeners")); /* * Creat...
6a0143de-bd25-4212-9c95-9b31a2345669
2
public void exibir(String num){ String res = null; for(int i = 0; i < telefonesEUA.size(); i++){ if( telefonesEUA.get(i).equals(num)){ res = telefonesEUA.get(i); } } System.out.println("(1)"+res.substring(0, 4)+"-"+res.substring(4, 8)); }
33a14644-2321-4339-b453-f542a4eb6360
2
public static void main(String argv[]) throws Exception { final long startTime = System.currentTimeMillis(); String inputFileName = argv[0]; final String outputFileName = argv[1]; int threadsCount = 4; if (argv.length > 2) { threadsCount = Integer.parseInt(argv[2]); } GridFactory gridFactory = new Fro...
c14f4c16-c24b-4427-8735-abe31878c176
0
public void run() { final String fileName = createFileName(); search(fileName); }
225ec77c-7eae-4304-b2c7-d0d1780b7af4
4
private void decompose() { for (ClassNode classNode : archive) for (Object node : classNode.methods) { MethodNode methodNode = (MethodNode) node; for (AbstractInsnNode abstractInsnNode : methodNode.instructions.toArray()) if (abstractInsnNode instanceof MethodInsnNode) scan((MethodInsnNode)...
af609201-eba0-4cac-8b91-decc4155e1db
7
private static int create(int t[]) { // constante des choix du menu final String menu[] = {"Début", "Fin", "Spécifier"}; int choix; // contient le choix de l'utilisateur dans le menu int index; // contient l'index de la case à modifier String input; // contient la valeur r...
44c5e4ce-cc69-4bd3-bf9b-973f7870c8b0
8
@SuppressWarnings("deprecation") @Override public void actionPerformed(ActionEvent e) { if(e.getSource() == btnGo) { if(!dayComboBox.getSelectedItem().equals("-")) { ViewAppointmentDatePanel vadp = new ViewAppointmentDatePanel(parent, username, Integer.parseInt((String) dayComboBox.getSelectedItem()), ...
55c6ae27-ef1c-4deb-8bef-8be2f995302f
6
private void cookFood(final Food food){ print("Action: cookFood(" + food + ")"); mCookGui.DoGoToFridge(); acquireSemaphore(semAtFridge); // mInventory.get(food.mChoice).mQuantity--; EnumItemType iType = Item.enumToEnum(food.mChoice); mRole.decreaseInventory(iType); /* //if food amount be...
95a4906c-b38a-492f-822d-470419f275af
0
@Override public void mousePressed(MouseEvent e) { unprocessedEvents.add(e); mouse = e.getPoint(); }
f2d938ce-111e-4bfe-ba14-eea6d3f4c490
9
@Override public void categoryShow(int refresh) { // TODO Auto-generated method stub appListener.getCategory(); jTable1 = new JTable(tablemodel) { private static final long serialVersionUID = 1L; /** * * @param row row number *...
d7a8c550-ed95-44c4-a731-1803e5969eaf
4
private String secondsToMinutes(int time) { int min = time / 60; int sec = time % 60; if(min<10) { if(sec<10) return "0"+min+":0"+sec; return "0"+min+":"+sec; } if(sec==0) return ""+min+":00"; if(sec<10) return ""+min+":0"+sec; return ""+min+":"+sec; }
a2ebaa55-ea77-4ae2-8717-1841718e8c90
4
public static void filledRectangle(double x, double y, double halfWidth, double halfHeight) { if (halfWidth < 0) throw new RuntimeException("half width can't be negative"); if (halfHeight < 0) throw new RuntimeException("half height can't be negative"); double xs = scaleX(x); double ys ...
3f59b7de-d5af-490d-9c70-200f2632efa2
4
private static boolean exportar(File file,List<JTable> tablas,List<String> nom_files){ try { //relaciona el stream de salida con el archivo creado DataOutputStream out = new DataOutputStream(new FileOutputStream(file)); //crea el libro para guardar el excel WritableWorkbook w = Workbook.createWorkbook(out...
2989ac66-7ddf-4b87-a382-58caca881d4e
1
protected void onLogin(String login, String password){ for (LoginListener listener: loginListeners) listener.onLogin(new LoginEvent(login, password)); }
f7991534-9d2a-48dd-a9de-0dc2c22bbb4a
8
public static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates) { if ((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) && model.probA!=null && model.probB!=null) { int i; int nr_class = model.nr_class; double[] dec_val...
747a0813-36c8-499b-ab90-455226d313b2
4
public boolean writeReport(String content){ Report report = generateReport(content); Session session = null; SessionFactory sessionFactory = null; try { Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder...
0f38b87d-c395-4b74-bfed-72407944a6ab
3
public final void setMinMeasuredValueDecimals(final int MIN_MEASURED_VALUE_DECIMALS) { final int DECIMALS = MIN_MEASURED_VALUE_DECIMALS > 5 ? 5 : (MIN_MEASURED_VALUE_DECIMALS < 0 ? 0 : MIN_MEASURED_VALUE_DECIMALS); if (null == minMeasuredValueDecimals) { _minMeasuredValueDecimals = MIN_MEASU...
8221a186-1bc2-47a4-bf8e-2bbbed99a27c
2
public static void setRenderingMode(DrawableComponent component, int mode) { if (mode == NORMAL_MODE) { //TODO:Normal mode render } if (mode == MODEL_MODE) { modelMode(component); } }
55a99fef-0c54-497e-b9ea-bdd1812db643
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int i = 1; for (String line; (line = in.readLine())!=null && !line.equals("#"); i++) { System.out.print("Case "+i+": "); if(line.equals("HELLO")) System.out.println( "ENGLIS...
1cce4630-11e2-4051-8caf-c57cf84bc23e
3
public ManaAltar getClosestManaAltar(Point point) { ManaAltar closestManaAltar = null; double distance = Double.POSITIVE_INFINITY; for(Building building : buildings) { if(building instanceof ManaAltar) { Point manaAltarPos = new Point(building.getIntX(), building.getIntY()); if(distance > Geometry.squa...
0243d35c-2daa-4f50-a844-14c762edec41
2
private static BigDecimal change(int[] coin_totals, BigDecimal balance, String remainderOf, int arrayIndex) { BigDecimal remainder = new BigDecimal(remainderOf); if(!balance.equals(ZERO_VALUE)) { BigDecimal monetary_remainder = balance.remainder(remain...
0979ffa4-f39b-46f7-bc8a-bc166da7fd47
1
@Override public int getWidth() { int width = 2; for (UiGlyph uiGlyph : this.uiGlyphs) { width += uiGlyph.getGlyph().getWidth(); } return width; }
d9661795-404c-4186-9713-f500964efbd7
6
public static Polynomial parse(String input) { Polynomial p = new Polynomial(); input = input.replace(" ", ""); input = input.replace("-", "+-"); input = input.replace("–", "+-"); String[] parts = input.split("\\+"); for (String part : parts) { if (!(part.trim...
180576cd-43c4-46e2-944b-2bb0aed4692a
5
private void handleFileSaveAs() { String chosenFileName = null; while(JFileChooser.APPROVE_OPTION == fileChooser.showSaveDialog(frame)) { File file = fileChooser.getSelectedFile(); chosenFileName = file.getAbsolutePath(); if(file.exists()) { int decision = JOptionPane.showConfirmDialog(frame ,new ...
41300f00-6948-4708-bba3-f5cbf561a9f7
7
public void uimsg(String msg, Object... args) { if (msg == "log") { Color col = null; if (args.length > 1) col = (Color) args[1]; out.append((String) args[0], col); } else if (msg == "btns") { if (btns != null) { for (Button...
0e258059-a561-4fc8-8ba6-c76883c74971
9
public void showClueNumber(int clueNumber) { setBackground(Color.WHITE); setBorder(BorderFactory.createEtchedBorder()); if(clueNumber != 0) { setFont(new Font(getFont().getName(), Font.BOLD, 16)); setText(Integer.toString(clueNumber)); validate(); } switch(clueNumber) { case 1: setForegrou...
e2f688b2-9fd4-4e0b-9490-7a53ab8aa1ef
4
public String toString() { switch( id ) { case Ai.TYPE_TEXT: return getText(); case Ai.TYPE_VALS: return getDefinition(); case Ai.TYPE_CATEGORIES: return getDefinition(); case Ai.TYPE_BUBBLES: return getDefinition(); } return super.toString(); }
ab9c0c6c-fa44-4ba9-94a6-a6a29460266e
8
public void onAction(String binding, boolean value, float tpf) { if (binding.equals("Left")) { keys[0] = value; } else if (binding.equals("Right")) { keys[1] = value; } else if (binding.equals("Up")) { keys[2] = value; } else if (binding.equals("Down")) { keys[3] = value; } else if (bind...
3b9551a9-aeb6-469c-81de-2591d613153e
1
public static Game Create(String name, int width, int height) throws Exception { if(game == null) { game = new Game(name, width, height); } else { throw new Exception(); } return game; }
451fe679-8372-48fd-a8c6-9704fc9c0241
5
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String url=req.getServletPath(); HttpSession session=req.getSession(); pm=PMF.get().getPersistenceManager(); if(url.endsWith("/login")) { Person p; UserService userService = UserS...
344dd3ea-1486-4512-9fb9-677e04805f7d
3
private Double parseFloat() throws StreamCorruptedException { StringBuffer lenStr = new StringBuffer(); while (input.remaining() > 0) { char ch = input.get(); if (ch == ';') { //indexPlus(1); break; } else { lenStr.append(ch); } } Double value = 0D; try { value = Double.valueOf(le...
cd86d933-44ea-4455-8893-e4281cf77c27
6
private static List<String> getResourcesFromJar(File file, String path, boolean directories) throws IOException { List<String> resources = new ArrayList<String>(); ZipFile zipFile = null; try { zipFile = new ZipFile(file); Enumeration<? extends ZipEntry> enumeration = z...
024adf1c-056a-4546-9b46-f35926156135
6
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Trip)) return false; Trip trip = (Trip) o; if (routes != null ? !routes.equals(trip.routes) : trip.routes != null) return false; if (vehicle != null ? !vehicle.equals(trip.vehicle) : ...
6f5ff6aa-b015-4de1-8d38-2d6aa76e47a0
3
public void visitStaticFieldExpr(final StaticFieldExpr expr) { if (expr.isDef()) { sideEffects |= SideEffectChecker.STORE; } final MemberRef field = expr.field(); try { final FieldEditor e = context.editField(field); if (e.isVolatile()) { sideEffects |= SideEffectChecker.VOLATILE; } conte...
0f42e71d-4a57-4b59-88e7-bd949602cfd5
7
public boolean hadNameAtTime(UUID uuid, String name, int timestamp) { Map<Integer, String> history = this.getNameHistory(uuid); for (int ts : history.keySet()) { if (!history.get(ts).equals(name)) continue; int next = (int) (System.currentTimeMillis() / 1000L); ...
71ea5eb1-5e13-4bdb-9d12-29d2c5054612
9
public void parseParameters(String paramstring) throws MaltChainedException { if (paramstring == null) { return; } final String[] argv; try { argv = paramstring.split("[_\\p{Blank}]"); } catch (PatternSyntaxException e) { throw new LibException("Could not split the parameter string '"+paramstring+"'....
b14ef1e0-bfcf-4487-99b5-891af741e182
8
public <X extends T> T getValue( Getter<X> populator ) throws ResourceNotFound { T value = getValueIfImmediatelyAvailable(); if( value != null ) return value; while( !lockForPopulation() ) { synchronized( this ) { while(beingPopulated) try { wait(); } catch( InterruptedException e ) { T...
65f7df66-b95a-4d16-a6ad-fbbbe3eec3f2
8
@Override public void executeMsg(Environmental host, CMMsg msg) { if(owner() instanceof MOB) { // check to see if this event is a LOOK or EXAMINE event // and see of the target of the action is the owner of // this hand of cards, and also check quickly whether // the player HAS any cards. if(((msg....
eb4c5507-b853-4b99-8536-244513e98772
8
public void generateMap(WumpusGraphics wg) { if (!mapGenerated) { // ensure we only generate the map once // generate exactly one wumpus int wX, wY; graphics = wg; do { wX = (int)(Math.random() * 4); wY = (int)(Math.random() * 4); } while (!validWumpusCoord(wX, wY)); ...
a09874f3-8856-4635-a74f-efcc05d8e145
8
public static Mesh loadMesh(String fileName) { String[] splitArray = fileName.split("\\."); String ext = splitArray[splitArray.length - 1]; if (!ext.equals("obj")) { System.err.println("Error: File format not supported for mesh data: " + ext); new Exception().printStackT...
77a3d5b9-261b-4128-ba25-3b4066aa2416
4
public static String sendGetRequest(String URL) { URL u = null; try { u = new URL(URL); } catch (MalformedURLException e1) { e1.printStackTrace(); } String contents = ""; try { BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream())); String line = ""; while ((line...
807d6cb8-0670-4a3e-a988-96b2f303b9f8
9
public void tick(){ int left = 0, down = 0, zoom = 0; if(window.getKey(KeyEvent.VK_LEFT)){left++;} if(window.getKey(KeyEvent.VK_RIGHT)){left--;} if(window.getKey(KeyEvent.VK_UP)){down--;} if(window.getKey(KeyEvent.VK_DOWN)){down++;} //y = win.pollMouseWheelClicks(); if(window.getKey(KeyEvent.VK_PAGE_U...
cd27403f-9772-46ad-855e-cf9cb1078f93
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double) o).isInfinite() || ((Double) o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
40d53f21-42c7-4700-b617-eb43b6fcd85d
6
public static boolean isLocationVisible(Location l) { if(NoFoW) return true; //Check all ships in player's fleet to see if any are within range. ArrayList<Ship> fleet = players.get(currentPlayer - 1).getFleet(); for(int i = 0; i < fleet.size(); i++) { Ship s = fleet.get(i); if(Location.distance(s.getLo...
a3312657-ec5d-47fa-9b1f-154a31ad8ac6
2
public NamedBinaryTag readNBT() throws IOException { final byte type = this.readByte(); if (type == NamedBinaryTag.TYPE_END) { return null; } final NamedBinaryTag nbt = NBTParser.createFromType(type); if (nbt != null) { nbt.readValue(this); } return nbt; }
ad1918a0-9b67-4762-a17e-1a451e2a0d06
9
public int removeNode(XMLTreeNode node, File bitmapFile){ if(node.isFileNode()){ // Remove a file int numOfBlocks = Integer.parseInt(node.getNode().getAttributes().item(0).toString().split("\"")[1]); int fileNumber = Integer.parseInt(node.getNode().getAttributes().item(3).to...
ed60ce9e-21ce-425c-b849-78d3801009b6
4
private void initialize() { setLayout(new BorderLayout(10, 10)); setSize(950, 550); setTitle("MoruTask"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ...
23947673-082d-4a52-bd8e-2b208aed77d8
2
public void put(Piece p, int x, int y) { if ( !isValidMove(x, y) ) { // direct error info to handler return; } if ( cache[x][y] != null ){ System.err.println( "Please Check Your Move!"); return ; } cache[x][y] = p; }
bfaae74d-1354-41cc-b10e-5fdae9b716fe
1
public void loot(){ if(loot.size() > 0){ Game.UI.showLootDialog(loot); } }
39a28e61-bdc4-40cb-885b-debe915ce9fd
0
public Employee(int id, String name, int age, int salary) { this.id = id; this.name = name; this.age = age; this.salary = salary; }
f7d8fd2a-9287-49f7-8ea9-e287bf69866d
5
public void set(String path, Object value) { Configuration root = getRoot(); if (root == null) { throw new IllegalStateException("Cannot use section without a root"); } final char separator = root.options().pathSeparator(); // i1 is the leading (higher) index ...
cfb7b090-43d1-4354-bea5-027b2166c7e9
6
public static void oldWriteANOVAs(File outFile, GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // open file for writing with a nice print stream object: PrintWriter ostream = makePWriter(outFile); // OKAY VAR NAME? // get all condition-group sequence...
59d83a98-45ea-440d-8f24-4b93a16dadcf
0
public BaseballGame(String teamOne, String teamTwo) { this.team1 = teamOne; this.team2 = teamTwo; totalGamesPlayed++; }
42aba53b-a4bc-45b9-b621-184997f8b89a
6
@EventHandler public void ZombieFireResistance(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Zombie....
ce4797e1-2cee-42c1-aebe-369b69b0b486
8
public void start() throws Exception { //TODO executors new Thread(null, flushManager, "node-manager[" + name + "]").start(); // new Thread(null, compactManager, "compact-manager[" + name + "]").start(); System.out.println("NODE: INFO: Starting Node"); Selector selector; ...
eda29bd9-d7f2-40b1-bab2-1ad4edcdd8e2
4
public static void main(String args[])throws java.io.IOException{ char choice, ignore; Help hlpobj = new Help(); for(;;){ do{ hlpobj.showmenu(); choice = (char) System.in.read(); do{ ignore = (char) System.i...
934e00c6-c72f-496c-a039-52a8ec5ce7bf
2
public MenuItem getReceiptUiItem() { if (receiptUiItem == null) { receiptUiItem = new MenuItem("Show Receipt Panel"); receiptUiItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { new ReceiptListPanel(); } catch (Exception ex) { ex.printSta...
e2a4cd14-add0-4f5d-b2c7-ad746d22c053
5
private int findeErsteFigur(Figur[] figurenArray) { int figurIndex = 0; boolean figurIstImZiel = false; do { int[] aktuellePos = figurenArray[figurIndex].getPosition(); figurIstImZiel = false; for (int[] zielPosition : getZielPsotionen()) { if (aktuellePos[0] == zielPosition[0] && aktuellePo...
9b22c2a5-71a3-4782-b002-5384a21a195e
1
public Object bind(Object delegate) { this.delegate = delegate; Class<?> cs = delegate.getClass(); return Proxy.newProxyInstance(cs.getClassLoader(), cs.getInterfaces(), this); }
37d990fc-e211-4df2-8c15-e5cd86647cc0
7
JPEGHuffman(byte[] data, int[] scan_index){ if (JPEGParser.verbose > 5) { System.out.println("Building Huffman Table..."); } mPairs = new TreeMap<String, Integer>(); // 表类型 0--DC 1--AC mType = data[scan_index[0]] >>> 4; // 表ID mID = data[scan_index[0...
1b2ed720-8157-4303-becd-2755d24c0a25
3
public static void inint(int n) { for (int i = 0; i < n; i++) for (int k = 0; k < n; k++) if (i != k) d[i][k] = INF; else d[i][k] = 0; }
569648ec-6ffa-436b-be68-e8bbcd185d44
3
private double[] getNormalisedData(int width, int height) { int averageSize = Math.max(data.length / width, 1); double[] result = new double[data.length / averageSize]; currentMaxValue = Double.NEGATIVE_INFINITY; // Average the data such that it fits on the x a...