method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4cffc852-03ca-46a2-9ed4-cca939cee5f1 | 5 | public void tick() {
// Calculating FPS
if (this.fps > 0) this.delta = 1000 / this.fps;
if (!Param.isPause()) {
if (!Param.isTitleScreen() && !Param.isEndScreen()) {
// Update the offset location
offX = (player.getX() - dimension.width / 2) + index;
offY = (player.getY() - dimension.height / 2) ... |
52f70e26-8063-4178-aa75-fd59607e3a67 | 5 | private void addModeConversionAndModeRuleConflict(final Theory theory, final String str) throws ParserException {
int l = -1;
if ((l = str.indexOf(DflTheoryConst.SYMBOL_MODE_CONVERSION)) > 0) {
String o = str.substring(0, l).trim();
String c = str.substring(l + DflTheoryConst.SYMBOL_MODE_CONVERSION.length()).... |
6f8e21e4-1b4e-486f-807a-60499dff5f9c | 8 | public void flip() {
Wire wire1 = ports[0].myWire;
Wire wire2 = ports[1].myWire;
if (wire1 != null) {
if (wire1.fromPort == ports[0]) {
wire1.fromPort = ports[1];
}
if (wire1.toPort == ports[0]) {
wire1.toPort = ports[1];
... |
a686f00e-a09d-4806-adfd-1ec429cee158 | 2 | private void growth() {
for (int i = 0; i < _cities.size(); i++) {
_cities.get(i).increasePopulation();
}
for (int i = 0; i < _econ.size(); i++) {
_econ.get(i).grow();
}
} |
f09abc5a-c5a5-4c0c-871e-b86a1fd3a72f | 8 | private static ArrayList<String> parenthSubExpr(String expr,
int splitIndex, boolean leftResult, boolean rightResult,
HashMap<String, ArrayList<String>> cache) {
ArrayList<String> leftSub = parenthExpr(expr.substring(0, splitIndex),
leftResult, cache);
ArrayList<String> rightSub = parenthExpr(
expr.su... |
97161032-bfb2-4daa-8206-1c8ac02fcf5b | 0 | public DatePane() {
this.setLayout(new BorderLayout());
this.add(total, BorderLayout.NORTH);
this.add(search, BorderLayout.CENTER);
} |
90c515df-a1fb-4a7a-9c29-12c93222307b | 2 | public void setElement(int x, int y, int value) {
if (x < matrix.length && y < matrix[x].length) {
matrix[x][y] = value;
}
} |
df2942ef-caf3-4db4-9c88-b8aafbaacfaa | 5 | private Stock fromJson(JSONObject stockJson) {
try {
Stock ret = new Stock();
ret.setSymbol(stockJson.getString("Symbol"));
if (!stockJson.isNull("LastTradePriceOnly"))
ret.setAsk((float) stockJson.getDouble("LastTradePriceOnly"));
if (!stockJson.isNull("Bid"))
ret.setBid((float) stockJson.getDoub... |
36c80dfa-b3ae-466c-98e2-74aca91d5a82 | 3 | public void run() {
ServerSocket svrSkt = null;
try {
svrSkt = new ServerSocket(port+2); // Set up socket
} catch (IOException e) { // IF socket cant be established
System.err.println("Could not listen on port: "+(port+2));
System.exit(-1);
}
while (true) {
try { // On new connection, create a ... |
892faef4-c9c0-41f3-be1c-e78644255894 | 1 | public static synchronized TaskManager getInstance() {
if (instance == null) {
instance = new TaskManager();
}
return instance;
} |
8151ddac-dab6-4777-b118-5960fdaa3793 | 1 | @Override
public void setCorrectAnswer() {
answer = InputHandler.getString("Is the answer true or false?").trim().toLowerCase().indexOf("true")>=0?true:false;
} |
8fa03700-a27a-48a4-a5ed-0cb1417841a1 | 3 | public static String lineEndingToPlatform(String line_ending) {
if (line_ending.equals(LINE_END_MAC)) {
return PLATFORM_MAC;
} else if (line_ending.equals(LINE_END_WIN)) {
return PLATFORM_WIN;
} else if (line_ending.equals(LINE_END_UNIX)) {
return PLATFORM_UNIX;
} else {
System.out.println("Unknown ... |
0ec8e2fb-94b2-419f-b4ac-477a325de2c8 | 0 | public double getHeight()
{
return height;
} |
5573bc41-4779-49a8-ade9-578976ba5a58 | 5 | @Override
public int compareTo(Card arg0) {
if(this.equals(arg0))
{
return 0;
}
if(this.value > arg0.value)
{
return 1;
}
else if(this.value < arg0.value)
{
return -1;
}
else
{
if(this.silverNum > arg0.silverNum)
{
return 1;
}
else if(this.silverNum < arg0.silverNum)
... |
d17d0cea-aac1-4fec-a372-467d0275ca88 | 5 | private boolean performerIsInOhterDropZone(AbstractComponent performer) {
if (performer instanceof Agent) {
try {
for (AbstractInteractionComponent comp : SimulationEngine
.getInstance().getWorld().getInteractionComponents()) {
if (comp instanceof DropZone) {
if (((DropZone) comp).contains((Ag... |
b86ec95b-a25e-4a8a-8fe4-a0f05d11d29c | 9 | private boolean isMinimal (Description description, Document document, Object... optionalArguments) {
if (description instanceof AttributeHolder && ((AttributeHolder) description).hasAttributes ()) {
return false;
}
if (description instanceof InstantaneousEvent) {
if (((I... |
9e00eba2-c536-4c42-b7ec-53fc665dcc57 | 1 | public static boolean isDigit(int c) {
return c >= '0' && c <= '9';
} |
77becde2-0c2e-4f67-98a1-1b1cfef93286 | 2 | @Override
public void actionPerformed(ActionEvent evt) {
System.out.println("VueNouvelleLocation::actionPerformed()") ;
Object sourceEvt = evt.getSource() ;
if(sourceEvt == this.bEnregistrer){
int indiceClient = cbClients.getSelectedIndex();
int numeroClient = numClients.get(indiceClient).intValue() ;
S... |
c4c99cf8-d6b0-4c04-9797-323190cc416f | 3 | @Override
public Article insert(Article obj) {
PreparedStatement pst = null;
try {
pst = this.connect().prepareStatement("INSERT INTO Article (titre, resume, date, id) VALUES (?,?,?,?);");
pst.setString(1, obj.getTitlre());
... |
e4a92f94-81aa-446e-a490-432d9e6ff80f | 8 | public void okGezinInvoer(Event evt) {
Persoon ouder1 = (Persoon) cbOuder1Invoer.getSelectionModel().getSelectedItem();
if (ouder1 == null) {
showDialog("Warning", "eerste ouder is niet ingevoerd");
return;
}
Persoon ouder2 = (Persoon) cbOuder2Invoer.getSelectionM... |
221224ca-cd51-4e26-9821-06aabd928bf9 | 4 | @Override
public void execute(VGDLSprite sprite1, VGDLSprite sprite2, Game game)
{
ArrayList<Integer> subtypes = game.getSubTypes(ispawn);
for (Integer i: subtypes) {
Iterator<VGDLSprite> spriteIt = game.getSpriteGroup(i);
if (spriteIt != null) while (spriteIt.hasNext()) ... |
3ffde9dd-1e79-473f-b2c3-1da172ee03c4 | 3 | @Override
public List<String> getPermissions(String world) {
List<String> perms = super.getPermissions(world);
TotalPermissions plugin = (TotalPermissions) Bukkit.getPluginManager().getPlugin("TotalPermissions");
for (String group : inheritence) {
try {
Permissio... |
6cedcc46-151d-430a-9f10-784bdfece611 | 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... |
8b8064de-f1a7-4c37-a7ea-1418d4a504b8 | 5 | public void testForOffsetHoursMinutes_int_int() {
assertEquals(DateTimeZone.UTC, DateTimeZone.forOffsetHoursMinutes(0, 0));
assertEquals(DateTimeZone.forID("+23:59"), DateTimeZone.forOffsetHoursMinutes(23, 59));
assertEquals(DateTimeZone.forID("+02:15"), DateTimeZone.forOffsetHoursMinut... |
29f44bc0-ec10-4288-b21e-5720ed2f7956 | 4 | void solve1() {
NHL nhl = new NHL(in);
double win = 0;
int count = 0;
double predicts = 0;
for (int i = 0; i < nhl.getAmountMatches(); i++) {
double predict = nhl.makeTotalPredict(nhl.getMatch(i));
// out.println(predict);
if (predict <= 0) {
... |
a4141938-fb0e-4aac-a7b5-d8a2fc03e793 | 9 | public static Object getListener(Object bag, int index)
{
if (index == 0) {
if (bag == null)
return null;
if (!(bag instanceof Object[]))
return bag;
Object[] array = (Object[])bag;
// bag has at least 2 elements if it is array
... |
7e244434-9d94-4dac-8b13-8976a9eaa184 | 2 | public void method290(int y, int arg1, int x, int z) {
GroundTile groundTile = groundTiles[z][x][y];
if (groundTile == null) {
return;
}
WallDecoration wallDecoration = groundTile.wallDecoration;
if (wallDecoration != null) {
int offX = x * 128 + 64;
int offY = y * 128 + 64;
wallDecoration.x = off... |
39f165ee-8482-41b3-bdac-b7ebf80b658e | 5 | public void habilitarFunciones(int perfil){
String consulta="select per_id_perfil,per_id_modulo,per_id_tarea from permiso where per_id_perfil="+perfil;
r_con.Connection();
ResultSet rs=r_con.Consultar(consulta);
Vector<Vector<Integer>>modulosTarea=new Vector();... |
10406000-b4ad-4586-8e31-664d49d0fa1d | 7 | @EventHandler
public void SkeletonResistance(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getZombieConfig().getDouble("Skeleton.... |
f7235679-1235-4202-aafb-51419d0cac6a | 2 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
String binN = Integer.toBinaryString(n);
int first = 0;
int second = 1;
int count = 0;
for (int i = 0; i < binN.length() - 1; i++) {
int nRigh... |
4038f667-d548-4e06-ac2c-a3fe5cce2a76 | 9 | private final int jjMoveStringLiteralDfa11_0(long old0, long active0, long old1, long active1, long old2, long active2)
{
if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L)
return jjStartNfa_0(9, old0, old1, old2);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException ... |
4d0bd194-f1c0-406b-92f2-3bd14db8c094 | 0 | @FXML
private void handleBtnCancelAction(ActionEvent event) {
clearFields();
} |
16b5725a-b830-4dbe-82d1-ae549608ad1e | 5 | protected void processReport() {
try {
log.info("Started the thread");
String error = checkFolder(reportFolder.getText());
if (!Utils.isEmpty(error)) {
log.info("Error: " + error);
Run.showErrorDialog(getSelfRef(), error);
return;
}
boolean doMusic = allMusicCheckBox.isSelected(... |
6a133103-283b-4287-aa3d-49411d30e960 | 7 | public static void Command(CommandSender sender)
{
if(!(sender instanceof Player))
me.Vinceguy1.ChangeGameMode.Functions.Message.Function(me.Vinceguy1.ChangeGameMode.ConfigClass.config.get("Messages.Errors.In-game Player").toString(), sender, null, null, true, false, false, null);
else
{
Player player = (P... |
5bc20767-4ea9-4042-80d2-d3f5bf3b4928 | 8 | @Override
public void doPivot(Integer pivotHoriz, Integer pivotVert) {
// { Preconditions
assert (this.model.getConstraints().size() > 0) : "Cannot do pivot without constraints";
assert (this.model.getObjfuncVariables().size() > 0) :
"Cannot do pivot with an empty objective-function";
assert (... |
18a39f00-74b6-4d10-be04-68581b904893 | 0 | public void setMatch(String match) {this.match = match;} |
d3b3cf26-d900-41e7-9638-cb9dff6628f7 | 1 | public boolean isElement()
{
if(elements.length == 1)
return true;
return false;
} |
faa316dc-9353-46b3-8296-23de5fb26d06 | 2 | private void myListMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myListMouseReleased
// TODO add your handling code here:
if( myList.getSelectedIndex() != -1 && evt.isPopupTrigger() ) {
UserListPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
}
}//GEN-LAST:e... |
09341950-6a32-4878-9b49-088156dbe30e | 7 | private void updateHeroDirection(Decision turn)
{
if(turn == Decision.TURN_LEFT)
{
if(heroDirection == Direction.UP)
{
heroDirection = Direction.LEFT;
}
else if(heroDirection == Direction.DOWN)
{
heroDirection = Direction.RIGHT;
}
else if(heroDirection == Direction.LEFT)
... |
c01d327f-651e-41ec-b230-b88433856183 | 7 | private void paySalary(String[] data){
int salarySize;
long id;
GregorianCalendar date = null;
try {
salarySize = Integer.parseInt(data[1]);
id = Long.parseLong(data[2]);
if(data.length == 4)
date = parseDate(data[3]);
Employee em = container.find(id);
if(date == null){
em.paySalary(sala... |
b4fb12b6-5ccb-4938-950c-71355e44b0c9 | 3 | public void update(){
if(alunoTurma != null){
Turma t = this.alunoTurma.getTurma();
if(t != null){
this.lblNumTurma.setText(Integer.toString(t.getNumeroTurma()));
this.lblPeriodo.setText(t.getPeriodoLetivo());
this.lblDisciplina.setText(
... |
df5e1b89-f8fb-4cf2-85c6-5c9ddf6dae44 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Telefone)) {
return false;
}
Telefone other = (Telefone) object;
if ((this.idTelefone == null && other.idTelefo... |
002074b7-3373-4654-aad3-c04a7e8054ae | 4 | @Override
public void caseAVetorVariavel(AVetorVariavel node)
{
inAVetorVariavel(node);
if(node.getFechaColchete() != null)
{
node.getFechaColchete().apply(this);
}
if(node.getNumInt() != null)
{
node.getNumInt().apply(this);
}
... |
ef407921-e072-4d84-b889-80f61c14467c | 0 | public static void stopTest(){
/*try{
if (threadExamineAlgorythm.isAlive())
threadExamineAlgorythm.stop();
}catch(NullPointerException ex){
*//* NOP *//*
}*/
interruptedProcess = true;
} |
73fb95ff-da4b-40c7-921b-2650dd3bb61b | 7 | protected boolean validateNode(Node<T> node) {
Node<T> lesser = node.lesser;
Node<T> greater = node.greater;
boolean lesserCheck = true;
if (lesser != null && lesser.id != null) {
lesserCheck = (lesser.id.compareTo(node.id) <= 0);
if (lesserCheck)
... |
2af04b9d-1108-4860-b7f2-8342dbddc3a6 | 3 | private static void addButtonChoosePanelBuilderListener(final CustomButton a) {
a.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (!Database.loaded)
return;
final JFrame jf = new JFrame(a.getText());
jf.setSize(1300, 650);
jf.setVisible... |
9e33f705-808d-484e-a965-df968f703c5d | 1 | public void printAllEdges()
{
for(Edge e : edges)
System.out.println(e);
} |
77f4a734-86cb-4cb2-9be0-15097928046a | 2 | public static IntTreeBag union(IntTreeBag b1, IntTreeBag b2){
IntTreeBag newBag = new IntTreeBag();//creates a new bag
if((b1 == null) || (b2 == null)){
throw new IllegalArgumentException(" at least one bag is empty");
}else{
newBag = (IntTreeBag) b1.clone();
}
newBag.addAll(b2)... |
fcca3414-9c44-4da3-8c28-531415785d31 | 5 | private void saveMCD(PrintStream out) throws IOException
{
out.println("<mcd>");
for (Iterator<ZElement> e = mcd.enumElements(); e.hasNext();) {
MCDObjet o = (MCDObjet) e.next();
if (o instanceof MCDEntite)
out.println("<entite nom=\"" + o.getName() + "\" x=\... |
daaa102a-7968-4ace-bd42-a9036d81b69e | 3 | @Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
Main.courier.send(sender, "requires-player", label);
return true;
}
final Player player = (Player) send... |
a87a1ea3-e633-400b-a1d5-a913c48f362a | 5 | public SendInvoiceResponse(Map<String, String> map, String prefix) {
if( map.containsKey(prefix + "responseEnvelope" + ".timestamp") ) {
String newPrefix = prefix + "responseEnvelope" + '.';
this.responseEnvelope = new ResponseEnvelope(map, newPrefix);
}
if( map.containsKey(prefix + "invoiceID") ) {
th... |
c829d00c-4d19-40c6-b198-bc2af43f22fb | 9 | /* */ public static void main(String[] paramArrayOfString) {
/* */ try {
/* 159 */ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
/* */ }
/* */ catch (Exception localException) {
/* */ }
/* 163 */
/* 164 */ System.setProperty("java.net.preferIPv... |
526ea696-cb9d-4b70-a6d3-80bb4862fbe6 | 4 | public void decodeAndRender(int id, String message) throws JSONException {
switch (id) {
case 100: // Message.java
Message chatMessage = enc.chattMessageDecode(message);
lg.chatgui.chatUpdate(chatMessage.message, chatMessage.user);
break;
case 101: // Create session
case 102: // Join session
this.... |
c30cb3e1-c6ad-4a90-abee-7fae9c858979 | 0 | public void setLoginpwd(String loginpwd) {
this.loginpwd = loginpwd;
} |
e4defa12-435d-4ca2-a0d2-6df296d484f2 | 2 | public Item(ItemType it, int l) {
itemType = it;
level = l;
if(level < 1) {
level = 1;
}
if(level > 20) {
level = 20;
}
} |
7307b8f0-e9e6-4470-ac11-c3e25e6452d1 | 4 | private boolean checkFeetCollision(Tile[][] tiles) {
for (int h = 0; h < tiles.length; h++) {
for (int w = 0; w < tiles[0].length; w++) {
if (tiles[h][w].getHitbox() != null && getFeetHitbox().collisionCheck(tiles[h][w].getHitbox())) { return true; }
}
}
r... |
b1721c1a-b8c5-44c5-a1fd-f1ee142847ce | 4 | private void connect(){
try {
if(!is_secondary()){
name ="rmi://127.0.0.1:9090/server1";
Naming.rebind(name, server);
System.out.println("Server 1");
connectBackupServer();
if(backupServer != null) {
System.out.println("hier!!!!!!!!!");
db.refresh();
backupServer.requestInit();
... |
37b2c2a9-c2db-424b-b63b-113c531b56f0 | 8 | public static void main(String[] args) {
//首先打开通道
try (AsynchronousServerSocketChannel serverSocketChannel = AsynchronousServerSocketChannel.open()) {
//是否打开
if (serverSocketChannel.isOpen()) {
//支持的optiosn
Set<SocketOption<?>> socketOptions = serv... |
38d6ffd0-afab-4de9-bbbb-8b2dd78bba50 | 0 | public void changeSelection (int row, int column, boolean toggle, boolean extend) {
super.changeSelection (row, column, toggle, extend);
myMultSimAct.viewAutomaton(this);
} |
a1bb88a8-1182-4b24-839c-100103c06a91 | 7 | protected void configurePopupMenu(JPopupMenu popupMenu) {
boolean canType = isEditable() && isEnabled();
// Since the user can customize the popup menu, these actions may not
// have been created.
if (undoMenuItem!=null) {
undoMenuItem.setEnabled(undoAction.isEnabled() && canType);
redoMenuItem.setEnabl... |
823a0045-d6c3-4157-991c-8d57f530ea59 | 9 | @Override
public long doRead(Master master, ReadRequest readRequest) {
incrementAccessAndMaybeRecalibrate(master);
long fileId = readRequest.getFileId();
Location accessLoc = readRequest.getLocation();
MasterMeta fm = master.map.get(fileId);
if (fm == null || fm.instances.size() == 0) {
retu... |
e7c1bb26-6514-403f-8226-74edeb0021c7 | 6 | private void close(Connection conn, PreparedStatement stmt,
ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (Exception ex) {
}
}
if (stmt != null) {
try {
stmt.close();
} catch (E... |
b47989a1-4442-4ae6-bd14-5e241191a2ce | 6 | private static void dump(char[] ram, int start, int len) throws Exception {
DataOutputStream dos = new DataOutputStream(new FileOutputStream("mem.dmp"));
for (int i = 0; i < len; i++) {
dos.writeChar(ram[start + i]);
}
dos.close();
for (int i = 0; i < len; )
{
String str = Integer.to... |
537ede93-c3a0-4f82-8607-cf1935ffd297 | 1 | public static void deleteProduct(Integer ID) {
try {
Database db = dbconnect();
String query = "DELETE FROM product "
+ "WHERE PID = ?";
db.prepare(query);
db.bind_param(1, ID.toString());
db.executeUpdate();
db.close();
} catch(SQ... |
927ced0b-e372-4729-af91-47895c46bed6 | 2 | private boolean isPartOf(Component c, Map<SLSide, List<Component>> map) {
for (SLSide s : SLSide.values())
if (map.get(s).contains(c)) return true;
return false;
} |
3b43caaf-e5b2-4398-b471-cf0d94ed4073 | 4 | public int itemIndex(String itemName){
if(!this.dataEntered)throw new IllegalArgumentException("no data has been entered");
int index = -1;
int jj=0;
boolean test = true;
while(test){
if(itemName.trim().equalsIgnoreCase(this.itemNames[jj].trim())){
ind... |
50c0aabc-3a37-4427-b529-43f63b349886 | 1 | public static int getPropertyDefaultAsInt(PropertyContainer container, String key) {
if (container != null) {
Object value = container.getPropertyDefault(key);
return convertObjectToInt(value);
} else {
throw new IllegalArgumentException("Provided PropertyContainer was null.");
}
} |
5a9b57b1-f776-47b5-9f4f-05da596321d3 | 6 | private void updateCurrentValues(NodeList nodeList){
// Iterate through the list of values to update the xml document
for (int i = 0; i < nodeList.getLength(); i++) {
Node currentNode = nodeList.item(i);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
// Cre... |
502e224a-9209-4e83-b948-c634249d6f1c | 2 | public boolean isAllEdgeVisited() {
for (Edge<T> e : edges) {
if (! e.visited) return false;
}
return true;
} |
adf4b64f-809e-4f5e-b7ea-e61492c4aafa | 6 | public IAction find(String url, IContext context) {
IAction action = _actions.get(url);
if (null != action)
return action;
Pattern p;
for (IAction anAction : _actions.values()) {
p = Pattern.compile(anAction.getRoute());
Matcher m = p.matcher(url);
if (m.find()) {
String[] groupsName = anAction.... |
43676dd7-9e98-49bc-921c-78aa6b65237c | 7 | public LinkedList scan(ListIterator listiterator, LinkedList linkedlist, LinkedList linkedlist1)
{
while(listiterator.hasNext())
{
XMLNode xmlnode = (XMLNode)listiterator.next();
if(xmlnode != null)
switch(xmlnode.XMLType)
{
ca... |
25ec645f-a618-4fed-85d0-c1c9254a0719 | 5 | private int sink(int i)
{
Key t = pq[i]; // Save key for later restoring
while (2 * i + 1 <= N) // while pq[i] has both the children
{
int j = 2 * i + 1; // rightmost child
// 1st comparision: Making j point to the least of the two
// children as pq[i] should sink to j
if (greater(pq[j], pq[j - 1]))... |
630c6430-024c-47f5-bf95-ca428f15b367 | 4 | public static Value<?> convertMessageToBencode (Message msg) {
Objects.requireNonNull(msg);
if (msg instanceof ErrorMessage) {
return convertErrorMessage((ErrorMessage) msg);
} else if (msg instanceof QueryMessage) {
return convertQueryMessage((QueryMessage) msg);
... |
fa639477-f161-4181-b368-a5e1086fe047 | 7 | public List<String> getValidationErrors() {
List<String> errors = new ArrayList<String>();
if (username == null || username.length() == 0) errors.add("Username is required");
if (button == null || button.length() == 0) errors.add("Button is required");
if (errors.size() > 0) return... |
def576e7-d83b-4d26-bec1-29148873d97e | 9 | private void processFile(File dir) {
String filepath = dir.getPath();
filepath = filepath.substring(root.length(), filepath.length());
filepath = filepath.substring(0, filepath.lastIndexOf(File.separator));
if (filepath != null && !filepath.equals("")) {
filepath = File.separ... |
1a93c765-9ba0-4bcf-8477-3720cdd503dc | 0 | public EntityManager getEntityManager() {
return entityManager;
} |
1af618b9-f786-4751-84e8-ae183fd19150 | 4 | public static <E> void rightShift (E[] array, int shift) {
if (shift > 0) {
// save items displaced off of right end
ArrayList<E> temp = new ArrayList<E>();
int length = array.length;
for (int i = length - shift ; i < length; i++) {
temp.add(array[i]);
}
// copy in place
for (int i = leng... |
f729ff37-c57f-43c4-962c-30337693e1f0 | 7 | @Override
public final void setShipInputBoard() {
shipBoard.setLayout(new GridLayout(PlayerInterface.LETTERS.length,
PlayerInterface.NUMBERS.length));
grid = new JButton[PlayerInterface.LETTERS.length][PlayerInterface.NUMBERS.length];
for (int y = 0; y < PlayerInterface.LETTERS.length; y++) {
for (int x ... |
24773826-92af-4e82-bcd6-569ae6f5f329 | 1 | private void setBalance(BigInteger balance) throws IllegalArgumentException {
if (! this.canHaveAsBalance(balance))
throw new IllegalArgumentException();
this.balance = balance;
} |
4d61353f-f913-4fee-8734-853c6f9c876b | 4 | private void showButtonClicked(ActionEvent e){
if (rStart.isSelected()){
sort(new StartComparator());
}
else if (rName.isSelected()){
sort(new NameComparator());
}
else if (rAge.isSelected()){
sort(new AgeComparator());
}
else if (rTime.isSelected()){
sort(new T... |
632761aa-d75a-4967-9fd4-8fd42e0668a6 | 2 | public static void debug(String msg) {
logger.setPriority(Priority.DEBUG);
if (console_write) {
console(msg);
}
if (log_write) {
logger.debug(msg);
}
logger.unsetPriority();
} |
f015adf6-e4be-4f9d-afcd-e318f74cf767 | 8 | public static String readToken(InputStream in, int delim,
String enc, int maxLength) throws IOException {
// note: we avoid using a ByteArrayOutputStream here because it
// suffers the overhead of synchronization for each byte written
int buflen = maxLength < 512 ? maxLength : 512; /... |
e7d0b56b-979f-432c-aa1c-7fa4a9a48bac | 3 | @Test
public void getSession() {
System.out.println(scraper.sessionExists(50, 4));
System.out.println(scraper.getSessionQuery(34, 1));
ArrayList<Speaker> speakers = scraper.getSession("&Session=jd41l1se");
//display the names
System.out.println("=====SPEAKER... |
64ce55bb-bde0-4db4-ad15-de6a07202887 | 2 | public static void main(String args[]) {
int gallons; // holds the number of gallons
double liters; // holds the number of liters
gallons=0;
liters=0;
for ( gallons = 0; gallons < 101; gallons++) {
liters = gallons * 3.7854;
System.out.println (gallons + " gallons is " + liters + " liters. ");
... |
8574d360-3379-4102-8ba2-4ad5d18db36b | 1 | public final Output createCustomOutput(final String implementor, final String[] params) throws CustomOutputException {
Class<Output> customClassToCreate = Output.class;
Output custom = customClassToCreate.cast(createCustom(implementor, params, customClassToCreate));
if (custom == null) {
throw new CustomOutput... |
eb2b98d8-45c4-41ab-b37b-c79140656440 | 6 | public static void main(String[] args) throws XMLStreamException, FactoryConfigurationError, IOException {
String eadfile = args[0];
String identifier;
String attrName=null;
String attrValue=null;
if (args.length >= 2) {
if (args[1].equals(DID)) {
id... |
53660c55-8b40-429a-8898-6bb29cb7cbe8 | 8 | public int kSmall(int[] arrA, int start, int end, int k) {
int left = start;
int right = end;
int pivot = start;
while (left <= right) {
while (left <= right && arrA[left] <= arrA[pivot])
left++;
while (left <= right && arrA[right] >= arrA[pivot])
right--;
if (left < right) {
swap(arrA, lef... |
d6586e1a-86e8-4233-b964-9ad99c1e6481 | 4 | public int getCorrectSize() {
if (correctSize == 0) {
correctSize = 72;
int[] sizes = {18,27,36,45,54,63,72};
for (int size : sizes) {
if (Kit.list.size() + 4 <= size && correctSize > size) {
correctSize = size;
}
}
}
return correctSize;
} |
ae7dbb08-f43d-4386-8a8c-90040120f238 | 0 | private ApplicationType(String name) {
this.name = name;
} |
d0ffd0a9-8805-4f0b-8bda-62420818f928 | 1 | @Override
public void run() {
arr_data = Customer.showAll();
data = new Object[arr_data.size()][];
for (int i = 0; i < arr_data.size(); i++) {
data[i] = arr_data.get(i).Array();
}
this.fireTableDataChanged();
} |
39ea3ff2-6b23-4727-857c-017bcfbf70b6 | 2 | private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlterarActionPerformed
Cliente editar = null;
ClienteDAO dao = new ClienteDAO();
try {
editar = dao.Abrir(this.idDoClienteSelecionado);
} catch (ErroValidacaoException ex... |
1f45fadc-37b2-4b1e-ae68-846aed179706 | 3 | private void doEditJH(HttpServletRequest request, HttpServletResponse response, boolean isEditUser) throws ServletException, IOException {
String jhId = StringUtil.toString(request.getParameter("jhId"));
if(!StringUtil.isEmpty(jhId)) {
LianXiWoMen lxfs = null;
try {
... |
3486962c-a7d6-4f17-ae07-2559447dc337 | 0 | @Test
public void test() throws SQLException {
Hive hive = new Hive();
hive.createTable();
hive.loadData();
} |
07e189f6-68ce-411c-8aaa-581bff5e80e1 | 4 | public boolean validateUserName(String userName) throws IllegalAccessError, SocketTimeoutException {
boolean answer = false;
try {
clientSocket.Escribir("USUARIO " + userName + '\n');
serverAnswer = clientSocket.Leer();
} catch (IOException e) {
throw new SocketTimeoutException();
}
if(serverAnswer !... |
093b5807-3dae-478f-a519-4b22262f72fc | 1 | @Override
public void performPhysics(Matter matter, Planet nearbyPlanet) {
matter.setVerticalVelocity(getNewVerticalVelocity(matter, nearbyPlanet.getGravity()));
matter.setHeight(getNewHeight(matter));
boolean hasHitGround = matter.getHeight() < 0;
if (hasHitGround) {
performHitGroundPhysics(matter, nearby... |
7d8806bb-aa6e-4f00-8afc-39b167757185 | 8 | private void valitseSiirto(Kentta kentta, int syvyys, int pelinumero) {
if(matintarkastaja.matti(kentta, omaPelinumero)) {
nykyinenArvo += laskeMattipainotus(syvyys);
return;
}
if(matintarkastaja.matti(kentta, vaihdaPelinumero(omaPelinumero))) {
nykyinenArvo -... |
97de6691-703c-432d-a78c-e90b45462689 | 4 | public void refresh() {
if (dataType.equals("video")) {
showVideos();
} else if (dataType.equals("news")) {
showNews();
} else if (dataType.equals("temperature")) {
showTemperature();
} else if (dataType.equals("log")) {
showLog();
}
} |
4f7c2737-e6fc-4253-b3a8-0aa5b305d1ca | 0 | @Test
public void determineHighestStraight_whenHandContainsAtoT_returnsAceHighStraight() {
Hand hand = findHighestStraight(fourFlushWithStraight());
assertEquals(HandRank.Straight, hand.handRank);
assertEquals(Rank.Ace, hand.ranks.get(0));
} |
c25920a7-0d01-4d83-b4d5-e1ce56b48ed3 | 4 | private void randomMove() {
switch (random.nextInt(4)) {
case 0:
currentMove = MoveDir.MOVE_LEFT;
break;
case 1:
currentMove = MoveDir.MOVE_RIGHT;
break;
case 2:
currentMove = MoveDir.MOVE_UP;
break;
case 3:
currentMove = MoveDir.MOVE_DOWN;
break;
}
gameObject.setMoveDir(currentMov... |
5a486656-d9a2-492b-85f0-db525411dfc2 | 4 | public static MyStack<Integer> duplicateStack(MyStack<Integer> original) {
MyStack<Integer> result = new ArrayStack<Integer>();
MyQueue<Integer> temp = new ArrayQueue<Integer>();
/*reverse the order of original elements*/
while(!original.isEmpty()){
temp.enqueue(original.pop());
}
while(!temp.isEmpty(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.