method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
99d9b579-029e-42f0-8291-5aac250d4d9c | 7 | @Override
public void run() {
Thread thisThread = Thread.currentThread();
long beforeTime, timeDiff, sleep;
list = model.getArray();
while (state == State.START && animator == thisThread) {
beforeTime = System.currentTimeMillis();
timeDiff = System.currentTimeMillis() - beforeTime;
sleep = delay - ti... |
20bac72d-1807-4d7b-a5b4-2b29c1da6b68 | 1 | private static boolean isNumber(int character) {
return character >= '0' && character <= '9';
} |
4195de10-d00f-4c8c-b726-320d5fe951fd | 7 | protected void UnZip() throws PrivilegedActionException
{
String szZipFilePath;
String szExtractPath;
String path = (String)AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
return Util.getWorkingDirectory() + File.separator;
... |
0d8bb977-9955-4194-92f8-b11841d9e083 | 3 | private static VDKFileVersion readVersion(String vdkFilePath) {
FileInputStream in;
int currentValue;
String strVDKFileVersion = null;
StringBuilder sb= new StringBuilder();
try {
in = new FileInputStream(vdkFilePath);
while((currentValue = in.read()) != 0){
sb.append((char) I... |
8eb71200-c7f9-4594-b714-bb87602930c3 | 0 | public String getName() {
return name;
} |
e71f7c15-7534-4bd4-b47e-f631ca0ec874 | 4 | public boolean addAll(SimpleSet<? extends E> c) {
for (E temp : c) {
if (super.isEmpty()) {
maxElement = temp;
} else if (temp.compareTo(maxElement) > 0) {
maxElement = temp;
}
}
super.addAll(c);
return true;
} |
6c2f79da-3c82-43b9-aec6-0011ce4528b9 | 3 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this);
if ((clipboardContent != null)
&& (clipboardContent.isDataFlavorSupported(DataFlavor.stri... |
3b76545e-7078-4018-8289-f962e909b00b | 0 | public QuestPoint(QuestType type) {
this.type = type;
QuestName = "";
questId = id;
PicturePaths = new ArrayList<String>();
PicturePaths.add("");
SoundPaths = new ArrayList<String>();
SoundPaths.add("");
paragraph="";
soundInventoryList = new ArrayList();
pictureInventoryList = new ArrayList();
so... |
f5752b83-ac5a-4e7a-a46d-1d7a8ac71efe | 8 | public MainMenu(Display d) {
display_ = d;
int frameWidth = 730, frameHeight = 480;
int buttonWidth = 350, buttonHeight = 75;
// Space between buttons and the Y component of first button
int betweenSpace = 20, buttonStart = 180;
// Set size of window
this.setSi... |
9451c967-e6e0-4912-bede-bdc239d25cb0 | 9 | @Override
public void spring(MOB target)
{
if(target.location()!=null)
{
if((!invoker().mayIFight(target))
||(isLocalExempt(target))
||(invoker().getGroupMembers(new HashSet<MOB>()).contains(target))
||(target==invoker())
||(doesSaveVsTraps(target)))
target.location().show(target,null,null,CMMs... |
00da56b1-3921-47f5-bd3b-1f2020d57ceb | 3 | public boolean looseMatch(ItemStack item) {
if (getId() != null && getId() == item.getTypeId()) {
return true;
}
Material mat = Material.getMaterial(name);
return (mat != null && mat.getId() == item.getTypeId());
} |
dac75b1e-8a3a-4ab3-81dc-8229da1f7ff8 | 8 | @SuppressWarnings("RedundantIfStatement")
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Record record = (Record) o;
if (x != record.x) return false;
if (y !=... |
f4fe2241-68c7-46ec-9229-551d6781aeae | 6 | public static String unescape(String string) {
int length = string.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; ++i) {
char c = string.charAt(i);
if (c == '+') {
c = ' ';
} else if (c == '%' && i + 2 < length) {
... |
01079ebc-52b5-4acb-9d5c-bf50fdef3133 | 3 | private static boolean isStringHasText(String text) {
if (!isStringHasLength(text)) {
return false;
}
int strLen = text.length();
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(text.charAt(i))) {
return true;
}
}
return false;
} |
7e20f06c-e82a-4efc-96c8-0513dcf4d717 | 8 | public String getRecommendListForCommonNeighbors() {
String recommend = "";
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/NETWORK_TEST?"
+ "user=root&password=root");
connect.setAutoCommit(false);
statement = connect.createSta... |
3fc2c04d-85d3-4f2d-86e4-16fd809ef10d | 4 | public boolean equals(Rectangle2D _rect) {
if(_rect.getX() == x && _rect.getY() == y &&
_rect.getWidth() == width && _rect.getHeight() == height) {
return true;
}
else {
return false;
}
} |
a1029dfa-50b4-47cd-a1f3-010affc4b06a | 7 | public boolean checkCollision(GameComponent component, float changeX, float changeY) {
for (Pushable push : pushList) {
if (push.checkCollision(component, changeX, changeY)) {
if (SolidCollision(push, changeX, changeY)) {
return true;
} else {
... |
fcf8297b-d288-4a76-ae76-2f8782656727 | 0 | public double getLengh(){
return lengh_circle = this.getHig()*Math.PI;
} |
a48ce066-aa85-4510-a900-862614b7bc9c | 2 | public void crearTabla(String nombreTabla, String tabla, String[] index)
{
try {
// En esta variable guardare la consulta de cada indice
String consulta;
this.bd.open();
this.bd.beginTransaction(SqlJetTransactionMode.WRITE);
// Funcion que recoge l... |
a2b3a2f3-3373-4311-a84c-941418ed7721 | 5 | static final BufferedImage getScaledImage(BufferedImage src, int newWidth,
int newHeight) {
if (src == null) {
return null;
}
if (newWidth == 0 && newHeight == 0)
return null;
BufferedImage scaledImage = new BufferedImage(newWidth, newHeight,
BufferedImage.TYPE_INT_RGB);
;
int w = src.getWidth(... |
501286a9-4e15-4e1e-b9b5-dc76348972a2 | 8 | private void string(String value) throws IOException {
String[] replacements = htmlSafe ? HTML_SAFE_REPLACEMENT_CHARS : REPLACEMENT_CHARS;
out.write("\"");
int last = 0;
int length = value.length();
for (int i = 0; i < length; i++) {
char c = value.charAt(i);
String replacement;
if... |
3ec1ce01-5539-4398-9e60-9c8437b4d987 | 1 | public void printElement() {
System.out.print("AGREGATION CONTAINER ");
System.out.print(this.container.getIdentifier() + " : " + this.container.getMultiplicity());
System.out.print(" PARTS ");
for(Role role : parts){
System.out.print(role.getIdentifier() + " : " + role.getMultiplicity() + ", ");
}
... |
8cdbcc50-2c5e-4782-aa79-25667800d6ba | 8 | public void execute(DocumentMap dm) {
documentMap = dm;
candidates = new HashSet<String>();
if ((query1 == null) || (query2 == null)) {
throw new RuntimeException("Invalid query");
}
/* this seems to be faster than using executor.invokeAll (see Or query)
Futur... |
4e0f8966-2170-44c6-9b79-98ac0cf2a966 | 4 | public static void createPDF(String path, String[] content, Boolean rotate) {
try {
File myFile = new File(path);
if (!myFile.exists()) {
myFile.createNewFile();
}
Document document = new Document(rotate == true ? PageSize.A4 : PageSize.A4.rotate());// 创建word文档,并设置纸张的大小
PdfWriter.getInstance(docume... |
f30a2221-af52-4088-bacd-3cb0cf0f9ea1 | 2 | protected Duration restReduced() {
Interval outer = new Interval(period.getEnd().minusWeeks(1), period.getEnd());
Duration aDay = new Duration(24 * hoursToMillis);
int reduced = intervals.countGaps(outer, aDay, Rest.REDUCED.getValue(), Rest.NORMAL.getValue());
if (reduced >= MAX_REDUCE... |
a065fbfa-afec-4420-97a6-4b1c7db7eb51 | 6 | public static void startupJavaOutput() {
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, Stella.$STELLA_MODULE$);
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
if... |
d1d1cde6-c8eb-404e-85ad-a5698a24c60d | 7 | public synchronized static boolean comprovingCollision(List<Ant> ants) {
for (int a = 0; a < ants.size(); a++) {
for (int b = 0; b < ants.size(); b++) {
if (a != b) {
if (distance(ants.get(a).getX(), ants.get(b).getX(), ants
.get(a).getY(), ants.get(b).getY()) < 50
&& reproduction(ants.get(a... |
d1872c01-d4e3-4aed-af9f-026c09659a11 | 8 | public static void dfs(int i, int value) {
if (fin || dp[i][value + MAX] == true)
return;
dp[i][value + MAX] = true;
if (i == p + 1) {
if (value == arr[p + 1]) {
for (int j = 1; j < arr.length - 1; j++) {
if (j != arr.length - 2)
out.append(arr[j] + "" + ops[j]);
else
out.appen... |
8d3b84c7-46a7-46da-b393-8fcf2dde5390 | 6 | public boolean checkHorizontal() {
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numColumns - 3; col++) {
int curr = gameGrid[col][row].getState();
if (curr > 0
&& curr == gameGrid[col + 1][row].getState() //increment the co... |
445222a0-544d-4812-932e-454af67a853f | 3 | public static String process(String name, SimpleHash params) {
if (m_templateConfig == null)
throw new NullPointerException("m_templateConfig is not initialized");
freemarker.template.Template template;
try {
template = m_templateConfig.getTemplate(name);
} catch... |
58d25003-9589-4b03-9254-f962aa1e40aa | 9 | private static void executeTests(File input, ChoiseImpl implementation) {
int testingCount = 3;
double nf = Math.pow(10, 6); // factor to convert from nano seconds to milliseconds
System.out.printf("\n\n~~~ Perfoming tests on %s, using %s%n" +
"~~~ average results based on %d test runs:%n", input.getName(... |
a3b2d474-8e69-4320-bb68-faf9f5a0d47e | 5 | public int getRed(int row, int col) {
if (row >=0 && row < rows && col >= 0 && col < columns && grid[row][col] != null)
return grid[row][col].getRed();
else
return defaultColor.getRed();
} |
e09c759d-c8c1-413b-bf90-0c82af33786a | 8 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(!super.tick(ticking, tickID))
return false;
if(ticking instanceof MOB)
{
final MOB M=(MOB)ticking;
if(activated)
{
synchronized(this)
{
final Room R=M.location();
if((activatedUntil!=null)
&&(R.getArea()!=null)
... |
d277a9f0-d99f-4dcc-87a5-f0040a71dd85 | 1 | public static String HMSFormatConvertor(int callDuration, int minuteUnit) {
if (callDuration < 0)
throw new IllegalArgumentException();
int hours = callDuration / (MinutesPerHour * minuteUnit);
callDuration = callDuration % (MinutesPerHour * minuteUnit);
int minutes = (int) ... |
06530b15-a3a3-416b-a425-08b064dc9642 | 3 | public Corridor getCorridor(int id) {
if (id < 0 || id >= corridors.length || id%2 == 0) {
return null;
}
return corridors[(id-1)/2];
} |
ad921e33-16c0-45c0-9246-467f98b59669 | 3 | public MenuPrinc () {
super();
try {
setImg(ImageIO.read(new File("img/background/menu.jpg")));
} catch (IOException e) {
e.printStackTrace();
}
_title.setBounds(240, 25, 310, 70);
_title.setFont(new Font("Arial", Font.BOLD, 45));
add(_title);
add(jouer);
jouer.addActionListener(new Act... |
e1b9d3ea-a87a-42d2-9a82-4d85bb2fc21a | 7 | @Override
public boolean valid() {
if (//&& options.beastOfBurden != Summoning.Familiar.CLAN_AVATAR
options.useBOB.get() &&
ctx.summoning.timeLeft() <= 420
&& ctx.summoning.points() < nextPoints
&& (ctx.backpack.isFull() || getBackpackOffering().isEmpty())
) {
Room startRoom = script.roo... |
0eb6f453-e87b-4819-bd4b-3307c1c80bd5 | 2 | public static boolean streetAddress(String address){
if(address.matches("(\\d)+(\\s)[a-zA-Z\\s\\.]+")&&address.length()<100)
return true;
return false;
} |
28190b25-ccf0-4511-8549-7750c903c1e6 | 3 | private static final byte[] encodeDictionary(HashMap<ByteBuffer, Object> dictionary) throws BencodingException
{
TreeMap<ByteBuffer, Object> sorted_dictionary = new TreeMap<ByteBuffer, Object>();
sorted_dictionary.putAll(dictionary);
byte[][] dictionary_parts = new byte[sorted_dictionary.key... |
2fbf7f58-b6b2-4322-aa1d-782500627943 | 2 | public AnimatedGraphic getState(int index) {
if (index < 0 || index >= animations.size()) {
throw new IndexOutOfBoundsException();
}
return animations.get(index);
} |
b856a3c1-d0c8-4c87-9994-de3ec52e7762 | 7 | public static Keyword continueSpecialistProof(ControlFrame frame, Keyword lastmove) {
{ Proposition proposition = frame.proposition;
NamedDescription description = Logic.getDescription(((Surrogate)(proposition.operator)));
java.lang.reflect.Method specialistcode = NamedDescription.lookupSpecialist(descr... |
86b46758-6e56-4ef2-a0fe-90e8ca9a4f30 | 1 | public static void main(String[] args) throws IOException{
if(args.length != 4){
System.out.println("Please use: ");
System.out.println("java Parse_file [input_file_path] [output_file_path] [global-voc_file_path] [specific-voc_file_path]");
System.exit(0);
}
// Input file name;
String input_name =... |
58ecf0bf-d062-43c4-8bce-e39ad9e5cd6b | 6 | public void faceObject(Entity obj){
if (obj != null)
if(obj.getBody() != null){
float dx = obj.getPosition().x - getPosition().x;
if(dx > 0 && isFacingLeft()) changeDirection();
else if (dx < 0 && !isFacingLeft()) changeDirection();
}
} |
2727056d-2d01-4da5-a873-e260ddd43827 | 4 | public static Trigger asTrigger (Action action)
{
switch ( action )
{
case LEFT_CLICK_AIR :
return LEFT_CLICK_AIR;
case LEFT_CLICK_BLOCK :
return LEFT_CLICK_BLOCK;
case RIGHT_CLICK_AIR :
return RIGHT_CLICK_AIR;
... |
7804b2a9-906f-4f32-9c09-a2b6cd34cdf5 | 8 | void setExampleWidgetSize () {
int size = SWT.DEFAULT;
if (preferredButton == null) return;
if (preferredButton.getSelection()) size = SWT.DEFAULT;
if (tooSmallButton.getSelection()) size = TOO_SMALL_SIZE;
if (smallButton.getSelection()) size = SMALL_SIZE;
if (largeButton.getSelection()) size = LARGE_SIZE;
... |
b8f642c3-ccbc-4757-9f69-80025bf89c81 | 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... |
ac62c975-aeb9-4d06-bdc6-ca4a499bcef6 | 1 | public static final String getLine() {
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
try {
return in.readLine();
} catch (IOException e) {
return "";
}
} |
5328373e-7c93-4cde-9e2c-2c221192590e | 1 | public PreferenceString getFileProtocol() {
if (useDocumentSettings()) {
return this.fileProtocol;
} else {
return Preferences.getPreferenceString(Preferences.FILE_PROTOCOL);
}
} |
97007f52-a641-475a-b2b7-2240345d72f7 | 3 | public void actionPerformed(ActionEvent e) {
if(e.getSource()==ince) {
ince.setBackground(Color.pink); //ðťɫ
stop.setBackground(Color.gray);
if(!(thread.isAlive())) {
thread=new Thread(this);
}
thread.start();
b=false;
}
if(e.getSource()==stop) {
ince.setBackground(Color.yellow);
stop.... |
41532753-ac93-4110-9b69-11ae5e93286d | 9 | protected void computeFloor(final float[] vector) {
int n = vector.length;
final int values = xList.length;
final boolean[] step2Flags = new boolean[values];
final int range = RANGES[multiplier - 1];
for (int i = 2; i < values; i++) {
final int lowNeighbourOffset =... |
d3181252-e76f-4b73-8470-10a61f23649a | 2 | public Value get(Key key) {
for (Node x = first; x != null; x = x.next) {
if (key.equals(x.key)) return x.val;
}
return null;
} |
166d0ce4-a9c6-4281-adc5-447fa821ffa9 | 7 | @Override
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
session = req.getSession(true);
sc = getServletContext();
if(!req.getParameter("korisnickoIme").equals("")){
korisnickoIme = req.getParameter("korisnickoIm... |
e77043e8-85e4-41ad-bd91-5194d0028248 | 2 | private void writeScore(long newScore) {
try {
String scoreToAdd[][] = {{SettingsModel.getUserName(), ""+newScore}};
String content=convertToSaveableString(insertSorted(scoreToAdd, s));
File file = new File(SavePath.getHighScorePath());
if (!file.exists()) {
file.createNewFile(... |
c9d36892-032e-4dc2-9e7f-1a2d3deb73ef | 8 | public VoiceDomoticaView(SingleFrameApplication app) {
super(app);
initComponents();
arduino = new Arduino();
arduino.initialize();
if(arduino.isConnected()){
this.jLabel3.setText("Arduino Connesso");
}
else {
this.jLabel3.setText("Arduino... |
0f25494f-84a5-416e-a12f-2ed8f2bc138d | 3 | private final CommandMap getCommandMap() {
if (cmap == null) {
try {
final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
cmap = (CommandMap) f.get(Bukkit.getServer());
return getCommandMa... |
4b8f2b50-7409-442c-96fb-0280ff2331c8 | 1 | private static void displayVideoSuggestions(VideoStore videoStore) {
try {
displayVideos(videoStore.getVideoSuggestions());
} catch (Exception e) {
System.out.println("There was an error while getting video suggestions.");
}
} |
5e38c6e1-e91d-4b9b-a878-61e39ed7734c | 3 | public Point getPosCritical(Component.Position pos) {
Point p = new Point(getX(), getY());
Point p2;
if (pos == Component.Position.right)
p2 = new Point(p.x + getWidth() + getHeight() / 4 + 1, p.y
+ getHeight() / 2);
else if (pos == Component.Position.left)
p2 = new Point(p.x - getHeight() / 4 - 1, ... |
efcdd729-304f-4f0c-b6fd-440e9e68af87 | 3 | private static void execute(String sql) {
try {
if (statement == null || statement.isClosed()) {
statement = conn.createStatement();
}
statement.execute(sql);
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
} |
51fd445c-8825-4c51-b38f-b3e7e12c89e7 | 1 | public static String format(BigDecimal value, int minnum, boolean b) {
if (value == null) {
return "0.00";
}
NumberFormat nbf = NumberFormat.getInstance();
nbf.setMinimumFractionDigits(minnum);
nbf.setMaximumFractionDigits(minnum);
nbf.setGroupingUsed(b);
return nbf.format(value);
} |
e8475c8e-3bec-44c4-bd97-ea125842653d | 7 | public ChatPacket[] getRoomMessages(LongInteger room) {
// TODO: Fix this
if (!store.messages.containsKey(room)) {
return new ChatPacket[0];
}
ArrayList<Integer> sorted = new ArrayList<Integer>();
for (LongInteger src : store.messages.keySet()) {
for (Cha... |
b636925f-35cc-4f35-bb82-ed1680ea5649 | 7 | public static void fireFirstDeclared(Throwable t, Class... declaredTypes) {
Throwable cause = t;
while (cause != null) {
cause = cause.getCause();
if (cause == null) {
break;
}
if (declaredTypes != null) {
for (Class declare... |
7b582288-da76-4b6b-b7ad-f1b357791b78 | 0 | public double getFirst()
{
return first;
} |
70c1cf65-fe77-4878-8474-84852d09b0cb | 2 | @Override
public void info(String message, Object... o) {
String formattedMessage = format(message, o);
if (infoMethod != null) {
try {
infoMethod.invoke(logger, formattedMessage);
} catch (Exception e) {
e.printStackTrace();
}
... |
5c2267d7-0e3a-4ec3-97ad-1febc26711fb | 9 | private String scrapeNews(String Ticker,List<struct_News> _News) throws IOException {
// TODO Auto-generated method stub
Document doc_curr = Jsoup.connect("http://finviz.com/quote.ashx?t="+Ticker).get();
Elements content_curr = doc_curr.getElementsByClass("fullview-news-outer");
String Time = "";
String T... |
621d73dc-4bbc-4353-ae7a-31e2d085164a | 2 | public void dumpExpression(TabbedPrintWriter writer)
throws java.io.IOException {
Type arrType = subExpressions[0].getType().getHint();
if (arrType instanceof ArrayType) {
Type elemType = ((ArrayType) arrType).getElementType();
if (!elemType.isOfType(getType())) {
/* We need an explicit widening cast *... |
4201d23c-54cb-4cef-b55b-e7c56ca85881 | 8 | private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) {
TextAnchor result = TextAnchor.CENTER;
if (anchor.equals(RectangleAnchor.TOP_LEFT)) {
result = TextAnchor.BOTTOM_LEFT;
}
else if (anchor.equals(RectangleAnchor.TOP)) {
result = TextAnchor.BOTT... |
757691ce-38bd-49b3-8bb5-12b3a9beafc0 | 9 | public void start2() {
wm = new double[20][Data.windows_size];
String QueryKinasesName = "%" + Data.kinease + "%";
//data.code = data.codenames[3];
String QueryCodeName = Data.code;
int windows_size = Data.windows_size;
//int windows_size = 9;
int shift = windo... |
16a0a547-496e-478c-8c2b-6b876988866c | 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... |
120281e5-7bc3-4219-9584-3f26bc3fab16 | 3 | public ArrayList<AdvancedLocation> getOccupiedLocation(MapLayer layer) {
switch (layer) {
case ActorLevel:
return this.makeAdvanced(super.getOccupiedLocations(), MapLayer.ActorLevel);
case FloorLevel:
return this.makeAdvanced(this.mapGrid.getOccupiedLocati... |
d9a18955-460c-4291-a0b8-4ec790048ca3 | 2 | private void tryMakeChildren(Herbivore female) {
if (female.femaleAgree()) {
this.setXPosition(female.getXPosition());
this.setYPosition(female.getYPosition());
this.timeOfInertion = 10;
female.timeOfInertion = 10;
this.previousAction = 8;
female.previousAction = 8;
this.passion = 100;
female.... |
6186463f-04b6-4d1b-8c6e-83f7439014f1 | 1 | public static void main(String[] args) {
RandomDoubles rd = new RandomDoubles();
for (int i = 0; i < 7; i++)
System.out.print(rd.next() + " ");
} |
ed88eadb-e52b-4a5a-9c18-7f9ff284d5fc | 3 | private boolean getJob(){
connect();
out.println(Command.GET_JOB);
try {
String jobsAvailable = in.readLine();
if(jobsAvailable == null || jobsAvailable.equals(Command.NO_JOB)){
System.out.println("Server has no jobs available");
return fal... |
e01119c2-e67c-4dbc-aa2e-104d99e3c4e9 | 5 | @Test
public void testSubtract() {
System.out.println("subtract");
Matrix<Complex> value = MatrixComplex.Value(0, 3, 0, 3, Complex.RealNumber(2.718281828));
MatrixComplex instance = this._matrix;
Complex[][] values = new Complex[3][3];
for (int r = 0; r < values.length; r++)
... |
12dbf74d-7bd4-4b7c-8940-8cca1e05277d | 3 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String page;
try {
AbstractCommand command = requestHelper.getCommand(request);
page = command.execute(request, response);
} catch (... |
39220ceb-04e7-4287-a69f-202a403e6c8d | 4 | public boolean fieldInCheck(Field checkField, Player player) { // Is specified field in check?
for (Field field : this.fields) {
if (field.hasPiece() && field.getPiece().isWhite != player.isWhite && field.getPiece().canAttack(this, field, checkField)) { // If opponent can attack check field
return true;
}
... |
0b1b96ac-6e5c-4f11-acf3-2121bf4dc36b | 3 | public ZElement getElement(String index)
{
if (index == Constantes.MCDENTITE1 )
return elem1;
else if (index == Constantes.MCDENTITE2 )
return elem2;
else if (index == Constantes.MCDASSOCIATION )
return elem3;
throw new IllegalArgumentException(""... |
d57f3e4a-0aa6-44e8-8ef2-8dbe98135117 | 6 | private void finalMerge0(int[] a, int low, int high) {
int mid = (low + high) / 2;
int i = low, j = mid;
int k = 0;
while (i < mid && j < high) {
if (a[i] < a[j]) {
temp[k++] = a[i];
i++;
} else {
temp[k++] = a[j];
... |
ad9af9b5-7de6-4e18-9622-c4de7d31b5f4 | 4 | @Override
public void remove() {
if(current == null) // empty iterator
return;
if(current.getPrev() != null)
current.getPrev().setNext(current.getNext());
if(current.getNext() != null)
current.getNext().setPrev(current.getPrev());
if(current.getPrev() == null)
map.root = current.g... |
326be3a5-a6a3-40fb-b33d-86bd028dcf26 | 4 | @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event) throws VanishNotLoadedException {
Player player = event.getPlayer();
String newQuitMessage = "";
newQuitMessage += this.plugin.getConfig().getString("server.quitmessage");
newQuitMessage =... |
6937dbfd-8da5-49e0-92c9-1d3ba75bfcc0 | 5 | private static double[] getResistPoints(int curvePoints,int lineNumber, double[] highPrices) {
double[] rPoints = new double[lineNumber];
for(int i =0;i<lineNumber-1;i++){
double price = 0;
for(int j=-curvePoints;j<=0;j++){
if((i+j>=0) && (i+j<lineNumber-1) && hig... |
e3386a44-a80c-4254-91c0-4742c8cad284 | 3 | public static String trimLeadingWhitespace(String str) {
if (!hasLength(str)) {
return str;
}
StringBuilder sb = new StringBuilder(str);
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
sb.deleteCharAt(0);
}
return sb.toString();
} |
21f5ea49-2ad6-417c-96ba-611be47b790e | 3 | public void accept(Visitor visitor) {
if (visitor.visit(this)) {
if (addr != null) {
addr.accept(visitor);
}
if (chan != null) {
chan.accept(visitor);
}
super.visitContainedObjects(visitor);
visitor.endVisit(this);
}
} |
735cd7b0-7f4e-4371-a7b9-062b48f0c79c | 4 | public Tile[][]changeY(Tile[][] piece, int offset)
{
for (int i = 0; piece != null && i < piece.length; i++)
for (int j = 0; j < piece[i].length; j++)
{
if (piece[i][j] != null)
... |
e0cde122-5d1e-4976-96bc-fea1c770edd4 | 9 | public int calculate(String s)
{
int n,r=0;
n=s.length();
Stack a=new Stack(n);
for(int i=0;i<n;i++)
{
char ch=s.charAt(i);
if(ch>='0'&&ch<='9')
a.push((int)(ch-'0'));
else
{
int x=a.pop();
... |
98f1cf5d-9754-48a3-8236-2c13b7606425 | 7 | @Override
public void update(GameContainer gc, StateBasedGame sbg, int delta)
throws SlickException {
int posY = Mouse.getY();
//Escape button below
if((posY<gc.getHeight()/3))
{
if(Mouse.isButtonDown(0)){
Barnacle.appgc.setDisplayMode(1280, 720, false);
... |
bcb3cef4-074e-443a-abb6-19e117b2474e | 5 | private void getNextPosition() {
// movement
if (left) {
dx -= moveSpeed;
if (dx < -maxSpeed) {
dx = -maxSpeed;
}
} else if (right) {
dx += moveSpeed;
if (dx > maxSpeed) {
dx = maxSpeed;
}
}
// falling
if (falling) {
dy += fallSpeed;
}
} |
ab38689f-559f-43b3-89f0-88bffb755aaa | 6 | @SuppressWarnings("unchecked")
private final void relocateInsert(ArrayList<Integer> hashs) {
for (Integer h : hashs) {
final ArrayList<Entry<K,V>> onle = (ArrayList<Entry<K,V>>)onl[h].clone();
for (Entry<K,V> e : onle) {
final HashCounter hc = new HashCounter(e.getK());
if (hc.mli!=e.getH()) {
onl... |
f435f3bd-d20b-492e-a0ec-93670c83d35b | 8 | private void classify(String inputFilename,
HashMap<String, LocationInfo> locations,
HashMap<Integer, UserInfo> users,
String outputFilename){
if ((new File(inputFilename).exists())){
// file exists, start reading data
try {
String line, location, result;
String[] splittedLine;
... |
018e5e81-6096-4ca2-b8fa-b5be1f60206b | 6 | @SubCommandHandler(name = "list", parent = "channel", permission = "multichat.channel.list")
public void channelListCommand(CommandSender commandSender, String[] commandArgs)
{
HelpScreen channelList = new HelpScreen("Channels List");
channelList.setHeader(StringUtil.formatColorCodes("&b<name> (Page <page> of <ma... |
8361bfa1-7cbe-4628-ac37-dce5e2a6669d | 2 | public void appendGap(int gapLength) {
byte[] code = bytecode;
int codeLength = code.length;
byte[] newcode = new byte[codeLength + gapLength];
int i;
for (i = 0; i < codeLength; ++i)
newcode[i] = code[i];
for (i = codeLength; i < codeLength + gapLength; ++i... |
3e95d1a1-517f-4423-87e2-672f55b2b885 | 6 | public static void spriteSheetToSubimages(SpriteSheet ss, SpriteSheetName name, Image[] spriteSheetTextureArray, Player player){
switch(name){
case block:
for(int i=0;i<spriteSheetTextureArray.length;i++)
spriteSheetTextureArray[i] = ss.grabSprite(Utility.STANDARD... |
9e709fcd-c5cc-4d38-bb95-3fa7f0054b62 | 2 | public static float findMaximum(Collection<Float> values) {
float MAX = Float.NEGATIVE_INFINITY;
for (float f : values)
if (f > MAX)
MAX = f;
return MAX;
} |
d523c667-3ed7-4cf2-ad49-290baea5bed0 | 2 | @Test
public void testSanitizeHtmlShortLengthMax() throws Exception {
String test = "";
for(int i = 0; i < 151; ++i) {
test += 'c';
}
try {
Sanitizer.sanitizeShortText(test).getCleanHTML();
} catch (org.owasp.validator.html.ScanException e) {
... |
3b95edd3-8da2-45e9-b727-48e7f9827471 | 0 | public BookingEntity() {
setId(System.nanoTime());
} |
cf139879-2f8b-49f5-bb2f-53ee0c42bef6 | 0 | public void addComboBox (String name)
{
invite.addItem(name);
} |
46ece8ce-b9f1-45bb-8396-e91a57bfe076 | 7 | private static boolean isContributingMethod(Method aMethod, Class aNativeClass){
boolean isPublic = Modifier.isPublic( aMethod.getModifiers() );
boolean hasNoArguments = aMethod.getParameterTypes().length == 0;
boolean hasReturnValue = aMethod.getReturnType() != Void.TYPE;
boolean returnsNativeObject = ... |
a2723d05-0233-4c21-a6a4-c28972e8110c | 5 | public void print() {
System.out.println("Name : "+name); // Affiche le nom.
System.out.println("Number : "+number); // Affiche le numero.
System.out.println("Color : "+color.toString()); // Affiche la couleur.
System.out.println("Towns:");
for (Town t: towns) { // Pour chaque ville.
System.out.print(t.get... |
94fff0c7-dfcd-4375-a487-fb34ad843650 | 4 | public void actionPerformed(ActionEvent event) {
if(event.getSource()==playButton) {
play();
}else {
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(event.getSource()==buttons[i][j])
click(i,j);
}
} |
e7f54b17-6839-425e-ba7a-1fe76b0145ff | 0 | @Test
public void singleDeleteByIndexSizeAndContent() {
a.insert(v);
a.delete(0);
// assertNull(a.get(0));
assertEquals(0, a.getSize());
} |
63d5e506-36c3-45da-be4b-ba9ec4d3333e | 1 | public void fillDeclarables(Collection used) {
for (int i = 0; i < subExpressions.length; i++)
subExpressions[i].fillDeclarables(used);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.