method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4a797d68-3994-4bf0-83d1-8ffea8723bb1 | 8 | protected void defineWorld(int worldType) {
world = new HashMap<Position,Tile>();
String[] layout;
if ( worldType == 1 ) {
layout = new String[] {
"...ooMooooo.....",
"..ohhoooofffoo..",
".oooooMooo...oo.",
".ooMMMoooo..oooo",
"...ofooohhoooo..",
... |
f52fe1c3-fda3-4ba6-9f71-e7381e547cb1 | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=prof... |
9230184e-e610-4489-8578-dddb16faf511 | 9 | public File getFileChoice(Component parent) {
if (chooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
File newFile = chooser.getSelectedFile();
if (chooser.getFileFilter() == zipFilter) {
// ZIP was selected...add .zip to the end of the filename
// if it doesnt exist alrea... |
b1ed11a2-5f37-42ee-8cad-5b555fd85af4 | 2 | @Override
public Connection getConnection() throws DatabaseManagerException {
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
return DriverManager.getConnection("jdbc:derby:" + createConnectionString());
} catch (SQLException e) {
throw new DatabaseManagerException("Failed to get connection u... |
543342c3-ec75-48ab-a0b1-b003610dbe89 | 9 | @Override
public void run() {
while (!Vars.stop) {
DatagramSocket sk = null;
try {
sk = new DatagramSocket(3998);
} catch (SocketException e1) {
e1.printStackTrace();
}
if (sk == null) {
return;
}
try {
sk.setSoTimeout(5000);
} catch (SocketException e2) {
e2.printStackTra... |
ec83b241-b3b2-4537-8884-e7889dbfb7b4 | 3 | public boolean insert(String word){
TrieNode location = root;
boolean result = false;
int char_code;
for(int i = 0; i < word.length(); i++) {
char_code = word.charAt(i) - 'a';
if(location.getBranch(char_code) == null){
location.createBranch(char... |
0f06c9f3-1893-43c6-9f16-c82607daf36e | 3 | public void writeResponse(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Note: This is needed only for development
String referer = request.getHeader("referer");
URI refererUri = null;
try {
refererUri = new URI(referer);
} catch (URISyntaxException e) {
... |
8f5804b1-a482-4290-a416-d9dc236b9936 | 6 | public static boolean checkPangrams(String s){
String allAlphabets = "abcdefghijklmnopqrstuvwxyz";
boolean[] b = new boolean[26];
char[] charArray = s.toCharArray();
for(char c: charArray) {
if(c >=97 && c <=122) {
if(!b[allAlphabets.indexOf(c)]) {
b[allAlphabets.indexOf(c)] = true;
}
}
... |
6c945fd0-75a0-4dd9-bbcc-da9555276e58 | 2 | public static void mkDirs(StringBuffer dirPath) {
File dir = new File(dirPath.toString());
if (!dir.isDirectory() && !dir.exists()) {
dir.mkdirs();
}
} |
feb0e75d-31cd-4f31-89a3-57de1e4ccf64 | 8 | public static String getRowString(int row) {
String strRow = "unknown";
switch (row) {
case ROW_1: strRow = "1"; break;
case ROW_2: strRow = "2"; break;
case ROW_3: strRow = "3"; break;
case ROW_4: strRow = "4"; break;
case ROW_5: strRow = "5";... |
c5dcf25a-616b-473f-9dd5-29875b13e40a | 5 | @Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No world given.");
reply("Usage: /gworld allowmonsters <worldname> <true|false>");
} else if (!hasWorld(worldName)) {
reply("World not found: " + worldName)... |
a616ed94-cc80-4bab-8002-5ce09a78bc78 | 0 | public void automataStateChange(AutomataStateEvent e) {
setDirty();
} |
999315a1-38df-45e7-ab6d-e43d0d73fec4 | 3 | @Override
public void itemStateChanged(ItemEvent e) {
vue.getZoneDesJoueurs()[nbJoueur].getBoutonAcheterMaison().setEnabled(false);
if(e.getStateChange() == ItemEvent.SELECTED && e.getItem() instanceof Propriete) {
Propriete p = (Propriete)e.getItem();
if(p.getNbMaison() != 4) {
vue.getZoneDesJoueu... |
086d0512-aee4-47fe-9bc6-707ad535cfb7 | 3 | public void reset()throws TableException{
String createString;
java.sql.Statement stmt;
try{
createString = "drop table " + PRODUCT_TABLE_NAME + ";";
stmt = mysqlConn.createStatement();
stmt.executeUpdate(createString);
} catch (jav... |
5e8d25e6-f2b5-4120-9360-5c04487cc46c | 1 | public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
} |
d466f97f-0b5d-4c49-84d8-32e5cc9557ee | 8 | @Override
public boolean selectFileToSave(OutlinerDocument document, int type) {
// we'll customize the approve button
// [srk] this is done here, rather than in configureForOpen/Import, to workaround a bug
String approveButtonText = null ;
// make sure we're all set up
lazyInstantiation();
// Setup ... |
e8f09276-b9e7-4574-939c-512a85d906fc | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... |
25642f90-c0a5-412b-adbf-cfdb8400ea5f | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... |
f7b7a8cb-4de1-4353-8035-a2eb2221669b | 7 | private Map<String, PatchScript> preParsePatchScripts(PromotionManifestParser pManifestParser){
Logger.logInfo("Validating patches...");
Map<String, PatchScript> lParsedScriptMap = new HashMap<String, PatchScript>();
//Map of patch labels to highest orders - used to verify script order is correct
... |
a4b2f87a-3954-4ba7-9ef2-41de730f1825 | 3 | public void update(TheaterSeats theaterSeats) {
for(int i = 0; i < seatStatus.length; i++)
for(int j = 0; j < seatStatus[i].length; j++)
if(theaterSeats.getSeatStatus(i, j) == 'O')
this.seatStatus[i][j] = 'O';
} |
a1c2fe17-f030-4992-a5ae-f19f0001b04a | 2 | public DefaultListModel<Juego> selectAllJuegos(){
DefaultListModel<Juego> model = new DefaultListModel<>();
try {
List<Juego> juegos = juegoDao.queryForAll();
for(Juego j: juegos) model.addElement(j);
} catch (SQLException ex) {
Logger.getLogger(D... |
206ea86e-a03c-409a-9a57-2d1ff644924f | 6 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
String oldpass = new String(p1.getPassword());
oldpass= Md5Hash.passwordsalted(oldpass);
String a= new String (p2.getPassword());
String b= new String (p3.getPassword());
Str... |
734e7a52-ff43-49e4-b587-37e6dba38f81 | 6 | public static void main(String[] argv) {
Properties param = new Properties();
//String midlet = null;
//String jadfile = null;
for (int i = 0; i < argv.length; i++) {
if (argv[i].startsWith("-")) {
param.put(argv[i].substring(1), argv[i + 1]);
... |
1d2f9f58-4414-42d0-b079-00e165fa3480 | 7 | public static void refreshCalendar(final int month, final int year) {
// Variables
final String[] months = { "January", "February", "March", "April",
"May", "June", "July", "August", "September", "October",
"November", "December" };
int nod, som; // Number Of Days, Start Of Month
// Allow/disallow butt... |
a63203d2-d69c-4bde-bb65-4e8245fbbb3e | 6 | public static void lowestCommonAncestorTwoIterative(BinaryTreeNode root, int d1, int d2) throws IllegalArgumentException {
if (d1 > d2) {
int t = d1;
d1 = d2;
d2 = t;
}
while (root != null) {
if (root.data >= d1 && root.data < d2) {
System.out.println("LCA-2: " + root.data);
return;
... |
ba8cd473-11ab-4a6f-b390-075f2687073d | 6 | public static int numDistinct(String s, String t) {
if (t.length() == 0)
return 1;
if (s.length() == 0)
return 0;
if (s.length() == 1 && t.length() == 1) {
if (s.charAt(0) == t.charAt(0)) {
return 1;
} else {
return 0;
}
}
if (s.charAt(0) == t.charAt(0))... |
dce54c81-9d68-4644-b5f7-9fb74c376cb0 | 5 | public void loadCity(int whichCity){
tl.setSquares();
if(whichCity == 1){
//loadCity16();
try{
//rl.saveMap(city1[5], "city1s6");
city1[0] = setMapSecs(rl.getMap("city1",false,"city1s1"));
city1[1] = setMapSecs(rl.getMap("city1",false,"city1s2"));
city1[2] = setMapSecs(rl.getMap("city... |
74a68d59-6655-42cb-bf13-4581dc09a834 | 1 | @Override
public void setLifeTimeToMax() {
lifetime = MAX_LIFETIME;
for(PositionChangedObservable o : hoveringElements) {
o.accept(new ActivatePowerFailureVisitor());
}
} |
1121b1d8-2a1c-489e-9496-7affc033d66a | 0 | public World(boolean hardcore){
this.assetManager = ContentManager.getInstance().getAssetManager();
this.hardcore = hardcore;
} |
21d7eacb-b5c2-4f34-aea7-50221858876a | 5 | public void close(Object ... objects) {
for (Object o : objects) {
String name = o.getClass().getName();
if (name.equals(Connection.class.getName())) {
closeConection((Connection)o);
} else if (name.equals(Statement.class.getName()) ||
name.equals(PreparedStatement.class.getName())) {
closeS... |
e1706d3d-dbe1-4b44-b6f8-4c5722be478c | 0 | public void startLiveWindowMode() {} |
111deec6-baa2-4b74-bb6d-5078bf7094f6 | 7 | @SuppressWarnings("unchecked")
protected boolean addValue(String subject, String variable, String value, boolean addToLines)
{
//if no subject, quit
if ((subject == null) || (subject.length()==0)) return false;
//if no variable, quit
if ((variable == null) || (variable.length()==0)) return false;
//if the... |
7155ddf8-7bbd-462d-b997-3b5818226b3b | 1 | public ResultSet returnPlayersInTeam(String teamName, String matchName){
try {
cs = con.prepareCall("{call returnPlayersInTeam(?,?)}");
cs.setString(1, teamName);
cs.setString(2, matchName);
rs = cs.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
} |
8a4e5107-aca3-4843-8806-e174823480bd | 9 | public void validate() throws XPathException {
//checkWithinTemplate();
// get the Mode object
if (!useCurrentMode) {
mode = getPrincipalStylesheet().getRuleManager().getMode(modeName, true);
}
// handle sorting if requested
AxisIterator kids = iterateAxis... |
5d8d131a-c823-4992-b137-7ec2ca500748 | 7 | private void incrementVariables(int round, int[] plate)
{
choice++;
if(round == 0)
choicesleft = (nplayers - index - choice) - 1; //Excluding the current plate
else
choicesleft = (nplayers + 1 - choice) - 1;
if(initflag)
{
for(int i = 0; i < length; i++)
numfruits = numfruits + plate[i];
if... |
715b794e-1d69-4072-bdfa-a4305a5bf2a3 | 7 | public void addDoc(int did) {
// Check if we need to add a skip list node
if (numDocs == 0) {
SkipNode node = new SkipNode(did, docs.size(), weights.size());
skipList.add(node);
} else if (numDocs % SKIP_INTERVAL == 0) {
SkipNode node = new SkipNode(lastDid, docs.size(), weights.size());
skipList.add... |
2beda034-7b5b-4e49-a818-ab5112936829 | 0 | public String getRWord(){
return rWord;
} |
12e6d519-18cd-4632-8830-ce86a7b6bd33 | 6 | public static boolean hasSmallPrimeDivisor(BigInteger w) {
BigInteger prime;
for (int i = 0; i < SMALL_PRIME_COUNT; i++) {
prime = SMALL_PRIME[i];
if (w.mod(prime).equals(ZERO)) {
if (DEBUG && debuglevel > 4) {
debug(prime.toString(16)+" | "+w.toString(16)+"...")... |
ef806f78-6be4-4e4d-a918-773628932d17 | 3 | @Override
public void onRepaint(Graphics g) {
try {
for(final int i : Skills.getExperiences()) {
totalXP += i;
}
currCount = totalXP;
totalXP = 0;
if(lastCount != currCount) {
combined = combined + Settings.amount;
}
lastCount = currCount;
paint(g);
} catch (Except... |
2349bab2-553a-4dc8-b534-a6fa9f38db38 | 5 | private static InputStream getInputStream(String filePath)
{
InputStream instream = null;
try
{
instream = new FileInputStream(filePath);
}
catch (Exception e)
{
URL url = PropertyReader.class.getClassLoader().getResource(filePath);
if... |
6bc2b939-278f-492e-a043-865c69bd494e | 0 | public boolean isViewed() {
return viewed;
} |
df96a305-3710-4b6b-8ab8-6e366a4a8b1c | 2 | public static Date ConverteData(String dataString) throws Exception {
if (dataString == null || dataString.equals("")) {
return null;
}
DateFormat fmt = new SimpleDateFormat("dd/MM/yyyy");
java.sql.Date data = new java.sql.Date(fmt.parse(dataString).getTime());
retu... |
c0b1cf97-a717-4eef-a2c6-3c7747e9aeb4 | 5 | public ClassAnalyzer findAnonClass(String name) {
if (innerAnalyzers != null) {
Enumeration enum_ = innerAnalyzers.elements();
while (enum_.hasMoreElements()) {
ClassAnalyzer classAna = (ClassAnalyzer) enum_.nextElement();
if (classAna.getParent() == this && classAna.getName() != null
&& classAna.... |
1c83a5c7-5f95-4233-a31f-5a6b12bf460c | 9 | private static String readQueryFromReader(Reader reader, NameChecker nameChecker) throws XPathException {
try {
FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.LARGE);
char[] buffer = new char[2048];
boolean first = true;
int actual;
int li... |
69d30164-12ce-47c3-b6c5-20918e5ee973 | 2 | private static Field getLabelStatusField() {
if (labelStatusField == null) {
labelStatusField = getLabelField("a");
if (labelStatusField == null) {
labelStatusField = getLabelField("status");
}
}
return labelStatusField;
} |
f2fba43a-599e-4399-923d-85545f9d84ce | 5 | private TreeWillExpandListener createTreeWillExpandListener() {
return new TreeWillExpandListener() {
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
onWillExpandOrCollapse(event, true);
}
public void treeWillCollapse(TreeExp... |
ff72c4fd-e093-47f1-b8e2-70387b54d9b8 | 3 | @Override
public void moveCustomerToSellerQueue(int currentPhase, Queue lineQueue,
ArrayList<TicketSeller> sellers) {
Customer tmpCustomer;
TicketSeller tmpSeller;
Random rd = new Random();
while(!lineQueue.isEmpty()){
int randomNum = rd.nextInt(Define.theNumberOfTicketSeller);
tmpSeller = s... |
b32dab92-684f-4d56-981e-c3d76ca7718e | 3 | private void setToolTips()
{
newButton.setToolTipText( LOCALIZER.getString(TT_NEW));
openButton.setToolTipText( LOCALIZER.getString(TT_OPEN));
saveButton.setToolTipText( LOCALIZER.getString(TT_SAVE));
playButton.setToolTipText( LOCALIZER.getString(TT_PLAY));
... |
8537461e-406d-40e7-8aa9-71fbc5bc494e | 4 | public int getOpcode(final int opcode) {
if (opcode == Opcodes.IALOAD || opcode == Opcodes.IASTORE) {
// the offset for IALOAD or IASTORE is in byte 1 of 'off' for
// primitive types (buf == null)
return opcode + (buf == null ? (off & 0xFF00) >> 8 : 4);
} else {
// the offset for other instructions is i... |
8ca12d57-2c69-4c2b-a00b-dda956f8b7d2 | 9 | @Override
public String toString() {
int spos = back;
int max = Math.min(start-1, end);
int charCount = 0;
for (int i = 0; i < max + 1 - back && i < BACK; i++) {
char c = buf[max-i];
if (c == '\r' || (c == '\n' && (max-i-1 < 0 || buf[max-i-1] != '\r'))) {
if (charCount > 0) break;
} else if (c != ... |
dac3e349-48f7-4688-87d7-727314f46543 | 1 | public void testNegated() {
Years test = Years.years(12);
assertEquals(-12, test.negated().getYears());
assertEquals(12, test.getYears());
try {
Years.MIN_VALUE.negated();
fail();
} catch (ArithmeticException ex) {
// expected
... |
693371f8-6243-4c3b-8566-78b8b374081c | 2 | private void fillChoice(JComboBox c, String implDir, String selection) {
c.removeAllItems();
Vector<String> names = Global.getImplementations(implDir);
if(!names.contains(selection)) {
names.add(selection);
}
for(String s : names) {
c.addItem(s);
}
c.setSelectedItem(selection);
} |
d8326e0a-77d4-47ac-9425-4156d4e6e3a4 | 8 | void visitAroundDFS(int i,int j, char[][] board)
{
board[i][j] = 'A';
if(i>0&&board[i-1][j]=='O')
{
visitAroundDFS(i-1, j, board);
}
if(i<height-1&&board[i+1][j]=='O')
{
visitAroundDFS(i+1,j,board);
}
if(j>0 && board[i][j-1]=='O')
{
visitAroundDFS(i,j-1,board);
}
if(j<width-1 && board... |
041b3b8a-573e-4132-8488-fde96d04be57 | 6 | private void removeSuperiorityImpl() throws TheoryNormalizerException {
List<Superiority> superiority = theory.getAllSuperiority();
List<Rule> rulesToAdd = new ArrayList<Rule>();
Set<String> rulesToDelete = new TreeSet<String>();
removeSuperiority_ruleModification(rulesToAdd, rulesToDelete);
// superiority... |
1572c60e-cb6a-4b08-9cb0-27e30a7c7c8f | 2 | @Override
public void run() {
try {
//System.err.println("DBThread Runs");
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/cdr_data?user=root&password=root");
preparedStatement = connect.prepareStatement("i... |
f9297441-0abf-4976-9544-a23257c7008a | 9 | protected int findPrototypeId(String s)
{
int id;
// #string_id_map#
// #generated# Last update: 2007-05-09 08:15:15 EDT
L0: { id = 0; String X = null; int c;
L: switch (s.length()) {
case 4: X="call";id=Id_call; break L;
case 5: X="apply";id=Id_apply; break L;
... |
2b5a6bec-9d06-4d0c-860a-f2841b22e823 | 9 | @EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Wolf))
return;
if (!(event instanceof EntityDamageByEntityEvent))
return;
EntityDamageByEntityEvent subEvent = (EntityDamageByEntityEvent) event;
Entity at... |
b905f675-c241-4178-bac3-eddb0578a336 | 9 | private void checkForPredefinedFragments() {
String str = getFragmentAsString();
if (str == null)
return;
boolean needPromoter = !str.startsWith(PROMOTER_FRAGMENT_STR);
boolean needStart = !str.startsWith(needPromoter ? START_FRAGMENT_STR : PROMOTER_START_FRAGMENT_STR);
boolean needTerminator = !str.endsW... |
76e6ff17-baa7-4cfb-919b-64d01dcd2259 | 6 | @Override
public void run() {
Long start = System.nanoTime();
try {
client.setSoTimeout(10000);
} catch (SocketException e) {
WebServer.triggerInternalError("Socket Timeout Set failed for socket on port " + client.getLocalPort()
+ ": " + e.getMessa... |
e5d85867-d065-4564-a631-c8e766858672 | 0 | public String getEmailAddress() {
return emailAddress;
} |
baba4543-a03b-4cd7-8145-65f801fc0fd3 | 8 | public void render() {
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
int xOffset = player.x - (screen.width / 2);
int yOffset = player.y - (screen.height / 2);
level.renderTiles(screen, xOffset, yOf... |
af479f10-b671-47a8-a462-8921e1f8f893 | 0 | public Product getResult() {
Product product = new Product(partA, partB, partC);
return product;
} |
5e26392b-6a19-46bc-acdf-ef4903025e91 | 9 | public CSVReader(String filename) {
rows = new ArrayList<CSVRow>();
if(FileHelper.fileExists(filename)) {
BufferedReader br = null;
String line = "";
int lineCount = 0;
try {
br = new BufferedReader(new FileReader(filename));
while ((line = br.readLine()) != null) {
if(ROW_LIMIT == -1 ||... |
e2fc1db1-f254-49b4-a3fb-17c3942fe5fd | 0 | public static void main(String[] args) {
Circle circle = new Circle();
circle.draw();
// Add Triangle
} |
b21aa645-be56-4710-97e8-aff7f9f85791 | 5 | @EventHandler
public void onTimeBanEvent(TimeBanBanEvent event) {
String admin;
if (event.getSender() != null && event.isSenderPlayer()) {
admin = event.getSender().getDisplayName();
} else {
admin = "console";
}
// get ban
Ban b = event.getBa... |
8405258a-3897-4409-a4cd-36c8917fdc7b | 3 | private boolean checkDuplicate(String userID){
if(count > 0){
for (int i = 0; i < clientObj.length; i++) {
if((clientObj[i].getUserID()).equals(userID)){
return false;
}
}
}return true;
} |
855cab26-e81a-4365-b8f9-3ce3cbbe43d2 | 0 | public int compareTo(FileWrapper o){
return id - o.getId();
} |
f43b7c72-1049-4c27-8e52-59013e27b1d1 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final AddressBinding other = (AddressBinding) obj;
if (deviceAddress == null) {
... |
7485ccc5-9456-4bb4-b41c-abea6a9af2f5 | 2 | public void apply() {
heading += headingDelta;
if (heading >= 360)
heading -= 360;
if (heading < 0)
heading += 360;
xPos += Math.cos(Math.toRadians(heading)) * movement;
yPos += Math.sin(Math.toRadians(heading)) * movement;
} |
1e4bd339-9e99-4d51-b054-a1dd47097aa5 | 7 | public boolean isTransitiva() throws NaoEhRelacao {
HashMap<Integer, HashMap<Integer, Elemento>> map = getMap();
Conjunto c = new Conjunto();
for (Map.Entry<Integer, HashMap<Integer, Elemento>> entry : map.entrySet()) {
Integer i = entry.getKey();
HashMap<Integer, Elemen... |
fc7ce900-2baa-4a2b-9e81-0b79ff462aa2 | 8 | public HashMap<Integer, Double> computeMatrixEigenVector(HashMap<Integer, HashMap<Integer, Double>> matrix, int maxIterator)
{
HashMap<Integer, Double> result = new HashMap<Integer, Double>();
//init
Iterator<Integer> it = matrix.keySet().iterator();
while(it.hasNext())
{
int key = it.next();
result.p... |
69186f98-087b-46a7-bfb7-a8b04e91f705 | 1 | @Override
protected void init() {
super.init();
BmTestManager bmTestManager = BmTestManager.getInstance();
bmTestManager.testInfoNotificationListeners.add(new ITestInfoNotification() {
@Override
public void onTestInfoChanged(TestInfo testInfo) {
if (te... |
37cd3a1d-366f-497a-aba3-0346ce9521ba | 1 | public double[] getY(double[] result, double x) {
double m = (x - h) / a;
double q = (1 - m * m) * b * b;
if (result == null) {
result = new double[2];
}
result[0] = Math.sqrt(q) + k;
result[1] = k - Math.sqrt(q);
return result;
} |
524c55af-4727-482f-9402-80d3c1ad8d97 | 5 | private void processOptions(){
longOptions = new HashMap<String,CmdLnOption>();
shortOptions= new HashMap<Character,CmdLnOption>();
for (CmdLnOption option: options){
option.setImmutable();
for (String name: option.getLongNames()){
if (longOptions.contains... |
95170b4f-7262-4714-a3f6-4cf8a2ab3a75 | 6 | public void testGetCycImage() {
System.out.println("\n**** testGetCycImage ****");
CycAccess cycAccess = null;
try {
try {
if (connectionMode == LOCAL_CYC_CONNECTION) {
cycAccess = new CycAccess(testHostName, testBasePort);
} else if (connectionMode == SOAP_CYC_CONNECTION) {... |
15cd621a-246b-4939-8196-bb87ec8a567b | 2 | public static int nextConnectionId(int connectionId) {
if(connectionId == Packet.ANONYMOUS_CONNECTION_ID || connectionId == Packet.MAXIMUM_CONNECTION_ID)
return Packet.MINIMUM_CONNECTION_ID;
return connectionId + 1;
} |
d8561532-f5d3-4a85-8865-663be714eb6c | 8 | public void listenToAuctionServer() {
// just build if the connection to the server is ok.
if (ioNotFound == false) {
String incommingMessage;
try {
while((incommingMessage = in.readLine()) != null) {
// server shut down
if (incommingMessage.equals("... |
a3987ea6-e812-4117-b893-69e5eef3ed87 | 8 | public char determineNewPosition(char firstChar,char lastChar) {
switch(firstChar) {
case 'B':
if (lastChar=='I') {
return 'B';
}
else if (lastChar=='E') {
return 'U';
}
else {
System.err.println("1st="+firstChar+" and last="+lastChar);
return 'U';
}
case 'O':
if (lastChar=='O') {
... |
15eac340-3419-421c-ad8f-0c21bdafe9d5 | 3 | public void debug_stack() {
StringBuilder sb=new StringBuilder("## STACK:");
for (int i=0; i<stack.size(); i++) {
Symbol s = stack.elementAt(i);
sb.append(" <state "+s.parse_state+", sym "+s.sym+">");
if ((i%3)==2 || (i==(stack.size()-1))) {
debug_message(sb.toString());
sb = new Stri... |
fd6ad8ee-26e7-4203-801e-07f35ff254d4 | 6 | private void createEdgesAndNodesFromLandPolygons(
HashMap<Integer, GMTShape> landPolygons,
HashMap<Integer, MapNode> nodes,
ArrayList<MapEdge> edges) {
// Create edges and nodes for each land polygon.
for (GMTShape shape : landPolygons.values()) {
if (sh... |
33855d7e-0dfd-4761-ab21-81ec3fc0343e | 3 | private void menuPage(){
menuPane = new JPanel();
menuPane.setBackground(SystemColor.activeCaption);
menuPane.setLayout(null);
//*****head label*****
JLabel lbl_menu = new JLabel("Menu");
lbl_menu.setFont(new Font("Arial", Font.BOLD, 30));
lbl_menu.setBounds(445, 20, 83, 56);
menuPane.add(lbl_menu);
... |
dd3ae1ee-c8e3-4c2f-91c9-172109da858d | 4 | private String[] parseTOC(InputStream toc) throws IOException{
LinkedList<String> ll = new LinkedList<String>();
while(true){
StringBuilder sb = new StringBuilder();
while(true){
char c = (char)toc.read();
if(c == -1){
ll.removeFirst();
ll.removeLast();
return ll.toArray(new String[0]);... |
d23bd48a-7ee2-4486-803d-d4cb41681921 | 0 | public void setLicenseDate(String licenseDate) {
this.licenseDate = licenseDate;
} |
e1c24f30-5545-47a7-bba1-64756fb1620a | 3 | private static byte[] pack(byte[] data, File path) throws IOException
{
JarInputStream in = new JarInputStream(new ByteArrayInputStream(data))
{
@Override
public ZipEntry getNextEntry() throws IOException
{
ZipEntry ret = super.getNextEntry();
... |
3b391192-958d-40da-95c5-68ca91143732 | 2 | @Override
public void onServerStatusChanged() {
ServerStatusController.ServerStatus serverStatus = ServerStatusController.getServerStatus();
switch (serverStatus) {
case AVAILABLE:
connectionStatus.setText("SERVER IS AVAILABLE");
connectionStatus.setForegr... |
d8b73eb2-14e3-4220-b923-3085114f5196 | 1 | private void nameCheck()
{
if (name.text().isEmpty()) {
name.setText(System.getProperty("user.name"));
}
} |
e3a89393-2585-4d60-a69b-58583abb056a | 1 | public static void main(String[] args) throws Exception{
int port = 9999;
ServerSocket listenSocket = new ServerSocket(port);
System.out.println("Multithreaded Server starts on Port "+port);
while (true){
Socket client = listenSocket.accept();
System.out.println("... |
d075a512-cdc8-46e6-94b7-793b6000a7aa | 2 | public void makeOneStep() {
for (int i = 0; i < nRows; i += 1) {
for (int j = 0; j < nColumns; j += 1) {
Denizen denizen = array[i][j];
denizen.makeOneStep(this);
}
}
setChanged();
notifyObservers();
} |
5b46fa50-1333-44e1-9cf8-8c5f6cdb7617 | 5 | @Override
public String toString() {
StringBuilder s = new StringBuilder();
int empty = 0;
for (String s1 : notes)
if (s1.isEmpty())
empty++;
if (!(empty >= NOTESIZE && vol == 'q')) {
for (String s1 : notes) {
s.append(s1);
... |
bd1620f5-0a56-45c0-b38f-f6710fe62db5 | 6 | public Point playerTakesTurn(Player player, Point selectedLocation) throws Connect4Exception, GameException {
Point locationMarkerPlaced = null;
if (player == null) {
throw new Connect4Exception(ErrorType.ERROR107.getMessage());
}
if (player.getPlayerType() != PlayerType.R... |
b47cb26f-13ab-4beb-ac66-f68b812c7e5d | 8 | public int checkGG()
{
boolean teamOneDefeat = true;
for(Integer i: teamOneInd)
{
if(!shipList.get(i).isDestroyed())
{
teamOneDefeat = false;
}
}
boolean teamTwoDefeat = true;
for(Integer i: teamTwoInd)
{
... |
f48cc2d9-5120-483d-9492-e79c9431aab3 | 8 | public void run() {
try {
boolean eos=false;
byte[] buffer=new byte[8192];
while(!eos) {
OggPage op=OggPage.create(source);
synchronized (drainLock) {
int listSize=pageOffsets.size();
long pos=
... |
20fae44f-b66a-4f08-86b2-7e199685d7ff | 1 | public static void main(String[] args) {
CycLParser parser = new CycLParser(System.in);
try {
parser.term(true);
} catch (Exception e) {
System.err.println(e);
}
} |
6b607233-fc99-4c51-9189-acc5b7b64240 | 3 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
final Location last = this.lastBlockChange.get(event.getPlayer().getName());
final Location to = event.getTo();
// only check further on block transitions
... |
dc97a2b4-728f-4f74-8bdc-854ebddc8c44 | 9 | public WeightedMove getBestMove(ChessGame game, int player, int depth){
calls++;
ArrayList<WeightedMove> possibleMoves = new ArrayList<WeightedMove>();
int[][] board = game.getBoard();
for(int x=0;x<8;x++){
for(int y=0;y<8;y++){
if(board[x][y]/7!=player)
continue;
Piece p = Piece.getPiece(board,... |
3fb1d1a2-d198-413a-a8db-98136518a6ed | 8 | @Override
public BigInteger convertControlValueToControlComparable(Object aValue)
{
if ( aValue instanceof BigInteger )
{
return (BigInteger) aValue;
}
else if ( aValue instanceof Integer )
{
return new BigInteger( ((Integer) aValue).toString() );
}
else if ( aValue instanceof String )
{
Stri... |
0aa5037d-0331-47b8-bc6c-4c7ae8cb3ca7 | 2 | private BaseCmd getCommands(String s) {
for (BaseCmd cmd : cmds) {
if (cmd.cmdName.equalsIgnoreCase(s)) {
return cmd;
}
}
return null;
} |
3c6b039d-5256-4057-bd74-4591b72b6496 | 7 | public boolean overlaps(CourseTime c) {
int[] cdays = c.getDays();
for(int i : cdays) {
for(int j : this.days) {
if(i == j) {
if(c.getStartTime() >= startTime && c.getStartTime() <= endTime) return true;
else if(c.getEndTime() <= endTime && c.getEndTime() >= startTime) return true;
else return... |
0ff2b325-2338-49ab-a6ed-8369e40a309f | 3 | final void method50ms() {
long timeMillis = System.currentTimeMillis();
while (true) {
if (System.currentTimeMillis() > timeMillis + 50)
return;
try {
Thread.sleep(51);
} catch (InterruptedException e) {
Thread.interrupted();
}
}
} |
7cf59495-f48b-43bd-a31a-614fd1d26eed | 4 | public void update() {
if(!isRunning) return;
for (Entity entity : entities) {
entity.update(0);
}
if(null != actions ){
synchronized (actions){
Iterator i = actions.iterator();
while (i.hasNext()){
((LoopedActi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.