method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
2e0668da-a322-4e8d-a0c9-4cc5920ea88c
1
@SuppressWarnings("unchecked") public Stack arbitrary(Random random, long size) { int length = (int) Arbitrary.random(random, 0, Math.min(Integer.MAX_VALUE, size)); Stack list = new Stack(); for (int i = 0; i < length; ++i) { list.add(su...
f08b6fe8-6faf-46ee-9d24-b70428f9dfb3
1
public double[] decodeDoubles() { double[] res = new double[decodeInt()]; for (int i = 0; i < res.length; i++) { res[i] = decodeDouble(); } return res; }
000017aa-e7c1-45ad-b6c4-1d7942502a9a
4
private BufferedReader makeRequest() { URL request; String authtext = ""; if(!mUser.equalsIgnoreCase("") && !mPass.equalsIgnoreCase("")) // If the user provided both username and password, include them. authtext = mUser + ":" + mPass + "@"; URL url; try { // Check that the URL is ok and form the request...
1ee589cb-a3d7-4fad-bfd4-6cd8a7d1d167
0
public NFAToDFA() { }
9016320e-3d82-46d0-a4c9-bc24a45029bc
9
public static boolean CanTheyCastling(Collection<Pawn> tmp, Pawn p2, Pawn p1, BoardGame elem) { // tmp is her the current BoardGame but don't care if (!_canCastling(tmp, p2,p1,elem)) // Start Position and Good Pawns/Color return false; if (elem.getPositionFirstObstacleColumnRange(tmp, p2, p1.GetPosition()) !=...
0d0baa13-9f44-4a83-82bd-987eb04450f1
4
public EnemyWaves(Board board,Point castlePos, Point enemyStartingPosition) { int nrOfWaves = 10; final double groupActivationTime = 1000.0; int y = board.getCastlePos().getY(); int x = 0; EnemyPath enemyPathing = new EnemyPath(enemyStartingPosition, castlePos); path = e...
c9e31166-5966-4ed8-9f2f-7c38323613d8
7
public int loadfileResult(String nfile, Map<String,Party> mParties) { double totalShare= 0.0; int updateFileValue = 1; try { // Let's go to process the file File file = new File(nfile); // JaxB process JAXBContext jaxbContext = JAXBContext.newInstance(ConstituencyResults.class); // Convert fr...
6f5416e1-7586-47bb-9f96-cc3b45508071
5
public void getKnightTour(mxAnalysisGraph aGraph, int xDim, int yDim, int startVertexValue) throws StructuralException { if (xDim < 5 || yDim < 5) { throw new IllegalArgumentException(); } ArrayList<Object> resultPath = new ArrayList<Object>(); int vertexNum = xDim * yDim; mxGraph graph = aGraph.getGr...
000e7d78-6c81-4746-821c-c43dc7a7d3a3
8
private void bindJDBCConfig(EnvConfigBean envConfig, Document document) { NodeList jdbcNodes = document.getElementsByTagName("jdbc"); if(null != jdbcNodes && jdbcNodes.getLength() > 0) { Node node = jdbcNodes.item(0); NodeList jdbcProps = node.getChildNodes(); ...
a7fbda70-f612-4d85-b840-294e481b8d42
0
public Child() { System.out.println("This is Child !"); }
418b7741-77bc-46c9-a52f-48e5b02e11b0
5
final void method438(int i, int i_64_, String string) { if (((Widget) this).aStringArray833 == null || i >= ((Widget) this).aStringArray833.length) { String[] strings = new String[i + 1]; if (((Widget) this).aStringArray833 != null) { for (int i_65_ = 0; ((i_65_ ^ 0xffffffff) > (((Widget) thi...
7890cf1e-41ab-4347-90d1-d0b02a5b40a0
0
private void setSpeed(Speed speed) { this.speed = speed; }
54be5f4b-0b1e-4074-8218-165c279a368a
8
@Override public void unInvoke() { final Physical P=affected; super.unInvoke(); if((P instanceof MOB)&&(this.canBeUninvoked)&&(this.unInvoked)) { if((!P.amDestroyed())&&(((MOB)P).amFollowing()==null)) { final Room R=CMLib.map().roomLocation(P); if(!CMLib.law().doesHavePriviledgesHere(invoker(), ...
423a65c1-686a-467f-af42-68f4545ee7fe
0
public String getLastName() { return LastName; }
a2421603-bd25-4966-8170-43f62b30ac1a
8
private Class<? extends ItemSimilarity> getSelectedItemSimilarityClass() { Class<? extends ItemSimilarity> clazz = LogLikelihoodSimilarity.class; if (similarClassBox.getSelectedIndex() == 1) { clazz = CityBlockSimilarity.class; } else if (similarClassBox.getSelectedIndex() == 2) { clazz = EuclideanDistan...
9fe9d249-4887-4da9-a540-45bcf49d80c0
6
@Override public ArrayList<Task> findByOwner(int id) { ArrayList taskList = new ArrayList(); try { connection = getConnection(); ptmt = connection.prepareStatement(QUERY_SELECT + " WHERE id_owner=?;"); ptmt.setInt(1, id); resultSet = ptmt.executeQuery(...
b71e2106-eb90-4fb6-b26d-2555901e7e15
0
public Point2D getMouse() { return (Point2D) mouse.clone(); }
0dc627f0-f87c-4178-863a-d9c5c04c08e0
9
@Override public boolean make(PublicGameBoard board) { BoardCoordinate c = _target.location(); int v = -1; boolean exp = board.isExpanded(); int nv = (exp)? NUM_VERTICES_EXP:NUM_VERTICES; Map<Integer, List<Integer>> x_gr = (exp)? X_GROUPS_EXP:X_GROUPS; Map<Integer, List<Integer>> y_gr = (exp)? Y_GROUPS_EXP...
62d5c912-b4d2-4df8-93fb-e763ca092941
0
private void stopNettyServer() { ChannelGroupFuture future = _channels.close(); future.awaitUninterruptibly(); _factory.releaseExternalResources(); _started = false; }
82482488-ccbe-4908-aa0e-6e96b7d6bd21
4
protected int neighborhood(boolean[][] tmpArea, int x, int y){ int neighborhood = 0; for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ if (tmpArea[x+i-1][y+j-1] ){ neighborhood++; } } } if (tmpArea[x][y] ){ neighborhood--; } return neighborhood; }
529cd697-6f1d-40b5-8bb4-e764fe5167e3
7
public void createFood(int size) { if (size >= maxX || size >= maxY) { return; } boolean validPos = false; while (!validPos) { food = new Food(size, new Vector2d((int)(Math.random()*(maxX-size)), (int)(Math.random()*(maxY-size)))); for (Snake snake : a...
380f4e4c-7f67-49c6-af6c-569d3e426a8f
1
public static String guessEncoding(byte[] bytes) { UniversalDetector detector = new UniversalDetector(null); detector.handleData(bytes, 0, bytes.length); detector.dataEnd(); String encoding = detector.getDetectedCharset(); detector.reset(); if (encoding == null) { encoding = DEFAULT_CONTENTTYPE; } ...
6b1fce2f-fe23-4ed1-b9bd-2d0369b989af
3
public void loadTileMap(String file) { InputStream is = getClass().getResourceAsStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String delimiter = "\\s+"; try { rowsInMap = Integer.parseInt(br.readLine()); colsInMap = Integer.parse...
42aefa4d-3eda-4952-bf5d-ed132536f403
3
public void setString(PString node) { if(this._string_ != null) { this._string_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); ...
a1cc2791-d990-458b-8103-10168c7f2595
7
private NodeDouble<E> getIndex(int index){ if (index == 0){ return _head; } else if(index == _lenght-1){ return _tail; } else if (0< index && index < _lenght-1){ int calculo = (_lenght/2) - index; NodeDouble<E> actual; if(calculo <= 0){ calculo = _lenght - index-1; actual = _tail; f...
919dd9ed-f011-4455-b776-06918979f791
4
public boolean FullGuthanEquipped() { if(playerEquipment[playerHat] == 4724 && playerEquipment[playerChest] == 4728 && playerEquipment[playerLegs] == 4730 && playerEquipment[playerWeapon] == 4726) { return true; } return false; }
6c5a4742-50cc-4342-8a5a-73d9df8e9a79
4
@SuppressWarnings("deprecation") public void send() { String httpsURL = url; String query = "access_token=" + token + "&message="; query += URLEncoder.encode(message); URL myurl; try { myurl = new URL(httpsURL); HttpsURLConnection con = (HttpsURLConnection) myurl .openConnection(); con.setReque...
aa735fff-6311-4e66-9b6d-d5d3c2f9a140
3
public int[] getNext(char[] t){ int[] next = new int[t.length]; next[0] = -1; int i = 0; int j = -1; while(i < t.length-1){ if(j == -1 || t[i] == t[j]){ i++; j++; next[i] = j; }else{ j = next[...
d2efe04c-50b1-4fa1-8eff-0255ec501cda
8
public static void endCalib() { CALIB_ADJ_MIN_Y = SCREEN_HEIGHT / 2; CALIB_ADJ_MAX_Y = SCREEN_HEIGHT / 2; CALIB_ADJ_MIN_X = SCREEN_WIDTH / 2; CALIB_ADJ_MAX_X = SCREEN_WIDTH / 2; for (int x = 127; x >= 0; x--) { if (CALIB_ADJ_X[x] == 1) { CALIB_ADJ_MIN...
7ad36392-a415-43bc-9463-a4f5b8953c6a
5
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=utf-8"); // String action = request.getParameter("action"); HttpSession session = requ...
e40b575c-c446-4426-a0cb-4c686e60649a
1
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User u = new User(); u.setName(request.getParameter("name")); response.setContentType("text/html;charset=UTF-8"); try (PrintWriter ...
2c4a0aea-dc48-4056-8ed4-7853c95c4177
6
public boolean growMelons(Player player, String[] args, int radius) { Block playerCenter = player.getLocation().getBlock(); // Get Centrepoint (Player) int melons = 0; for (int x = -radius; x < radius; x++) { for (int y = -radius; y < radius; y++) { for (int z = -radius; z < radius; z...
538ef40e-f8dd-4922-ab30-5840c31b46a7
6
public boolean getBoolean(String key) throws JSONException { Object object = this.get(key); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String)object).equalsIgnoreCase("false"))) { return false; } else if (object.equals(Boolean.T...
5dcbb71d-14e9-499d-944f-55eb461cf5b8
2
private void sendToAllBut(String name,String message) { for (ClientAgent cl : handlers) { if (cl.getClientName().compareTo(name) != 0) cl.sendChatMessage(name,message); } }
38aded64-ebcb-4c6b-a8a2-bbb7db901973
4
@Override public void onFinish() { Vertex leader = null; for (Vertex v : player.graph.vertices) if (v.getVariable("leader").equals("yes")) leader = v; if (leader == null) return; Object[] values = { leader.getID(), player.model.overallMessageCo...
22a4f435-8c72-4277-b09a-93a9def72b90
2
@Override public String format(LogRecord record) { StringBuilder sb = new StringBuilder(); sb.append("[").append(record.getLevel().getName()).append(" ").append(new Date().toString()) .append("] ") .append(formatMessage(record)) .append(LINE_SEPARATOR); if (record.getThrown() != null) { try {...
df3af780-3975-41c5-9962-6c2a7323bf28
9
public ArrayList<Move> getPossibleMoves() { ArrayList<Move> possibleMoves = new ArrayList<Move>(); for(int i = - 1; i <= 1; i += 2) { for(int j = -1; j <= 1; j += 2) { Location currentLoc = new Location(getLoc().getRow() + j, getLoc().getCol() + i); if(getBoard().isValid(currentLoc)) {...
93f20341-adfa-4c89-b918-708171814861
6
private void setActions(){ back = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { new MainMenu(trolleyApp); removeActions(); } }; next = new AbstractAction() { @Override p...
25bfe7b4-7dcf-4d8f-880a-d56a760dec45
4
private static void forward() { source.remove(MAN); destination.add(MAN); for (int i = 0; i < source.size(); i++) { if (source.get(i).equals(lastTransfer)) { continue; } ArrayList<String> sourceSimulator = new ArrayList<String>(source); ArrayList<String> destinationSimulator = new ArrayList<Stri...
10634f7e-a265-4680-a8f5-259ef3ff1942
3
public boolean appliesToCurrentEnvironment() { if (this.rules == null) return true; Rule.Action lastAction = Rule.Action.DISALLOW; for (Rule rule : this.rules) { Rule.Action action = rule.getAppliedAction(); if (action != null) lastAction = action; } return lastAction == Rule.Action.AL...
50d047bd-3b74-4e40-993a-7ee0f24a665f
3
@Override public boolean contains(Object item) { boolean isContains=false; for (int i = 0; i < numItems; i++) { if (items[i] != null && items[i].equals(item)){ isContains= true; break; } else isContains= false; } return isContains; }
94a7c60c-0ca3-4207-92b9-33df359be063
8
private CohoSolverResult rightEnd(double alpha, double delta, LPBasis leftB, CohoSolverResult result, CohoSolver solver, Matrix A_C,Matrix x, Matrix y, int beginTime, int minTimes,int maxTimes){ LPBasis rightB = result.optBasis(); double stepTurn = Math.max(delta+planeEps*planeEps*Math.max(1,alpha),planeEps...
23505c25-0b09-4148-a011-91995962ae1b
9
void addOrder(OMMMapEntry entry) { OMMData data = entry.getData(); if (data.getType() != OMMTypes.FIELD_LIST) { myCallback.notifyStatus("AddOrder: Invalid data type; expecting FieldList!!!"); return; } OMMData keyData = entry.getKey(); if (key...
524da0af-abba-40e2-98b2-847d36565d34
9
public void nextCycle(Node node, int protocolID) { // Do that only once: if (avg_done == false) { calculateAVG(protocolID); System.out.println("AVG only once " + average); } if (Math.abs(value - average) < 1) { AvgBalance.suspend(node); // switch off ...
ec3f87a0-d3da-41d3-83a7-4f6124895710
6
public void drawObjects(Graphics2D g, Iterable<GameObject> objs) { double minx = center.x - Constants.FRAME_WIDTH /2.0; double maxx = center.x + Constants.FRAME_WIDTH /2.0; double miny = center.y - Constants.FRAME_HEIGHT /2.0; double maxy = center.y + Constants.FRAME_HEIGHT /2.0; ...
8e783bf0-b781-45ea-b2c1-ec7529036de9
0
@Override public int getMaximum() {return bar.getMaximum();}
85bb6203-414d-41cb-9f4e-42021b27edbe
5
private void print() { for(int i = 0; i < map.length; i++){ for(int j = 0; j < map[0].length; j++){ if(map[i][j] == 5f) System.out.print("X"); else if(map[i][j] == 2f) System.out.print("#"); else if(map[i][j] == 3f) System.out.print("@"); else System.out.print("+"); } System.out.println(); ...
9870824a-35c5-4f59-9fa3-5906291b183b
7
@Override public T invoke(Object... parameters) { if (!this.isValid()) return null; boolean needsInstance = this.isStatic ? false : (this.from != null ? false : true); Object instance = needsInstance ? parameters[0] : (this.isStatic ? null : this.from); if (needsInstance)...
ad1091f8-92f5-43b4-a870-3fab68681a3d
3
private static void playLocallyAgainstSelf() { PlayChess whiteTeam = new PlayChess(Board.white); PlayChess blackTeam = new PlayChess(Board.black); while (true) { System.out.println("MOVING FOR WHITE"); if (whiteTeam.board.gameIsOver()) { System.out.println("Game over"); break; } Node nextNode ...
728d01a4-5fd9-4f95-8eb7-90c9da3c78c0
9
public SceneComponent() { shapes = new ArrayList<SceneShape>(); selectS = null; addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { boolean clicked = false; mousePoint = e.getPoint(); for (SceneShape s : shapes) { if (s.contains(mousePoint)) { s.s...
10344278-acd4-48ca-957d-9f0c6a948356
8
private String prepareConfigString(String configString) { int lastLine = 0; int headerLine = 0; String[] lines = configString.split("\n"); StringBuilder config = new StringBuilder(""); for (String line : lines) { if (line.startsWith(this.getPluginName() + "_COMMEN...
afb8fd1a-792d-4728-818c-627684dcd836
2
public short getMaximumDifference_as_short(){ short diff = (short) 0; if(this.type==8 || this.type==9){ short max = this.getMaximum_as_short(); short min = this.getMinimum_as_short(); diff = (short)(max - min); } else{ throw new IllegalArgu...
429188ef-eada-4fe3-9ed7-4affa27b0f8f
4
public double deltaCostForReplace(Integer sourceNode, Integer targetNode) { if ( steps.contains(targetNode) || !steps.contains(sourceNode)) { throw new IllegalArgumentException("path doesn't contain 'sourceNode' or path already contains 'targetNode'"); } int position = ...
f3cd04f8-7dd4-43fb-a52f-5570bf420f28
1
public static Long getPlayerPrevTime(Player player) { if(cooldown.containsKey(player)) return cooldown.get(player); else { cooldown.put(player, System.currentTimeMillis()); return (long) -1; } }
8c241576-b746-4c31-89e4-80d43d02a60b
3
public void setColcheteD(TColcheteD node) { if(this._colcheteD_ != null) { this._colcheteD_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.par...
6705fa58-6977-43c2-a6ec-7e8e588ceb9e
4
@Override public double getValue(int row, int col) throws MatrixIndexOutOfBoundsException { if ((row < 0) || (col < 0) || (row >= mas.length) || (col >= mas[0].length)) { throw new MatrixIndexOutOfBoundsException("Inadmissible value of an index."); } return mas[row][col]; }
7f0ae585-8284-4f57-9f08-e81459ce6b62
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (int N; (N = parseInt(in.readLine().trim()))!=0; ) { int[][] puntos = new int[N][2]; for (int i = 0; i < N; i++) { StringTokenizer st = new StringTokenizer(in.readLine()....
8f23bc66-c9c5-4791-a5e8-2d22ba7c939a
1
public void setOn(boolean isOn) { _isOn = isOn; if (_isOn) { this.setIcon(_onImage); } else { this.setIcon(_offImage); } }
9cd30312-5ccd-4bab-af7f-8a30604d4c67
2
public void placeRoad(EdgeLocation edgeLoc) { if (!playingRoadBuildingCard) presenter.buildRoad(edgeLoc); else { if (numRoadsPlaced == 0) { numRoadsPlaced++; edgeLoc1 = edgeLoc; } else { presenter.playRoadBuildingCard(edgeLoc1, edgeLoc); numRoadsPlaced = 0; playingRoadBuildingCard =...
2f411790-943e-4120-bf96-a73bfc76d98c
1
public void initOperands(int opcount) { operandcount = opcount; subExpressions = new Expression[opcount]; for (int i = 0; i < opcount; i++) { subExpressions[i] = new NopOperator(Type.tUnknown); subExpressions[i].parent = this; } updateSubTypes(); }
c4400f2d-045b-4bdf-b668-6f1065724c5a
8
static private int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(2, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(3, active0); return 4; } switch(curChar) { cas...
010eae45-1ce3-4be3-b62f-3bb4b87441a3
0
public Map<SootClass, Set<Integer>> getLayoutClasses() { return this.layoutClasses; }
986fdda1-896f-4c2d-8a04-53bfcd6b9a71
4
public static boolean isValid(byte[] buf) { return ByteUtils.startWith(buf, (byte) SPECIFIER_STRING) || ByteUtils.startWith(buf, (byte) SPECIFIER_ERROR) || ByteUtils.startWith(buf, (byte) SPECIFIER_INTEGER) || ByteUtils.startWith(buf, (byte) SPECIFIER_BULK) || ByteUtils.startWith(buf, (byte) SPECIFIE...
f51e8cff-096f-4d34-8301-3be8ad720cf6
4
public void run() { Thread.currentThread().setName("ManagerSocketServer"); chatServer = ChatSocketServer.getServerSingleton(); chatServer.start(chatSocketServerPort); gameServer = GameSocketServer.getServerSingleton(); gameServer.start(gameSocketServerPort); if (debug) { User amir = User.getInstance("Ami...
c2367369-c14c-433e-b956-3840e1cb70fe
0
public void closeDoor() { System.out.println("模板共性,关闭车门"); }
55883438-9541-490a-b617-b698c7f71c25
2
@GET public Response twitterAuthorization( @QueryParam("oauth_token") String oAuthToken, @QueryParam("oauth_verifier") String oAuthVerifier) { if (oAuthToken != null) { twitterManager.setAccessCode(oAuthToken, oAuthVerifier); return Response.ok(Response.Status.OK).build(); } else { try { return ...
d5ac8e46-d83d-4933-989b-62b41baf9c57
4
private static boolean Delete(File f, String line) { try { List<String> lines = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new FileReader(f)); String line_file; while((line_file = reader.readLine()) != null){ lines.add(line_fil...
61de54c1-c318-4323-ac70-988d3c563c48
4
public static void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis) { if (semiMajorAxis < 0) throw new RuntimeException("ellipse semimajor axis can't be negative"); if (semiMinorAxis < 0) throw new RuntimeException("ellipse semiminor axis can't be negative"); double xs = s...
f8608e20-9e73-4bab-8f71-3e1b642491e7
6
public void renderTile(int xp, int yp, Tile tile) { for (int y = 0; y < tile.sprite.SIZE; y++) { int ya = y + xp; for (int X = 0; y < tile.sprite.SIZE; X++) { int Xa = X + xp; if (Xa < 0 || Xa >= width || ya < 0 || ya >= width)break; pixels[Xa+ya*width]= tile.sprite.pixels[X+y*tile.sprite.SIZE]; ...
3123cd37-ce06-4940-b944-c1beb97233af
8
public boolean fixIntegrity() { for (AIObject ao : new ArrayList<AIObject>(aiObjects.values())) { if (!ao.checkIntegrity()) { logger.warning("Dropping invalid AIObject: " + ao.getId() + " (" + ao.getClass() + ")"); ao.fixIntegrity(); } ...
96594b6f-eab4-4dee-891e-1aa1eecb807b
7
static String[] sort(String[] input){ String temp; int left=0; int right=0; for(int i=1; i<input.length;i++){ left=0; right=i-1; while(left<right){ int mid=(left+right)/2; if(input[mid].compareTo(input[i])>0){ right=mid-1; }else{ left=mid +1; } } t...
184815e3-b38d-4a5f-8e0c-0d20d8e622fe
3
public static double calculateWordRankAverage(String text) { double rank = 0; String[] words = Database.simplifyText(text).split(" "); for (String word : words) { rank += 1.0 / Database.WORD_STATS.get(word); } double value = rank / words.length; if (value != value || Double.isInfinite(value)) value =...
f8592eae-03ab-412b-9bc7-1c1c682fedca
4
public void box(final Type type) { if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return; } if (type == Type.VOID_TYPE) { push((String) null); } else { Type boxed = getBoxedType(type); newInstance(boxed); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -...
57ba6f54-e181-4923-b9a7-124ffdb32318
8
public void selectAnswer(ArrayList<Card> anyCardList) { int solutionCount = 0; boolean needPersonCard = true; boolean needRoomCard = true; boolean needWeaponCard = true; while(solutionCount < 3) { for(int i = 0; i < anyCardList.size(); i++) { if(needPersonCard && (anyCardList.get(i).getCardType() == CardT...
50b2d3e3-b15e-447a-bdc7-291cbc586126
9
public String readUntil(String pattern) throws InterruptedException, IOException { cnt=0; char lastChar = pattern.charAt(pattern.length() - 1); StringBuffer buffer = new StringBuffer(); char ch = (char) dataIn.read(); String msg; String broken[]; while (runner==1) { ...
b29b5eaf-8cd4-4885-ba9d-faad27a4a32e
5
public void createDialogControls(final Shell parent) { final Display display = parent.getDisplay(); // message Label message = new Label(parent, SWT.NONE); message.setText(GraphicsExample.getResourceString("GradientDlgMsg")); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.hor...
f4579ca8-47ca-4ec8-8ca7-a2fbe1bc069c
1
private void setPopupMenu(JComponent component) { //Создаем контекстное меню final JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Кредиты клиента.."); popup.add(menuItem); //Добавляем слушателя на нажатие кнопки меню и на показ контекстного меню ...
8c5de035-e2ad-4ceb-94a4-418dcddfd193
3
public Image getScaledImage( InputStream in ) throws IOException { BufferedImage img = ImageIO.read( in ); int width = img.getWidth(); int height = img.getHeight(); if ( width <= maxIconWidth && height < maxIconHeight ) return img; if ( width > height ) { height /= width/maxIconWidth; width = m...
53ba21d7-9023-4312-9459-05608ce82abe
0
public void setId(final Long id) { this.id = id; }
15a5fe54-2b94-4884-9dae-6aceba720d09
0
public static void randomize(JCellule[][] grid, JLabel lblGeneration, JButton btnProchaineGeneration) { ControllerGrille.grid.randomize(); synchroniser(grid, lblGeneration, btnProchaineGeneration); }
3cf070ad-b854-445f-b330-b04d07aa1e39
3
static PreciseDecimal safegetInstanceDouble(final long base, final int factor) { final long absBase = Math.abs(base); if (absBase > MAX_PRECISE_DOUBLE_BASE) { final int scale = (int) (absBase / MAX_PRECISE_DOUBLE_BASE); // TODO also check the factor not to be neg. if (scale > 100) { return getInstanc...
430074f2-505d-4bdb-aefd-86eb625e89bb
8
public void aload(int no) { LocalVariableState locals = getLocalVars(); if (locals.size() <= no) { throw new InvalidBytecodeException("Cannot load variable at " + no + ". Local Variables: " + locals.toString()); } StackEntry entry = locals.get(no); if (entry.getType()...
360b2b9c-1e18-4dca-a65e-80ff8abff14e
2
public QueryDefinition getQuery(String name) throws Exception { QueryDefinition query = null; try { Node node = Utilities.selectSingleNode(this.doc, "/c:settings/c:queries/c:query[@c:name='" + name + "']", this.namespaces); if(node != null) { query = new QueryDefinition(node); } } catch (XPathExp...
7cae8ba7-c93b-4a4f-bd31-5a21da5d93c7
2
private Args parseOptions(String option,Args args){ String[] options = option.split(","); for(String op : options){ if(StringUtils.isNotBlank(op)){ args.getOptions().add(op.toLowerCase()); } } return args; }
f7c93db7-8d48-4172-a045-5f8fdcd6c447
7
public void ThereCanOnlyBeOne(List<ClusteredLinkElement> links) { List<ClusteredLinkElement> removeMe = new ArrayList<ClusteredLinkElement>(); for( ClusteredLinkElement link : links ) { for( ClusteredLinkElement other : links ) { if( removeMe.contains(other)) continue; String a = getDomainNa...
a26618e6-1404-43ad-acc2-93114e98051b
2
public void testNameProviderSecurity() { if (OLD_JDK) { return; } try { Policy.setPolicy(RESTRICT); System.setSecurityManager(new SecurityManager()); DateTimeZone.setNameProvider(new MockOKButNullNameProvider()); fail(); } catch...
09947637-282c-41e6-9c1c-0c2120de88a9
4
public boolean access(int i, int j) { if (i < 0 || j < 0 || i >= height || j >= width) { return false; } else { return true; } }
6e39d7b6-4547-44ae-be77-8e75b6ca99b4
3
public void shoot(int yield) throws IllegalStateException { if(this.getWorld() == null) return; if(this.getCurrentWeapon() == null) throw new IllegalStateException("The worm hasn't got a weapon equipped."); WeaponProjectile projectile = this.getCurrentWeapon().createProjectile(yield); if(projectile != ...
f7748581-03f3-45bb-bf40-29964351b2ae
8
public void create_menu(JMenuBar menu_bar) { JMenuItem menu_item; JCheckBoxMenuItem checkbox_menu_item; JRadioButtonMenuItem radio_button_menu_item; // Hmmm... code re-use? This looks more like code polycopy... // // define the "Avionics" menu // JMenu xhsi_avionics_menu...
2fee83f0-4dd9-4e16-9a78-f1657b146334
2
private void renderBeginPositions(Graphics2D graphics) { int startPointGridXCoordinate = 150; int startPointGridYCoordinate = 20; for (PlayerInfo p : objectTron.getPlayers()) { if (objectTron.getPlayerNumberByPosition(p.getPlayerPosition()) == 0) graphics.drawImage(cellFinishRed, (p.getBeginPosition...
829df9ec-d8bd-4da6-b728-87a38b3cc580
7
protected void loadPhysicalEntity2Compartment() { String name = "PhysicalEntity_2_compartment"; String fileName = dirName + name + ".txt"; if (verbose) Timer.showStdErr("Loading " + name + " from '" + fileName + "'"); int i = 1; for (String line : Gpr.readFile(fileName).split("\n")) { // Parse line Str...
2ef27337-aa55-4caf-b8e4-6a36f109393f
5
private void validate(BudgetFormData budgetFormData) throws Exception { if(budgetFormData == null) { throw new Exception("BudgetFormData is null."); } else { if(budgetFormData.getSalary() == null || budgetFormData.getSubmittedOn() == null) { throw new Exception(...
1221b989-e616-46da-9d55-8d7ce611cdad
7
public void Save_Level() { Save_Waypoints(); Clean_List(); try { FileWriter fw = new FileWriter(System.getProperty("user.dir") + "/" + "level.cfg", false); BufferedWriter output = new BufferedWriter(fw); int i = 1; for (GroupedRooms room : rooms) { output.write(String.format("#--ROOM %d--#...
3e8972f9-d507-412a-a2eb-e8007c28e601
5
public Object getCellEditorValue() { if (editor != null) { Object o = editor.getCellEditorValue(); if (o == null && component instanceof JTextField) try { // hackage to obtain value from JTable$GenericEditor java.l...
2919d7ac-a5e3-4f25-9167-113d1b60c220
4
public void paintScreen() { try { Graphics g = getGraphics(); if ((g != null) && (dbImage != null)) { g.drawImage(dbImage, 0, 0, null); // バッファイメージを前へ } Toolkit.getDefaultToolkit().sync(); if (g != null) { g.dispose(); // グラフィックobjを破棄 } } catch (Exception e) { e.printStackTrace(); } ...
a6cabf05-0747-4c60-b299-fa85b266a4c8
1
public static Inicio getInstance() { if (instance == null) { instance = new Inicio(); } return instance; }
5d7c51b6-3c4f-4356-9f34-d412a0ee500f
6
private void checkWhileDeclaration() throws Exception { if(iterator < tokenList.size() && tokenList.get(iterator++).getType() != TokenType.L_PAR) { // missing opening parenthesis throw new Exception("Syntax Error at line " + tokenList.get(iterator-1).getLine() + ": Expected ( and got \"" + tokenList.get(i...
c125af20-9728-46b9-a26f-423663e65f9f
4
public void tryToBuildSuperTowerAtLocation(SuperTowerType type, Point location) { if (!hasSuperTower()) { boolean validSuperTowerLocation = !Map.blockedForHero(location.x, location.y) && !Map.blockedForTowers(location.x, location.y); if (money >= SUPER_TOWER_BUILD_COST && validSuperTowerLocation) { buildSu...
db143aab-234b-4a6b-b473-ca6b1260da58
9
public char toChar() { switch (this) { case _0: return '0'; case _1: return '1'; case _2: return '2'; case _3: return '3'; case _4: return '4'; case _5: return '5'; case _6: return '6'; case _7: return '7...
0f5f7f49-06a3-48d2-80f4-84b4e182790b
4
@Override public void update() { if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { scroll(0, 5); } if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { scroll(0, -5); } if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { scroll(-5, 0); } if (Ke...