method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
ceb778a8-0b55-43d5-adc5-baff0453d65f | 8 | @Override
public String showColourOfDay(int Day){
String msg1;
try{
if(Day==1){
msg1 = new String("\nDay : Sanday = Red colour");
return msg1;
}
else if(Day==2){
msg1 = new String("\nDay : Monday = Yellor colour");
return msg1;
}
else if(Day==3){
msg1 = new Stri... |
26ef9035-604e-43c9-b543-414f1e23ec0b | 2 | public static Service SelectServiceByIdEntreprise(int id) throws SQLException {
String query = null;
Service service = new Service();
ResultSet resultat;
try {
query = "SELECT * from SERVICE where ID_ENTREPRISE=? ";
PreparedStatement pStatement = ConnectionBDD.g... |
137921db-a9f1-47bc-9507-5d18ab014fbf | 3 | protected static String detailedResponse(int status,String method,String resource) {
String response;
switch(status){
case 400:
response="Your browser sent a request that this server could not understand.";
break;
case 404:
... |
6313fad0-777f-425a-942f-b7f4b3b8b6b5 | 7 | public void topo() {
java.util.ArrayList<Vertex> s = new java.util.ArrayList<>();
int numOfVertices = vertices.length;
while (numOfVertices > 0) {
int tempNumOfVertices = numOfVertices;
Vertex noSuccessorVertex = noSuccessor();
if (noSuccessorVertex != null) {
for (int i = 0; i < vertices.length; i... |
fe84f4e0-5e89-432a-91f7-bbff8364a6d2 | 1 | public static void buildFrontier(final FlowGraph graph, boolean reverse) {
if (!reverse) {
DominanceFrontier.calcFrontier(graph.source(), graph, reverse);
} else {
DominanceFrontier.calcFrontier(graph.sink(), graph, reverse);
}
} |
1a681030-6c99-46bf-bb39-b044accfb50b | 8 | @Override
public void positionnementAleatoire() {
this.difficulte = this._partie.getParametre().getDifficulte();
Iterator iterator = this._partie.getParametre().getBateaux(this._partie.getParametre().getEpoque()).keySet().iterator();
while(iterator.hasNext()) {
... |
0e979de8-10af-4c0f-963f-602307e162e5 | 3 | @Override
public RoleSchool deserialize(JsonElement je, Type typeOfT, JsonDeserializationContext jdc) throws JsonParseException {
JsonObject jsonObject = je.getAsJsonObject();
String type = jsonObject.get("roleName").getAsString();
switch(type.toLowerCase()){
case "stude... |
de651329-f426-4c7a-9885-314fb306347f | 9 | private Map<Class<?>, Set<Class<?>>> buildDirectOwnedToOwnerdMap() {
Map<Class<?>, Set<Class<?>>> clsToOwnersMap = new HashMap<>();
for (Class<?> ownerCls : ownerToOwnedMap.keySet()) {
Map<String, Class<?>> ownedMap = ownerToOwnedMap.get(ownerCls);
for (Class<?> ownedCls... |
62756549-a3a4-4322-9643-b3ac3125f8e7 | 8 | public void listTranslateRules() {
try {
translateRulesFolder = (Folder) session.getObjectByPath("/TranslateRules");
} catch (CmisObjectNotFoundException e) {
System.out.println("translateRules folder not found, creating one.");
Map<String, String> properties = new H... |
0a111e85-088e-4d4e-8cd5-71cd247854ce | 6 | public void run(){
try{
line = (SourceDataLine)AudioSystem.getLine(info);
line.open(af);
line.start();
int num = 0;
while((ais != null) && ( num = ais.read(buff)) != -1){
{
interf.updateDiagram(buff);
line.write(buff, 0, num);
}
}
line.drain();
}catch (IOException e) {
// ... |
e2457a15-ae18-4bca-abb3-322914dfcaf4 | 2 | public boolean addEntity(Entity e) {
for(Entity col : entities) {
if(e.isTouching(col)) {
return false;
}
}
entities.add(e);
return true;
} |
f87416ed-0897-4b80-8b6d-987895515056 | 4 | @Override
public void doAction(String choice) {
switch (choice) {
case "H": // display the help menu
HelpHuntGatherView HelpHuntGatherView = new HelpHuntGatherView();
HelpHuntGatherView.display();
break;
case "T": // hunt
... |
3d912f24-cb4d-4250-bbee-e0f6f0bef740 | 1 | public void testConstructor_RD_RI5() throws Throwable {
DateTime dt = new DateTime(TEST_TIME_NOW);
Duration dur = new Duration(-1);
try {
new MutableInterval(dur, dt);
fail();
} catch (IllegalArgumentException ex) {}
} |
1206d137-e014-40ea-a276-7676de29ffe3 | 8 | public Map<LinkedList<Candidate>, Integer> getDirectedGraph()
{
HashMap<Ranking, Integer> ranks = new HashMap<>();
for (IVoter voter : voters)
{
// make sure the voter has ordered the candidates
if (voter.getCurOrdering() == null)
voter.orderC... |
2aa67c19-2fba-4c63-b69e-7dfedd6294ae | 9 | public void addSong(Song song, Artist a){
List<String> terms = a.getTerms();
songCount++;
int tempYear = song.getYear();
String yearStr = "";
if(tempYear > 1000 && tempYear < 2050){
yearStr = String.valueOf(tempYear);
}
else{
yearStr = "Non... |
b72824e2-0618-43e1-8349-1d17bd5b358f | 3 | public boolean SetDecoderProperties(byte[] properties)
{
if (properties.length < 5)
return false;
int val = properties[0] & 0xFF;
int lc = val % 9;
int remainder = val / 9;
int lp = remainder % 5;
int pb = remainder / 5;
int dictionarySize = 0;
for (int i = 0; i < 4; i++)
d... |
b14a9b4b-8ab3-490a-a263-87715d7a66da | 3 | public static List<List<Token>> buildBoard(int size){
List<List<Token>> result = new ArrayList<List<Token>>();
if(size <= colorList.size()){
List<Color> colors = getColors(size);
colors = palettoShuffle(colors, size);
for(int i=0; i< size;i++){
List<Token> newList = new ArrayList<Token>();
for(int... |
f932a923-c33c-4a10-b5ce-1557a76068c6 | 3 | public static Edge createBisectingEdge(Site site0, Site site1) {
double dx, dy, absdx, absdy;
double a, b, c;
dx = site1.get_x() - site0.get_x();
dy = site1.get_y() - site0.get_y();
absdx = dx > 0 ? dx : -dx;
absdy = dy > 0 ? dy : -dy;
c = site0.get_x() * dx + si... |
7d1173e0-e662-49a2-b528-431f4c1945ff | 6 | private void updateSelection() {
resetSelection();
switch (choiceSelected) {
case 1:
if (saveFileExists) {
regButton = new Sprite(selConButton);
regButton.setX(150);
regButton.setY(250);
} else {
regButton = new Sprite(selButton);
regButton.setX(150);
regButton.setY(400);
... |
789adf68-7fa0-42ff-9828-8ad92852086a | 0 | public void setName(String name) {
this.name = name;
} |
28159a6a-7a67-4a76-b8f4-283bacbc0e24 | 4 | public int[] roomNeighbour(int roomNumber){
int room1,room2,room3,room4;
//room1=oben, room2=rechts, room3=unten, room4=links
if((roomNumber-6)>=0){
room1 = roomNumber-6;
}
else{
room1 = -1;//-1steht fuer eine ungueltige raumnummer
}
if((roomNumber+1)%6!=0){
room2 = roomNumber+1;
}
else{
r... |
b7cfbbd5-81fb-44f9-b018-8cc364ba1dce | 0 | public Object getKey() {
return key;
} |
5d2bbe5b-6133-4de9-9e8b-0b12d9275b3c | 9 | public void inline(Object code) {
// First load the class for the inlined code.
Class codeClass = code.getClass();
String className = codeClass.getName().replace('.', '/') + ".class";
ClassLoader loader = codeClass.getClassLoader();
InputStream in;
if (loader == null) {... |
fc203337-a625-463f-aade-c9f4a70e4d8f | 9 | public BankBillet update(BankBillet billet)
throws CobreGratisBadRequestException,
CobreGratisUnauthorizedException, CobreGratisForbiddenException,
CobreGratisNotFoundException,
CobreGratisServiceUnavailableException,
CobreGratisInternalServerErrorException,
CobreGratisTooManyRequestsException,
Cob... |
6dcfc2b2-f005-4ec7-9832-97706ddb83c2 | 4 | public static boolean validMulticast(String ip) {
if (ip == null || ip.isEmpty()) return false;
ip = ip.trim();
if ((ip.length() < 6) & (ip.length() > 15)) return false;
try {
Pattern pattern = Pattern.compile("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[... |
c00d2839-7f8b-4158-8883-0156f74d4492 | 3 | @SuppressWarnings("unchecked")
@Override
public void mouseClicked(MouseEvent e) {
JList<String> list = (JList<String>) e.getSource();
if(e.getClickCount() == 2){
int index = list.locationToIndex(e.getPoint());
ListModel<String> dlm = list.getModel(... |
3a12b2c6-b1c2-403b-a0cb-b5bf76940662 | 9 | public void harvest() {
for (ListenerHolder listener : listeners.values()) {
if (listener.getLiveUntil() < admin.calculateTime()) {
cancelListener(listener);
}
}
List<ISemiSpaceTuple> beforeEvict = new ArrayList<ISemiSpaceTuple>();
... |
70cdb32f-d908-467a-a688-622c747b7e39 | 3 | private void updateGridletProcessing()
{
// Identify MI share for the duration (from last event time)
double time = GridSim.clock();
double timeSpan = time - lastUpdateTime_;
// if current time is the same or less than the last update time,
// then ignore
if (timeSpa... |
20b68de4-2f37-4bb2-900f-441623930608 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EntityUniqueIdentifier other = (EntityUniqueIdentifier) obj;
if (clazz == null) ... |
4a54d554-96c0-4ebb-99aa-ee8d6929e7cc | 4 | @SuppressWarnings("unchecked")
@Override
public String displayQuestionWithAnswer(int position, Object userAnswer) {
String questionStr = (String) question;
ArrayList<String> answerList = (ArrayList<String>) answer;
String userAnswerStr = (String) userAnswer;
boolean correct = false;
if (getScore(userAnswer)... |
2a507c5b-921e-4634-9977-f770464bb45e | 9 | private Collection<Library> allocateBooksForLibraries(final String book, final int quantity,
final Collection<Library> allLibrariesToBeAllocated) {
final Collection<Library> allocatedLibraries = new HashSet<Library>();
int remaningQty = quantity;
for (Library library : allLibrariesToBeAllocated) {
if (l... |
3febdbe8-a842-4787-916a-c0f4a8dca321 | 5 | public void initialize() {
// For each card
for ( int i = 0; i < ga.getNumberOfCards(); i++ ) {
int availableStock = 0;
int requiredStock = ga.getCardList().get( i ).getNumber();
for ( int j = 0; j < ga.getSellers().length; j++ ) {
this.availableStock[j][i] = ga.getAvailabilityConstraints()[j][i];
... |
3630f2fc-e6c9-4a23-bae6-535743da7db5 | 3 | public void loadLocations() {
Connection conn = plugin.getDbCtrl().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = String.format("SELECT * FROM `%s`",
plugin.getDbCtrl().getTable(Table.LOCATION));
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
w... |
353f34ba-08d6-49ea-bbee-7a4d3d73da48 | 9 | private static Expr analyzeSeq(C context, ISeq form, String name) throws Exception{
Integer line = (Integer) LINE.deref();
if(RT.meta(form) != null && RT.meta(form).containsKey(RT.LINE_KEY))
line = (Integer) RT.meta(form).valAt(RT.LINE_KEY);
Var.pushThreadBindings(
RT.map(LINE, line));
try
{
Object me = ma... |
1aad68a4-c88c-4b99-9c2c-bda232917edb | 0 | public String getGoTo() {
return goTo;
} |
13da4938-802a-4572-b48c-17fb65171ae6 | 9 | public BookingListResult(JSONObject json) throws JSONException {
super(json);
if (json.has("result")) {
JSONArray jsonArray = json.getJSONArray("result");
String packageId = null;
Vector packetItems = null;
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject bookingJson = jsonArray.getJ... |
1931cbfe-f400-4395-ab1b-7884279b1778 | 6 | public ArrayList<Trajet> rechercheTrajet(String villeDepart,
String villeArrivee,
DateTime dateDepart,
boolean avecConducteur,
boolean avecPlacesLibres){
ArrayList<Trajet> resultat = new ArrayList<Trajet>();
for(Trajet t : listeTrajets){
if(villeDepart.equalsIgnoreCase(t.getVilleDepart()) &&
v... |
87decd84-38e7-4306-b1c5-736ada946017 | 4 | public void addStock(Stock stock) throws StockAlreadyExistsException,
PortfolioFullException {
int countStockSymbol = 0;
// find the symbol's index and count
for (int i = 0; i < portfolioSize; i++) {
if (stocksStatus[i].getSymbol() == stock.getSymbol()) {
countStockSymbol++;
}
}
if (countStockSy... |
04da06bc-177d-4b6f-b2e0-78f3ace2a981 | 3 | public SpriteSheet(String path){
BufferedImage image = null;
try {
image = ImageIO.read(SpriteSheet.class.getResourceAsStream(path));
} catch (IOException e) {
e.printStackTrace();
}
if(image == null){
return;
}
this.path = path;
this.width = image.getWidth();
this.hei... |
8228cadb-3b0b-4380-9635-2b108df60790 | 9 | public void targetActor() {
GameActor t = getTargetedActor();
if(t != null && withinRadius(t)) {
PhysicsComponent tPC = (PhysicsComponent)t.getComponent("PhysicsComponent");
if(tPC != null) {
PhysicsComponent ownPC = (PhysicsComponent)getOwningActor().getComponent... |
abccd770-03ef-43b9-bc6c-943bca16099a | 2 | public static String removeChar(final char theChar, final String theString) {
final StringBuilder s = new StringBuilder();
for (int i = 0; i < theString.length(); i++) {
final char currentChar = theString.charAt(i);
if (currentChar != theChar) {
s.append(currentCh... |
dd3cf4b0-931a-4cdd-8fed-a7d208b332b9 | 3 | private void initFolder() {
// On crée le dossier temporaire contenant les images
String dirName = "img";
File dir = new File(dirName);
if ( !dir.mkdirs() )
JOptionPane.showMessageDialog(this,
"Impossible de créer le dossier temporaire contenant les images... |
75b1a080-cf7a-479d-994d-b1e6ec09875e | 2 | public int compareTo(Point other)
{
return (distance > other.distance+0.01) ? 1 : (distance < other.distance-0.01) ? -1 : 0;
} |
59cb8e30-79bd-449d-903b-6dcd21fb93fc | 9 | public float[] analyzeBook(){
PDFTextStripper stripper;
float posMax = 0;
float negMax = 0;
int curPage = 0;
while (curPage <= bookGrain){ //while on page i
try {
stripper = new PDFTextStripper();
stripper.setStartPage(curPage);
stripper.setEndPage(curPage);
i... |
621ac776-2ebc-463b-8152-1136f1138d5f | 2 | @Override
public String toString() {
if (isVertical) {
return "[x=" + value + "]";
} else if (isHorizontal) {
return "[y=" + value + "]";
} else {
String b = String.format("%+f", this.b);
return "[y=" + this.k + "*x" + b + "]";
}
} |
a5c900f2-c4fe-4255-bdb2-142aa6c15f8c | 7 | public ListNode merge(ListNode l1, ListNode l2) {
if (l1 == null){
return l2;
}
if (l2 == null){
return l1;
}
ListNode superHead = new ListNode(-1);
ListNode temp = superHead;
while (l1 != null&&l2 != null){
if(l1.val<l2.val){
... |
19bb1661-8824-49f0-ade0-acf5168628d6 | 7 | @Override
public void act() {
getImage().scale(40, 40);
checkFall();
onTouchMovingBrick();
if (speed / 4 <= 0) speed = 4;
if (Greenfoot.isKeyDown("a")) {
move(-speed / 4, 0);
switchImageLeft();
}
if (Greenfoot.isKeyDown("d")) {
... |
11832f65-3a46-4f78-8833-312f2e09b16f | 4 | private static double getIconRatio(BufferedImage originalImage,
BufferedImage icon)
{
double ratio=1;
if (originalImage.getWidth()>icon.getWidth())
{
ratio=(double)(icon.getWidth())/originalImage.getWidth();
}
else
{
ratio=icon.get... |
6fa3db5e-86f1-4d16-964c-84bbc1b92585 | 6 | public void DeleteDiffFiles(DatabaseAccess JavaDBAccess, String TargetPHPFileSelectedComboBox) {
int TARGET_PHP_FILES_ID = 0;
PreparedStatement ps = null;
Connection conn = null;
try {
if ((conn = JavaDBAccess.setConn()) != null) {
System.out.println("Connec... |
f787dbc2-805f-4c69-b236-40127a631ebb | 8 | synchronized Class<?> defineClass(final String binaryName, final ClassNode cn) {
final ClassWriter cw = new ClassWriter(0);
cn.accept(cw);
final byte[] b = cw.toByteArray();
if (dumpClasses) {
final File f = new File(System.getProperty("user.home") + File.separator + "dump" + File.separator
+ binaryName... |
fc441f26-b061-439e-b00c-8866cd33b3bd | 3 | public boolean isUnit(){
boolean test = true;
for(int i=0; i<this.numberOfRows; i++){
for(int j=0; j<this.numberOfColumns; j++){
if(this.matrix[i][j]!=1.0D)test = false;
}
}
return test;
} |
f55f99d5-257b-444a-bfe1-b78e94ba7adf | 6 | public void move()
{
if (path.size()<=1)
path=getLongestPath(getPos());
else
for (int n=path.size()-2;n>=0 && n>path.size()-10 ;n--)
{// path.size()-1 is always taken: the bike is there
if (path.get(n).notFree())
{
... |
b1a67e60-0204-45ee-8bfb-f87113f31d6f | 3 | private static boolean isInsideInSameHorizontalSpace(Positioned a, Positioned b)
{
return a.leftBorder() == b.leftBorder() &&
a.rightBorder() == b.rightBorder() &&
(pointInside(a, (b.leftBorder() + b.rightBorder()) / 2, b.topBorder(), true) ||
pointIn... |
a5d35534-a5b7-47a0-b4e6-c7f36be138fc | 2 | private PreferencesWindow() {
super(PREFERENCES, StdImage.PREFERENCES);
Container content = getContentPane();
mTabPanel = new JTabbedPane();
for (PreferenceCategoryProvider category : CATEGORIES) {
try {
addTab(category.create(this));
} catch (Exception exception) {
Log.error("Trying to load " + c... |
b66ca98e-5be0-40e0-9386-bd5e3188ceed | 7 | public void keyPressed(KeyEvent e)
{
int key = e.getKeyCode();
if(vert)
{
if(key == KeyEvent.VK_UP)
{
keyboardInput=true;
if(y<min)
{
y=min;
}
displacement-=32;
}
if(key == KeyEvent.VK_DOWN)
{
keyboardInput=true;
if(y+height>max)
{
y=max-height;
displ... |
46645548-be0f-473e-8ee0-d94166c84ff6 | 3 | public static void binaryinsertsort(int[] a,int i){
int left = 0,right = i-1;
int temp = a[i];
while (left<=right) {
int middle=(left+right)/2;
if (temp<a[middle]) {
right= middle-1;
}else {
left = middle+1;
}
}
for (int k=i-1;k>=left;k--){
a[k+1] = a[k];
}
a[left] = temp;
} |
ed00b357-658e-4b3b-826d-2b5a3816bd71 | 5 | public static <A> Ord<Stream<A>> streamOrd(final Ord<A> oa) {
return ord(s1 -> s2 -> {
if (s1.isEmpty())
return s2.isEmpty() ? Ordering.EQ : Ordering.LT;
else if (s2.isEmpty())
return s1.isEmpty() ? Ordering.EQ : Ordering.GT;
else {
final Ordering c = oa.c... |
7c771bc0-e71c-4e64-a263-33b7fa7af893 | 9 | public ArrayList<String> placeDotCom(int comSize) {
// Declare Function Locals
ArrayList<String> alphaCells = new ArrayList<String>();
// String [] alphacoords = new String [comSize]; // ArrayList to Hold AlphaNumeric Coordinates
String temp = null; // Temporary String for concat
int [] coords = new... |
7f4c9e0a-162e-4e67-8e89-0b5539c78e9a | 1 | public void writeToChannel(String text){
try{
bw.write("PRIVMSG "+ channel +" :"+text+"\n");
bw.flush();
}catch(IOException e){
System.out.println("IRC: Failure when trying to write to server: "+e.getMessage());
}
} |
32b74f2c-886b-4086-989e-c8ec0a4f0d23 | 7 | public static String trimSectionEndBlanks(String text) {
if (isBlank(text)) {
return text;
}
boolean isBlank = false;
int endIndex = text.length();
if (text.length() >= 1) {
if (text.charAt(text.length() - 1) == ' ') {
isBlank = true;
endIndex--;
}
}
for (int i = text.length() - 1; i ... |
9e7163a7-d8e6-4664-8f50-b5d71fa18b23 | 2 | public void updateRole( final long id, final String roleStr ) throws IOException {
if( id == 1 ) {
logger.warning("Can't update roles for admin");
return;
}
final UserRole neuRole = UserRole.roleForString(roleStr);
if( neuRole == null ) {
logger.warning("Unknown role.");
return;
}
(new S... |
8248a3ac-6e35-4c5c-b8da-ef58c88cc797 | 0 | public void setType(String type)
{
this.type = type;
} |
8dc28c43-2e0b-4f28-afcd-635dec7bc160 | 6 | protected void processBackgroundReads() {
logger.info("Processing background reads...");
logger.info("Computing RPKM values using " + threads + " threads...");
long tstart = System.currentTimeMillis();
this.transcripts = new ArrayList<TranscriptRecord>();
GeneModelProducer produ... |
cfc7ddfc-48a6-4042-bc05-95f2542e3eea | 2 | @Override
public void render(Screen screen) {
super.render(screen);
int dist = getHeight() / SCORES_SHOWN;
int i = 0;
for (Long score : scores) {
if (scaleText)
Art.FONT.render(getX(), getY()+(dist*i), dist, Timer.longToTimeString(score), screen);
else {
Art.FO... |
2f3825e1-ffbf-4aa8-b19f-033817e08216 | 9 | public static void main(String[] args) {
Assemble_dir ad = new Assemble_dir();
//if (args==null || args.length==0){
// System.out.println("Usage: java -jar BatchAssemble input directory> <output directory> <lookup table path> <regular expression filter> <overwrite=true/false>");
// System.out.println("Use... |
3fe34eee-36ce-475e-a8ef-a25c08481941 | 1 | private static void renderElements(int windowX, int windowY){
Font.render("Element", windowX + 16, windowY + height - 24);
GL11.glDisable(GL11.GL_TEXTURE_2D);
for(int i = 0; i < 3; i++){
GL11.glColor3f(0.5f, 0.5f, 0.5f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(windowX + 16 + i*32 + i*4, windowY + he... |
f3d45a2d-c955-411c-be56-6149d238dcec | 9 | public void selectSquibGroup(int index){
Universe u = sequence.getSquibGroups().get(index).getSquibs();
// Clear any previously selected squibs
visualSchematicController.deselect();
// And select the squibs from the given group
for (Firebox fb : u.getFireboxList())
{
for (Lunchbox lb : fb.getLunchb... |
4f4b89a6-acbd-4bf6-8160-2dd0b4cdd6c9 | 7 | private boolean method66(int i, int j, int k)
{
int i1 = i >> 14 & 0x7fff;
int j1 = worldController.method304(plane, k, j, i);
if(j1 == -1)
return false;
int k1 = j1 & 0x1f;
int l1 = j1 >> 6 & 3;
if(k1 == 10 || k1 == 11 || k1 == 22)
{
ObjectDef class46 = ObjectDef.forID(i1);
int i2;
int j2;
... |
7c0ada02-bcf8-4861-b733-c67e270d8eac | 8 | public static void pointIntersectsRectangleOuter(
float pointX, float pointY, float speedX, float speedY, float radius,
float rectX1, float rectY1, float rectX2, float rectY2,
float timeLimit, CollisionResponse response) {
// Assumptions:
assert (rectX1 < rectX2) && (rectY1... |
b7fb8945-73c4-4209-b71a-62e7e3a04ca6 | 2 | @Override
public void close() throws IOException {
if (fileChannel != null) {
fileChannel.close();
}
if (rf != null) {
rf.close();
}
// GC
threadLocalByteBuffer.set(null);
threadLocalByteBuffer = null;
} |
ae5a0445-abf2-460a-b61d-5cbf76787888 | 9 | synchronized public BlockTuple getNextToDoAndStart() throws InterruptedException{
BlockTuple res = null;
while(toDoList.isEmpty() && !workFinished)
wait();
if(workFinished)
//Schalte Thread aus, arbeit ist vorbei;
return null;
//
while(res == null){
if(workFinished)
Thread.currentThread().int... |
ce4afaa5-d9a5-4293-97cf-dcc3493f745f | 7 | public synchronized void getAvgTempForStnsWithinTimeRange(Date fromDate, Date toDate){
PreparedStatement pstmt = null;
int avgTemp = 0;
String stn = "";
HashMap<Integer, String> hmResult = new HashMap<Integer, String>();
ResultSet rs = null;
try{
conn = DBConnectionMgr.getConnection();
if(conn !=... |
d61a5d77-fb9c-4f9f-8693-214e72010725 | 9 | private void setGSState(String name) throws IOException {
// obj must be a string that is a key to the "ExtGState" dict
PDFObject gsobj = findResource(name, "ExtGState");
// get LW, LC, LJ, Font, SM, CA, ML, D, RI, FL, BM, ca
// out of the reference, which is a dictionary
PDFObje... |
022c772e-ca46-4603-b307-9a3641fade36 | 5 | public int readPackage(int depth, HashMap classes, String packageName,
int count) {
if (depth++ >= MAX_PACKAGE_LEVEL)
return count;
String prefix = packageName.length() == 0 ? "" : packageName + ".";
Enumeration enum_ = ClassInfo.getClassesAndPackages(packageName);
while (enum_.hasMoreElements()) {
// ... |
e17ab844-d302-48be-aa46-1493d85ad230 | 3 | public List<Entry> getEntryList() {
List<Entry> list = new LinkedList<>();
try {
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM comments ORDER BY time");
if (resultSet == null) {
... |
79fdb7e1-8cd5-4fdc-9cda-1d8e3130563b | 9 | public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof AirlineException)) return false;
AirlineException other = (AirlineException) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsC... |
b6820b48-ddd3-478a-acb3-3001a5bafc5e | 2 | */
protected void dragExitColumn(DropTargetEvent dte) {
List<Column> columns = mModel.getColumns();
if (columns.equals(mSavedColumns)) {
repaintColumn(mModel.getDragColumn());
} else {
columns.clear();
columns.addAll(mSavedColumns);
repaint();
if (mHeaderPanel != null) {
mHeaderPanel.repaint(... |
01317ced-6701-4d5a-a254-4057f4c85b72 | 9 | public static String uncompressUtf8(String str){
if (str == null || str.length() == 0) {
return str;
}
try{
int idx = str.indexOf('_');
String len = str.substring(0,idx);
String cont = str.substring(idx+1,str.length());
byte[] compressArr = new byte[Integer.parseInt(len)];
int i = 0;
for(int ... |
12a49b5c-d669-4cd5-9d39-bba3f629ba92 | 7 | @EventHandler
public void onFlagTake(PlayerInteractEvent e) {
final Player p = e.getPlayer();
if (e.getAction()== Action.RIGHT_CLICK_BLOCK||e.getAction()==Action.LEFT_CLICK_BLOCK) {
final Block b = e.getClickedBlock();
if (CTF.gm.isPlaying(p)) {
if (b.getType(... |
550b3fe7-b527-4224-922e-8e7630f701c1 | 2 | private static void trimWSFromNode(Node node) {
NodeList children = node.getChildNodes();
for(int i = 0; i < children.getLength(); ++i) {
Node child = children.item(i);
if(child.getNodeType() == Node.TEXT_NODE) {
child.setTextContent(child.getTextContent().trim());
}
... |
3728505f-b355-49e8-95ae-44b0ec3a90e0 | 3 | private void open(final JFrame frame) {
final JFileChooser chooser = new JFileChooser(new File(GuiUtils.CURRENT_DIRECTORY));
chooser.setSelectedFile(new File("scsync.config"));
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(frame)) {
final Gson gson = new GsonBuilder().create();
try {
GuiUtil... |
43703322-2e94-4356-a19a-fb6c01bc6efc | 2 | public static ArrayList<Employee> showAll() {
ArrayList<Employee> employees = new ArrayList<Employee>();
Database db = dbconnect();
try {
db.prepare("SELECT * FROM employee WHERE bDeleted = 0 ORDER BY EID");
ResultSet rs = db.executeQuery();
while(rs.next()) {
... |
604945bc-5ab0-4892-ad34-0ef33f6e89e3 | 7 | @Test
public void testForcedMove() {
try {
Scanner sc = new Scanner(new File("./test/myBoard.txt"));
//
int xSize = sc.nextInt();
int ySize = sc.nextInt();
//
int [][] newField = new int[xSize][ySize];
for (int y = ySize - 1; y > -1; --y) {
for (int x = 0; x < xSize; ++x) {
newField[... |
e3fcfaba-d8af-40a5-b6de-94baaf8299d9 | 2 | public CheckboxMenuItem getToolTipCheckBox() {
if (toolTipCheckBox == null) {
toolTipCheckBox = new CheckboxMenuItem("Set tooltip");
toolTipCheckBox.setState(true);
toolTipCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
int toolTipCheckBoxId = e.getStateChan... |
b2c8c98c-df71-4c5a-bb30-7ebaeddcd90e | 2 | public Point getRoute(int x, int y)
{
if (thread != null) {
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return route[y][x];
} |
af9e8991-9766-47eb-a773-f7839f168c64 | 4 | @Override
public IMatrix nInvert() {
/*
* inverz se računa kao umnožak inverza determinante matrice i
* transponirane adjungirane matrice početne matrice;
* ukoliko je determinanta 0, tada inverz ne postoji i takva matrica
* naziva se singularna matrica
*/
double determinant = this.determinant();
... |
9ed6b6cd-a463-4680-b47d-d9d5cb00c6d3 | 3 | @Override
public boolean onKeyDown(int key) {
if(super.onKeyDown(key)) {
return true;
}
if(key == Keyboard.KEY_ESCAPE || key == Keyboard.KEY_TAB) {
Application.get().getHumanView().popScreen();
return true;
}
return true;
... |
d011b1be-d50b-45e8-a007-09a7dba7ed35 | 3 | @Override
public void actionPerformed(ActionEvent arg0) {
switch(arg0.getActionCommand()) {
case ("Ok"): {
LAF = lookAndFeel.get(combo1.getSelectedIndex());
if(j != null) {
try {
UIManager.setLookAndFeel(LAF.getClassName());
} catch(ClassNotFoundException | InstantiationException
|... |
80cdef5a-4f19-462c-af53-3560558bf3d9 | 2 | public static void powMatrix(int[][] f, int n){
if(n<2) return;
powMatrix(f, n/2);
twoMatrix(f);
if(n%2 == 1)
oneMatrix(f);
} |
63c2d575-3b6f-4473-9f3d-44e30400097c | 3 | public synchronized void init() {
Object tmp = library.getObject(entries, "Pages");
pageTree = null;
if (tmp instanceof PageTree) {
pageTree = (PageTree) tmp;
}
// malformed core corner case, pages must not be references, but we
// have a couple cases that bre... |
48f386d0-c7c3-422e-b3f5-597f9e343476 | 1 | public LinkedList<Item> createLinkedList(int items) {
LinkedList<Item> list = new LinkedList<Item>();
for (int i=0;i<items;i++) {
Item item = genItem(i,items);
list.add(item);
}
return null;
} |
2d4746d7-5ecd-4398-9670-053f15b8c83d | 3 | public void setFullscreen(boolean fullscreen) {
if (Client.instance.preferences.video.fullscreen == fullscreen) {
try {
Class<?> application = Class.forName("com.apple.eawt.Application");
Method getApplication = application.getMethod("getApplication");
Object app = getApplication.invoke(null);
Method requ... |
e6e4d84d-30e6-4b3c-be3e-0fbaefa398e3 | 3 | private String diffStateTreasure(GameState old, GameState curr, Card card)
{
Color faction = card.getFaction();
Loot oldLoot = old.getPlayer(faction).getLoot();
Loot currLoot = curr.getPlayer(faction).getLoot();
if(oldLoot.equals(currLoot))
return null;
for(String t : Treasure.allTreasures())
{
... |
793252b6-820f-40e6-a735-e8f0e3227048 | 0 | public static void main(String[] args) {
LiftOff launch = new LiftOff();
launch.run();
} |
3d9e9485-57f5-459d-9501-80540b593535 | 7 | public void forcePlus(Items items, int plus) {
if (plus < 0 || plus > 15)
return;
for (Shoes x : items.getShoes()) {
x.setPlus(plus);
}
for (Gloves x : items.getGloves()) {
x.setPlus(plus);
}
for (Pants x : items.getPants()) {
x.setPlus(plus);
}
for (Armor x : items.getArmors()) {
x.setP... |
19d1164f-602e-4cdc-a6b0-aa7d8c887b8c | 8 | private void calculateSmoothingFactor(){
if (!vocab.isWordUpdated(ID)) {
clusterWords();
//zeros = (K+1)^2 - occupied contexts
//count nonZeros and find the minimum and its frequency
int nonZeros = 0;
int min = 0;
int minValues = 0;
for (int[] ai : clusterContexts){
for (int j : ai){
if ... |
72d87659-ea02-4912-b8ff-e76567ba4817 | 6 | public void merge(Map<String, Category> categoryMap) {
for (MergerInfo mi : miList) {
List<Player> mergedPlayers = new ArrayList<Player>();
AggregationGroup group = mi.getGroup();
String groupName = group.getKana();
Category category = categoryMap.get(groupName);
System.out.println(category);
Map<St... |
b8c4a88d-cf43-4a7b-8c36-b6f582f17c81 | 3 | public Form getForm(int formId) throws FormNotFoundException, ErrorRecreatingFormException {
try {
String q = "select formobject from form where formid = ?";
PreparedStatement st = conn.prepareStatement(q);
st.setInt(1, formId);
ResultSet rs = st.executeQuery();
... |
7e2438ab-b931-47b3-afb0-22dfa63f74d3 | 2 | @Test
public void findUser(){
Connection conn = null;
Statement statement = null;
ResultSet reSet = null;
try{
conn = JDBCUtils.getConnection();
statement = conn.createStatement();
reSet = statement.executeQuery("select * from table_user");
while(reSet.next()){
String Id = reSet... |
ed465fbb-4a39-4626-ba82-40564873f9b9 | 9 | @Override
public boolean perform(GameEntity performer, GameEntity target) {
if (target instanceof Actor) {
Actor actor = (Actor) target;
if (hardAmount != 0) {
actor.addHealth(hardAmount);
} else if (dynamicAmount != null) {
int maxHealth =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.