method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
9157e70a-f096-4b73-9526-cf928572462e | 9 | @Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
} else if (e.getID() == KeyEvent.KEY_RELEASED) {
if (e.isControlDown() && e.getKeyChar() != 'y' && e.getKeyCode() == 89) {
System.out.println("ctrl + y - ... |
4141e942-a213-44c6-be29-10977dea4bb9 | 8 | @Override
public void addValeur(Valeur valeur) throws ProfondeurMaximaleAtteinteException {
int cle = valeur.getCle();
if (arbre.getRacine() == null) {
arbre.setRacine(new NoeudBinaireImplementation(valeur));
} else {
int i = 2;
NoeudBinaireImplementation... |
80010775-194a-47f1-a244-39197bf81cdb | 6 | public boolean containsKey(K key) {
if (root == null)
return false;
Node node = root;
while (true) {
if (key.compareTo(node.mKey) < 0) {
if (node.left == null)
return false;
else
node = node.left;
} else if (key.compareTo(node.mKey) > 0) {
if (node.right == null)
return f... |
05430766-eab9-4833-b1d1-2051fe0d144d | 0 | public EvenChecker(IntGenerator g, int ident) {
generator = g;
id = ident;
} |
2053bf7c-58ff-4985-af09-4c140f9061fd | 5 | public <T> Object doInvoke(MethodInvocation invocation) {
// 统一异常处理,日志,参数检查
try {
return invocation.proceed();
} catch (PrecondictionException e) {
logger.error("Precondiction Error", e);
return new CommonResp<T>(false, e.getErrorCode(), e.getMessage());
} catch (BizException e) {
String errorDesc =... |
417e88aa-5014-4e24-96bd-0bb158b389ea | 1 | public static String formatDate(Date date) {
return isToday(date) ? TODAY.format(date) : NOT_TODAY.format(date);
} |
777eb292-baee-412a-9abf-d6f6b25eb752 | 0 | @Override
public int compareTo(Shape shape) {
return Double.compare(getArea(), shape.getArea());
} |
cbdd5dd9-0ecf-4897-b37e-c187ed8735e7 | 7 | public static void main(String[] args)
{
SkipListOfStrings ss = new SkipListOfStrings();
if (! ss.contains("a"))
{
System.out.println("a is not in the list");
} // if
ss.add("a");
ss.add("bb");
ss.add("ccc");
ss.add("dddd");
ss.add("eeeee");
if (ss.contains("... |
a9a0c9e0-ff9a-49af-a782-7084fb443efc | 3 | public static ArrayList<Rating> getTestSet(String file) {
ArrayList<Rating> testset = new ArrayList<Rating>();
InputStream fis = null;
BufferedReader br;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
br = new ... |
86291b8d-2793-4be0-b1c8-53c0b8745113 | 4 | public Army split(Army newArmy) {
Army h = new Army();
for(Legion l : newArmy.getUnits()) {
for(Legion a : units) {
if (l.getType() == a.getType()) {
if(l.getCount() > a.getCount()) {
l.setCount(l.getCount() - a.getCount());
h.add(a);
} else {
h.add(l);
remove(l.getType());... |
c894078d-a2a7-40f1-963e-4ad2bd199be8 | 3 | @Override
public void setDefaultChannel(ChatChannel channel)
{
this.defaultChannel = channel;
if (defaultChannel != null)
{
for (ChatChannelPlayer channelPlayer : players.values())
{
if (channelPlayer.getCurrentChannel() == null)
{
defaultChannel.join(channelPlayer.getPlayer());
chann... |
4248a54b-f327-4d4c-92b8-4fd5327fac6a | 4 | private void updateLeftAndRight() {
final StringBuilder sb = new StringBuilder();
for (final ChangedFile f : this.unstagedFiles.values()) {
if (sb.length() == 0) {
sb.append("<html><font face=\"Courier New\">");
} else {
sb.append("<br/>");
}
sb.append(f.toString());
}
sb.append("</font></h... |
8d6add60-161d-4e2e-bc59-1ce478a534c0 | 9 | public void scrollCellToView(JTable table, int rowIndex, int vColIndex) {
if (!(table.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Rectangle viewRect =... |
1e05bb62-00c1-4228-b6f3-af22d3313e4c | 8 | public Wave50ChampionBlue(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 4500; i++){
if(i % 8 == 0)
add(m.buildMob(MobID.GYARADOS));
else if(i % 8 == 0)
add(m.buildMob(MobID.PIDGEOT));
else if(i % 6 == 0)
add(m.buildMob(MobID.CHARIZARD));
else if(i % 5 == 0)
add(m.buil... |
bf402c59-744f-461f-aa76-3d6e0bc1f831 | 4 | public ArrayList<Unit> getPlayersUnits(Player player) {
ArrayList<Unit> units = new ArrayList<Unit>();
for (Cell[] cell1 : cells) {
for (Cell cell : cell1) {
if (cell.getUnit() != null) {
if (Teams.comparePlayers(cell.getUnit().getOwner(), player)) {
units.add(cell.getUnit());
}
}
}
... |
99e05111-e88a-4758-8f71-b29975717e21 | 3 | public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace... |
dcf939ad-5344-434b-a35a-8c01b90d499e | 5 | private Method findMethod(Class clazz, String callName, Argument[] args)
{
Method method = null;
METHOD_LOOP:
for (Method m : clazz.getMethods())
{
if (!m.getName().equals(callName)) continue;
Class[] paramTypes = m.getParameterTypes();
if (args.length != paramTypes.length) continue;
for (i... |
3bbc62ec-85e4-43a1-a6f2-67914a341b71 | 0 | public void method1() {
this.method2();
} |
9a9ea68f-42f7-476f-a1e0-e5fd381c3ed1 | 2 | @Override
public int filterRGB(int x, int y, int argb) {
if (mIncludeAlpha || (argb & OPAQUE) == OPAQUE) {
int darkenBy = (int) (((argb >> 16 & 255) * 0.3 + (argb >> 8 & 255) * 0.59 + (argb & 255) * 0.11) / 2.55);
argb = argb & OPAQUE | mRed * darkenBy / 100 << 16 | mGreen * darkenBy / 100 << 8 | mBlue * darke... |
66305641-e3a4-4a8f-a559-a0aff26cbaf7 | 0 | public int getDirection() {
return this.direction;
} |
c94573d0-4b74-4a30-ba5e-f672afc292c6 | 6 | @Override
public void handle(KeyEvent keyEvent) {
TextField txt_TextField = (TextField) keyEvent.getSource();
if (txt_TextField.getText().length() >= maxLength) {
keyEvent.consume();
}
if(keyEvent.getCharacter().matches("[0-9.]")){
if(txt_TextField.getText().c... |
6169b8e6-f27f-45a5-9c00-aae59ea8efcd | 3 | private void newAttachmentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newAttachmentButtonActionPerformed
JFileChooser filechooser = new JFileChooser();
filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = filechooser.showOpenDialog(null);
... |
c25c5c05-fd80-4a00-b951-36a2d8f228e6 | 3 | public synchronized MessageBlock getNextBlock(final int size, final long time) {
int length = size;
int offset = currentOffset;
/*
* Search first for block to resent.
*/
MessageBlock mb = checkForMissingBlocks(size, time);
if (mb != null)
return mb;
/*
* Then send the next block if available.
... |
2ee85d27-8583-488f-a10a-d9a9b8fad388 | 2 | public RondPoint(int taille) {
int j, i;
VoieInterne vi, suivante;
VoieExterne sortie;
ArrayList<VoieEnum> voiesEnum;
voiesExternes = new ArrayList<VoieExterne>();
voiesInternes = new ArrayList<VoieInterne>();
voiesEnum = new ArrayList<VoieEnum>();
for (i = 0; i < 4; i = i ... |
92bd4bec-1251-41d8-89c9-90248bcf63e9 | 2 | public static Tile get(int id) {
for (Tile tile : tiles)
if (tile.tileID == id) return tile;
return tileVoid;
} |
5d47d63d-ac30-40ed-acee-63a314b7b28e | 3 | @Override
public void run() {
getNetworkHandler().fireNetworkEvent(new NetworkEvent(NetworkEvents.START_CLIENT, "Starting client..."));
setClient(true);
setServer(false);
echoSocket = setUpConnection(port, hostname);
// return if connection went to hell or w/e
if (echoSocket == null)
return;
getNetw... |
8b0c8a84-da79-400a-9dfb-d479bce04bcb | 8 | public Token next() throws IOException
{
// reset the value builder
value.setLength( 0 );
// if there's a token waiting, return it
if( next != null )
{
current = next;
next = null;
return current;
}
while( true )
{
int read = source.read();
if( read == -1 )
{
if( value.length() ... |
bf032eb9-8db3-4313-a92b-5c7f4549a530 | 3 | public void setParamValues(double[] paramValues) {
this.paramValues = paramValues;
int index = 0;
for (int i = 0; i < paramData.length; i++) {
double[] data = new double[paramData[i].getCalibrationDataSize()];
if (paramValues.length < data.length) {
... |
f968240f-e161-4c47-b319-05feaf18f3e2 | 6 | public static List<String> splitLine(String l)
{
StringBuilder[] builders = new StringBuilder[] { new StringBuilder(), new StringBuilder(), new StringBuilder() } ;
int segment = 0;
boolean seeking = false;
for (int i = 0; i < l.length(); i++)
{
char next = l.charAt(i);
if (Character.isWhitespace(ne... |
c80e8b35-9de4-4bb2-90fa-05f5705a1ae1 | 8 | public static int countNeighbours(long world, int col, int row) {
int c = 0;
if (getCell(world, col - 1, row - 1) == true) {
c += 1;
}
if (getCell(world, col, row - 1) == true) {
c += 1;
}
if (getCell(world, col + 1, row - 1) == true) {
c += 1;
}
if (getCell(world, col - 1, row) == true) {
... |
343d5f25-07e0-4fce-8b48-2f1720b41570 | 9 | public static void parseVaccFile(String file) {
int[] numVaccines = VaccinationSimulation.numberOfVaccinesSpread;
String[] fractions = {"1.0","0.8","0.6","0.4","0.2"};
String[][] data = new String[numVaccines.length][fractions.length];
int row = 0;
int col = 0;
try {
BufferedReader in = new BufferedReade... |
72c1ed49-b938-4aa5-b11c-14c7d720fd23 | 0 | public void MenuFrame()
{
JFrame menuFrame = new JFrame("Menu Tool ");
JMenuBar jMenuBar = new JMenuBar();
JMenu m1 = new JMenu("File");
JMenu m2 = new JMenu("Save");
JMenu m3 = new JMenu("load");
JMenu m4 = new JMenu("Quit");
JMenuItem i1 = new JMenuItem("New File");
JMenuItem i2 = new JMenuI... |
05c9228e-b6a1-4ee1-ac9c-887848c324f2 | 1 | public boolean end() {
return this.eof && !this.usePrevious;
} |
55d5356f-313e-4e9a-ae7c-d0f06f21916b | 1 | public void actionPerformed(ActionEvent event) {
Component source = null;
try {
source = (Component) event.getSource();
} catch (Throwable e) {
// Might not be a component, or the event may be null.
// Who cares.
}
performAction(source);
} |
13ad68f7-7d54-4617-9a1b-b742e68e5115 | 5 | public Action(Peg x, Peg y, Peg z, Action parent, int type, int diskNum)
{
this.x = x;
this.y = y;
this.z = z;
this.diskNum = diskNum;
while ((width = 3 * Peg.width + horMargin*4) <= 250) {
horMargin += 10;
}
height = Peg.height + vertMargin*2;
... |
beaec1e2-b9b3-4ca7-932f-19d6c3e2046f | 2 | public ComplexMatrix(Complex[][] m) throws Exception {
/*
* Here (i, j) notation is used. i - a row index j - a column
* index j=1 j=2
* i=1 [ [ 11, 12],
* i=2 [ 21, 22] ]
*
* c o l s
* r [ [ 11, 12, 13],
* o [ 21, 22, 23],
* w [ 31, 32, 33] ]
* s
... |
f6abc74e-308a-44aa-ab5a-a3f85331fad0 | 4 | public void doPost( HttpServletRequest req, HttpServletResponse reponse ) throws ServletException, IOException{
req.setCharacterEncoding("UTF-8");
// Création de l'objet
String id = req.getParameter("id");
if(id != null)
{
User user = ofy().load().type(User.class).parent(KeyFactory.createKey... |
b8e674c6-ae9b-4d74-b277-4e8496c2692e | 4 | public static int characterSize(int character) throws JSONException {
if (character < 0 || character > 0x10FFFF) {
throw new JSONException("Bad character " + character);
}
return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3;
} |
e786e0b5-671f-48e8-8cb1-dfbd51098ba1 | 1 | public void Stop()
{
if (isRunning)
isRunning = false;
} |
2b9e2a77-4a67-4479-8f59-0105e5bd872b | 1 | public void insertEnd(int red, int green, int blue, Object runlength) {
if (size == 0) {
setHead(tail = new SListNode((short) red, (short) green,
(short) blue, runlength, null));
} else {
tail.next = new SListNode((short) red, (short) green, (short) blue,
runlength, null);
tail = tail.next;
}
... |
87fcad5a-8b71-49e0-aaf8-0c6a92453542 | 6 | public void run() {
synchronized(this){
try {
URL Url = new URL(this.url);
URLConnection conn = Url.openConnection();
conn.setDoOutput(true);
conn.setReadTimeout(10000);
status=true;
returned=false;
JProgres... |
f9be50ea-af79-4950-a28a-28d5f06b7fb0 | 1 | @Override
public int attack(double agility, double luck) {
if(random.nextInt(100) < luck)
{
System.out.println("I just threw a fire ball!");
return random.nextInt((int) agility) * 2;
}
return 0;
} |
a6142fe0-7c40-4eb5-a9ee-4992a6945fe7 | 1 | public void setCombineAnimation(boolean combineAnimation) {
this.combineAnimation = combineAnimation;
if(combineAnimation) scaleCombine = 1.5;
} |
9241f2ad-7401-4dc1-adfa-20573fdfc569 | 9 | public void formAndCallURL(int URLid)//location
{
String location=null;
if(URLid == 0) //Stereograhic projection
{
//Get location from html file
location = getParameter("location0");
}
if(URLid == 1) //Lamber Conformal Conic
{ ... |
787622e4-aa17-49de-b907-f6e233b19d1e | 9 | public void addTumorTab(Tumor tumor){
TumorPanel tumorPanel = new TumorPanel();
tumorPanel.setBackground(xipColor);
//add adjudicator
JTabbedPane tabbedPanePrevReport = new JTabbedPane();
JTextArea textAreaPrevReport = new JTextArea(10, 70);
textAreaPrevReport.setBackground(xipLightBlue);
textAre... |
3eadc50a-6004-4b7a-bf21-bddaf9126cdc | 5 | private Node nodeIfInBounds(int x, int y) {
if(x > 0 && y > 0 && x < map.getWidth() && y < map.getHeight() && !map.isBlocked(new Vector2(x, y)))
return nodes[x][y];
return null;
} |
6c45bca4-4edc-46fa-8510-a1c5770a50bf | 8 | @Override
public boolean beginPath(final NestedTimerPath root, final TimerStatistics call) throws IOException {
sb.append(getPre());
if (call != null) {
final boolean belowThreshold = call.getTotalNanos() < totalNanosThreshold;
final boolean currentlySkippedLevelChanges = roo... |
24e4842d-0887-4b8c-9e49-1bbacdaa977c | 9 | public static void main(String args[]){
initDisplay();
drawDisplay();
canvas.setPaint(Color.BLACK);
canvas.drawString("You go first: drag your mouse between two vertices to move.", 100, 550);
// comment-in the second line and comment-out the first to use your Player class... |
9a72059c-da26-4731-8674-0acc3d0406fa | 2 | public PlayerGridFactory(Grid grid, FullGridFactory factory) {
if (grid == null)
throw new IllegalArgumentException("Grid can't be null!");
if (factory == null)
throw new IllegalArgumentException("Factory can't be null!");
this.factory = factory;
this.grid = grid;
generatePlayerList(2); // Default se... |
c050d4c8-18ca-4c29-889b-aa396887567f | 4 | public StructuredBlock prevCase(StructuredBlock block) {
for (int i = caseBlocks.length - 1; i >= 0; i--) {
if (caseBlocks[i].subBlock == block) {
for (i--; i >= 0; i--) {
if (caseBlocks[i].subBlock != null)
return caseBlocks[i].subBlock;
}
}
}
return null;
} |
3f490258-cf93-458b-a380-e7a52acdcda4 | 5 | public static void apply(Op op) {
Document doc = textArea.getDocument();
int pos = textArea.getCaretPosition();
if (op == null)
return;
try {
if (op.getOpType() == OpType.INSERT_CHAR) {
Insertion insertion = (Insertion) op;
//builde... |
22478e04-889a-47fc-b181-ebfddc602dc6 | 0 | public StopWatch() {
start = System.currentTimeMillis();
} |
9403e274-c2a7-4634-abee-c5947b222553 | 3 | int getUTFIndex(String str) {
// Check if it is in the pool already
Integer index=UTFs.get(str);
if (index==null) { // add UTF to the pool
index=new Integer(poolEntries++);
try {
constPool.write(1); // CONSTANT_Utf8 = 1;
constPool.writeUTF(str);
} catch (java.... |
06c2399b-015e-45de-8900-1cfcd3696ed8 | 7 | private boolean touchVertically(Line first, Line second ) {
Point fEnd = first.getEnd();
Point sEnd = second.getEnd();
if (fEnd.getX() != sEnd.getX()) {
return false;
}
Point fStart = first.getStart();
Point sStart = second.getStart();
if ((fStart.... |
ca37a2ed-d59a-4165-90f3-d195a8b3252a | 0 | public void setFunFecmod(Date funFecmod) {
this.funFecmod = funFecmod;
} |
5ae2e403-2243-41ad-8147-efbba34420a1 | 7 | @Override
public void action() {
this.parentAgent = ((PatientAgent) this.myAgent);
switch (step) {
case 1:
if (parentAgent.getHospitalAgent() != null) {
step++;
} else {
block();
}
break;
case 2:
if (((PatientAgent) this.myAgent).getAppointment() != 0) {
step +=2;
} else {
... |
b6f5219d-643d-4eff-a7e3-daa11fa4204e | 9 | public void clearTheSkys(Hashtable<Room,MapRoom> mapRooms)
{
for(final Enumeration<Room> e=mapRooms.keys();e.hasMoreElements();)
{
final Room R=e.nextElement();
final Room UP=R.rawDoors()[Directions.UP];
if((UP!=null)
&&(UP.roomID().length()==0)
&&(UP instanceof GridLocale))
{
final List<Room... |
a88b8cdc-0276-4d71-922d-cc43426885a9 | 2 | @Override
public void command(Command command) {
switch (command) {
case OPEN:
if (open) {
open = false;
passable = false;
opaque = true;
spriteID = closedsprite;
} else {
... |
e5a251e7-5a85-4661-affc-02af0f65ab20 | 0 | @Test
public void findHighestFlushOrStraight_whenFlushOrStraightPossible_returnsFlush() {
Hand hand = findHighestFlushOrStraight(sixFlushWithStraight());
assertEquals(HandRank.Flush, hand.handRank);
assertEquals(Rank.Jack, hand.ranks.get(0));
assertEquals(Rank.Ten, hand.ranks.get(1));
assertEquals(Rank.Nine,... |
863cc2a3-10db-4f6c-b95f-911397640ec9 | 5 | @SuppressWarnings("unchecked")
protected Object readResolve() throws ObjectStreamException {
try {
Class messageClass = Class.forName(messageClassName);
Method newBuilder = messageClass.getMethod("newBuilder");
MessageLite.Builder builder =
(MessageLite.Builder) newBuilder.... |
caa0bd2b-06bb-4cc9-aa90-da40fe3c37ca | 7 | public String dibujarMunieco() {
String retornar = "";
switch (this.cantidadErrores) {
case 0:
retornar = " ";
break;
case 1:
retornar = " " + "O" + "<br>";
break;
case 2:
retornar = " " + "O" + "<br>" + "/";
break;
case 3:
retornar = " " + "O" + "<br>" + "/" + "|";
break;
case 4:
... |
6dd0e38e-c09e-4f84-ad8a-88348af0b2c7 | 2 | public int compare(RegisteredChunkyListener i, RegisteredChunkyListener j) {
int result = i.getPriority().compareTo(j.getPriority());
if ((result == 0) && (i != j)) {
result = 1;
}
return result;
} |
09fb7891-1383-432e-96e6-d027f804530f | 7 | public static List<File> getFileList(String loc, String fileEnd)
{
if (fileEnd == null)
{
fileEnd = "";
}
if (loc == null)
{
loc = dir;
}
// Directory path here
String file;
File folder = new File(loc);
File[] li... |
d3159185-3f68-41df-89dc-b570e60771c0 | 4 | public static Image exponentialNoise(Image original, double lambda, double p) {
if (original == null)
return null;
Image expo = original.shallowClone();
for (int x = 0; x < original.getWidth(); x++) {
for (int y = 0; y < original.getHeight(); y++) {
double rand = Math.random();
double noise = 1;
... |
824adb2b-139d-4dd9-aa83-4d5293ee23a0 | 7 | protected void paintComponent(Graphics g){
super.paintComponent(g);
//System.out.println("repainted");
Graphics2D g2 = (Graphics2D) g;
//draw the player
Player player = GUI.g.player;
Image img = player.playerImage;
g2.drawImage(img, player.xPosition, player.yPosition, null);
//draw items
fo... |
1d0508e9-596a-447b-a5ac-ba599222dbe4 | 4 | public void testInit() {
for (int x = 24995; x < 25000; x++) {
int y = 25001;
worldHash.addTile(x, y, Tile.WALL_STONE);
}
for (int x = 25001; x < 25005; x++) {
int y = 25001;
worldHash.addTile(x, y, Tile.WALL_STONE);
}
worldHash.add... |
34865a22-a7d2-4bb2-a91b-bee9690a1a8b | 8 | public ArrayList<Integer> grayCode(int n) {
ArrayList<Integer> result = new ArrayList<Integer>();
if (n == 0)
return result;
// form two arrays, digitArray is digit from lower position to higher
// position, so digitsArray[0] meaning 0/1 on the lowest position of n,
// valueArray is decimal value represe... |
3442d5d3-837f-44c4-9c5f-9b6efe98fb80 | 9 | public void draw(GOut g) {
if (!Config.showMyAvatar)
this.c.x = newc;
else
this.c.x = oldc;
int i = 0;
int w = frame.sz().x + margin;
long now = System.currentTimeMillis();
synchronized (ui.sess.glob.buffs) {
for (Buff b : ui.sess.glob.... |
9a4da7a9-00fd-458b-9e1a-bf6236bc1e1f | 9 | public void run() {
try {
// start read server
Selector selector = Selector.open();
ServerSocketChannel server_channel = ServerSocketChannel.open();
server_channel.configureBlocking(false);
server_channel.socket().bind(new InetSocketAddress("localhost", read_port));
server_channel.registe... |
7f8d2b8d-ae13-48dd-96ca-494f601ff169 | 3 | @Override
public void evaluateLabels(Map<String, Integer> labelValues, int position)
throws TokenCompileError {
data.evaluateLabels(labelValues, position);
int dest = data.getUnresolvedWord();
int delta = dest - position;
// Q: If the instruction's size might be 2 words, the... |
7ec0d15c-e3fc-4585-a768-8a22d8134808 | 6 | public static void manageStudents() {
System.out.print("Do you want to add (0) or delete (1) a student ? ");
int res = -1;
while (res < 0 || res > 1) {
Scanner sc = new Scanner(System.in);
res = sc.nextInt();
}
switch (res) {
case 0:
createStudent();
break;
case 1:
if (FileReadService.sL... |
321d2acb-f3a7-4f61-9a9b-0fb40ee0c128 | 2 | public
boolean isOK() {
if (getTitle()==null || getTitle().isEmpty())
return false;
return true;
} |
a3931b21-f62d-4782-91cc-0f8c72f94a12 | 1 | public boolean addOneProduct() {
if (quantity < product.getStock()) {
quantity++;
return true;
}
return false;
} |
115b7286-7cce-415b-aa96-0b54fd9552de | 5 | public boolean loadBoard(String[] countriesArray, String[] adjacenciesFileArray, String[] continentsFileArray) {
isLoaded = false;
countriesMap = new HashMap<String, Country>();
continentsMap = new HashMap<String, Continent>();
// Populates countriesMap
for (i = 0; i < countriesArray.length; i++) {
... |
6a421e44-3bb5-4924-900c-e8b2513675cc | 6 | public int indexOfItemId(int itemId) {
int beginIndex = 0, halfIndex, endIndex = itemIds.length;
if(itemIds.length > 0) {
while(true){
halfIndex = (endIndex - beginIndex) / 2 + beginIndex;
if(itemId < itemIds[halfIndex]){
if(endIndex - beginIndex <= 1){
return -1;
}
endIndex = halfIn... |
7df05497-6c6c-4784-9894-8f2a0259bdab | 0 | public void mouseClicked(MouseEvent e)
{
System.out.println("Click Mouse !");
} |
1e13d876-62be-4acd-9495-9771fbb5183f | 8 | public static void javaDetails(File fileName, DetailObject detailObject) {
detailObject.updateNumberOfFiles();
DetailObject.updateTOTAL_NUMBER_OF_FILES();
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = bufferedReader.readLine()) != null) {
... |
e47f24a8-c93d-45c6-9b3a-14b35b26d2ed | 8 | public void receiveFrame(USART.Frame frame) {
int data = frame.value;
if (mode) { // Instruction mode
switch (data) {
case CLEAR_SCREEN:
clearScreen();
break;
case SCROLL_LEFT:
scrollLeft();
... |
359ef430-b202-4c24-8e9c-93829a1d15e2 | 2 | int bitDiff(int a, int b) {
int count = -1;
while (a < b && b < 0) {
b <<= 1;
count++;
}
return count;
} |
14a7c6b0-b3ab-40f9-a41d-b4a95d591a58 | 3 | public ArrayList<Ocupacion> resultQueryOcup(String sql){
ArrayList<Ocupacion> ocuList = new ArrayList<Ocupacion>();
try {
rs = stm.executeQuery(sql);
try {
while(rs.next()){
Ocupacion item = new Ocupacion(rs.getInt("idocupacion"),
rs.getString("ocupacion"));
ocuList.add(item);
... |
9d90ac5b-a670-4e59-a124-f5192443460c | 3 | public void taBort (String hornNamn)
{
Punkt[] h = new Punkt[this.horn.length - 1];
int i = 0;
int j = 0;
while (i < horn.length && j < h.length) {
if (hornNamn == horn[i].getNamn()) {
i++;
}
else {
h[j] = horn[i];
i++;
j++;
}
}
this.horn = h;
} |
9cc65598-3432-4db8-9fe2-a006315835da | 8 | public final NTSParser.dvar_annot_return dvar_annot() throws RecognitionException {
NTSParser.dvar_annot_return retval = new NTSParser.dvar_annot_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token name=null;
Token LPAR_S76=null;
Token RPAR_S78=null;
... |
422569d1-1106-4232-acfd-67458dcc8772 | 6 | @SuppressWarnings("unchecked")
public static <T extends Number> T mul(T e1, T e2, Class<T> type) {
T result = ElementOpUtils.getNeutralMulElem(type);
switch (type.getSimpleName()) {
case "Byte":
return (T) (Byte) (byte) ((Byte) e1 * (Byte) e2);
case "Short":
return (T) (Short) (short) ((Short) e1 * (S... |
0eb91505-876d-49e6-8404-4b15ada24f9f | 7 | private GASolution<int[]> algorithmRun() {
GASolution<int[]> best = null;
for (int iter = 0; iter < maxiter; iter++) {
gBestChanged = false;
evaluate();
// for (int i = 0; i < popSize; i++) {
// evaluator.evaluate(population.getSolAt(i));
// }
best = Collections.min(population.getSols());
if (glo... |
6240666e-bf2a-470a-a26b-34f9bc2daca8 | 8 | protected void optimize1() throws Exception {
//% main routine for modification 1 procedure main
// while (numChanged > 0 || examineAll)
// numChanged = 0;
int nNumChanged = 0;
boolean bExamineAll = true;
// while (numChanged > 0 || examineAll)
// numChanged = 0;
while (nNumCha... |
9ea5a587-4b95-46e4-ab0f-860de61c3098 | 9 | public int isInside(int p_x, int p_y)
{
for (Rectangle r : rectList)
{
if((r.getX()<p_x && p_x<(r.getX()+r.getWidth())) && (r.getY()<p_y && p_y<(r.getY()+r.getHeight())))
{
return rectList.indexOf(r);
}
}
if((getX()<p_x && p_x<(getX()+getWidth())) && (getY()<p_y && p_y<(getY()+getHeight())))
... |
ca66b1c2-d964-405e-a698-f6e56939c5d5 | 4 | public void timedTipActions(){
if(showTip1){
tipSteps++;
switch(tipSteps){
case 1:{
drawTip1 = true;
break;
}
case 2:{
drawTip1 = false;
drawTip2 = tru... |
402e1aea-1d9e-4a98-9b54-13c0b73e6f26 | 8 | public AbstractEntity getEntity(String name) {
if (!entityCache.containsKey(name)) {
//create it from a string
boolean isSolid = true;
int buyValue = -1;
int sellValue = -1;
Element root = document.getRootElement();
for (Iterator i = root.elementIterator(); i.hasNext(); ) {
... |
c85d14ad-a158-4b3b-b8d2-3b2bfffbf361 | 3 | * if the Loop is empty
*/
public E removeCurrent() {
E tmp = curr.getData();
if (tmp == null || numItems == 0)
throw new EmptyLoopException();
if (numItems == 1) {
msgLoop = new DblListnode<E>();
numItems--;
return tmp;
}
curr.getPrev().setNext(curr.getNext());
curr.getNext().set... |
0ec59c37-2927-42b6-9631-65b6055fd656 | 1 | public void handlePlayerInventoryClick(InventoryClickEvent e) {
if(e.getSlotType() == ARMOR) {
e.setCancelled(true);//Doesn't work in creative mode (Bukkit bug)
((Player)e.getWhoClicked()).updateInventory();
}
} |
10e3896d-4543-4e8a-80e9-c0c50152d100 | 8 | public static boolean hasAtLeastOneMethodWithName(Class<?> clazz, String methodName) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
Method[] declaredMethods = clazz.getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getName... |
e51cccb4-7958-44da-818f-90165dd47523 | 7 | public void insertString(int offs, String str,
javax.swing.text.AttributeSet a) throws BadLocationException
{
String texto = getText(0, getLength());
try
{
if (Character.isDigit(str.charAt(0)))
{
super.remove(0, getLength());
texto = texto.replace(".", "");
StringBuffer s = new StringBuffe... |
85173dd6-a15e-4698-a98b-04775c85beaa | 2 | public static void setWordWrap(IEditorPart editor, boolean state) {
if (editor == null) {
return;
}
// editor (IEditorPart) adapter returns StyledText
Object text = editor.getAdapter(Control.class);
if (text instanceof StyledText) {
StyledText styledText ... |
6aedc6f9-e656-4dc4-88df-621313872077 | 4 | public void start() {
timer.schedule(new TimerTask() {
public void run() {
update();
timer.cancel();
}
private void update() {
try {
String line;
BufferedReader in = new BufferedReader(
new InputStreamReader(JFrameMain.proc
.getErrorStream()));
while ((line = in.r... |
dec44c8b-a8d9-43db-9351-7085baec32cf | 1 | private void loadFromFile() {
try {
FileInputStream file = new FileInputStream(filename);
properties = new Properties();
properties.loadFromXML(file);
file.close();
} catch (Exception e) {
System.err.println( e.getMessage() );
}
} |
4708df8e-c4a7-4017-8f4a-7fb6e0832259 | 9 | public IP4(int t1, int t2, int t3, int t4) throws MalformedIPException {
StringBuffer errorMessage = new StringBuffer("");
if ((t1 < 1) || (t1 > 254))
errorMessage.append(
"tuple1 is malformed. Must be between 2 and 254.\n");
if ((t2 < 1) || (t2 > 254))
errorMessage.append(
"tuple2 is malformed. ... |
41c9a147-aa73-4f69-82d3-addc10fd2807 | 2 | public void doA03(MsgParse mp)
throws SQLException {
if (!mp.visit.getPatient_class().isEmpty())
try {
// use the mrn in the A03 to identify the patient (we want the pid)
// use patient.pid as visit.patient_pid
// where visit.patient_pid = patient.pid
... |
60088a81-f001-44b7-80d5-885f79f44719 | 2 | public static void main(String[] argsv) {
// Setting op a bank.
Bank christmasBank = new Bank();
christmasBank.addAccount(new BankAccount(BigInteger.valueOf(100)));
christmasBank.addAccount(new BankAccount(BigInteger.valueOf(50), BigInteger.valueOf(-1000)));
// Print the balanc... |
02e8d0b5-cfa3-475d-bd16-660d8eac51f5 | 7 | public static void qsortSpecialForRoman(int a[], int l, int r){
if(l>=r) return;
int i=l, j=r, m=i+j>>1;
do{
while(a[i]<a[m]) ++i;
while(a[j]>a[m]) --j;
if(i<=j){
int t=a[i]; a[i]=a[j]; a[j]=t;
++i; --j;
}
}w... |
e2efd3ab-c248-46c0-a4da-12a276b17318 | 1 | @Test
public void testListMock() {
NoteService s = new MockNoteService();
for (Iterator<NoteEntity> iter = s.list().listIterator(); iter.hasNext();) {
NoteEntity note = iter.next();
System.out.println(note);
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.