method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
f8fd6b15-0d26-45c5-bebd-f5a6fdaaea4e | 0 | public PooledThread() {
super(ThreadPool.this,
"PooledThread-" + (threadID++));
} |
1cafa1fd-c87f-4047-a63b-fab3aef7e6c5 | 6 | public AbstractInsnNode clone(final Map labels) {
FrameNode clone = new FrameNode();
clone.type = type;
if (local != null) {
clone.local = new ArrayList();
for (int i = 0; i < local.size(); ++i) {
Object l = local.get(i);
if (l instanceof LabelNode) {
l = labels.get(l);
}
clone.local.ad... |
fe3d503c-6e98-4d95-85fe-c0ef5d8ccd3d | 7 | private void computeArcSlots(Digraph<SugiyamaNode<V>,SugiyamaArc<V,E>> graph) {
List<SugiyamaArc<V,E>> arcs = new ArrayList<SugiyamaArc<V,E>>(graph.getEdgeCount());
// collect arcs
for (SugiyamaNode<V> source : graph.vertices()) {
for (SugiyamaNode<V> target : graph.targets(source)) {
arcs.add(graph.get(s... |
2c34d133-0b6e-4b9d-8c99-f1c9249e2264 | 2 | public void step() {
parentFrame.getWorld().step();
parentFrame.repaint();
if (++numStepsSoFar == numStepsToRun)
stop();
Grid<T> gr = parentFrame.getWorld().getGrid();
for (Location loc : gr.getOccupiedLocations())
addOccupant(gr.get(loc));
} |
0bcb142a-394b-450f-9fc2-c4af3681c758 | 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... |
2fed3c91-242f-4560-8728-f8a735c6d339 | 3 | public static void main(String[] args){
int[] fac = new int[10];
for (int i=0;i<10;i++) fac[i] = factorial(i);
int sum=0;
for(int i=10;i<2e7;i++){
if (i == facSum(i, fac)) sum+=i;
}
System.out.println(sum);
} |
0e236d90-2674-4815-a3ef-cb77603521d4 | 8 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((assentos == null) ? 0 : assentos.hashCode());
result = prime * result
+ ((horarioChegada == null) ? 0 : horarioChegada.hashCode());
result = prime * result
+ ((horarioSaida == null) ? 0 : horarioSa... |
d67f36dd-e215-453c-983f-a17f14f4d47c | 7 | @Override
public void gotoDetail(GoodsStatus gs, String goodUrl) {
Document doc = null;
try {
doc = Jsoup.connect(goodUrl).timeout(0).get();
} catch (IOException e) {
logger.error(e.getMessage(), e);
gs.setStatus(GoodsStatus.NOT_FOUND);
gs.setResult(GoodsStatus.SEARCH_EXCEPTION);
return;
}
Ele... |
945474a2-64c3-4ae5-af89-c20153833821 | 9 | public static AbstractCommand createCommand(TimeBan plugin, String cmd) {
AbstractCommand result = new NullCommand(plugin);
TimeBanCommands command;
try {
command = TimeBanCommands.valueOf(cmd.toUpperCase());
} catch (IllegalArgumentException e) {
return result;
... |
5c0255cc-b2b2-43b8-a154-53328e84c9a7 | 3 | public void run() {
T current;
while (!isInterrupted()) {
/* select next thread */
current = queue.getNext();
if ((current != null) && (current.isAlive())) {
/* Print Log */
reportThreadState();
current.setPriority(Thread.MAX_PRIORITY);
System.err.println("**... |
8225f8f9-c04a-41e2-ac92-b30c655787aa | 2 | public static byte[] decrypt(byte[] encoded_message) throws Exception {
if (encoded_message[0] == (byte) 0x02) {
int padding;
for (padding = 1; encoded_message[padding] != (byte) 0x00; padding++) ;
byte[] decoded_message = new byte[encoded_message.length - 1 - padding];
... |
0701ac71-be84-4ed9-9857-44452c184463 | 4 | public String GetNextString(){
if (text.length() == 0) return null;
int nextSeperator = text.indexOf("|");
if (nextSeperator == -1) return null;
String currentString = text.substring(0, nextSeperator);
text = text.substring(nextSeperator+1);
if (currentString.startsWith("\n")) currentString = currentS... |
9324077b-dded-4ca1-9fd6-8786596415ac | 5 | public static void run() {
final String dir = "E:\\DropBox\\DEV\\AdCleaner\\adcleaner\\~\\.adcelaner\\screens\\";
ImageSimilarityComparer comparer = new ImageSimilarityComparer();
ArrayList<File> files = new ArrayList<File>() {{
add(new File(dir + "video1_10.png"));
add... |
285444d3-8da5-477f-9ed1-d793926fef2e | 1 | public static TestcaseFactory getInstance() {
if (instance == null) {
instance = new TestcaseFactory();
}
return instance;
} |
0295f9f5-7e22-4e4e-824e-b738947c6041 | 3 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
if(commandLabel.equalsIgnoreCase("smite")) {
Player target = (Bukkit.getServer().getPlayer(args[0]));
if (target == null) {
sender.sendMessage(args... |
d83d0718-881a-429b-b0a0-d4a708f27073 | 9 | public void setTileDamage(){
for(int xx=0;xx<SIZE;xx++){
for(int yy=0;yy<SIZE;yy++){
switch(world[xx][yy]){
case STONE:
worldDamage[xx][yy]=10;
break;
case WOOD:
worldDamag... |
fbea38fb-b5bf-4abe-be15-23bef661e5d3 | 8 | public void confirmClicked(boolean par1, int par2)
{
if (this.deleteClicked)
{
this.deleteClicked = false;
if (par1)
{
this.serverList.remove(par2);
this.saveServerList();
}
this.mc.displayGuiScreen(this);
... |
f71e1513-0dc0-4a85-b947-3d0ee11f61d6 | 2 | public MinimapPanel(Coord c, Coord sz, Widget parent) {
super(c, sz, parent, "Minimap");
mrgn = Coord.z;
fbtn.visible = true;
cbtn.visible = false;
{
vcl = new IButton(new Coord(0, -2), this, Resource.loadimg("gfx/hud/slen/dispauth"), Resource.loadimg("gfx/hud/slen/dispauthd")) {
private boolean v = false;
... |
922a7b9c-9df7-45df-8eaa-54c85c38ea2a | 0 | public synchronized int getSharedCounter() {
return sharedCounter;
} |
6d8864b5-0936-4a8f-8ccb-7eeab1591401 | 3 | public boolean canTeach(Field aField, Group aGroup) {
//System.out.println("Teacher.canTeach() : " + this + " " + aField + " " + aGroup + " " + this.maxWeekWorkedHours.substract(this.currentWeekWorkedHours) + " " + aGroup.classes.get(aField));
boolean res = false;
if (aGroup.getClasses().get(aField).add(t... |
9949f2ba-ef78-43f5-86a8-3e23313ebdf2 | 8 | public static void main(String... args) {
String makefileName;
String fileInfoName;
if (args.length == 0) {
usage();
}
makefileName = "Makefile";
fileInfoName = "fileinfo";
int a;
for (a = 0; a < args.length; a += 1) {
if (args[a... |
4b74d9d0-d8f6-4e0a-a646-f8d722e76b85 | 5 | @Override
protected void Work(double time_sec)
{
if (IsAlive())
{
LifeCalc(time_sec);
if (thirst > 0)
{
if(target==null)
target = GetNearestObjectByMat(Enums.GMaterials.Woter);
if (target instanceof LandO... |
ad59be0f-d686-438e-a122-86d763706528 | 2 | public boolean superClassOf(ClassInfo son) {
while (son != this && son != null) {
son = son.getSuperclass();
}
return son == this;
} |
8d153d55-cb81-4036-b43f-0f45b0db32ae | 9 | public static void removebAndacFromStrinInplace(char[] str) {
int i = -1, j = 0;
int len = str.length;
while(j < len) {
if(j < len-1 && str[j] == 'a' && str[j+1] == 'c') {
j += 2;
} else if(str[j] == 'b') {
j++;
} else if(i >= 0 && str[i] == 'a' && str[j] == 'c') {
i--;
j++;
} else {
... |
0df30d89-01b8-4b6c-b10a-c7c3bdd1dc35 | 3 | public void coeff(double[][] dct_coef, int n) {
double sqrt_1 = 1.0 / Math.sqrt(2.0);
for (int i = 0; i < n; i++) {
dct_coef[0][i] = sqrt_1;
}
//Initialize coefficient
for (int i = 1; i < n; i++) {
for (int j = 0; j < n; j++) {
dct_coef[i][j] = this.a* Math.cos(i * Math.PI * (j + 0.5) / ((double) n... |
bae5c446-23da-4cf4-b4db-18c11e2b53fd | 9 | public boolean doTransformations() {
if (instr == null)
return false;
/*
* Do on the fly access$ transformation, since some further operations
* need this.
*/
if (instr instanceof InvokeOperator) {
Expression expr = ((InvokeOperator) instr).simplifyAccess();
if (expr != null)
instr = expr;
... |
9bf84e3b-1a14-4450-bcb2-ec29ee3352d7 | 5 | public SQLManager(String context)
{
try
{
Context initCtx = new InitialContext();
Object obj = initCtx.lookup(context);
ds = (DataSource)obj;
if (ds == null)
throw new Exception("PAWS-Core: Failure to Create Datasource");
}
catch(SQLException ex)
{
while (ex != null)
{
System.ou... |
8da3f881-7d97-403d-b1cb-c539d522f52a | 8 | public static Object escape(Object original) {
if (original instanceof Character) {
char u = (char) ((Character) original);
int idx = "\b\t\n\f\r\"\'\\".indexOf(u);
if (idx >= 0)
return "\\" + "btnfr\"\'\\".charAt(idx);
if (u < 32)
return "\\" + Integer.toOctalString(u);
if (u > 126)
return... |
ad7039dc-7d4d-4f04-81d8-f1e2741d210a | 9 | public String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.... |
b330368d-caf8-4101-80c6-bbe64442d8a5 | 6 | public void handleLine(List<String> line) throws Exception {
if (line.size() == 0)
return;
if (_trimValues) {
for (int i = 0; i < line.size(); i++)
line.set(i, line.get(i).trim());
}
if (!_initialized) {
readSchema(line);
_initialized = true;
} else {
readEntity(line);
}
_line++;
i... |
e1058a59-54af-45da-8b07-498e5c00139b | 2 | public void testValues(int id) {
ArrayList<Float> stats = new ArrayList<Float>();
long time = System.currentTimeMillis();
for (Entry<Float, float[][]> ent : DB_ARRAY.entrySet()) {
float[][] dats = ent.getValue();
for (float[] d : dats) {
stats.add(d[id]);
}
}
StatInfo show = new StatInfo(stats, ... |
e3a05709-88b7-4e5b-9fe1-f14da5601d1b | 4 | private String read_col(char[][] trans_block,int start_pos,int end_pos)
{
if(start_pos>end_pos)
return "";
StringBuilder sb=new StringBuilder();
int row=trans_block.length;
int col=trans_block[0].length;
assert(end_pos<col);
for(int i=1;i<row;i++)
{
for(int j=start_pos;j<=end_pos;j++)
{
if(t... |
e3c8f3ea-b52a-41ae-8f47-10469eabf721 | 4 | public boolean isOptOut() {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g... |
912eb82a-e255-4c5c-960e-8b2d4b1903c1 | 0 | public CellTest() {
} |
c66a06a3-41ad-42b4-bedf-220ce3f20aab | 6 | public static List<List<Intersection>> getGroups(Board board, int player) {
int boardSize = board.boardSize;
int[][] intersections = board.intersections;
List<List<Intersection>> groups = new ArrayList<>();
for (int x = 0; x < boardSize; ++x) {
for (int y = 0; y < boardSize; ++y) {
if (intersections[x][... |
7dab0012-7acc-4182-af65-5631b0316229 | 5 | @Override
public Object getValueAt(int row, int column) {
switch(column) {
case ID : return listRdvAnciens.get(row).getId();
case MEDECIN : return listRdvAnciens.get(row).getMedecin();
case SPECIALISATION : return listRdvAnciens.get(row).getTypeRdv().g... |
a9e4da64-7190-46df-8fd3-468b28aeaf5d | 7 | public boolean isOnPF(int marginx,int marginy) {
if (!getTileBBox(temp_bbox_copy)) {
temp_bbox_copy.x = (int)x;
temp_bbox_copy.y = (int)y;
temp_bbox_copy.width = 0;
temp_bbox_copy.height = 0;
}
if (!pfwrapx) {
if (temp_bbox_copy.x+temp_bbox_copy.width < -marginx) return false;
if (temp_bbox_cop... |
f3c6b8a9-7b6d-4516-88c7-0ed8a632a103 | 8 | public static List<FreightBean> getFreightBeans(String firstPageHtmlString) {
// TODO Auto-generated method stub
List<FreightBean> retFreightBeans = new ArrayList<FreightBean>();
try {
Parser divParser = new Parser(firstPageHtmlString);
NodeList divNodeList = divParser.parse(new HasAttributeFilter("class"... |
df352bcb-b6dd-4835-a8e4-2dbf5ddab597 | 4 | public int setLeadership(String playerName, double leadership) {
String SQL = "UPDATE " + tblSkills + " SET " + "`leadership` = ? WHERE `player` LIKE ? ;";
int updateSuccessful = 0;
Connection con = getSQLConnection();
PreparedStatement statement = null;
try {
statement = con.prepareStatement(SQL);
s... |
788d836a-ada2-4934-8d3f-4fb52153b0fa | 5 | public void initialise(World world) throws PatternFormatException
{
String[] cellParts = cells.split(" ");
for (int i=0;i<cellParts.length;i++)
{
char[] currCells = cellParts[i].toCharArray();
for (int j=0;j<currCells.length;j++)
{
if (currCells[j] != '1' && currCells[j] != '0') ... |
b873fb90-05f9-4f5e-9a09-3ab16283b4ff | 4 | public static void simpleExpression(Item i, Operation actOperation) {
if(i.getSym() == Constants.SEMICOLON) {
return;
}
if(i.getSym() == Constants.PLUS) {
actOperation.setOperator(Constants.PLUS);
Expression.simpleExpression(Scanner.get(), actOperation);
}
else if(i.getSym() == Constants.MINUS... |
a44f0587-2169-44cf-9cec-747b8b8a8bab | 3 | public synchronized void update(long elapsedTime) {
if (frames.size() > 1) {
animTime += elapsedTime;
if (animTime >= totalDuration) {
animTime = animTime % totalDuration;
currFrameIndex = 0;
}
while (animTime > getFrame(currFrame... |
6c5f9c4e-729e-4433-b8c5-5d961644cfd6 | 4 | private boolean saveAs() {
FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
saveDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"});
saveDialog.setFilterNames(new String[] {"Address Books (*.adr)", "All Files "});
saveDialog.open();
String name = saveDialog.getFileName();
if(name.equals(""... |
d40ea893-50eb-43ab-a7aa-ac113c8273cc | 4 | @Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
DefaultContentRect other = (DefaultContentRect) obj;
if (id != other.id) return false;
return true;
} |
948c7e42-7f80-4c51-bd89-7cbced62c308 | 1 | public void testRandomNumber() {
int number = MathUtils.getRandomNumber(0, 10);
assertTrue(number >= 0 && number < 10);
number = MathUtils.getRandomNumber(0, 1);
assertEquals(0, number);
number = MathUtils.getRandomNumber(10, 11);
assertEquals(10, number);
} |
5012c877-215a-4b42-8afd-544195a00bbc | 5 | public String formatWaitTimeLeft(Player p, int hour, int min, int sec){
if(p.hasPermission(DeityNether.OVERRIDE_PERMISSION)){
return cu.format(lang.getString("nether.time.wait.override").replaceAll("%header", getHeader()));
}else if(p.hasPermission(DeityNether.GENERAL_PERMISSION)){
String h = "";
String m ... |
6ae83c90-0f39-4261-95d2-2ab289c3a7e5 | 2 | public static SquareTag getName(char tag) {
if (mapping == null) {
mapping = new HashMap<Character, SquareTag>();
for (SquareTag ut : values()) {
mapping.put(ut.tag, ut);
}
}
return mapping.get(tag);
} |
058ebe95-eb78-4fbb-bc07-6a9284d62aef | 7 | public void options(int option) {
switch (option) {
case 1: // Getting an order
for (;;) {
System.out.println();
printAll();
System.out.println("GETTING AN SPECIFIC ORDER\n");
System.out.println("Order id: ");
int orderId = input.nextInt();
input.nextLine();
retri... |
394e9c96-2472-4b96-bd40-cfddda9f6e89 | 1 | public static GameModel loadFromFile(String filename)
throws MapLoaderException {
try (Scanner scanner = new Scanner(new File(filename))) {
GameField field = parseSquares(scanner);
parseBuildings(field, scanner);
parseUnits(field, scanner);
return new GameModel(field);
} catch (IOException e) {
... |
00ba7b22-4074-49c9-a8a2-e96b8d06fc28 | 8 | public static final Vector<Object> loadClassList(final String defaultPath, String requestedPathList, final String subDir, final Class<?> ancestorC1, final boolean quiet)
{
final Vector<Object> v=new Vector<Object>();
int x=requestedPathList.indexOf(';');
while(x>=0)
{
String path=requestedPathList.substring... |
0bad0a31-8508-4b59-bea0-f37eed20106f | 5 | public static void main(String[] args) {
int[] array = { 18, -2, 29, 66, 23, 142, -34, 0, 13 };
System.out.println("Input Array: ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.println("\n");
int n = array.... |
fc711bb9-b621-4de5-9513-702b93da820b | 6 | private void FallDown() {
if (fallSpeed <= 20)
fallSpeed = fallSpeed * 1.05;
for (int i = 0; i < collisionRange.size(); i++) {
if (getRectangle().intersects(collisionRange.get(i))) {
if (collisionRange.get(i).getY() > this.getY()
&& collisionRange.get(i).getY() <= this.getY()
+ this.getHeigh... |
99b61fb9-de9e-4423-a313-6a206ac3a25c | 4 | public static int numberOfDoubledPawns(Board b, int color) {
int doubledPawns = 0;
for (int file = 0; file < b.board.length; file++) {
boolean firstPawnFound = false;
for (int rank = 0; rank < b.board[file].length; rank++) {
if (b.board[rank][file] == 1 * color) {
if (!firstPawnFound) {
firstPa... |
e3f7f1a4-0b9c-40cc-822b-3900afb7c28a | 6 | private void checkDiscipline() {
int period = (isRude() ? 1 : 2) * DECLINEPERIOD;
if (getAge() % period == 0) {
if (--shittingDiscipline < 0) {
shittingDiscipline = 0;
}
if (--excitingDiscipline < 0) {
excitingDiscipline = 0;
}
if (--furifuriDiscipline < 0) {
furifuriDiscipline = 0;
}
... |
0e771671-08eb-456c-a32b-c79fbc44c6fc | 6 | public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source.equals(menuItemExport)) {
// Menu Item "Export as CSV has been selected"
if (controller.getState() == ApplicationState.INITIALIZED_WITH_DATA) {
// Exportable Data is available
System.out.println("Save as CVS");... |
7cd3c666-1e46-490c-b3e9-085bf0cc51ba | 2 | public TileReader(){
Properties prop= new Properties();
try{
InputStream in = getClass().getResourceAsStream("/res/tiles.txt");
prop.load(in);
String stri[] = prop.getProperty("pictures").replaceAll("\\s+","").split(",");
Tile.scenePics= new Image[stri.length];
for(int i=0;i<stri.length;i++){
... |
8257aea1-23da-4a00-9783-0faac13767c0 | 3 | public void play( ) {
synchronized( this ) {
if( !paused )
return;
double offset = ( System.currentTimeMillis( ) - pauseTime ) / 1000.0;
for( Message m : waitQueue )
m.bumpReceiveTime( offset );
for( Message m : sendQueue )
m.bumpSendTime( offset );
paused = false;
}
ssi.statusChanged... |
f808644b-c8bc-4a17-bdd3-52d92c6d4b99 | 0 | @Override
public void hhhh() {
hello.hhhh();
} |
5ebf0171-fafc-45f3-b0be-2627dd2af361 | 1 | public OutputStream store(String name) throws IOException {
final File nm = forres(name);
File dir = nm.getParentFile();
final File tmp = new File(dir, nm.getName() + ".new");
dir.mkdirs();
tmp.delete();
OutputStream ret = new FilterOutputStream(new FileOutputStream(tmp)) {
public void close() throws IOExceptio... |
8caf5e3a-c922-4e6d-a321-f8c148fc7c20 | 5 | public void render(GameContainer arg0, StateBasedGame arg1, Graphics arg2)
throws SlickException {
page.render();
land.draw(4,4,848,759);
if (dragHeadingState) {
arg2.setColor(Color.red);
shapeRenderer.fill(shape);
}
Iterator i = airportList.iterator();
while (i.hasNext()) {
((Ai... |
a2bf4d07-0e7d-469d-98a2-6f01fc4e8c7a | 2 | public ArrayList<Coche> searchCoches(String mat){
ArrayList<Coche> cList = new ArrayList();
ArrayList<Coche> res = new ArrayList();
cList.addAll(cjtCoches.values());
for(int i=0; i<cList.size(); ++i){
if(cList.get(i).getMatricula().contains(mat))
res.add(cList... |
12d5a345-60a6-4f87-85be-1c247264ced5 | 9 | private Future<?> display(final boolean error) {
final String msg = this.getMessage();
if (error) {
getLogger().log(Level.SEVERE, null, this);
} else {
if (this.getCause() != null) {
getLogger().log(Level.INFO, null, this);
}
}
... |
648e45fb-91c8-4ac6-8d46-220f9594a4d9 | 2 | public static CharSeq ApplyToAll1 (Main.AA1 fun, CharSeq s)
{
CharSeqIt csi = new CharSeqIt(s); //initialize iterator
String NewSeq = ""; //initialize string to stick th result of fun.go into
char currentval = 0; //current char
while(csi.hasNext())
{
try
{
currentval = csi.next... |
b0795d50-9857-4670-af9e-33d885a16ec9 | 3 | public void addProperty(Space p) {
property.add(p);
// Change the property's font color to player's color
if(number == 1)
p.buttLabel.setForeground(GameBoard.PLAYER1);
else if(number == 2)
p.buttLabel.setForeground(GameBoard.PLAYER2);
else if(number == 3)
p.buttLabel.setForeground(GameBoard.PLAYER... |
a04ff6f7-2f22-4760-9320-cbebe43520ad | 0 | public Set<Being> getBeings() {
return new HashSet<Being>(beings);
} |
fe75f967-7ada-4980-9756-b44215055c6e | 9 | private void addToCounts(Instance instance) {
double [] countsPointer;
double [] countsNoClassPointer;
if(instance.classIsMissing())
return; // ignore instances with missing class
int classVal = (int)instance.classValue();
double weight = instance.weight();
m_ClassCounts[classVal... |
3718e63f-8df2-4c5f-8766-9a7c9cc6256b | 8 | @Override
public void actionPerformed(ActionEvent arg0) {
if(arg0.getActionCommand() == "exportLogins"){
ExportFile export = new ExportFile("usuariosOnline.txt");
export.export(textlogin.getText());
} else if (arg0.getActionCommand() == "exportInfo"){
ExportFile export = new ExportFile("infoServidor.txt")... |
c33aa55d-eeb8-4e5c-aab7-647b19e85e5c | 1 | @Override
public void free() {
try {
fileChannel.truncate(0);
} catch (IOException e){/**/}
} |
d30d3742-2e1d-40ee-845e-1d0c994bf401 | 2 | public static void main(String args[]){
long start = System.currentTimeMillis();
PrintWriter outputStream = null;
try{
outputStream =
new PrintWriter (new FileOutputStream("myIntegers.txt"));
}
catch(FileNotFoundException e){
System.out.println("Error opening the file.");
}
... |
58a6a1ee-d4aa-4015-b638-5e9efc5731c6 | 7 | @Override
public String perform(HttpServletRequest request) {
List<String> errors = new ArrayList<String>();
HttpSession session = request.getSession();
request.setAttribute("errors", errors);
String success;
try {
CreateUserForm form = formBeanFactory.create(request);
request.setAttribute("form", for... |
dca09b38-e32e-493a-b8a9-46e611cf7e64 | 5 | @Test
public void findsCorrectUnobstructedPoints()
{
VertexContainer vc = new VertexContainer();
Vertex src = vc.addVertex(0, 0);
Point p1 = vc.addPoint(-1, -4);
Point p2 = vc.addPoint(2, -1);
Point p3 = vc.addPoint(3, 3);
Point p4 = vc.addPoint(-4, -3);
P... |
6361d017-d93c-4aac-b8c8-6c8d165fda1a | 3 | public void addService(Service newService){
boolean exists = false;
for (Service service : services) {
if(service.getName().equalsIgnoreCase(newService.getName())){
exists = true;
}
}
if(!exists){
services.add(newService);
}
... |
431c1c26-9f97-4a06-b961-48d478bdd967 | 8 | private void createAnd(String in1, String in2, String out)
{
AndGate and = new AndGate();
// Connect the first input
// Check if the in wire is an input
if (stringToInput.containsKey(in1))
{
Wire inWire = new Wire();
stringToInput.get(in1).connectOutput(inWire);
and.connectInput(inWire);
}
// C... |
bf74ff1b-a921-455c-8939-058b191716a5 | 6 | private String getFile(String link)
{
String download = null;
try
{
// Open a connection to the page
URL url = new URL(link);
URLConnection urlConn = url.openConnection();
InputStreamReader inStream = new InputStreamReader(urlConn.getInputStrea... |
20784703-3a1c-4711-8e7a-7c539b76cbab | 4 | public boolean isOptOut() {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g... |
699f4f5c-9328-4b70-ace7-11819e1800b0 | 0 | public void matchesContainsMethodWithNoArguments()
{
Filter containsMethod = containsMethod( "usingDefaultClassLoader" );
assert containsMethod.matches( ClassLoaderBuilder.class );
assert !containsMethod.matches( Filter.class );
} |
236b929f-6f40-45ba-99b1-bbda6a81b333 | 3 | public boolean isBalanced2(BTPosition<T> current)
throws InvalidPositionException {
if (current == null)
return true;
int diff = treeHeight(current.getLeft())
- treeHeight(current.getRight());
if (Math.abs(diff) > 1)
return false;
else
return isBalanced(current.getLeft())
&& isBalanced(cu... |
8236e009-4ff2-43bc-8402-bdbdde0d7633 | 0 | public final void addDragListeners(final Node n) {
n.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent me) {
startDragX = me.getSceneX();
startDragY = me.getSceneY();
root.setStyle("-fx-opacity:.7;");
}
});
n.setOnMouseReleased(new EventHandler<MouseE... |
494190b8-20a8-464d-b698-1c9e2748c3db | 3 | private ArrayList<Integer> generateUpDownDestinations( int position, int[] directions ) {
ArrayList<Integer> destinations = new ArrayList<Integer>();
for ( int direction : directions ) {
for ( int i = 1; isValidDestination( position + i*direction ); i++ ) {
if ( enemyPieceAt( position + i*directi... |
99bd84bc-593d-4c10-8f11-edc31192989d | 6 | public void disablePlayerOneSpaces()
{
for (int x = 0; x < checkersSpaces.length; x++) {
for (int y = 0; y < checkersSpaces.length; y++) {
if(checkersSpaces[x][y].getIcon() != null && checkersSpaces[x][y].getIcon().equals(playerOneCheckerPiece))
{
checkersSpaces[x][y].setDisabledIcon(playerOneChecker... |
c1f1fd54-e5c0-4837-948a-5f7b6e92dd5c | 3 | public int cellAt(int x, int y) {
for (int i = 0; i < body.size(); i ++) {
if (body.get(i).x == x && body.get(i).y == y) {
return i;
}
}
return -1;
} |
f44c6045-aad0-46bd-a6b5-caa5895ca9ef | 9 | public static HereditaryProperty merge2(final HereditaryProperty a, final HereditaryProperty b) {
return new HereditaryProperty() {
@Override
public Collection<Permutation> getBasis() {
throw new UnsupportedOperationException("Not supported yet.");
}
... |
f67665f4-97be-4ed8-8052-7822dd79c2da | 2 | public void setLocation(int x, int y) {
List l = getWorld().getObjectsAt(x, y, null);
for (int i = 0; i < l.size(); i++) {
Actor actor = (Actor) l.get(i);
if (actor != this) {getWorld().removeObject(actor);}
}
super.setLocation(x,y);
} |
3eecb7c8-8cd1-4ac7-9ba9-e751e740ba9d | 4 | public void setValueAt(Object value, int row, int col) {
try {
switch (col) {
case 0 :
try {
Date d = SBStringUtils.dateFormatShort.parse(value.toString());
myRecipe.setNoteDate(row, d);
} catch (ParseException e) {
System.out.println("Unable to parse " + value.toStr... |
af9f41e6-7b3b-4591-b49c-6ea7d0ac3b76 | 5 | private static boolean modifySchedule(Schedule bean, PreparedStatement stmt, String field) throws SQLException{
String sql = "UPDATE prescriptions SET "+field+"= ? WHERE work_day = ? and username = ?";
stmt = conn.prepareStatement(sql);
if(field.toLowerCase().equals("work_from"))
stmt.setTime(1, bean.get... |
c4924f00-5870-4774-9d1d-33ab6aedbfcb | 5 | @Override
public void run( ) {
this.running = true;
while ( this.running ) {
if ( this.listeners.size( ) != 0 ) {
final EventType elem = this.queue.poll( );
if ( elem != null )
for (final IListener<EventType> li : this.listeners)
li.handle(elem);
}
try {
Thread.sleep(5);... |
7dbcbdc3-360a-4621-a0fa-a07c9ba34056 | 1 | public void addInvalidConstantName(String constantName) {
if (invalidConstantNames == null) {
invalidConstantNames = new ArrayList();
}
invalidConstantNames.add(constantName);
} |
896e581c-7e26-4650-921d-996e27563771 | 1 | private int getMaxStats(int idx){
int max = stats[PROGRESSION]+bonusStart[idx];
if(stats[PROGRESSION] <= 1) return bonusStart[idx];
else return (int)(max*coeffStats[idx]);
} |
1d3915e0-f261-4cd3-bb0e-a9d92b96eb55 | 3 | public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.browse){
Chooser frame = new Chooser();
url.setText(frame.fileName);
filePath = frame.fileName;
}
else if (e.getSource() == this.checkUrl){
new Listview("List of bad URLs", new CheckUrls(filePath).get_list(), filePath, atf,this).se... |
4a5c8d17-b48e-4168-b048-8892f7c97e7a | 2 | public static void stop() {
if (task != null && !task.isDone()) {
task.cancel(true);
task = null;
BmLog.info("TestInfoController is stopped");
}
} |
8a04aebf-9ff0-421c-bd07-bb2446e584ad | 5 | public void handleRequest(ServerRequestEvent event)
{
JSONObject request = event.getRequest();
try
{
if(!ChunkyTransactions.getInstance().getAPI().checkAPIKey(request.getString("APIKey")))
{
ChunkyTransactions.getInstance().getMessage().debug("Connection Refused!");
DataOutputStream out =... |
8917988d-c440-4dda-bd48-69e2e46ff355 | 5 | private Object handleNote(Object tos, String id, String ref) {
if (tos instanceof NoteContainer) {
if (ref == null) {
Note note = new Note();
((NoteContainer)tos).addNote(note);
return note;
}
else {
NoteRef noteRef = new NoteRef();
... |
6196a862-258b-4678-b9cf-a58601d75fa1 | 3 | public List<String> findSubstring(String s, List<String> allKUniversals) {
List<String> foundSubstrings = new ArrayList<String>();
for (String string : allKUniversals) {
int length = s.length();
if (string.substring(0, length).equals(s) && !string.equals(s)) {
fou... |
bf888a7b-5c30-4117-98a5-50c39161eff1 | 5 | @Override
public void mousePressed(MouseEvent e) {
if ( e.getSource() instanceof PlacementTile) {
//Creation et initialisation de la tuile
PlacementTile pt = (PlacementTile)e.getSource();
Tile tile = new Tile(selected.getType(), pt.getOrientation());
tile.setLocation(pt.getX(), pt.getY());
//Envoi... |
1a7c4840-07c1-4433-8cd2-756ae1714ea3 | 7 | @Override
public double timeToReach(Node startNode, Node endNode, Message msg) {
// TODO Auto-generated method stub
double dist = startNode.getPosition().distanceTo(endNode.getPosition());
/* Link rate | time arrive mSec | dist
* ----------------------------------------------------
* 11 | 2542 | 399
... |
60de913b-096a-4838-b92a-cd3087a05da0 | 7 | public void bouwSpeelveld() throws AngryTanksException { //bouwt het speelveld op basis van level
if(!isSpeelveldBouwKlaar()) throw new AngryTanksException("Speelveld kan niet gebouwd worden. Stel eerst een level in.");
laatsteSchot = new Schot(Orientatie.RECHTS, 0, 0, new Positie(0,0), 0, new HashMap<... |
21b464d4-d2bb-490c-bdc3-504174ee43d1 | 1 | @Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
} |
28376114-5cd9-4a4c-970c-3730640b223c | 1 | private void renderPlayerInventory(Graphics2D graphics) {
for (int i = 0; i < objectTron.getActivePlayerInfo().getInventoryItems().size(); i++) {
int xCoordinate = startPointXCoordinate + (i%3 * 40);
int yCoordinate = startPointYCoordinate + 350 + (i/3 * 40);
List<ElementInfo> item = new ArrayList<ElementInf... |
673c1ef9-94d2-4cd8-9c8f-6f1f8bd58024 | 4 | @Test
public void savenowtest() throws ClassNotFoundException, IOException{
try{
@SuppressWarnings("resource")
ObjectInputStream osb = new ObjectInputStream(new FileInputStream("bookcollection.txt"));///óϾ , Ͼ׳ϴ° ҽ߰
bookcollectb.setBookCount(osb.readInt());
bookcollectb.collectionb.clear();
for( int ... |
df6dc65b-2be3-4941-adf8-457f6bd05097 | 5 | private boolean camposNecesarios () {
boolean rta;
if ((jTextField1.getText().equals("")))
{
JOptionPane.showMessageDialog(null, "Complete el campo nombre!","Atención",JOptionPane.WARNING_MESSAGE);
jTextField1.requestFocus();
rta = false;
}
else{
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.