method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
05b8fe03-6a25-4353-99e9-abf78c127bd4 | 7 | public void drawMissiles(Graphics2D g2d) {
// Code to handle missiles of craft
missileList = craft.getMissiles();
for(int i = 0; i < missileList.size(); i++) {
Missile currMissile = missileList.get(i);
if(currMissile != null && currMissile.isVisible()) {
currMissile.move();
g2d.drawImage(cu... |
98714045-fa44-430f-9b59-c759215242d5 | 4 | public static boolean isMostlyNumeric(String var) {
if (Functions.isEmpty(var)) return false;
//int digits = 0; // these were put here in case we wanted to do some statistical analysis as part of this routine.
//int letters = 0;
// if first or last are digits, keep.
if (ctype_digit(var.charAt(0))) return true... |
19e2ba48-ba7b-4b1d-ad6f-b232f2a9a345 | 0 | public static Inches FeetToInches(Feet f) {
return new Inches(f.getQuantity() / 12);
} |
d9af7b38-b54a-4205-bfe0-c4316f179f1c | 9 | public static void main(String[] args) {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "shopkeepr");
try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException ex) {
System.out.println("Unable to load native look... |
598c9771-d993-44c6-834d-1590d122ae1b | 5 | private void editMatchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editMatchButtonActionPerformed
// TODO add your handling code here:
try{
matches.get(matchList.getSelectedRow());
MatchTeamFrame frame = new MatchTeamFrame();
frame.se... |
715de24a-bc2c-4cc9-944c-7bd2d9a8651c | 5 | private Menu createPopUpMenu() {
Menu popUpMenu = new Menu(shell, SWT.POP_UP);
/**
* Adds a listener to handle enabling and disabling
* some items in the Edit submenu.
*/
popUpMenu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
Menu menu = (Menu)e.widget;
MenuItem[] items =... |
ec1ee846-501a-4523-a573-7df7b5a96a89 | 9 | void processSymmetryOperationsLoopBlock() throws Exception {
parseLoopParameters(symmetryOperationsFields);
int nRefs = 0;
for (int i = propertyCount; --i >= 0;)
if (propertyReferenced[i])
nRefs++;
if (nRefs != 1) {
logger
.log("?que? _symmetry_equiv or _space_group_symop p... |
cb7bdf5a-5b58-416c-9a10-63f4617d2e92 | 2 | private static void writeItems(final Collection itemCollection,
final DataOutput dos, final boolean dotted) throws IOException {
int size = itemCollection.size();
Item[] items = (Item[]) itemCollection.toArray(new Item[size]);
Arrays.sort(items);
for (int i = 0; i < size; i++) {
dos.writeUTF(items[i].name... |
e153b83f-2974-428f-a1a1-565e46cc11fc | 8 | public void testQuoting() {
String input;
String output;
input = "blahblah";
output = Utils.quote(input);
assertTrue("No quoting necessary", !output.startsWith("'") && !output.endsWith("'"));
input = "";
output = Utils.quote(input);
assertTrue("Empty string quoted", output.... |
7819f49e-0aa2-4ab4-a6fc-6848b4f44b04 | 6 | public synchronized void remove(NotifierTarget target) {
if (mNameMap.containsKey(target)) {
if (target instanceof BatchNotifierTarget) {
mBatchTargets.remove(target);
}
for (String name : mNameMap.get(target)) {
if (name.length() > 0) {
HashSet<NotifierTarget> set = mProductionMap.get(name);
... |
34960c12-acdc-4d4a-a4ea-30f888313519 | 5 | public static void saveProperties(String file, String title, Map props) throws IOException {
BufferedWriter bw = null;
OutputStreamWriter osw = null;
final char[] NEWLINE = System.getProperty("line.separator").toCharArray();
File f = new File(file);
FileOutputStream fos = new FileOutpu... |
723ee5ab-f5d1-46dd-870c-3a5ddd043ab1 | 3 | public void editMethods(DragAndDropClassObject ddClassObject){
Vector<Object> methods = new Vector<Object>();
ImageIcon icon = new ImageIcon("");
for (String attribute:ddClassObject.classObject.methods){
methods.add(attribute);
}
Object[] possibilities = methods.toArray();
String s = (String)JOptionPane.... |
75f06cae-0b31-42e9-9500-cf7c6821518b | 6 | public void testMultipleStops() throws Exception
{
String s1 = getRandomString(3);
String s2 = getRandomString(3);
while( s2.equals(s1))
s2 = getRandomString(3);
String s3 = getRandomString(3);
while( s3.equals(s1) || s3.equals(s2))
s3 = getRandomString(3);
String s4 = getRandomString(... |
884011f8-e4a8-44ed-9a53-3bf7a669dc2e | 4 | public Game getGame(){
boolean test = false;
if (test || m_test) {
System.out.println("EndDisplay :: getGame() BEGIN");
}
if (test || m_test) {
System.out.println("EndDisplay :: getGame() END");
}
return m_game;
} |
6a6fcd49-e6d5-4b0b-b0cf-1b7137cda216 | 1 | private static void doStatInfoForBundleVsMarket(ArrayList<String> bundle) {
float marketChange = Database
.calculateMarketChange(0f, Float.MAX_VALUE);
ArrayList<Float> relChange = new ArrayList<Float>();
int i = 0;
for (String ticker : bundle) {
relChange.add(Database.calculatePercentChange(
Databas... |
62fcfd9a-bbe9-49c0-8b52-0ffa8e525daa | 8 | public int calculateTripletsBestResult(){
int triplets = 0;
int surprisings = this.getSurprising();
for (Integer myInt : this.getScores()) {
int maxResult = myInt / 3;
if (myInt % 3 > 0) {
maxResult++;
}
if (maxResult >= this.getScoreReference()) {
triplets++;
} else {
/* my be a surpri... |
5199d895-3f9a-4049-856b-67599381fac2 | 1 | public JSONObject getJSONObject(String key) throws JSONException {
Object o = get(key);
if (o instanceof JSONObject) {
return (JSONObject)o;
}
throw new JSONException("JSONObject[" + quote(key) +
"] is not a JSONObject.");
} |
b0c85702-60d2-422f-98c5-5578939e0a97 | 6 | public void edgeDetection(int edgeDist) {
Pixel leftPixel = null;
Pixel rightPixel = null;
Pixel[][] pixels = this.getPixels2D();
Color rightColor = null;
for (int row = 0; row < pixels.length; row++) {
for (int col = 0; col < pixels[0].length - 1; col++) {
leftPixel = pixels[row][col];
rightPixel ... |
ac7d4efb-d1de-4e71-93bb-2d872f5e2b40 | 8 | public BoardColorSelectMenu(Game game, JFrame frame, int stateToNotShow1, int stateToNotShow2)
{
super(game,frame);
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
header = new JLabel(" Choose Board Color");
header.setFont(smallFont);
greyButton = new JButton("Grey");
gre... |
87f69df9-5d87-4bb7-9808-a5dc80857d5a | 7 | public String createBookWithParameters(String name, String author, String year, BookType bookType, String cover, String description) {
int yearToInt = 0;
// Check the name
if (name.equals("")) {
return "the book name is empty";
}
if (author.equals("")) {
return "the author name is empty";
}
... |
90ccb539-5b01-47d2-bd9c-f8a58d057a47 | 5 | private void registerUser(String user, String password) throws RegistrationException{
if(user == null || password == null){
throw new RegistrationException("Username or password was inValid.");
}
if(user_exists(user)){
throw new RegistrationException("Username already exist.");
}
if... |
7a291f8d-39cd-4baf-bdd7-326f67916ec0 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final WriteAccessSpecification other = (WriteAccessSpecification) obj;
if (listOfProp... |
37dbfca1-954d-417a-bf27-081a046f165d | 4 | public static Direction valueOfSingle(String d) {
d = d.toLowerCase();
if(d.equals("n")) return NORTH;
if(d.equals("w")) return WEST;
if(d.equals("e")) return EAST;
if(d.equals("s")) return SOUTH;
return null;
} |
5ef21b28-bda5-463a-abaa-fde8dc6b3bcf | 6 | public static byte[] TripleDES_Encrypt(byte[] data,byte[][] keys)
{
int lenght=0;
byte[] padding = new byte[1];
int i;
lenght = 8 - data.length % 8;
padding = new byte[lenght];
padding[0] = (byte) 0x80;
for (i = 1; i < lenght; i++)
padding[i] = 0;
byte[] tmp = new byte[data.length + lenght];
... |
761c31dd-7bc5-4c9c-8474-9fd091fa3d7d | 8 | public ArrayList<TrendPoint> detectTrends(ArrayList<Double> shortSerie, ArrayList<Double> longSerie){
ArrayList<TrendPoint> result = new ArrayList<TrendPoint>();
boolean nextIsRise = false;
//Must check if we should start on negative or positive
int startPos = 0;
for(int i = 0; i < shortSerie.size(); i++){... |
d7a9a7c2-8f3d-47bf-8f3c-1aa1070f5ad9 | 2 | public Client getByUsersId(int usersId) {
Client client = new Client();
try {
PreparedStatement statement = getConnection().prepareStatement(usersIdQuery);
statement.setInt(1, usersId);
ResultSet result = statement.executeQuery();
if (result.next()) {
... |
ad0c6f9e-bd72-48aa-b3e8-9ff435974948 | 7 | private void processExtNode(Element e) throws InvalidBLXXMLException, ServiceNotFoundException, ExtensionLoadException {
try {
NodeList nodes = e.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
Node node = nodes.item(i);
if(node.getNodeType() != Node... |
852a3961-8595-43da-8e1f-dcf66d538051 | 0 | @Override
public VueMenu getVue() {
return (VueMenu) vue;
} |
67f7df52-fb04-4b20-955e-775dc53a9569 | 3 | private String[] recursiveListFiles(String pathname, File file) throws IOException {
// Name of the current subdirectory
Message msg = null;
pathname += "/" + file.getName();
System.out.println("Current subdirectory: " + pathname);
// Get list of contents as string[]
File[] fileList = file.listFiles();
... |
a893b739-4d3d-4fa1-892e-646efe5afa3c | 0 | @Override
public Balance Accesscreate() {
return Balance.create();
} |
194da578-dfa2-44be-897c-c623bf7cac23 | 3 | private Double isValidAnswer(Double result) {
result = Math.round(result * 100.0) / 100.0;
String comparedFloatPoint = ("" + result).split("\\.")[1];
if (comparedFloatPoint.contains("E") || comparedFloatPoint.length() > 1)
return null;
long point = Long.parseLong(comparedFloa... |
59d2c9e9-789e-45d8-a12d-f1a7958ba553 | 9 | @SuppressWarnings("rawtypes")
public static void notEmpty(Object obj, String message) {
if (obj == null){
throw new IllegalArgumentException(message + " must be specified");
}
if (obj instanceof String && obj.toString().trim().length()==0){
throw new IllegalArgumentException(message + " must be specified")... |
01c2259d-0e6d-4ea5-933e-7b256961216d | 0 | private void placeControls() {
placeEquationParameters();
placeIntegrationParameters();
placeInterpolationParameters();
placeInitialConditions();
placeButtonControls();
} |
d5ea7b21-f538-4929-bef9-b0640daae13f | 5 | private OfficeWordContainer() {
} |
29b5afcd-6435-4ec8-8718-fc80164fe5d7 | 0 | public void setName(String name) {
this.name = name;
} |
d7fa3e75-45ac-424b-a899-5ac7f8d92ff9 | 3 | public void addSound(Sound sound){
try {
Clip audioClip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(sound.AUDIO_FILE);
audioClip.open(ais);
soundClipStash.put(sound.TYPE, audioClip);
} catch (UnsupportedAudioFileException e)... |
1cc4c192-57d2-40c3-8185-bbb31b8eae53 | 9 | public static Double inlineDistanceBetweenPoints(Polyline polyline, Point p1, Point p2) {
Double distance = null;
for (int i = 0; i < polyline.size() - 1; i++) {
Point pp1 = polyline.getPoint(i);
Point pp2 = polyline.getPoint(i + 1);
Line line = new Line(pp1, pp2);
... |
15a78096-3d55-419c-9264-693ed6babd2e | 6 | private void createMesh(int x, int y, int z, float r, float g, float b) {
/*
* This checks to make the block's face is touching another block. If not don't show the face.
* TEMP: All values added to color will be removed. They are light place holders. "Psuedo-light"
*/
// Left
if (!checkLeft(x, y, z)) {
... |
caa64a44-2dfb-4417-9ec2-d565a0c0880a | 5 | public Element output(Document doc, int slot){
TNode main = new TNode("item", getName(), doc);
main.setAttribute("slot", String.valueOf(slot));
if(getVisiblename() != null){
main.setAttribute("name", getVisiblename());
}
if(getLore() != null){
main.setAttr... |
5b8df6b6-0616-4107-b710-dddc2f9a1eb5 | 9 | public String nextToken() throws JSONException {
char c;
char q;
StringBuffer sb = new StringBuffer();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
... |
67c57699-716a-4ede-a359-8a80a3573bf2 | 6 | public final static int dehexchar(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'A' && c <= 'F') {
return c - ('A' - 10);
}
if (c >= 'a' && c <= 'f') {
return c - ('a' - 10);
}
return -1;
} |
80b74bb1-1356-4b46-87d0-0405529d65e9 | 9 | public String nextToken() throws JSONException {
char c;
char q;
StringBuilder sb = new StringBuilder();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
... |
4e71c491-d909-47ab-974e-7c9c16e82257 | 3 | private static void corpTest(ArrayList<Kill> kills, String name) {
ArrayList<Kill> commonList = killStats.Stats.compairEntityKill(kills,
name);
Kill latestLoss = new Kill();
latestLoss.setKillTime(new GregorianCalendar(0, 0, 0, 0, 0, 0));
for (Kill k : commonList) {
if (k.getVictim().getPilot().getChara... |
a66b4e1d-8ded-49d9-ae66-c18025373451 | 4 | public static int gcd(int n1, int n2) {
int gcd = 1;
int k = 2;
while (k <= n1 && k <= n2) {
if (n1 % k == 0 && n2 % k == 0) {
gcd = k;
}
k++;
}
return gcd;
} |
fc79ac5f-e222-4bdb-941a-658800df3cbe | 1 | public GenericDAO<Employee> getEmployeesDAO()
{
if (_employeesDAO == null)
{
_employeesDAO = new GenericDAO<Employee>(Employee.class);
}
return _employeesDAO;
} |
382756d5-beba-4d53-87b8-a53a2bff7bd4 | 0 | public RollHandler(boolean right) {
this.right = right;
} |
fc0122f5-6e27-43ac-8ca8-d51bd2d4e943 | 2 | public String strageAccess(DataName d) {
Cache cache = WikiUtil.getCache(60 * 60 * 48);
String data = (String) cache.get(inputName + "," + d.name());
if (data == null) {
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Key key = KeyFactory.createKey("seiyu", inputName);
E... |
132eeb63-b301-4a58-827d-b3de493d125e | 8 | public static void main(String[] args) throws Throwable{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();int caso=1;
for(StringTokenizer st;(st=new StringTokenizer(in.readLine()))!=null;caso++){
int N=parseInt(st.nextToken()),V=parseInt(st.nextToken(... |
15bf3b2f-33a9-4eb1-bcc7-613676f826dd | 2 | public static void main(String args[]) {
if(args.length == 0){
hexxThread = new Thread(new Runnable() {
@Override
public void run() {
state = new State();
ui = new HaxagonUI();
board = new Board(5, state, ui);
synchronized (state) {
try {
state.wait();
} catch (Inter... |
206c4da6-fc90-4aad-9e66-3cc771ea7362 | 2 | private List<Invasor> selectInvasores(Juego juego){
List<Invasor> listInvasores = new ArrayList<>();
ForeignCollection<Invasor> invasores = juego.getInvasores();
CloseableIterator<Invasor> itInvasores = invasores.closeableIterator();
try {
try{
... |
4cc1fb6b-c4d9-4813-8e1d-e4ff6bcf08be | 8 | protected void onGuiEvent(GuiEvent ev) {
// ----------------------------------------
command = ev.getType();
if (command == QUIT) {
try {
home.kill();
for (int i = 0; i < container.length; i++) container[i].kill();
}
catch (Exception e) { e.printStackTrace(); }
myGui.setVisib... |
2414d600-8f17-47fe-8fa8-318e859bc7af | 1 | public void testConstructorEx_Partial() throws Throwable {
try {
new Partial((ReadablePartial) null);
fail();
} catch (IllegalArgumentException ex) {
assertMessageContains(ex, "must not be null");
}
} |
0b3b767c-f662-4efb-ae2d-008ee5fbaab2 | 9 | @Override
public void modifyStdItem(MOB mob, Item E, int showFlag) throws IOException
{
if((showFlag == -1) && (CMProps.getIntVar(CMProps.Int.EDITORTYPE)>0))
showFlag=-999;
boolean ok=false;
while(!ok)
{
int showNumber=0;
if(CMLib.flags().isCataloged(E))
{
if(CMLib.catalog().isCatalogObj(E.Nam... |
0838dc50-1ae5-4cef-a38c-815368b1b968 | 3 | Polygon generatePolygon()
{
if (lineUpperX.size() > 0)
{
int[] xP = new int[2 * lineUpperX.size() + 1];
int[] yP = new int[2 * lineUpperY.size() + 1];
int i;
for(i=0; i < lineUpperX.size(); i++)
{
xP[i] = lineUpperX.get(i);
yP[i] = lineUpperY.get(i);
... |
1ae1519c-156a-4c6e-8371-12391afca062 | 7 | public static <T extends Number> ArrayList<ArrayList<T>> sub(ArrayList<ArrayList<T>> a, ArrayList<ArrayList<T>> b, Class<T> type) {
try {
ArrayList<ArrayList<T>> result = new ArrayList<ArrayList<T>>();
if (a.size() != b.size() && a.get(0).size() != b.get(0).size()) {
throw new IllegalArgumentException();
... |
b3129f04-3414-4319-9e45-bdc1e9f62105 | 5 | public void deleteDuplicates() {
if (_root == null || _root.Next == null) {
return;
}
Node<T> current = _root;
while (current != null) {
Node<T> runner = current;
while (runner.Next != null) {
if (runner.Next.Data == current.Data) {
runner... |
06452d39-1144-45dc-9cc0-e0ce603d0c7b | 0 | public static void main(String[] args) {
// Testing the Message Board
MessageBoard board = new MessageBoard();
User madalin = new User("Madalin");
User alina = new User("Alina");
Message m1 = new Message(madalin, "Hey Alina, how are you doing?");
Message m2 = new Message(alina, "I'm doing good, tha... |
ed3786df-f142-45ed-bee4-933b1b59376c | 9 | protected Instance convertInstance(Instance instance) throws Exception {
Instance result;
double[] newVals;
Instance tempInst;
double cumulative;
int i;
int j;
double tempval;
int numAttsLowerBound;
newVals = new double[m_OutputNumAtts];
tempInst = (Instance) instanc... |
2fb44836-12e0-45e1-967a-f5d528b7bab5 | 9 | public void move() {
for (Organism org : Ecosystem.getRed()) {
if (getDist(org) < 50) {
int x = posX - org.posX;
int y = posY - org.posY;
double d = Math.sqrt(x * x + y * y);
movX += 10 * (x / d);
movY += 10 * (y / d);
}
}
for (Organism org : Ecosystem.g... |
c93a1caa-459a-49ba-aa64-eb162b1750d1 | 9 | private Pair partition(T[] a, int lo, int hi)
{
// 3-way partitioning
// = < unprocessed > =
//[lo ... p-1][p ... i-1][i ........ j][j+1 ... q-1][q ... hi]
int p = lo, i = lo, j = hi, q = hi;
T v = a[lo];
while (true)
{
int cmp;
while ((cmp = ... |
f83a4dd5-534e-47a8-a678-e05812d2af1f | 5 | private void fillData(){
for (AbstractUnit unit : units) {
if(unit instanceof IOutputUnit ){
IInstructionUnit nextUnit = (IInstructionUnit) ((IOutputUnit)unit).getNextUnit();
if(nextUnit == null){
// tulip.Tulip.mainFrame.writeConsole("unit №"+unit.... |
3508d233-6a96-4abc-84aa-11472db4a992 | 2 | private static Image doAwesomeThresholding(Image original, boolean merged) {
if (original.isHsv()) {
throw new IllegalStateException();
}
long t0 = System.currentTimeMillis();
AwesomeThresholding tp = new AwesomeThresholding(original);
tp.calculateMeansAndDevs();
if (merged) {
tp.compareDevsAndMerge(... |
3211bc9d-caef-4e27-9fd4-e78e73f3e6d0 | 5 | public final boolean isOccupied()
{
Rectangle tileRect = new Rectangle(mapX * TILE_SIZE, mapY * TILE_SIZE, TILE_SIZE, TILE_SIZE);
for (int x = -1; x < 2; x++)
for (int y = -1; y < 2; y++)
for (Entity entity : hub.game.region.getTile(x, y).getEntities())
if (entity.getData()[ENTITY_STATE] =... |
73a7b285-6ed4-4194-a96f-8a2657a7b905 | 2 | @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (rotation % 2 == 1) {
g.drawLine(0, 100, 50, 100);
g.drawLine(150, 100 , 200, 100);
g.drawLine(50, 100, 140, 80);
g.fillRect(48, 98, 5, 5);
g.fillRect(148, 98... |
936753ae-3ed7-4fd9-953d-b028c89d88e9 | 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... |
38119a04-c45e-4cc5-a2ba-b67b3fcebb69 | 0 | public void Join(String channel) throws Exception
{
Writer.write("JOIN " + channel + "\r\n");
Writer.append("WHO " + channel);
Writer.flush();
} |
a699adbd-6d7c-485e-8597-3b0dc589e0a9 | 2 | private void populateLineList() {
String line;
try {
while ((line = br.readLine()) != null)
lineList.add(line);
} catch (IOException e) {
e.printStackTrace();
}
} |
35d7c02f-1c56-4f32-b5d9-442c56dbe096 | 4 | public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch(keyCode) {
case KeyEvent.VK_W :
bu = true;
break;
case KeyEvent.VK_S :
bd = true;
break;
case KeyEvent.VK_A :
bl = true;
break;
case KeyEvent.VK_D :
br = true;
break;
default : ;
}
dir = location(... |
425b31db-f098-4631-a0e4-cab184b23caa | 6 | public static int expGacha(MapleCharacter player) {
if (!player.haveItem(Items.GachaType.regular, 1)) {
player.dropMessage("You do not have a Gacha ticket");
return 0;
}
player.gainItem(Items.GachaType.regular, -1);
int chance1 = (int) Math.floor(10 * Math.random(... |
ce267139-4f88-4fb5-ac5b-ac49b334dac3 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OutputCanDDeliveryOrderItemDiscPK other = (OutputCanDDeliveryOrderItemDiscPK) obj;
if (!Objects.equals(th... |
a5989e90-1f83-4fbc-96e8-df987e606b2c | 9 | public static Class<? extends ATile> getTileClass(String s) {
Class<? extends ATile> tileClass = null;
switch (s) {
case "void":
tileClass = VOID.tileClass;
break;
case "hole":
tileClass = HOLE.tileClass;
break;
case "asteroid":
... |
c1caef3c-46bd-49ab-bb30-8962e297f5c5 | 3 | @Override
public void update(final Observable observable, final Object object)
{
if (observable instanceof ClientInfo)
{
final ClientInfo clientInfo = (ClientInfo) observable;
if (object instanceof String)
{
final String string = (String) object;
final String answer = parserIn(string);
Log.d(... |
4dad42f5-12bd-438e-9a23-ccbdab8ee232 | 3 | public void setLogLevel(final String name) {
Level level;
try { level = Level.parse(name); } catch (final Exception e) {
level = CustomPlugin.DEFAULT_LOG;
this.getLogger().warning("Log level defaulted to " + level.getName() + "; Unrecognized java.util.logging.Level: " + name + ";... |
8ab52e3b-6bcd-4c1c-a6b2-c0df37cadcba | 4 | public Polar setCenter(Object[] center)
{
if (center.length != 2 || !center[0].getClass().getName().equals(center[1].getClass().getName()))
throw new IllegalArgumentException("center参数的形式:[String,String]或[int,int]");
else if (center[0] instanceof String || center[0] instanceof Number)
... |
fb919cf2-7ce2-4aa7-9b2a-c9522fe0eab2 | 1 | public ChiSquared(int nu) throws ParameterException {
if (nu < 1) {
throw new ParameterException("ChiSqared parameter nu >= 1.");
} else {
this.nu = nu;
norm = new Normal(0, 1);
}
} |
99a29ad5-7431-4119-861e-f10fe7e70e56 | 7 | public ArrayList<Card> buildDeck(Integer numPlayers){
// local var's
int lvSuitCount;
int lvCardId = 0;
Card lvNewCard;
ArrayList<Card> lvNewCardDeck = new ArrayList<Card>();
//evaluate input and set number of Suits for the new deck
if (numPlayers == 2 || numPlayers == 3) {
lvSuitCount = numPlayers + ... |
109d1a27-c4b3-4977-95d6-bf68fbac88ee | 6 | static void removeEdge(HashSet<String> subgraph) {
double min_jaccard = Integer.MAX_VALUE;
int max_union = 0;
String min_a = null;
String min_b = null;
for (String from : subgraph) {
for (String to : graph.get(from)) {
if (subgraph.contains(to)) {
double jaccard = jaccard(from, to);
if (jacca... |
258f4472-e1d0-4a4f-b83f-f6a71a69f955 | 8 | @Override
public void moveLeft () {
if (!checkMove ()) {
return;
}
score--;
final GameControllerEvent event = createEvent (LEFT_MOVE);
final Cell before = map.findRobot ();
if (before.x > 1) {
final Cell after = before.left ();
final AbstractElement e =... |
b8ca7b65-de07-4706-893e-5f0fbb62ad8e | 4 | private void handleHandshake(Channel channel, ByteBuf byteBuf) {
int length = ByteBufUtils.readVarInt(byteBuf);
int opcode = ByteBufUtils.readVarInt(byteBuf);
int protoVersion = ByteBufUtils.readVarInt(byteBuf);
String address = ByteBufUtils.readUTF(byteBuf);
int port = byteBuf.... |
e88699ad-f242-4133-ad33-f196d73fc600 | 5 | @SuppressWarnings({ "unchecked", "rawtypes" })
private List createMBeanAttributes(MBeanServerConnection mbc, ObjectName mBeanName, String attributePattern)
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
List attributes = new ArrayList();
MBeanInfo mbi = mbc.getMBean... |
479abbf9-204a-48e5-b60c-bb8a897ebfaa | 8 | protected void setupMouseControls() {
// right click to set the color
final int tilesWide = _stamp.getTilesWide();
final int tilesHigh = _stamp.getTilesHigh();
final int oamsWide = tilesWide / 2;
_stamp.addMouseListener(new MouseInputAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getButton(... |
b56edfb1-573f-4315-a6d1-21ba08c07255 | 7 | public boolean actionDeliverOres(Actor actor, Venue venue) {
if (verbose) I.sayAbout(actor, "Returning to "+venue) ;
for (Service type : Smelter.MINED_TYPES) {
if (venue instanceof Smelter) {
final Service output = ((Smelter) venue).output ;
if (type != output) continue ;
}
... |
de1089c4-eadd-4349-8461-af0a0f102ba4 | 6 | public void hitDragonClaws(final Client c, int damage) {
if(!c.usingClaws) {
return;
}
if(c.clawHit[0] <= 0) {
getDragonClawHits(c, damage);
}
if(c.npcIndex > 0) {
c.getCombat().applyNpcMeleeDamage(c.npcIndex, 1, c.clawHit[0]);
c.getCombat().applyNpcMeleeDamage(c.npcIndex, 2, c.clawHit[1]);
} el... |
251b6074-f2cc-40e9-9dfb-71d70fa45886 | 0 | @Test
public void threeFeetIsEqualToOneYard(){
ArithmeticQuantity feet = new ArithmeticQuantity(3, Distance.FEET);
ArithmeticQuantity yards = new ArithmeticQuantity(1, Distance.YARDS);
assertEquals(feet, yards);
assertEquals(yards, feet);
//assertEquals(new Quantity(1.5, YA... |
23119586-3972-43bc-bf3b-b0af4699c8b0 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Vertice other = (Vertice) obj;
if (index == null) {
if (other.index != null)
return false;
} else if (!index.equals(other.index))
ret... |
46fabf13-357a-4d91-a5e8-b51f3f34744c | 2 | public int firstIndexOf(String datum) {
for (int i = 0; i < size; i++) {
if (data[i] == datum) {
return i;
}
}
return -1;
} |
60087d9a-3728-471d-9e24-635c871f1c3d | 1 | private int getRows(String tabla) {
int rows = -1;
try {
PreparedStatement pstm = (PreparedStatement) conectar().prepareStatement("SELECT count(1) as total FROM " + tabla);
ResultSet res = pstm.executeQuery();
res.next();
rows = res.getInt("total");
... |
1e2221d6-9547-45bb-9b9a-a63af6d59f19 | 1 | public int getLastY(int offset) {
if(offset <= this.index)
return line[index - offset][1];
else
return -1;
} |
18852178-2f6c-40e5-a7d9-ecb86dc71060 | 3 | public static int getReturnSize(String methodTypeSig) {
int length = methodTypeSig.length();
if (methodTypeSig.charAt(length - 2) == ')') {
// This is a single character return type.
char returnType = methodTypeSig.charAt(length - 1);
return returnType == 'V' ? 0 : usingTwoSlots(returnType) ? 2 : 1;
} el... |
c27ed96c-239d-4ab0-8ae2-93c95dc72884 | 7 | public Message getMessage(int queueId, int senderId, boolean peek) throws MessageDequeueException, MessageDequeueQueueDoesNotExistException, MessageDequeueEmptyQueueException, MessageDequeueNotIntendedReceiverException {
try {
_out.writeInt(20); //Size
_out.writeInt(Response.MSG_QUEUE_DE... |
7db7cee3-6925-4f2a-bfda-792e1d054154 | 7 | private void generateTerritorySeeds(){
boolean[][] assigned = new boolean[size][size];
ArrayList<ArrayList<Tile>> territoryTiles = new ArrayList<ArrayList<Tile>>();
for (int i = 0; i < territories.length; i ++){ // create a new list for each territory to house their tiles
territoryTiles.add(new ArrayList<Ti... |
a0e2bca6-fafc-493b-8602-9a6a0beff456 | 2 | public int bitsNeedToConvert(int A, int B){
//XOR A and B to get a new integer.
//Whatever bits of 1 in this integer is the return value.
int C = A ^ B;
int count = 0;
for(int i=0;i<32;i++){
if((C & (1 << i)) > 0){
count ++;
}
}
return count;
} |
d0593553-7420-45db-8861-1444564ff6eb | 7 | @Override
protected boolean catchIt(MOB mob, Physical target)
{
final boolean caughtIt=super.catchIt(mob,target);
if(!(affected instanceof Drink))
return caughtIt;
if(CMLib.dice().roll(1,1000,0)>(alchoholContribution()*alchoholContribution()*alchoholContribution()))
return caughtIt;
if((target!=null)&&(... |
c8209159-7706-4362-a3d0-74018004fbe3 | 8 | public int getTotalFrequencias(ArrayList<Byte> contexto, int nivel){
if(nivel > -1){
if(this.isEsc() || (this.getValor() != contexto.get(nivel))) return -1;
}
if(nivel == contexto.size() - 1) {
if(this.isEsc()) return -1;
int contador = 0;
for(Contexto c : filhos){
contador += c.getFrequenc... |
371f7de3-dd36-4802-9cee-4768229b2d0d | 9 | private static String js_slice(String target, Object[] args) {
if (args.length != 0) {
double begin = ScriptRuntime.toInteger(args[0]);
double end;
int length = target.length();
if (begin < 0) {
begin += length;
if (begin < 0)
... |
a1dc1158-fb0a-42fa-ba9d-88c37fe96717 | 4 | public static WidgetChild getChild(final BookDraggable b) {
if (b == null)
return null;
WidgetChild wc = Widgets.get(BookDraggable.BOOK_WIDGET, BookDraggable.MAIN_CHILDREN);
return (wc == null || (wc = wc.getChild(b.getChildId())) == null
|| wc.getTextureId() != b.getChildTexture() ? null : wc);
} |
408148f1-ec88-4066-80f8-fd91fbddacdd | 0 | @Test
public void runTestInsecureBank() throws IOException {
InfoflowResults res = analyzeAPKFile(false);
// 7 leaks + 1x inter-component communication (server ip going through an intent)
Assert.assertEquals(8, res.size());
} |
f26672b4-f3f5-4738-aa78-147c81fcef7b | 9 | public void collision(List<Entity> entities)
{
synchronized(bullets)
{
for(int bulletIndex = 0; bulletIndex < bullets.size(); bulletIndex++)
{
for(int entityIndex = 1; entityIndex < entities.size(); entityIndex++)
{
if(entit... |
a2753cad-bbad-4e37-92b2-c4d6176fd439 | 2 | public void showMsg(Displayable form) {
Alert success = new Alert("Login Successfully", "Your Login Process is completed!", null, AlertType.INFO);
// success.setImage(img2);
Form login = (Form) form;
/* TextField userName = (TextField) login.get(0);
TextField password = (TextF... |
eb12a18d-7750-4c8e-af91-cbb6c221c6a0 | 0 | public static void handleInvocationTargetException(
InvocationTargetException ex) {
rethrowRuntimeException(ex.getTargetException());
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.