method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
15fea362-97f9-4894-854c-4ab021dc3872 | 9 | @Override
public JSONObject main(Map<String, String> params, Session session)
throws Exception {
JSONObject rtn = new JSONObject();
long targetUserId = Long.parseLong(params.get("id"));
User targetUser = User.findById(targetUserId);
if(targetUser == null) {
rtn.put("rtnCode", this.getRtnCode(406));... |
cff15972-d43e-45a1-823c-66060d1add64 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Departamento other = (Departamento) obj;
if (this.id != other.id) {
return false;
}
... |
dd7ec2c6-5d65-4965-aa53-859cffb419fb | 8 | public void showFileSelectDialog() {
File f = new File("outgoing" + File.separatorChar);
JFileChooser chooser = new JFileChooser(f);
chooser.setCurrentDirectory(f);
javax.swing.filechooser.FileFilter filter = new javax.swing.filechooser.FileFilter() {
@Override
public boolean accept(File pathname) {
... |
9d21cd63-930a-4b26-84e2-09cf571de09c | 6 | product[] readdata(String fn) {
File ifile = new File(fn);
FileInputStream f_in = null;
BufferedInputStream b_in = null;
DataInputStream d_in = null;
boolean eof = false;
product[] pr = new product[50];
try {
f_in = new FileInputStream(ifile);
b_in = new BufferedInputStream(f_in)... |
4d6a4145-e0df-4b70-9f30-eb26666d8840 | 6 | protected void installListeners() {
super.installListeners();
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
focusListener = new FocusListener() {
public void focusGained(FocusEvent e) {
if (getComponent() != null) {
orgB... |
a203e3ea-943a-41dd-98f5-0ffb8e28a65d | 2 | public Server_Socket(Core core, int port)
{
this.core = core;
try {
serv_socket = new java.net.ServerSocket(port);
if (t == null) {
t = new Thread(this);
t.start();
}
//int newPort = 50000 - n... |
66ddaa1a-4d2a-4b2d-90f2-ce00dbe2fa22 | 9 | @Override
public void run() {
final ArrayList<Integer> keys = new ArrayList<Integer>(count.keySet());
Collections.shuffle(keys);
for (Integer key : keys) {
final Integer clicksRemaining = this.count.get(key);
if (clicksRemaining == 0) {
continue;
}
int clicksToDo = Random.nextInt(0, clicksRemai... |
d626e581-853e-4a29-bbea-8fbf24a8b22a | 3 | public void fireChatEventToListeners(ChatEvent chatEvent) {
chatEvent = formatChatMessage(chatEvent);
for (MessageListener messageListener : messageListeners) {
if (chatEvent.getReceipient() == messageListener.getReceipient() || messageListener.getReceipient() == Receipient.GLOBAL)
messageListener.onChatEven... |
9d494cec-ea38-4158-bf77-82398e6cd1a8 | 7 | @Override
public boolean tick(Tickable ticking, int tickID)
{
super.tick(ticking,tickID);
if(canAct(ticking,tickID))
{
if(ticking instanceof MOB)
assistMOB((MOB)ticking);
else
if(ticking instanceof Room)
for(int i=0;i<((Room)ticking).numInhabitants();i++)
assistMOB(((Room)ticking).fetchInh... |
de0f20bd-c650-48bd-b755-90a074fcf5b6 | 7 | private Method findMethodWith( Class<? extends Annotation> type, boolean isOptional )
{
Method[] methods = process.getClass().getMethods();
for( Method method : methods )
{
if( method.getAnnotation( type ) == null )
continue;
int modifiers = method.getModifiers();
if( Modi... |
2e47ec91-f004-450b-8847-c840b3a59082 | 1 | public void update(Stage stage) {
if(source != null) {
setCenterPosition(source.getX(), source.getY());
}
} |
9bdfd275-f2f7-4f41-86aa-dace95f9bed2 | 4 | public int getHandValue()
{
int total = 0;
int aces = 0;
for (Card c : cards)
{
if (c.getValue().getValue() == 11)
{
aces++;
}
else
{
total += c.getValue().getValue();
}
}
... |
9fada1a8-799b-46fc-ad14-ec5edb98e767 | 1 | public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\aawor_000\\workspace\\TCPServer\\src\\Users\\Adam.txt"));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
... |
eb9c2ede-679f-4d76-bf9e-536ca2d3e610 | 4 | public ArrayList<Administrador> getByNombre(Administrador admin){
PreparedStatement ps;
ArrayList<Administrador> admins = new ArrayList<>();
try {
ps = mycon.prepareStatement("SELECT * FROM Administradores WHERE userName LIKE ?");
ps.setString(1, "%"+admin.getNombre()+"%"... |
fda230be-862f-48ac-8308-a52ae4a0e82a | 9 | private boolean execEstimate(VectorMap queryParam, StringBuffer respBody, DBAccess dbAccess) {
try {
int clntIdx = queryParam.qpIndexOfKeyNoCase("clnt");
String clientName = (String) queryParam.getVal(clntIdx);
int ftrsIdx = queryParam.qpIndexOfKeyNoCase("ftrs");
... |
9d8de9f7-ff64-48b2-9bea-689f8e4fb601 | 7 | public void runAssert() {
// need to get the object we will run the assertions on.
final Object object;
try {
object = callable.call();
} catch (final Exception e) {
final String message = (name == null) ? "Could not retrieve object." :
"Could ... |
3f108e97-1358-4cc8-979c-810a2dee8878 | 0 | public void setPin(String pin) {
this.pin = pin;
} |
2d8dddd1-6495-407f-99ee-5d80a8882141 | 6 | public static boolean warpNextMap_Agent(final MapleCharacter c, final boolean fromResting) {
final int currentmap = c.getMapId();
final int thisStage = (currentmap - baseAgentMapId) / 100;
MapleMap map = c.getMap();
if (map.getSpawnedMonstersOnMap() > 0) {
return false;
}
if (!fromResting) {
clearMap(m... |
da0ae4da-5eea-4200-86b3-718420876c4c | 0 | private Combination<Colors> generateAttemptCombination4() {
List<Token<Colors>> attemptTokens = new ArrayList<Token<Colors>>();
attemptTokens.add(new Token<Colors>(Colors.G));
attemptTokens.add(new Token<Colors>(Colors.Y));
attemptTokens.add(new Token<Colors>(Colors.P));
attemptTokens.add(new Token<... |
749eb771-6e50-4688-a888-8de5459fc301 | 6 | public static void addInserDzien(int ID)
{
boolean flaga=true;
for (int i=0 ; i<DniInsert[0] ; i++)
{
if(ID==DniInsert[i+2])
{
flaga=false;
break;
}
}
if(flaga)
{
// Count ArraySize
if (DniInsert[0]+2 >=DniInsert[1])
{
int[] tempArray = new int[DniInsert[1]];
for (in... |
9e82c990-963b-4825-b2a4-e806a7a8ff45 | 6 | private int jjMoveStringLiteralDfa10_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjMoveNfa_0(0, 9);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
return jjMoveNfa_0(0, 9);
}
switch(curChar)
{
case 66:
return jjMoveStringLiteral... |
6af7f485-99d0-4198-86bd-e33fda94c3d3 | 2 | @Override
/**
* This method will be used by the table component to get
* value of a given cell at [row, column]
*/
public Object getValueAt(int rowIndex, int columnIndex) {
Object value = null;
Contestant contestant = contestants.get(rowIndex);
switch (columnIndex) {
case COLUMN_USERNAME:
value = c... |
70278e59-1706-407b-abc9-9bd876adaaac | 3 | public void resetGame(int boardSize, int handicap, Player player1, Player player2) {
if (computerMatch != null) {
computerMatch.requestStop();
}
gameOver = false;
this.player1 = player1;
this.player2 = player2;
board = new Board(boardSize, handicap);
analyzerPanel.analyze(board);
activeMove = new ... |
7267908b-4055-4495-af4c-5077c848213e | 2 | public AnnotationVisitor visitAnnotation(final String desc,
final boolean visible) {
if (!ClassReader.ANNOTATIONS) {
return null;
}
ByteVector bv = new ByteVector();
// write type, and reserve space for values count
bv.putShort(cw.newUTF8(desc)).putShort(0);
AnnotationWriter aw = new AnnotationWriter(... |
1c748c5d-8022-44f8-903e-a79cb4456181 | 2 | public boolean removeBook(String title)
{
boolean delete = false;
if (aBookIndex.containsKey(title)) {
Item tempBook = aBookIndex.remove(title);
authorIndex.remove(((Book)tempBook).getAuthor());
for (String s: tempBook.keywords) {
keywordIndex.get(s).... |
4e6e8b11-77c2-467f-a62f-7419058123a1 | 9 | public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Insert a bunch of numbers separated by coma bitch");
String[] array1 = input.nextLine().split(",");
int length = array1.length;
int[] array2 = new int[length];
f... |
f861f976-afc5-41f0-9aa8-0669fd87b2d4 | 8 | public void setTokenizerProperties(TokenizerProperties props) throws NullPointerException {
if (props == null) {
throw new NullPointerException();
}
// set properties
if (_properties != null) {
_properties.removeTokenizerPropertyListener(this);
}
_properties = props;
_properties... |
d2ddbaeb-70e9-4746-bb00-0d63a76f1c43 | 8 | @Override
public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
{
if (npc instanceof L2ChestInstance)
{
// This behavior is only run when the target of skill is the passed npc.
if (!Util.contains(targets, npc))
return super.onSkillSee(npc, caster, ski... |
e2692f03-9aa6-4769-85f3-9e8697c22fd2 | 7 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String accion = request.getParameter("accion");
if (accion != null) {
response.sendRedirect("http://www.unac.edu.co");
} else {
Stri... |
9399354a-5145-4a68-8100-3da6f35aa3a8 | 5 | public void ProcessInPacketBuffer() {// process a packet for distance updates
BlastPacket bpkt, BlastPktNext;
DataPacket dpkt, DataPktNext;
while (!BlastPacketInBuf.isEmpty()) {
bpkt = BlastPacketInBuf.removeFirst(); // if (TempPkt instanceof BlastPacket) { } ?
BlastPktNext = ProcessBlastPacket(... |
d65acca9-4921-42e7-bc72-1e0e33c7f6ed | 9 | public boolean sendScreenCaptures(String[] cmd, String screenImgSavePath, String fileNameWithoutExtension)
{
try
{
ArrayList alToSend = CaptureScreen.captureScreens(screenImgSavePath, fileNameWithoutExtension);
if ((alToSend == null) || (alToSend.size() < 1))
{
return false;
}... |
05b3a972-c46e-4ed1-8b4a-166a5b9da391 | 7 | private void refreshCalendar(int month, int year) {
int nod, som; // Number Of Days, Start Of Month
prevMonth.setEnabled(true);// enable button
nextMonth.setEnabled(true);// enable button
if (month == 0 && year == actualYear) {
prevMonth.setEnabled(false);
} // disable button as already pass
if (month ==... |
454b61a7-6b7c-4e8c-b6fe-bce1c314a7c2 | 1 | public static Entry[] mergeSortAndPopulate(int[] list) { //For testing only
Entry[] input = new Entry[list.length];
for(int i = 0; i < list.length; i++) {
input[i] = new Entry(list[i], randomName());
}
return mergeSort(input);
} |
ab9b0de9-962d-4e8d-8565-2f05fbbd6673 | 3 | public Children(Entity... childs) {
// Create a list list with the size of child's array
children = new ArrayList<Entity>(childs.length);
for (Entity child : childs) {
Spatial childSpatialComponent = child.getComponent(Spatial.class);
Equipment childEquipmentComponent = child.getComponent(Equipment.class);... |
b55d45cf-ffef-4bd8-85b4-90bf2a8ef325 | 0 | public void setVerboseLevel(int level) {
this.verbose_level = level;
} |
17fdae3c-a327-4ea6-b3a6-48e0b7886808 | 2 | private static double compare(String alg1, String alg2, int N, int T,
String inputType, String dataType)
{
Comparable[] a = new Comparable[N];
Comparable[] b = new Comparable[N];
try
{
SortHelper.class.getMethod("put" + inputType + "Input",
Comparable[].class).invoke(null, (Object) a);
}
catch ... |
99c82d05-9d2b-4fb6-8524-1a3b016d59b1 | 4 | public static EnumTemperature getFromValue(float rawTemp) {
if (rawTemp > 1.00f) {
return HOT;
}
else if (rawTemp > 0.85f) {
return WARM;
}
else if (rawTemp > 0.35f) {
return NORMAL;
}
else if (rawTemp > 0.0f) {
return COLD;
}
else {
return ICY;
}
} |
f80b929f-a467-4769-a4da-84e3c12bb470 | 0 | public NondeterminismPane(AutomatonPane ap) {
super(new BorderLayout());
ap.addMouseListener(new ArrowDisplayOnlyTool(ap, ap.getDrawer()));
add(ap, BorderLayout.CENTER);
add(new JLabel("Nondeterministic states are highlighted."),
BorderLayout.NORTH);
} |
22f1db6b-231f-445f-aa46-46dc26df83a7 | 5 | @RequestMapping(value = "/game/requests/response/", method = RequestMethod.POST)
public String checkResponseRequestPage(IdForm idForm, ModelMap model){
if (!idForm.getId().equals("")) {
int id = Integer.parseInt(idForm.getId());
String state = idForm.getState();
try {
... |
216001d6-8fe2-41e1-8a07-c403fb3585f9 | 1 | public void setXVal(Double[] newXVal) {
if (newXVal == null) {
this.xVal = new Double[0];
} else {
this.xVal = Arrays.copyOf(newXVal, newXVal.length);
}
} |
4edb23ea-ac12-4ae5-aa18-e2c4e4ffcaeb | 6 | @Override
public void onKeyPressed(char key, int keyCode, boolean coded)
{
// Tests the functions of the wavsound
if (!coded)
{
// On d plays the sound
if (key == 'd')
{
this.testsound.play(null);
System.out.println("Plays a sound");
}
// On e loops the sound
else if (key == 'e')
{
... |
d9404266-5479-4c4a-a1f5-432fcea1980a | 1 | public MoviePathSearcher(Model m) {
this.m = m;
pathsToMovies = new Path[100];
matcher = new PathMatcher[100];
pathIndex = 0;
int i = 0;
for (String s : m.getSearchKeywords()) {
matcher[i++] = FileSystems.getDefault().getPathMatcher("glob:" + s);
}
} |
b6534407-2200-4f66-b4ef-d4385c63e2f9 | 4 | private static void mergeMaps(Map<String,Integer> map1, Map<String,Integer> map2){
Objects.requireNonNull(map2);
for (Map.Entry<String, Integer> e : Objects.requireNonNull(map1).entrySet()) {
if (e != null) {
int val = 0;
if (map2.get(e.getKey()) != null) val = map2.get(e.getKey());
if (val != 0) {
... |
5286e33d-3a49-42e4-b359-729bea80972f | 4 | private void displayMiddleBorder() {
System.out.print(B_HEAD);
boolean dec = false;
for (int i=0; i < this.size; i++) {
int size = this.size;
while (size > 0) {
System.out.print("-");
size -= (dec ? 1 : 0);
dec=(!dec);
}
System.out.print((i < this.size-1 ? "-+" : ""));
}
... |
43192bf4-7e52-4046-a629-cb0b845d3ef8 | 0 | Physics() {
this.totalForce = new SimpleVector();
this.location = new SimpleVector();
} |
dc26ec88-15b8-481e-8d1a-5e98e4211fa3 | 2 | private static <E extends Enum<E>> E valueOf(final Class<E> type, final int ordinal) {
final E[] enums = type.getEnumConstants();
return (ordinal >= 0 && ordinal < enums.length ? enums[ordinal] : null);
} |
5fb45030-2bce-4659-a809-bdbb9494169c | 1 | @Test
public void shouldSortProvidedArray2() throws Exception {
Integer[] array = new Integer[]{4, 2, 4, 1, 3, 45, 23, 424, 3};
sort.sort(array);
for (int i : array) {
System.out.println(i);
}
} |
32074a89-1829-4ab0-a77a-e1d8d6f676d0 | 5 | public boolean removeAllEdges(Object origin, Object destination)
{
// retrieve the origin and destination vertices
Vertex o = (Vertex)theItems.get(origin);
Vertex d = (Vertex)theItems.get(destination);
if (o == null || d == null)
{
// one of the vertices does not exist
return false;
}
// remo... |
17b17982-d990-41b4-acf7-748cb998f8e1 | 2 | @Test
public void getWidth(){
Tile[][] tiles = new Tile[15][10];
for (int x = 0; x < tiles.length; x++){
for(int y = 0; y < tiles[0].length; y++){
tiles[x][y] = new Tile(new Position(x, y), 0);
}
}
World w = new World(tiles);
assertTrue(w.getWidth() == 15);
} |
133a1d28-4564-476b-b7b9-a9ba777004c6 | 8 | public void run(){
while(true){
String line = scan.next();
if ( line.equals("next")) next();
if ( line.equals("previous")) previous();
if ( line.equals("stop")) stopMusic();
if ( line.equals("pause")) pause();
if ( line.equals("play")) play();
if ( line.equals("random")) randomize();
if ( line... |
cc541abe-a75b-4597-be06-21fc70993ff8 | 6 | public int numDistinct(String S, String T) {
if (S == null || T == null) {
return 0;
}
int[][] nums = new int[S.length() + 1][T.length() + 1];
for (int i = 0; i < S.length(); i++) {
nums[i][0] = 1;
}
for (int i = 1; i <= S.length(); i++) {
for (int j = 1; j <= T.length(); j++) {
nums[i][j] = ... |
ea3ce44c-8745-47bc-9037-655c351db780 | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if(mob.fetchEffect(this.ID())!=null)
{
Ability A=mob.fetchEffect(ID());
if(A!=null)
A.unInvoke();
A=mob.fetchEffect(ID());
if(A!=null)
mob.tell(L("You are already hiding in plain ... |
954b9121-d113-4a48-8ffa-9cf8c80723d4 | 4 | @Override
protected String toString(int indent) {
String str = toString(indent, "IfStatementNode\n");
if(exp1 != null)
str += exp1.toString(indent+1) + "\n";
if(stateSeq1 != null)
str += stateSeq1.toString(indent+1) + "\n";
if(elseIfs != null)
str += elseIfs.toS... |
16bb169a-4477-495b-b801-9bf302fe2ca0 | 0 | private void fireConnectEvent(ConnectEvent evt) {
fireClientConnectEvent(evt);
} |
0a8ea145-62cd-44e7-b6f4-507149d4a40b | 0 | public void stop() {
timer.cancel();
timer = null;
tick = 0;
elapseTime = 0;
state = EnumStopWatchState.STOP;
log.info("stop stopwatch, it's state:" + state + ", elapseTime:"
+ elapseTime);
} |
33613f99-e97a-4cea-9eaa-8102dd6b3be7 | 3 | public EasyDate setTimeZoneOffset(int minutes) {
StringBuilder timeZoneID = new StringBuilder().append("GMT").append((minutes > 0 ? '+' : '-')).append(minutes / 60);
int min = minutes % 60;
if (min > 0) {
timeZoneID.append(':');
if (min < 10) {
timeZoneID.append('0');
}
timeZoneID.append(min);
}... |
bd26e61e-6d94-4234-8e5d-30e56ef925a3 | 7 | private void updateFromModel()
{
if (enabledButton != null) {
enabledButton.setSelected(valueFilledIn);
enabledButton.setEnabled(enabled);
}
if ((timeClock != null) && (timeClock.isVisible())) {
timeClock.setEnabled(valueFilledIn && enabled);
}
if ((dateClock != null) && (date... |
294c7052-3493-4a86-97b8-52d1b3d589f9 | 4 | private void nextpoints(int alg) {
for (int i = 0; i < points; i++) {
double xf = Math.random();
double yf = Math.random();
int xi = (int) Math.floor(ximlen * xf);
int yi = (int) Math.floor(yimlen * yf);
doCalculation(xf, yf, xi, yi);
}
runtotal += points;
if (quad < 1.001) {
quad = 1;
} el... |
e4f6a713-5b1d-4c27-99e4-3c5b1eacf02f | 3 | public String version_string()
{
switch (h_version)
{
case MPEG1:
return "MPEG-1";
case MPEG2_LSF:
return "MPEG-2 LSF";
case MPEG25_LSF: // SZD
return "MPEG-2.5 LSF";
}
return(null);
} |
4aaf459d-36ee-473c-be0a-7d080d71f775 | 6 | public static HttpURLConnection getValidConnection(URL url) {
HttpURLConnection httpurlconnection = null;
try {
URLConnection urlconnection = url.openConnection();
urlconnection.addRequestProperty("User-Agent", "Mozilla/4.0(compatible;MSIE 5.0;Windows NT;DigExt)");
... |
ca6d56f4-07fa-45f0-b945-c029c6290ff7 | 5 | public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Verwendung: <Akteurdatei> <Szenendatei>");
System.exit(-1);
}
File acteurs = new File(args[0]);
File scene = new File(args[1]);
if (!acteurs.exists() || acteurs.isDirectory()) {
System.err.println("Die Akteurdatei ... |
1f2d9740-f521-4879-8760-8672a6f2b3dc | 6 | private void selectionMouseCursor(Page currentPage, Point mouseLocation) {
if (currentPage != null &&
currentPage.isInitiated()) {
// get page text
PageText pageText = currentPage.getViewText();
if (pageText != null) {
// get page transform, s... |
86e1d576-efba-42de-85d0-4af5bfd49d7a | 0 | private CollectionUtils() {} |
93ce1b1e-f842-46ac-af4e-b76a0fceb565 | 2 | private void checkCollision() {
if(r.intersects(StartingClass.hb.getHeliBoy1())){
visible = false;
StartingClass.score += 1;
}
if (r.intersects(StartingClass.hb2.getHeliBoy2())){
visible = false;
StartingClass.score += 1;
}
} |
00d07b22-d918-4a91-9fc6-79b2174ab8f4 | 5 | public void clickedUnit(Unit unit) {
reset();
clickedName.setText(unit.getName());
clickedName.setOpaque(false);
gameIconPanel.add(clickedName);
if (unit.getName().equals("Tank") || unit.getName().equals("Marine")) {
String path = "/imgs/units/" + unit.getName() + ".png";
if (unit.getName() == "Mari... |
7f416aea-0f38-4d4a-99d9-247fc3b80f0c | 0 | @Test
public void testGetRoot() {
QuickUnion spy = Mockito.spy(new QuickUnion(5));
assertThat(spy.getRoot(0), is(0));
assertThat(spy.getRoot(1), is(1));
assertThat(spy.getRoot(2), is(2));
assertThat(spy.getRoot(3), is(3));
assertThat(spy.getRoot(4), is(4));
spy.union(0, 1);
assertThat(spy.getRoot... |
20636423-3adc-4c6e-91e3-cf1dd5ce09db | 4 | public static boolean writeCSV(RosterDB rosterDB, String absolutePath) {
// create output file
FileWriter outputStream = null;
try {
outputStream = new FileWriter(absolutePath);
outputStream.write("Name,Vorname,Handy,Aspirant\n");
for (Roster r: rosterDB.getRosters()) {
outputSt... |
3d5c91e2-8e6b-4858-8671-043791b7a646 | 0 | @Override
public String getSex() {
return super.getSex();
} |
769888ec-687a-465d-a770-3b883638658e | 2 | private void mouseHelper(int codeNeg, int codePos,
int amount)
{
GameAction gameAction;
if (amount < 0) {
gameAction = mouseActions[codeNeg];
}
else {
gameAction = mouseActions[codePos];
}
if (gameAction != null) {
gameActio... |
951780ed-70d4-4db5-85b8-32ea76a28d53 | 7 | @EventHandler(priority=EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent e)
{
if(e == null)
return;
Player p = e.getPlayer();
if(e.getClickedBlock() == null)
return;
Location l = e.getClickedBlock().getLocation();
if(l == null || TreasureManager.currentTreasureLocation =... |
b94a80c8-8c7b-4ccc-abf7-805af17e71d0 | 2 | public Cliente getCliente(String nome) throws ExceptionGerentePessoa{
for (Cliente c : clientes) {
if (c.getNome().equalsIgnoreCase(nome)) {
return c;
}
}
throw new ExceptionGerentePessoa("Cliente n��o cadastrado");
} |
f832f89c-9632-4175-8c94-39d971acc765 | 2 | public List<String> getArguments() {
List<String> arguments = new ArrayList<>();
for (CmdLineData one : mData) {
if (!one.isOption()) {
arguments.add(one.getArgument());
}
}
return arguments;
} |
2270c3ea-a329-4a44-9998-d21ec989ea13 | 1 | public void sizeColumnToFit(TreeColumn column) {
int width = getPreferredColumnWidth(column);
if (width != column.getWidth()) {
column.setWidth(width);
invalidateAllRowHeights();
run();
repaint();
}
} |
b4f1638f-a27f-4b90-9489-c72e0c2b1bda | 8 | private static void lagNode(Node node, String ord, int len, int index) {
while (len > index) {
char c = ord.charAt(index);
if (node != null){
HashMap<Character, Node> tempMap = node.barn;
if (!tempMap.containsKey(c) && tempMap.containsKey('?'))
tempMap.put(c, new Node());
if (len == index + 1) ... |
aaa9df92-782a-4c91-9ecf-961f47c4f4d3 | 2 | public int getIceResistance(){
int value = 0;
for (Armor armor : armorList) {
if(armor != null) value += armor.getStats().getIceResistance();
}
return value;
} |
f9adece6-577f-4db8-a64a-d717261dd5e9 | 4 | public void createSons(){ // Tested
SimulatedPlanetWars simpw = this.getSim();
for (Planet myPlanet: simpw.MyPlanets()){
//avoid planets with only one ship
if (myPlanet.NumShips() <= 1)
continue;
// We create a son for each of the possible situations
for (Planet notMyPlanet: simpw.NotMyPlane... |
d08bfdcb-01fb-461c-adc0-b9f8a3ba08c2 | 5 | @Override
public int compare(Person o1, Person o2) {
if (o1.getFirstName().equals(o2.getFirstName())
&& o1.getSecondName().equals(o2.getSecondName())
&& o1.getMail().equals(o2.getMail())
&& o1.getPhone().equals(o2.getPhone()))
return 0;
if ... |
f3af2ca8-f519-43c0-9942-ae80d5e918a6 | 6 | private double medianOfMedians(ArrayList<double[]> puntos, int axis,int start,int end){
switch (end-start+1){
case 1: return puntos.get(start)[axis];
case 2: return (puntos.get(start)[axis]+puntos.get(start+1)[axis])/2;
case 3: return medianOfThree(puntos, axis,start);
case 4: return medianOfFour(puntos, axis... |
effb593d-3809-4e9b-9fb8-1c6c8be8eb14 | 9 | @Override
public void onCommand(POP3Session session, String argument1,
String argument2) throws POP3Exception {
// 检查会话状态是否合法
if (session.getState() != POP3State.TRANSACTION) {
throw new POP3Exception("-ERR auth first");
}
User user = session.getUser();
List<Email> emailList = user.getEmailList();
/... |
31a20305-8210-4601-88a8-85d69443db48 | 9 | public void watch(String dirPath) {
Path dirToMonitor = Paths.get(dirPath);
try {
watcher = dirToMonitor.getFileSystem().newWatchService();
// Register create, modify and delete watchers
dirToMonitor.register(watcher,
StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_DELETE,
... |
4eecad4a-0cc0-4ccc-a5db-4936803ecb47 | 9 | @Override
public void run() {
boolean done = false;
int waitTime = 500;
try {
Packet pack = new Packet("PUTCHUNK", "1.0", chunk, null);
DistributedBackupSystem.cManager.sendPacket(pack, CommunicationManager.Channels.MDB);
do {
int storedCount = 0;
try {
Thread.sleep(waitTime);
} catch... |
efce3826-a5e2-4872-991b-47340e335127 | 4 | private boolean validateCardType(String cardNumber, CreditCardType cardType) {
CodeValidator apacheCardValidator;
switch (cardType) {
case VISA:
apacheCardValidator = org.apache.commons.validator.routines.CreditCardValidator.VISA_VALIDATOR;
break;
case AMERICAN_EXPRESS:
apacheCardValidator = org.apache... |
5c90bd4f-0f33-42ae-a5ec-b9fe11e65afd | 2 | private void drawtracking(GOut g) {
g.chcolor(255, 0, 255, 128);
Coord oc = viewoffset(sz, mc);
for (int i = 0; i < TrackingWnd.instances.size(); i++) {
TrackingWnd wnd = TrackingWnd.instances.get(i);
if (wnd.pos == null) {
continue;
}
Coord c = m2s(wnd.pos).add(oc);
g.fellipse(c, new Coord(100... |
f3ed15f2-5c04-47ee-968b-d42448118618 | 8 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
Date now = new Date();
String username = request.getParameter("username");
String emailAddress = request.getParameter("emailAddress");
String hashedPassword... |
dea428cb-845b-48f0-8da2-a4cd2a7aa928 | 3 | public JSONObject accumulate(
String key,
Object value
) throws JSONException {
testValidity(value);
Object object = opt(key);
if (object == null) {
put(key, value instanceof JSONArray ?
new JSONArray().put(value) : value);
} else if (... |
07e7d5be-f3bd-4357-afdd-9bf4cc7471f3 | 4 | public void verteile_neu_ohne(Spieler zuentfernenderspieler, Spieler[] andereSpieler){
/*
sag mal codest du mit dem editor??
wie gesagt , ja - und ich finde fuer Editor programmieren hab ich relativ wenig falsch gemacht.
und vlt. pfuscht du in zukunft nicht so rum, dass... |
97068c39-d842-43e1-833a-46dd04a9ead1 | 8 | private void render(Graphics g) {
OpSolution sol = solution;
g.setColor(Color.black);
g.fillRect(0, 0, width, height);
// render the ideal solution
int y = 0;
g.setColor(Color.cyan);
for (Double c : sol.ideal) {
int x = (int) (c * width);
g.drawLine(x, y, x, y + 8);
}
y+=9;
// render the ... |
f39dfab6-3c40-4e45-b74c-5aec4f2b9365 | 7 | private void onTranslate(final String mode) {
new Thread() {
public void run() {
try {
copyMarkedText();
final String text = getClipboardData();
if(text != null) {
translator = createSelectedTranslator();
if(translator == null) return;
translator.setFrom(gui.getComboFrom(... |
cc74607c-c774-431e-8795-c7820beb848b | 6 | private static void editarMusica()
{
boolean salir;
String nombre, codigo;
Integer idMusica;
Musica musica;
do
{
try
{
System.out.print( "Introduce el Id del producto msica: ");
idMusica = Integer.parseInt( scanner.nextLine());
if ((musica = Musica.buscar( idMusica)) == null)
... |
4cd45782-524d-4ef5-a3fb-df226f1b40ac | 4 | private void moveListElement(int increment)
{
Object mover = jListLocations.getSelectedValue();
int oldIndex = jListLocations.getSelectedIndex();
int newIndex = oldIndex + increment;
if(oldIndex < 0 || newIndex > jListLocations.getModel().getSize() - 1)
return;
if... |
f6fc36f9-2d69-4943-a017-a2680005e7b2 | 4 | public void addBook(Book book) {
Connection con = null;
PreparedStatement pstmt = null;
try {
DBconnection dbCon = new DBconnection();
Class.forName(dbCon.getJDBC_DRIVER());
con = DriverManager.getConnection(dbCon.getDATABASE_URL(),
dbCo... |
be5413d2-ff02-477d-a41d-9566c9e418fe | 7 | public static String getDefaultNickname()
{
configLocation = System.getProperty("user.home") + File.separator + "." + title.toLowerCase() + File.separator;
try
{
FileInputStream fis = new FileInputStream(configLocation + "defaultnick");
BufferedReader br = new BufferedReader(new FileReader(new File(config... |
7ee7838f-b85f-43f9-9f86-04b98cae344c | 8 | public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
{
if (c instanceof AbstractButton == false)
{
super.paintBorder(c, g, x, y, w, h);
return;
}
AbstractButton button = (AbstractButton) c;
ButtonModel model = button.getModel();
if (model.isEnabled())
{
boolean isPressed... |
c20479db-80ae-4daa-9654-cfc132c97e98 | 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.");
... |
23a02c22-c51b-4968-ac08-e8e44d2f23cb | 3 | protected void initNewDebateComponents() {
createDebateJfme = new JFrame();
createDebateJpel = new JPanel();
createDebateJfme.add(createDebateJpel);
titleCDJlbl = new JLabel("Title:");
titleCDJlbl.setFont(new Font("Tahoma", 1, 16));
maxTurnsCDJlbl = new JLabel("Max Turns");
maxTurnsCDJlbl.setFont(new Font... |
4b5c54a2-5d7d-4844-a76a-6e98213187e4 | 4 | public boolean findAtNE(int piece, int x, int y){
if(x==0 || y==7 || b.get(x-1,y+1)==EMPTY_PIECE) return false;
else if(b.get(x-1,y+1)==piece) return true;
else return findAtNE(piece,x-1,y+1); // there is an opponent
} // end findAtNE |
8316c26d-7bf9-4bff-a893-73ad5b89fd1c | 6 | public List<Chromosome> select(List<Chromosome> population,
int targetPopulationSize) {
List<Chromosome> survivors = new LinkedList<Chromosome>();
List<Double> absoluteFitnesess = new LinkedList<Double>();
double totalFitness=0;
for(Chromosome c : population) {
double valor = Math.abs(f.calculate(d... |
aa3094cf-3ded-4c97-b6b5-3091ea4fb56a | 6 | private Node higherNode(T k) {
Node x = root;
while (x != NULL) {
if (k.compareTo(x.key) <0) {
if(x.left != NULL){
x = x.left;
}else{
return x;
}
} else {
if(x.right != NULL){
x = x.right;
}else{
Node current = x;
while(current.parent != NULL && curr... |
1b2dad86-ba34-4d99-806a-01aa704762d9 | 0 | public int getNbCoupMax(){
return Integer.parseInt(propriete.getProperty("nb_coups"));
} |
3c648818-a0ee-4642-9549-5733368e7b53 | 8 | public void actionPerformed (ActionEvent event)
{
if (event.getSource() == begin)
{
int i = 0;
double d = 0.00;
String nump = NumProducts.getText();
String dprice = DesiredPrice.getText();
String s = OptionalAdditions.getText();
output.setText(" ");
errlabel1.setFore... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.