method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
b80beb8c-0ebe-4cab-a030-df55b7d35923 | 1 | public boolean levelUp() {
if(this.experience >= this.cap)
{
this.setCap(this.cap * 2);
this.setLevel(this.level++);
addStats();
return true;
}
return false;
} |
94c0ae5f-fcc1-468b-a97a-baa50bbfe3d5 | 2 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BookService bookService = (BookService) getServletContext().getAttribute("bookService");//呼叫service
int booksCount = bookService.getBooksCount();//取得book總數
int size = (request.getParameter("size") != null) ? Integer.parseInt(request.getParameter("size")) : 10;//檢查目前page,size
int page = (request.getParameter("page") != null) ? Integer.parseInt(request.getParameter("page")) : 1;//此變數名稱固定在getBooksPages()方法裡
List<StringBuilder> pages = getBooksPages("ShowBookList.view", booksCount, size);//計算需要頁面且回傳超連結
Set<Book> bookSet = bookService.getAllBook(Math.min(page, pages.size()), size);//根據page與size查找資料庫book,page不超過size
request.setAttribute("page", page);//給頁面目前page
request.setAttribute("size", size);//給頁面目前size
request.setAttribute("booksPage", bookSet);//給搜尋結果
request.setAttribute("pagesCount", pages);//給超連結
request.getRequestDispatcher("BookList.jsp").forward(request, response);
// BookService bookService=(BookService) getServletContext().getAttribute("bookService");
//
//
//
// request.setAttribute("bookSet", bookService.getAllBook());//List給頁面
// request.getRequestDispatcher("BookList.jsp").forward(request, response);
// String Result = gson.toJson(bookList);
// String Result = gson.toJson(booksPrint);
// try {
// PrintWriter out = response.getWriter();
// out.print(Result);
// out.close();
// } catch (IOException e) {
// System.out.println(e);
// }
// response.setContentType("text/html;charset=UTF-8");
// PrintWriter out = response.getWriter();
// try {
// /* TODO output your page here. You may use following sample code. */
// out.println("<!DOCTYPE html>");
// out.println("<html>");
// out.println("<head>");
// out.println("<title>Servlet ShowBookList</title>");
// out.println("</head>");
// out.println("<body>");
// out.println("<h1>Servlet ShowBookList at " +bookSet+ "</h1>");
// out.println("</body>");
// out.println("</html>");
// } finally {
// out.close();
// }
} |
0785ba65-9655-4b47-84b0-8c54b42df311 | 1 | public void update(long deltaMs) {
if(Application.get().getLogic().getActor(weaponID) == null) {
weaponID = NO_WEAPON;
}
} |
9b16d129-9be1-4922-96e9-a9a209d7e4bf | 0 | @Test
public void testCalculateRewardPoints() {
this.card2.makePurchase(100);
this.card2.makePurchase(100);
this.card2.makePurchase(100);
this.card2.makePurchase(100);
assertEquals(400, this.card2.calculateRewardPoints());
} |
d5c0d4fd-dff4-4cc0-b762-a3905ed35377 | 0 | public String getMimeType() {
return mimeType;
} |
1e6db459-4a7d-4bf4-81d2-3b2fd67be648 | 2 | public static String[] searchEmployee(Integer ID) {
Database db = dbconnect();
String [] Array = null;
try {
String query = ("SELECT * FROM employee WHERE EID = ? AND bDeleted = 0");
db.prepare(query);
db.bind_param(1, ID.toString());
ResultSet rs = db.executeQuery();
while(rs.next()) {
Array = new String[]{rs.getString(rs.getMetaData().getColumnName(2)),
rs.getString(rs.getMetaData().getColumnName(3)),
rs.getString(rs.getMetaData().getColumnName(4)),
rs.getString(rs.getMetaData().getColumnName(5)),
rs.getString(rs.getMetaData().getColumnName(6))};
}
db.close();
} catch (SQLException e) {
Error_Frame.Error(e.toString());
}
return Array;
} |
7be2ef91-61c4-4cbd-92ab-6dff95b3e0d1 | 7 | public void render(boolean[] displaySegments){
GL11.glTranslatef(pos.x(), pos.y(), 0);
texture.bind();
if(displaySegments[0]){
GL11.glTranslatef(0, -height/2, 0);
renderSegment(width*0.6f, height*0.125f);
GL11.glTranslatef(0, height/2, 0);
}
if(displaySegments[1]){
GL11.glTranslatef(width/2, -height/4, 0);
GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
renderSegment(width*0.6f, height*0.125f);
GL11.glRotatef(-90, 0.0f, 0.0f, 1.0f);
GL11.glTranslatef(-width/2, height/4, 0);
}
if(displaySegments[2]){
GL11.glTranslatef(width/2, height/4, 0);
GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
renderSegment(width*0.6f, height*0.125f);
GL11.glRotatef(-90, 0.0f, 0.0f, 1.0f);
GL11.glTranslatef(-width/2, -height/4, 0);
}
if(displaySegments[3]){
GL11.glTranslatef(0, height/2, 0);
renderSegment(width*0.6f, height*0.125f);
GL11.glTranslatef(0, -height/2, 0);
}
if(displaySegments[4]){
GL11.glTranslatef(-width/2, height/4, 0);
GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
renderSegment(width*0.6f, height*0.125f);
GL11.glRotatef(-90, 0.0f, 0.0f, 1.0f);
GL11.glTranslatef(width/2, -height/4, 0);
}
if(displaySegments[5]){
GL11.glTranslatef(-width/2, -height/4, 0);
GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
renderSegment(width*0.6f, height*0.125f);
GL11.glRotatef(-90, 0.0f, 0.0f, 1.0f);
GL11.glTranslatef(width/2, height/4, 0);
}
if(displaySegments[6]){
renderSegment(width*0.6f, height*0.125f);
}
GL11.glTranslatef(-pos.x(), -pos.y(), 0);
} |
40ef60ab-ed9b-4b5b-888b-b4bc60c7c4b9 | 7 | public static void run(Bot bot, String res, String sender, String s) {
if (!sender.matches("(.*)[bB][oO][tT](.*)|(.*)Satoshi[DV]ICE(.*)")) {
int now = (int) System.currentTimeMillis();
int threshold = now - intTime;
intTime = now;
if (threshold < 1200) {
Logger.warn("Flood WARNING!");
//System.out.println(Colors._RED + "WARNING! Flood: " + String.format("%d", threshold) + Colors._NORMAL);
if (warn1 == true && warn2 == true) {
if (sender.equals(lastSender) && !lastSender.equalsIgnoreCase("SatoshiVICE")) {
bot.kick(res, sender, "Welcome to my demon-haunted world " + sender + "! :)~~");
Logger.warn(">> KICKING " + sender);
//System.out.println(Colors._RED + ">> KICKING " + sender + Colors._NORMAL);
}
} else {
if (warn1 == true) warn2 = true;
else warn1 = true;
}
} else {
warn1 = false;
warn2 = false;
Logger.info("Flood: " + String.format("%d", threshold));
//System.out.println(Colors._CYAN + "Flood: " + String.format("%d", threshold) + Colors._NORMAL);
}
lastSender = sender;
}
//bot.log(sender + System.currentTimeMillis() + s);
/*if (s.equals(lastMessage1) && s.equals(lastMessage2) && s.equals(lastMessage3)) {
//kick
System.out.println(sender + " THIRD STRIKE! YOU'RE OUT!!");
} else {
lastMessage3 = lastMessage2;
lastMessage2 = lastMessage1;
lastMessage1 = s;
}*/
} |
c37d76d5-8fe2-45ea-bd58-bb18df756811 | 5 | @Override
public void initialize(InputSplit arg0, TaskAttemptContext arg1)
throws IOException, InterruptedException {
try {
reader = new PartitionReader(new OptimusConfiguration(((TRANSInputSplit)arg0).getConfDir()));
} catch (WrongArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(-1);
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
split = (TRANSInputSplit) arg0;
TransHostList list = split.getHosts();
Vector<Host> h = list.getHosts();
String hostname = InetAddress.getLocalHost().getHostName();
Host use = null;
for( int i = 0 ; i < h.size(); i++)
{
if( hostname.equals(h.get(i).getHost()))
{
use = h.get(i);
break;
}
}
if(use == null)
{
Random rand = new Random();
use = h.get(rand.nextInt()%h.size());
}
dp = use.getDataProtocol();
} |
a9cb996f-b0db-4b77-8ac4-b52bf380c5d1 | 0 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
modificarFrame.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed |
038b31b1-9550-4501-9a1c-80e21fa45f5c | 0 | public static void main(String[] args) {
// 从控制台输入数字
System.out.println("请输入你要处理的数字:");
Scanner input = new Scanner(System.in);
Long testObject = input.nextLong();
Handler handler = new HandlerImplOne();
String info = handler.dealWith(testObject);
System.out.println(info);
} |
a916b2ba-d49f-462c-bb31-04b7f995e124 | 0 | public void cancelEdit() {
super.cancelEdit();
setTimeSpinners();
} |
379345bb-5e66-4f3e-b158-1af1a4f41f27 | 0 | public Tag getTag(Component component) {
return (Tag) componentTags.get(component);
} |
b9224668-6d26-408f-87fe-a0b2de03dc23 | 4 | @Override
public void run() {
try {
System.out.println("run it!");
input = getBufferedReader(client.getInputStream());
output = getPrintStream(client.getOutputStream());
System.out.println("Stream it!");
hello(user.getUsername(), Server.GLOBAL_SUPPORTS, "0.1");
System.out.println("Handshake gestuurd!");
Command handshake = new Command(input, true);
System.out.println("Handshake ontvangen!");
if (!handshake.getCommand().equals(ClientProtocol.HANDSHAKE)) {
throw new ProtocolException("No handshake received", 1); //TODO
}
System.out.println("Handshake OK!");
while (true) {
handlePacket(new Command(input, true));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
8f484d57-ea8b-4c34-8f81-a709d5b6789d | 2 | public void initCodeRedSchedule() {
codeRedSchedule.clear();
for (Match match : matches){
if(match.searchFor(2771)){
codeRedSchedule.add(match);
}
}
} |
bb9fee24-f58c-40b8-948e-9da2c039e90c | 0 | public RandomSkipIterator(IRandomAccessor2<T> accessor, int count)
{
this._accessor = accessor;
this._pos = count;
} |
29e3c817-4bc1-4a44-9656-b5f031bee246 | 2 | private static HashSet<Class<?>> getSupportedTypes()
{
HashSet<Class<?>> set = new HashSet<>();
set.add(String.class);
set.add(Boolean.class);
set.add(Integer.class);
set.add(Double.class);
set.add(Byte.class);
set.add(Short.class);
set.add(Long.class);
set.add(Float.class);
set.add(int.class);
set.add(boolean.class);
set.add(byte.class);
set.add(short.class);
set.add(long.class);
set.add(float.class);
return set;
} |
2979a7e7-4cff-4ac0-9125-627188eb04ad | 3 | public static void square(double x, double y, double r) {
if (r < 0) {
throw new IllegalArgumentException("square side length must be nonnegative");
}
double xs = scaleX(x);
double ys = scaleY(y);
double ws = factorX(2 * r);
double hs = factorY(2 * r);
if (ws <= 1 && hs <= 1) {
pixel(x, y);
} else {
offscreen.draw(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
}
draw();
} |
e5be30dd-751f-4dfb-9aac-ec7d8ff63db9 | 4 | private static void bilinear(float p) {
ImageData imageData = original.getImageData();
int[][] two1 = new int[imageData.height][imageData.width];
for (int i = 0; i < imageData.height; i++) {
for (int j = 0; j < imageData.width; j++) {
two1[i][j] = imageData.getPixel(j, i);
}
}
int[] one1 = ImageUtils.two2one(two1);
int w = imageData.width;
int h = imageData.height;
int ow = (int)(w*p);
int oh = (int)(h*p);
int[] one2 = GT.bilinear(one1,w, h,ow, oh, p );
int[][] two2 = ImageUtils.one2two(one2, ow, oh);
imageData = new ImageData(ow, oh, 8, imageData.palette);
for (int i = 0; i < oh; i++) {
for (int j = 0; j < ow; j++) {
imageData.setPixel(j, i, two2[i][j]);
}
}
bilinear = new Image(original.getDevice(), imageData);
bilinearHisto = ImageUtils.analyzeHistogram(bilinear.getImageData());
} |
155cf5e9-1d0c-4056-a843-629bb8bd0544 | 2 | @Override
public RegisterUserResponse registerUser(String username, String password) {
ArrayList<Pair<String,String>> requestHeaders = new ArrayList<Pair<String,String>>();
requestHeaders.add(new Pair<String,String>(CONTENT_TYPE_STR, APP_JSON_STR));
UserRequest loginRequest = new UserRequest(username, password);
ICommandResponse response = this.clientCommunicator.executeCommand(RequestType.POST, requestHeaders,"user/register", loginRequest, String.class);
boolean successful = false;
String cookie = "";
String playerName = "";
int playerID = -1;
if(response.getResponseCode() == 200) {
successful = true;
cookie = response.getResponseHeaders().get("Set-cookie").get(0);
int index = cookie.lastIndexOf(";Path=/");
cookie = cookie.substring(0, index);
String subCookie = cookie.replaceFirst("catan.user=", "");
PlayerLoginCookie playerCookie = null;
try {
String cookieJSON = URLDecoder.decode(subCookie, this.cookieEncoding);
playerCookie = (PlayerLoginCookie) this.cookieTranslator.translateFrom(cookieJSON, PlayerLoginCookie.class);
playerID = playerCookie.getPlayerID();
playerName = playerCookie.getName();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return new RegisterUserResponse(successful, response.getResponseMessage(), playerName, cookie, playerID);
} |
f140e124-9746-4e43-a64a-9c1dd568edfe | 4 | private void removeIcon(String icon) {
for (Pair<String, Integer> pair : icons) {
if (pair.getLeft().equals(icon)) {
icons.remove(pair);
break;
}
}
for (Channel channel : getChannels()) {
String remove = PacketCreator.removeIcon(channel.getName(), name,
icon);
for (Client target : channel.getClients()) {
target.send(remove);
}
}
} |
39e8c57b-0b45-43fa-93ae-752f981ebf87 | 8 | private boolean createTable() {
Connection conn = null;
Statement s = null;
ResultSet rs = null;
try {
conn = getConnection();
s = conn.createStatement();
s.executeUpdate(sqlMakeTable);
try {
// make sure `uuid` column exists, otherwise table is outdated and needs to be dropped and made again
rs = s.executeQuery(sqlCheckTableUUID);
if (!rs.first())
{
log.info(name + ": Table outdated and missing UUID column, dropping and recreating");
s.executeUpdate(sqlDropTable);
s.executeUpdate(sqlMakeTable);
}
rs.close();
} catch (SQLException ex2){}
rs = s.executeQuery(sqlCheckTableExist);
if (rs.first()) {
rs.close();
s.close();
conn.close();
return true;
}
} catch (SQLException ex) {
log.severe(name + ": " + ex.getMessage());
} finally {
try {
if (rs != null)
rs.close();
if (s != null)
s.close();
if (conn != null)
conn.close();
} catch (SQLException ex) {
log.severe(name + ": " + ex.getMessage());
}
}
return false;
} |
fcc9afdc-0003-4e61-b086-25f4c89b5ebb | 5 | private boolean purchase(ShopItem item, int amount)
throws InterruptedException {
final int oldID = item.getID();
validate(item.getSlot());
if (oldID != item.getID())
throw new RuntimeException("Inconsistent item! Required: " + oldID + ", but found: " + item.getID());
else if (item.getAmount() <= 0)
return false;
switch (amount) {
case 1:
return item.purchaseOne();
case 5:
return item.purchaseFive();
case 10:
return item.purchaseTen();
}
return false;
} |
37e19b6e-025e-4971-950b-839a2ad6d61b | 8 | public static synchronized String[] getTwitchStreamList() {
//TODO ensure these streams are loaded up via text file
twitchStream.areStreamsUp();
ArrayList<String> streamList = TwitchStream.getStreamList(); //ids for stream
ArrayList<String> streamName = TwitchStream.getStreamName(); //name for streamer
ArrayList<Boolean> streamAlive = TwitchStream.getStreamAlive(); //whether the stream is up or not
ArrayList<String> finalList = new ArrayList<>();
ArrayList<String> onlineList = new ArrayList<>();
ArrayList<String> offlineList = new ArrayList<>();
ArrayList<String> makeLowercase = new ArrayList<>();
try {
for(int i = 0; i < streamList.size(); i++) {
//checks if streamer is on
String tempName = streamName.get(i);
if (Character.isAlphabetic(tempName.charAt(0)) && !Character.isUpperCase(tempName.charAt(0))) {
makeLowercase.add(tempName);
tempName = Character.toUpperCase(tempName.charAt(0)) + tempName.substring(1);
}
if (streamAlive.get(i)) {
onlineList.add(tempName +" (ONLINE)");
} else {
offlineList.add(tempName);
}
}
} catch (Exception e) {
// System.out.println(e);
//Can error here from multi threading from adding and removing streams
}
Collections.sort(onlineList);
Collections.sort(offlineList);
finalList.addAll(onlineList);
finalList.addAll(offlineList);
for (int i =0; i < finalList.size(); i++) {
for(String lowercase : makeLowercase) {
if (finalList.get(i).equalsIgnoreCase(lowercase)) {
finalList.set(i, lowercase);
}
}
}
return finalList.toArray(new String[finalList.size()]);
} |
b28abffa-6ef3-4dff-a56e-3e8b20991364 | 4 | private static void typeCheckCodeGenerator( SemanticAction node, String leftOrRight )
{
switch ( node.getType() )
{
case DEFINITION:
if( !node.getName().equals("main") ){
}
break;
case PRINT:
break;
case INTEGER:
break;
}
} |
0f9249c2-c13c-4a61-b600-c471a89e8e26 | 0 | public String getColumnName() {
return name;
} |
162d543b-2aeb-4f54-8761-8279e31b8c4f | 7 | public void RSAEncrypt(int length) throws RdesktopException {
byte[] inr = new byte[length];
// int outlength = 0;
BigInteger mod = null;
BigInteger exp = null;
BigInteger x = null;
this.reverse(this.exponent);
this.reverse(this.modulus);
System.arraycopy(this.client_random, 0, inr, 0, length);
this.reverse(inr);
if ((this.modulus[0] & 0x80) != 0) {
byte[] temp = new byte[this.modulus.length + 1];
System.arraycopy(this.modulus, 0, temp, 1, this.modulus.length);
temp[0] = 0;
mod = new BigInteger(temp);
} else {
mod = new BigInteger(this.modulus);
}
if ((this.exponent[0] & 0x80) != 0) {
byte[] temp = new byte[this.exponent.length + 1];
System.arraycopy(this.exponent, 0, temp, 1, this.exponent.length);
temp[0] = 0;
exp = new BigInteger(temp);
} else {
exp = new BigInteger(this.exponent);
}
if ((inr[0] & 0x80) != 0) {
byte[] temp = new byte[inr.length + 1];
System.arraycopy(inr, 0, temp, 1, inr.length);
temp[0] = 0;
x = new BigInteger(temp);
} else {
x = new BigInteger(inr);
}
BigInteger y = x.modPow(exp, mod);
this.sec_crypted_random = y.toByteArray();
if ((this.sec_crypted_random[0] & 0x80) != 0) {
throw new RdesktopException(
"Wrong Sign! Expected positive Integer!");
}
if (this.sec_crypted_random.length > SEC_MODULUS_SIZE) {
// logger.warn("sec_crypted_random too big!"); /* FIXME */
}
this.reverse(this.sec_crypted_random);
byte[] temp = new byte[SEC_MODULUS_SIZE];
if (this.sec_crypted_random.length < SEC_MODULUS_SIZE) {
System.arraycopy(this.sec_crypted_random, 0, temp, 0,
this.sec_crypted_random.length);
for (int i = this.sec_crypted_random.length; i < temp.length; i++) {
temp[i] = 0;
}
this.sec_crypted_random = temp;
}
} |
63939d01-ed44-4ae4-ac8a-3fbc3d5895a9 | 0 | public void setSecond(T newValue) { second = newValue; } |
56671f2a-cb4e-4b79-b532-2328103c38ea | 5 | static final synchronized void method1142(byte i) {
anInt1913++;
if (Class168.anObject2256 == null) {
try {
Class var_class
= Class.forName("java.lang.management.ManagementFactory");
Method method
= var_class.getDeclaredMethod("getPlatformMBeanServer",
null);
Object object = method.invoke(null, null);
if (i == 26) {
Method method_37_
= (var_class.getMethod
("newPlatformMXBeanProxy",
(new Class[]
{ (Class.forName
("javax.management.MBeanServerConnection")),
(aClass1919 != null ? aClass1919
: (aClass1919
= method1143("java.lang.String"))),
(aClass1920 != null ? aClass1920
: (aClass1920
= method1143("java.lang.Class"))) })));
Class168.anObject2256
= (method_37_.invoke
(null,
(new Object[]
{ object,
"com.sun.management:type=HotSpotDiagnostic",
(Class.forName
("com.sun.management.HotSpotDiagnosticMXBean")) })));
}
} catch (Exception exception) {
System.out.println("HeapDump setup error:");
exception.printStackTrace();
}
}
} |
c8c2199f-9bcc-4992-894e-0f175eda786f | 4 | @Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (! (obj instanceof MessageContainer)) {
return false;
}
MessageContainer other = (MessageContainer) obj;
if (messageID != other.messageID) {
return false;
}
return true;
} |
20190c9f-20e2-4240-a09c-03351eb8718e | 1 | private static int decodeConnectionId(byte connectionId) {
return (int) (connectionId < 0 ? connectionId - 2*Byte.MIN_VALUE : connectionId);
} |
a84cb0e3-6545-4853-877b-5235781f6934 | 6 | public char charAt(int index) throws IndexOutOfBoundsException, NullPointerException {
if(index < 0 || index > this.length() - 1) {
throw new IndexOutOfBoundsException();
}
if(this.head == null) {
throw new NullPointerException();
}
this.current = this.head;
for(int i = 1; i <= index; i++) {
if(this.current == null) {
throw new NullPointerException();
}
if (this.current.getPointer() == null) {
return current.getData();
}
this.current = this.current.getPointer();
}
return this.current.getData();
} |
f5d93d84-e1b8-4236-bc84-6af3a9cd72fe | 0 | @Override
public void run() {
MailUtil.sendMailSynchron(subject, content, email, force);
} |
c74d33a8-c695-4540-9daf-610bba6a0248 | 4 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
try {
String empleado = JOptionPane.showInputDialog("Confirmar");
String sql = "INSERT INTO ventas(Empleados_idEmpleados, precio_total) VALUES( ?, ? )";
String sql1 = "INSERT INTO productos_has_ventas(productos_idproductos, ventas_idventas, cantidad_venta) VALUES(?, ?, ?) ";
String sql3 = "UPDATE productos "
+ "SET cantidad = cantidad - ? "
+ "WHERE idproductos = ? ";
String sql4 = "SELECT idempleados FROM empleados WHERE idempleados = ?";
Connection conn = Conexion.GetConnection();
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sql);
PreparedStatement ps1 = conn.prepareStatement(sql1);
PreparedStatement ps3 = conn.prepareStatement(sql3);
PreparedStatement ps4 = conn.prepareStatement(sql4);
ps4.setString(1, empleado);
ResultSet rs = ps4.executeQuery();
if (rs.next()) {
ps.setString(1, empleado);
ps.setString(2, jLblPrecio.getText());
ps.execute();
conn.commit();
String sqlLast = "SELECT `AUTO_INCREMENT` - 1 "
+ " FROM INFORMATION_SCHEMA.TABLES "
+ " WHERE TABLE_SCHEMA = 'gamecrush' "
+ " AND TABLE_NAME = 'ventas' ";
Connection connLast = Conexion.GetConnection();
PreparedStatement psLast = connLast.prepareStatement(sqlLast);
lastId = psLast.executeQuery();
lastId.next();
String lastIdPed = lastId.getString(1);
System.out.println(lastIdPed);
int rows2 = jTableVentas.getRowCount();
for (int j = 0; j < rows2; j++) {
ps3.setInt(1, (int) tmVent.getValueAt(j, 2));
ps3.setString(2, (String) tmVent.getValueAt(j, 0));
ps3.executeUpdate();
conn.commit();
}
for (int j = 0; j < rows2; j++) {
ps1.setString(1, (String) tmVent.getValueAt(j, 0));
ps1.setString(2, lastIdPed);
ps1.setInt(3, (int) tmVent.getValueAt(j, 2));
ps1.execute();
conn.commit();
}
cancelVenta();
clearVenta();
} else {
JOptionPane.showMessageDialog(this, "Empleado no valido");
}
ps.setString(1, sql);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}//GEN-LAST:event_jButton1ActionPerformed |
6372ff6b-d8ca-4abf-9427-6757ca54db8f | 1 | public void usingEntrySet(Map<Integer, String> map){
for(Map.Entry<Integer, String> entry: map.entrySet()){
System.out.println("Key: "+entry.getKey()+" Value: "+entry.getValue());
}
} |
e01fdca7-7e33-489d-9eed-06fd785605d0 | 3 | public void addTile(int tileX, int tileY, int tileType)
{
Tile tile = null;
if(tileType == TileTypes.BASIC_WALL)
{
tile = new TileWall(tileX * Tile.TILE_SIZE, tileY * Tile.TILE_SIZE, true);
}
else if(tileType == TileTypes.PATH)
{
tile = new TilePath(tileX * Tile.TILE_SIZE, tileY * Tile.TILE_SIZE, false);
}
else if(tileType == TileTypes.DIAMOND)
{
tile = new TileCollectableDiamond(tileX * Tile.TILE_SIZE, tileY * Tile.TILE_SIZE, true);
}
tiles[tileX][tileY] = tile;
} |
77fb2a4d-5089-453f-b86d-5670cda4a2d6 | 1 | public String getMethodrefClassName(int index) {
MethodrefInfo minfo = (MethodrefInfo)getItem(index);
if (minfo == null)
return null;
else
return getClassInfo(minfo.classIndex);
} |
02f28479-b66f-47a6-a4fb-7440e8903fac | 0 | public Image getImageBytesAndContentTypeById(String id) {
return imageTemplateRepository.getImageBytesAndContentTypeById(id);
} |
741cc5c4-5e42-437c-a9db-7d749d08e1a1 | 1 | public static World GetWorld(String name) {
if (Core.getPlugin().getServer().getWorld(name) == null) {
LoadWorld(name);
}
return Core.getPlugin().getServer().getWorld(name);
} |
adf8b09c-843c-470d-a54d-2a3b79340453 | 4 | @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event){
Player player = event.getPlayer();
if(isSignLine(event.getLine(0)))
for(String s : signLines)
if(event.getLine(0).equalsIgnoreCase(s)) {
if(player.hasPermission("bank.sign.place")) {
event.setLine(0, s);
player.sendMessage(Messages.signRegistered);
} else event.setLine(0, ChatColor.RED + s + ChatColor.RED); //The last + ChatColor.RED is to center it properly ;p
break;
}
} |
27a40875-b86b-48fe-b24b-12b7a0bba186 | 8 | private void calculateDimensions( int cWidth, int cHeight )
{
// Calculate chart dimensions
chartWidth = ( cWidth == 0 ? DEFAULT_WIDTH : cWidth );
chartHeight = ( cHeight == 0 ? DEFAULT_HEIGHT : cHeight );
if ( cWidth > 0 ) numPoints = cWidth;
// Padding depends on grid visibility
chart_lpadding = ( graphDef.showMajorGridY() ? graphDef.getChartLeftPadding() : CHART_LPADDING_NM );
chart_bpadding = ( graphDef.showMajorGridX() ? CHART_BPADDING : CHART_BPADDING_NM );
// Size of all lines below chart
commentBlock = 0;
if ( graphDef.showLegend() )
commentBlock = graphDef.getCommentLineCount() * (nfont_height + LINE_PADDING) - LINE_PADDING;
// x_offset and y_offset define the starting corner of the actual graph
x_offset = LBORDER_SPACE;
if ( graphDef.getVerticalLabel() != null )
x_offset += nfont_height + LINE_PADDING;
imgWidth = chartWidth + x_offset + RBORDER_SPACE + chart_lpadding + CHART_RPADDING;
y_offset = UBORDER_SPACE;
if ( graphDef.getTitle() != null ) // Title *always* gets a extra LF automatically
y_offset += ((tfont_height + LINE_PADDING) * graphDef.getTitle().getLineCount() + tfont_height) + LINE_PADDING;
imgHeight = chartHeight + commentBlock + y_offset + BBORDER_SPACE + CHART_UPADDING + CHART_BPADDING;
} |
a433f611-2543-40e6-a660-426e44735dc2 | 9 | public int getDiggingDepth(Item item)
{
if(item==null)
return 1;
switch(item.material()&RawMaterial.MATERIAL_MASK)
{
case RawMaterial.MATERIAL_METAL:
case RawMaterial.MATERIAL_MITHRIL:
case RawMaterial.MATERIAL_WOODEN:
if(item.Name().toLowerCase().indexOf("shovel")>=0)
return 5+item.phyStats().weight();
return 1+(item.phyStats().weight()/5);
case RawMaterial.MATERIAL_SYNTHETIC:
case RawMaterial.MATERIAL_ROCK:
case RawMaterial.MATERIAL_GLASS:
if(item.Name().toLowerCase().indexOf("shovel")>=0)
return 14+item.phyStats().weight();
return 1+(item.phyStats().weight()/7);
default:
return 1;
}
} |
d21a5c22-f9c9-430b-a06d-7d2c0a37dd24 | 5 | public boolean setField(int maxField, int nodeID, int eventType,
int startTime, int endTime) {
// need to subtract by 1 since array starts at 0.
if (nodeID > 0) {
NODE_ID = nodeID - 1;
} else
throw new IllegalArgumentException("Invalid node id field.");
// get the max. number of field
if (maxField > 0) {
MAX_FIELD = maxField;
} else {
throw new IllegalArgumentException("Invalid max. number of field.");
}
// get the event type field
if (eventType > 0) {
EVENT_TYPE = eventType - 1;
} else {
throw new IllegalArgumentException("Invalid event type field.");
}
// get the start time field
if (startTime > 0) {
START_TIME = startTime - 1;
} else {
throw new IllegalArgumentException("Invalid start time field.");
}
// get the end time field
if (endTime > 0) {
END_TIME = endTime - 1;
} else {
throw new IllegalArgumentException("Invalid end time field.");
}
return true;
} |
64349727-3e48-4083-bc93-92b4ee655c70 | 1 | public UserDao getUserDao(){
if(userDao == null)
userDao = new UserDaoImpl();
return userDao;
} |
e72574c9-ec12-44b4-b1d0-1185e891db46 | 6 | public void goTop()
{
nNode = top;
sRecno = 0;
found = false;
for(;;)
{
goNode();
readPage();
if(left_page>0) nNode=left_page;
else
{
for(;;)
{
if(key_cnt>0 || right_page<0) break;
nNode = right_page;
goNode();
readPage();
}
nKey = 0;
if(LEAF)
{
found = true;
sRecno = pgR[nKey];
break;
}
else nNode = pgR[nKey];
}
}
} |
b89c4202-5524-4f3d-b39c-fbaa756753d3 | 3 | @Override
protected void resolveCollision(GameContext g, Collidable c, float percent) {
// if (isDead) {
// return;
// }
if (c instanceof DynamicPolygon) {
DynamicPolygon d = (DynamicPolygon)c;
// if (d.isDead) {
// return;
// }
setCollisionPosition(percent);
if (d.vertices != vertices)
return;
// kill both polygons
// setDead(true);
// d.setDead(true);
g.removals.add(this);
g.removals.add(d);
// create new polygon
int newVertices = vertices+1;
Vector newVelocity = Vector.scalar(.75F,Vector.add(velocity,d.velocity));
g.additions.add(new DynamicPolygon(model,collisionPosition.x,collisionPosition.y,newVelocity.x,newVelocity.y,newVertices));
// create remainder dots
int numDots = vertices - 2;
for (int i = 0; i < numDots; i++) {
float xVel = model.dotMaxVel*model.getRandom().nextFloat() - (model.dotMaxVel/2F);
float yVel = model.dotMaxVel*model.getRandom().nextFloat() - (model.dotMaxVel/2F);
g.additions.add(new Dot(model,collisionPosition.x,collisionPosition.y,xVel,yVel,true));
}
g.additions.add(new Explosion(model,collisionPosition.x,collisionPosition.y,Parameters.LINE_COLOR));
}
} |
109a72e6-54ec-4a59-8ea0-09b8df6fc442 | 1 | public String toString() {
try {
return this.toJSON().toString(4);
} catch (JSONException e) {
return "Error";
}
} |
626ab57b-b719-4856-ac1a-8c608417d158 | 8 | private static void point_search(finger_print fp) {
// TODO Auto-generated method stub
ArrayList<Integer> lst = new ArrayList<Integer>();
for (Integer fid : fp.feature_map.keySet()) {
if (finger_print.invert_index.containsKey(fid)) {
for (Integer potent : finger_print.invert_index.get(fid)
.keySet()) {
lst.add(potent);
}
}
break;
}
for (Integer fid : fp.feature_map.keySet()) {
double fval = fp.feature_map.get(fid);
for (int i = 0; i < lst.size(); i++) {
if (!finger_print.invert_index.containsKey(fid)) {
lst.clear();
break;
}
else if (!finger_print.invert_index.get(fid).containsKey(
lst.get(i))) {
lst.remove(i);
i--;
} else if (finger_print.invert_index.get(fid).get(lst.get(i)) != fval) {
lst.remove(i);
i--;
}
}
}
System.out.println(lst.size());
} |
d7da8fd5-d8bb-4802-9939-1b58ab199423 | 4 | private void addHouse(Tile temp, Point position)
{
MapObject obj = new Building(temp, sfap.objSize,
this.TILE_SIZE, position, 0);
if (Collision.noCollision(grid, obj.getStartPos(), obj.getEndPos()))
{
if (!Collision.intersects(obj.getPlace(), gridBoundary))
{
for (int k = position.x; k < position.x + sfap.objSize.height; k++)
{
for (int l = position.y; l < position.y + sfap.objSize.width; l++)
{
gridArea--;
this.mapObjects.add(obj);
this.grid[k][l].setObject(obj);
}
}
}
}
} |
6f42370b-ba82-40ec-90a5-50e45c5c90ed | 6 | public boolean contains(Vector vector) {
if(vector.x > max.x || vector.x < min.x || vector.y > max.y || vector.y < min.y) {
return false;
}
Edge ray = new Edge(vector, new Vector(min.x - 1, min.y - 1));
int intersections = 0;
for(Edge edge : edges) {
if(ray.intersects(edge, true)) {
intersections++;
}
}
return (intersections % 2) == 1;
} |
694388fa-f8c6-4784-b6e9-d8fe2ed61247 | 2 | @Override
public int matches( char[] sequenceA, int indexA, char[] sequenceB, int indexB, int count )
{
for (int i = 0; i < count; i++)
{
char a = sequenceA[indexA + i];
char b = sequenceB[indexB + i];
if (Character.toLowerCase( a ) != Character.toLowerCase( b ))
{
return i;
}
}
return count;
} |
a4d22559-ac34-41b8-a7a9-672b3618bc5c | 6 | public static ArrayList<IStudent> sort(ArrayList<IStudent> students) throws IllegalArgumentException {
ArrayList<IStudent> temp1 = new ArrayList<>();
ArrayList<IStudent> temp2 = new ArrayList<>();
ArrayList<IStudent> temp3 = new ArrayList<>();
ArrayList<IStudent> temp4 = new ArrayList<>();
ArrayList<IStudent> tempResult = new ArrayList<>();
if (!students.isEmpty()) {
for (IStudent student : students) {
int rank = student.getSatifaction();
if (rank == 1) {
temp1.add(student);
} else if (rank == 2) {
temp2.add(student);
} else if (rank == 3) {
temp3.add(student);
} else if (rank == 4) {
temp4.add(student);
}
}
tempResult.addAll(temp1);
tempResult.addAll(temp2);
tempResult.addAll(temp3);
tempResult.addAll(temp4);
} else {
throw new IllegalArgumentException("Utilities.sort - ArrayList is empty");
}
return tempResult;
} |
c30844cd-8ddc-4069-b3a3-78d3502d88f3 | 5 | public static String writeKarnaughMap(KarnaughTable kmap, int nbrVars) {
int width = nbrVars * 50;
String s = "";
s += "<div id=\"cent\" align=\"center\">";
s += "<h3 class =\"subsubTitle2\">"
+ Tools.getLocalizedString("KARNAUGH_MAP.Name") + ":" + "</h3>";
s += "<table width=\"" + width + "\"><tr>";
s += "<th></th>";
String[] colomNames = getColonneName(nbrVars);
String[] linesNames = getLigneName(nbrVars);
for (int i = 0; i < colomNames.length; i++) {
s += "<th>" + colomNames[i] + "</th>";
}
s += "</tr><tr>";
for (int i = 0; i < kmap.getRow(); i++) {
for (int j = 0; j < kmap.getColumn() + 1; j++) {
if (j == 0)
s += "<th>" + linesNames[i] + "</th>";
else {
if (kmap.getCellValue(i, j - 1))
s += "<td class=\"ones\">1</td>";
else
s += "<td>0</td>";
}
}
s += "</tr><tr>";
}
s = s.substring(0, s.length() - 4);
s += "</table>";
s += "</div>";
return s;
} |
923fed4d-b305-4f78-bd39-5d0999ee29e7 | 9 | private Mob(Map<String, Object> cfg)
{
super.setMapCfg(cfg);
spawnChance = getAndSet("SpawnChance", 1);
int maxAlive = getAndSet("MaxAlive", 0);
int mobCooldown = getAndSet("MobCooldown", 60) * 1000;
boolean enforceAllRemovalConditions = getAndSet("EnforceAllCooldownConditions", false);
if (maxAlive > 0)
maxAliveLimiter = new MobCounter(maxAlive, mobCooldown, enforceAllRemovalConditions);
playerLimitGroup = getAndSet("PlayerLimitGroup", "").toLowerCase();
regionLimitGroup = getAndSet("RegionLimitGroup", "").toLowerCase();
heightOffset = getAndSet("HeightOffset", 0);
bypassMobManagerLimit = getAndSet("BypassMobManagerLimit", false);
bypassSpawnLimits = getAndSet("BypassPlayerAndRegionMobLimit", false);
delayRequirementsCheck = getAndSet("DelayRequirementsCheck", false);
mobType = ExtendedEntityType.valueOf(getAndSet("MobType", "UNKNOWN"));
if (MMComponent.getAbilities().isEnabled())
{
String abilitySetName = getAndSet("AbilitySet", "default");
abilitySet = abilitySetName.equalsIgnoreCase("default") ? null : AbilitySet.getAbilitySet(abilitySetName);
if (abilitySetName.equalsIgnoreCase("default") && abilitySet == null)
MMComponent.getSpawner().warning("Missing AbilitySet: " + abilitySetName);
if (abilitySet != null && mobType == ExtendedEntityType.UNKNOWN)
mobType = abilitySet.getAbilitySetsEntityType();
}
if (mobType == ExtendedEntityType.UNKNOWN)
{
super.clearCfg();
return;
}
Map<String, Object> cfgMap = MiscUtil.copyConfigMap(getAndSet("Requirements", new LinkedHashMap<String, Object>()));
requirements = new SpawnRequirements(cfgMap);
set("Requirements", cfgMap);
if (!requirements.required())
requirements = null;
cfgMap = MiscUtil.copyConfigMap(getAndSet("Action", new LinkedHashMap<String, Object>()));
action = new Action(cfgMap);
set("Action", cfgMap);
super.clearCfg();
} |
dc54667b-8a62-43ff-a6ea-fa7a978950d3 | 1 | public int exprHashCode() {
int v = 5 + kind ^ receiver.exprHashCode();
for (int i = 0; i < params.length; i++) {
v ^= params[i].exprHashCode();
}
return v;
} |
dae47a53-4768-4dbb-a60c-c8ddfce5e120 | 3 | public DirtBasedAgentState(MovementAction action, Sensor sensor) {
super(action);
dist = new int [Direction.values().length];
type = new int [Direction.values().length];
for (String s : sensor.getSenseKeys()){
String tag[] = s.split("-");
Direction d = Direction.valueOf(tag[0]);
if (s.contains(DirtBasedAgentSenseConfig.DISTANCE_SUFFIX)){
dist[d.ordinal()] = (int) sensor.getSense(s).getValue();
}else if (s.contains(DirtBasedAgentSenseConfig.TYPE_SUFFIX)){
type[d.ordinal()] = (int) sensor.getSense(s).getValue();
}
}
} |
b31171c6-1d21-4ecb-ab18-515230de99fe | 8 | public static ArtNetObject decodeArtNetPacket(final byte[] packet, final InetAddress ip) {
// The ArtNetPacket.
final ArtNetObject artNetObject = null;
// Set generals infos
final String hexaBrut = byteArrayToHex(packet);
final String id = new String(packet, 0, 7);
// Extract OpCode
int opCode = ((packet[9] & 0xFF) << 8) | (packet[8] & 0xFF);
opCode = Integer.parseInt(Integer.toHexString(opCode));
// Yes, it's a ArtNetPacket
if (!"Art-Net".equals(id)) {
return null;
}
/*
* Dicover the type of the packet.
* Please refer to OpcodeTable.
*/
if (OpCodeConstants.OPPOLL == opCode) {
/*
* ArtPollPacket : This is an ArtPoll packet,
* no other data is contained in this UDP packet
*/
if (!checkVersion(packet, hexaBrut)) {
return null;
}
return decodeArtPollPacket(packet, hexaBrut);
} else if (OpCodeConstants.OPTIMECODE == opCode) {
/*
* ArtTimePacket : OpTimeCode
* This is an ArtTimeCode packet.
* It is used to transport time code over the network.
*/
if (!checkVersion(packet, hexaBrut)) {
return null;
}
return decodeArtTimeCodePacket(packet, hexaBrut);
} else if (OpCodeConstants.OPPOLLREPLY == opCode) {
// ArtPollReply : This is a ArtPollReply packet.
return decodeArtPollReplyPacket(packet, hexaBrut, ip);
} else if (OpCodeConstants.OPOUTPUT == opCode) {
// ArtDMX
return decodeArtDMXPacket(packet, hexaBrut);
} else if (OpCodeConstants.ARTADDRESS == opCode) {
// ArtAddress
return decodeArtAddressPacket(packet, hexaBrut);
}
return artNetObject;
} |
d2046fa5-1a03-4d7f-88e4-861f0a027b01 | 9 | public static int[][] generateSpiralMatrix(int n) {
if(n < 1) {
return null;
}
int[][] input = new int[n][n];
int count = 1;
int rowStart = 0;
int rowEnd = n-1;
int columnStart = 0;
int columnEnd = n-1;
while(rowStart<= rowEnd && columnStart<=columnEnd) {
// print the upper edge
for(int i = columnStart; i <= columnEnd; i++) {
input[rowStart][i] = count++;
}
rowStart++;
// print the right edge
for( int i = rowStart; i<= rowEnd; i++) {
input[i][columnEnd] = count++;
}
columnEnd --;
//print the bottom edge if required
if(rowStart <= rowEnd) {
for( int i = columnEnd; i >= columnStart; i--) {
input[rowEnd][i] = count++;
}
rowEnd--;
}
//print the left edge if necessary
if(columnStart<=columnEnd) {
for(int i = rowEnd; i>= rowStart; i--) {
input[i][columnStart] = count++;
}
columnStart++;
}
}
return input;
} |
2e434675-3e0a-42d5-8241-40febae265a9 | 8 | public void setSecurity(Security value)
{
security = value;
String userName = security.getUserName();
String passwordText = security.getPassword();
String account = security.getAccount();
if (userName != null && userName.trim().length() != 0)
{
// If no password is given and the userName contains "@" and an account is given, then
// append the account to the username (e.g. joe@1234567890).
if (passwordText == null || passwordText.length() == 0)
{
if (userName.indexOf("@") < 0 && account != null && account.length() > 0)
{
userName += "@" + account;
}
}
}
else if (account.trim().length() != 0)
{
userName = security.getAccount().trim();
passwordText = security.getLicense().trim();
}
else
{
throw new IllegalStateException("Must supply either a " +
"valid Account or UserName in the " +
"avatax4j.properties file");
}
SecurityHeader securityHeader = new SecurityHeader();
UsernameToken usernameToken = new UsernameToken();
usernameToken.setUsername(userName);
Password password = new Password();
password.setType(PASSWORD_TEXT_TYPE);
password.set_value(passwordText);
usernameToken.setPassword(password);
securityHeader.setUsernameToken(usernameToken);
setHeader(WSSE_NAMESPACE, "Security", securityHeader);
} |
3c9e8d72-dc97-4972-980f-f2cb5ec833a7 | 2 | public static void loadFromFile() throws Exception{
String filename = "Girl.bin";
File file = new File(filename);
FileInputStream fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis);
try{
Object temp = ois.readObject();
if(temp.getClass().getName().equals("Girl")){
head = (Girl) temp;
}
}catch(EOFException e){
System.out.println("File loaded");
}
} |
dc606593-d388-4fb5-b04d-d8076361453a | 6 | public void pintarTableroVirtual() {
int aleatorio;
Random pitopitogorgorito=new Random();
for (int i = matrizVirtual.length-1; i >= 0; i--) {
System.out.println(" _______________________________________");
System.out.print(i + " |");
for (int j = 0; j < matrizVirtual[0].length; j++) {
switch (matrizVirtual[j][i]) {
case 0:
{
aleatorio=pitopitogorgorito.nextInt(4);
if(aleatorio==0)
System.out.print(" ~ |");
else
System.out.print(" |");
}
break;
case 1:
System.out.print(" # |");
break;
case 2:
System.out.print(" * |");
break;
}
}
System.out.println();
}
System.out.println(" ---------------------------------------");
System.out.println(" 0 1 2 3 4 5 6 7 8 9");
System.out.println();
} |
9144bcc6-d52a-44ea-841d-7054270ab579 | 1 | private String chooseFile(String mode)
{
JFileChooser chooser = getFileChooser(mode);
if (chooser.showDialog(org.analyse.main.Main.analyseFrame, null) == JFileChooser.APPROVE_OPTION) {
return chooser.getSelectedFile().getAbsolutePath();
}
return null;
} |
14356e23-30df-4d26-aeb3-7e75511ea5e3 | 4 | public boolean contains(final Location location) {
return world.equalsIgnoreCase(location.getWorld().getName()) && location.getX() <= xMax && location.getZ() <= zMax && location.getX() >= xMin && location.getZ() >= zMin;
} |
7353ff2d-0326-4aa8-b144-a470f40ab098 | 8 | protected void layout(Composite composite, boolean flushCache) {
Rectangle rect = composite.getClientArea();
Control[] children = composite.getChildren();
int count = children.length;
if (count == 0)
return;
int width = rect.width - marginWidth * 2;
int height = rect.height - marginHeight * 2;
if (type == SWT.HORIZONTAL) {
width -= (count - 1) * spacing;
int x = rect.x + marginWidth, extra = width % count;
int y = rect.y + marginHeight, cellWidth = width / count;
for (int i = 0; i < count; i++) {
Control child = children[i];
int childWidth = cellWidth;
if (i == 0) {
childWidth += extra / 2;
} else {
if (i == count - 1)
childWidth += (extra + 1) / 2;
}
child.setBounds(x, y, childWidth, height);
x += childWidth + spacing;
}
} else {
height -= (count - 1) * spacing;
int x = rect.x + marginWidth, cellHeight = height / count;
int y = rect.y + marginHeight, extra = height % count;
for (int i = 0; i < count; i++) {
Control child = children[i];
int childHeight = cellHeight;
if (i == 0) {
childHeight += extra / 2;
} else {
if (i == count - 1)
childHeight += (extra + 1) / 2;
}
child.setBounds(x, y, width, childHeight);
y += childHeight + spacing;
}
}
} |
73f68352-0535-4a9f-87ae-eadda1d93602 | 2 | public final Hashtable<Integer,Integer> distributionOnl() {
final Hashtable<Integer,Integer> onld = new Hashtable<Integer,Integer>();
for (int m=0; m<this.m; m++) {
final Integer key = onl[m].size();
Integer value = onld.get(key);
if (value==null) onld.put(key, value);
else value++;
}
return onld;
} |
d915318f-7f0c-4736-9135-cf7dad6032a2 | 8 | public void pixel_frontiere_proche(int i, int j, Image image){
//Si le pixel n'est pas en haut
if(i != 0){
if(image.getPixel(i - 1, j).getColor().equals(Color.BLACK)){
image.getPixel(i, j).setFrontiereProche(true);
}
}
//Si le pixel n'est pas en bas
if(i != image.getHauteur() - 1){
if(image.getPixel(i + 1, j).getColor().equals(Color.BLACK)){
image.getPixel(i, j).setFrontiereProche(true);
}
}
//Si le pixel n'est pas à gauche
if(j != 0){
if(image.getPixel(i, j - 1).getColor().equals(Color.BLACK)){
image.getPixel(i, j).setFrontiereProche(true);
}
}
//Si le pixel n'est pas à droite
if(j != image.getLargeur() - 1){
if(image.getPixel(i, j + 1).getColor().equals(Color.BLACK)){
image.getPixel(i, j).setFrontiereProche(true);
}
}
} |
f48c9f3b-12f0-4211-8dbb-b6b6c420ed8e | 6 | private void cancelKeys() {
if (cancelQueue.isEmpty())
return;
Selector selector = this.selector;
for (;;) {
CancellationRequest request = cancelQueue.poll();
if (request == null) {
break;
}
DatagramChannel ch = channels.remove(request.address);
// close the channel
try {
if (ch == null) {
request.exception = new IllegalArgumentException(
"Address not bound: " + request.address);
} else {
SelectionKey key = ch.keyFor(selector);
request.registrationRequest = (RegistrationRequest) key
.attachment();
key.cancel();
selector.wakeup(); // wake up again to trigger thread death
ch.disconnect();
ch.close();
}
} catch (Throwable t) {
ExceptionMonitor.getInstance().exceptionCaught(t);
} finally {
synchronized (request) {
request.done = true;
request.notify();
}
if (request.exception == null) {
getListeners().fireServiceDeactivated(this,
request.address,
request.registrationRequest.handler,
request.registrationRequest.config);
}
}
}
} |
390fb144-1c66-415d-8eb9-ccefef968dda | 9 | void dfs(String[] board, int i, int j, int color){
int[] x = {-1,-1,0,1,1,0};
int[] y = {0,1,1,0,-1,-1};
int n = board.length;
colors[i][j] = color;
for(int e=0; e<6; e++){
int u = i+x[e];
int v = j+y[e];
if(u>=0 && u<n && v>=0 && v<n && board[u].charAt(v)=='X'){
if(colors[u][v] == 0){
required = 2;
dfs(board, u, v, 3-color);
} else{
if(colors[u][v] == colors[i][j]) required = 3;
}
}
if(required == 3) return;
}
} |
56cd2e0a-c6f9-4d1d-a3c3-841eec0f04eb | 7 | public void write(Writer writer)
throws IOException
{
if (this.name == null) {
this.writeEncoded(writer, this.contents);
return;
}
writer.write('<');
writer.write(this.name);
if (! this.attributes.isEmpty()) {
Iterator iter = this.attributes.keySet().iterator();
while (iter.hasNext()) {
writer.write(' ');
String key = (String) iter.next();
String value = (String) this.attributes.get(key);
writer.write(key);
writer.write('='); writer.write('"');
this.writeEncoded(writer, value);
writer.write('"');
}
}
if ((this.contents != null) && (this.contents.length() > 0)) {
writer.write('>');
this.writeEncoded(writer, this.contents);
writer.write('<'); writer.write('/');
writer.write(this.name);
writer.write('>');
} else if (this.children.isEmpty()) {
writer.write('/'); writer.write('>');
} else {
writer.write('>');
Iterator iter = this.iterateChildren();
while (iter.hasNext()) {
XMLElement child = (XMLElement) iter.next();
child.write(writer);
}
writer.write('<'); writer.write('/');
writer.write(this.name);
writer.write('>');
}
} |
9f845515-a98c-4ec8-af4f-a7548533a4c9 | 6 | private String getRemainingTime(long seconds) {
// This is only an approximation - it doesn't count actual calendar months
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
long months = days / 30;
long years = days / 365;
boolean oneDayLeft = days == 0;
boolean oneHourLeft = hours == 0;
// Take the modulus of each component to get relative time
seconds %= 60;
minutes %= 60;
hours %= 24;
days %= 30;
months %= 12;
StringBuilder time = new StringBuilder();
if (years > 0) time.append(years + "y ");
if (months > 0) time.append(months + "m ");
if (days > 0) time.append(days + "d ");
if (hours > 0) time.append(hours + "h ");
if (oneDayLeft) time.append(minutes + "m ");
if (oneHourLeft) time.append(seconds + "s");
return time.toString();
} |
dccf5f39-ee44-4ec7-8023-cebab159358e | 2 | public CommandWords() {
commands = new HashMap<String, String>();
captureGroups = new HashMap<String, int[]>();
HashMap<String, String> commandFile = KvReader.readFile("help.kv");
for(Entry<String, String> e : commandFile.entrySet()){
String eKey = e.getKey();
if(eKey.substring(eKey.length()-1).equals("$")){
captureGroups.put(eKey, parseCaptureGroups(e.getValue()));
} else {
commands.put(eKey, e.getValue());
}
}
} |
90dfa4e3-8ef0-4aed-bef9-774bb9701871 | 2 | public boolean formExists(int formId) {
try {
String q = "select count(*) from form where formid = ?;";
PreparedStatement st = conn.prepareStatement(q);
st.setInt(1, formId);
ResultSet rs = st.executeQuery();
conn.commit();
rs.next();
return rs.getInt(1) > 0;
} catch(Exception e) {
try {
e.printStackTrace();
conn.rollback();
} catch(Exception e2) {
e2.printStackTrace();
}
return false;
}
} |
0515cc90-5b6c-4add-b031-ea78bbe9badd | 9 | public void payInstallment(Payment payment) throws Exception {
if (payment == null) {
throw new Exception("Payment tidak boleh null.");
}
if (payment.getPaymentStatus() == null) {
throw new Exception("Payment status tidak boleh null.");
}
if (!payment.getPaymentStatus().equals('N')) {
throw new Exception(
"Payment tidak dapat dibayarkan karena status payment bukan 'N' (New).");
}
if (payment.getAmount().compareTo(BigDecimal.ZERO) != 1) {
throw new Exception("Amount harus lebih besar dari nol.");
}
Transaction transaction = null;
Session session = HibernateUtil.openSession();
transaction = session.beginTransaction();
LoanAccountService loanAccountService = new LoanAccountService();
LoanAccount loanAccount = loanAccountService.getLoanAccount(payment
.getAcountNo());
if (loanAccount == null) {
transaction.rollback();
session.close();
throw new Exception("Loan account " + payment.getAcountNo()
+ "tidak ditemukan.");
}
session.refresh(loanAccount);
Hibernate.initialize(loanAccount.getLoanAccountSchedules());
List<LoanAccountSchedule> loanAccountSchedules = loanAccount
.getLoanAccountSchedules();
LoanAccountSchedule loanAccountSchedule = null;
for (LoanAccountSchedule schedule : loanAccountSchedules) {
if (schedule.getPaidStatus().equals('U')) {
loanAccountSchedule = schedule;
break;
}
}
if (loanAccountSchedule == null) {
transaction.rollback();
session.close();
throw new Exception("Tidak ada angsuran yang belum dibayar.");
}
if (loanAccountSchedule.getOutstanding().compareTo(payment.getAmount()) != 0) {
transaction.rollback();
session.close();
throw new Exception(
"Cicilan tidak sesuai dengan jumlah pembayaran.");
}
loanAccountSchedule.setPaidStatus('P');
payment.setPaymentStatus('P');
session.update(loanAccountSchedule);
session.update(payment);
transaction.commit();
session.close();
} |
da3cc721-0e48-43e7-960d-70b68cc64c92 | 3 | final public void Additive_operator() throws ParseException {
/*@bgen(jjtree) Additive_operator */
SimpleNode jjtn000 = new SimpleNode(JJTADDITIVE_OPERATOR);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
if (jj_2_60(3)) {
jj_consume_token(PLUS);
} else if (jj_2_61(3)) {
jj_consume_token(MINUS);
} else {
jj_consume_token(-1);
throw new ParseException();
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
jjtn000.jjtSetLastToken(getToken(0));
}
}
} |
091acf10-72cd-4fc2-9a9d-a9471b4c44ef | 0 | public ArrowNontransitionTool(AutomatonPane view, AutomatonDrawer drawer) {
super(view, drawer);
} |
d7ef4167-ef30-4e1a-8be4-86ae06d461a0 | 0 | public final void drawArrow(Graphics g) {
int center = getWidth() >> 1;
g.setColor(Color.black);
g.drawLine(center, 0, center, ARROW_LENGTH);
g.drawLine(center, ARROW_LENGTH, center - 10, ARROW_LENGTH - 10);
g.drawLine(center, ARROW_LENGTH, center + 10, ARROW_LENGTH - 10);
g.translate(0, ARROW_LENGTH);
} |
77fabaa0-0922-4b3a-a7a1-44b825e40693 | 0 | public String getTelefon() {
return telefon;
} |
874e3098-0ad6-4349-a2c8-e9d2a84a05bf | 7 | @Override
public V opposite(V vertex, E edge) {
// Check that both the edge and vertex are in our graph.
if (vertex == null || edge == null || !vertices.contains(vertex)
|| !edges.contains(edge)) {
return null;
}
// Get the vertices for the edge.
Set<V> vertices = edgesToVertices.get(edge);
if (vertices.contains(vertex)) {
// We know this was a valid search. Return the opposite vertex.
Iterator<V> iter = vertices.iterator();
while (iter.hasNext()) {
V v = iter.next();
if (!v.equals(vertex)) {
return v;
}
}
}
return null;
} |
43879374-fced-4061-8529-3de0a9eb8652 | 8 | public void save() {
try {
if (getSize() == 0) {
if ((file.exists()) && (!file.delete())) {
throw new DataBaseException("Cannot delete a file!");
}
deletePath();
} else {
createPath();
if (!file.exists()) {
if (!file.createNewFile()) {
throw new DataBaseException("Cannot create a file " + fileName);
}
}
try (RandomAccessFile outputFile = new RandomAccessFile(fileName, "rw")) {
for (Map.Entry<String, String> node : old.entrySet()) {
outputFile.writeInt(node.getKey().getBytes(StandardCharsets.UTF_8).length);
outputFile.writeInt(node.getValue().getBytes(StandardCharsets.UTF_8).length);
outputFile.write(node.getKey().getBytes(StandardCharsets.UTF_8));
outputFile.write(node.getValue().getBytes(StandardCharsets.UTF_8));
}
outputFile.setLength(outputFile.getFilePointer());
}
}
} catch (FileNotFoundException e) {
throw new DataBaseException("File save error!");
} catch (IOException e) {
throw new DataBaseException("Write to file error!");
}
} |
0af0a6f7-bebd-4f4b-b21e-aece5a4ff8df | 1 | public static DateConverter getInstance() {
DateConverter dateConverter = SHARED_INSTANCE;
if (dateConverter == null) {
dateConverter = new DateConverter();
}
return dateConverter;
} |
f1c78ec2-a541-4f40-a711-e71ab93ed292 | 9 | public static Stella_Object accessXmlExpressionIteratorSlotValue(XmlExpressionIterator self, Symbol slotname, Stella_Object value, boolean setvalueP) {
if (slotname == Stella.SYM_STELLA_REGION_TAG) {
if (setvalueP) {
self.regionTag = ((Cons)(value));
}
else {
value = self.regionTag;
}
}
else if (slotname == Stella.SYM_STELLA_REGION_MATCH_FUNCTION) {
if (setvalueP) {
self.regionMatchFunction = ((FunctionCodeWrapper)(value)).wrapperValue;
}
else {
value = FunctionCodeWrapper.wrapFunctionCode(self.regionMatchFunction);
}
}
else if (slotname == Stella.SYM_STELLA_DOCTYPE) {
if (setvalueP) {
self.doctype = ((XmlDoctype)(value));
}
else {
value = self.doctype;
}
}
else if (slotname == Stella.SYM_STELLA_DOCTYPE_ITERATORp) {
if (setvalueP) {
self.doctypeIteratorP = BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper)(value)));
}
else {
value = (self.doctypeIteratorP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
}
}
else {
{ OutputStringStream stream000 = OutputStringStream.newOutputStringStream();
stream000.nativeStream.print("`" + slotname + "' is not a valid case option");
throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
}
}
return (value);
} |
e00aecb1-395b-485c-9713-0524f3a318cb | 1 | private Object getKey(Object key)
{
if(key instanceof CaseInsensitiveString)
{
return caseMap.get(((CaseInsensitiveString)key).lcString());
}
return key;
} |
556ddb73-12e6-4083-8a69-c882ba8f93e7 | 1 | public static void main(String[] args) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"context/jdbcContext.xml");
// dataSourceはSpringで作成。
DataSource source = (DataSource) ctx.getBean("dataSource");
Connection con = source.getConnection();
Statement stat = con.createStatement();
PreparedStatement ps = con.prepareStatement("SELECT * FROM TEST WHERE NAME = ?");
// バインドパラメータの設定
ps.setString(1, "huge");
// クエリ実行
ResultSet resultset = ps.executeQuery();
while (resultset.next()) {
String a = resultset.getString(1);
String b = resultset.getString(2);
SimpleLogger.debug(a + ":" + b);
}
resultset.close();
stat.close();
con.close();
} |
537afad9-3663-4b30-8ddb-a8eff909686b | 8 | public boolean isPolymorphic(int site) {
if (sg.size()==0)
return false;
char base = sg.get(0).at(site);
int seqNum = 0;
while (seqNum < sg.size() && charIsGap(base) ) {
base = sg.get(seqNum).at(site);
seqNum++;
}
//Every base is a gap in this column, I guess we return false here
if (seqNum == sg.size()) {
return false;
}
boolean same = true;
for(int i=seqNum; i<sg.size() && same; i++) {
char compBase = sg.get(i).at(site);
if ((!charIsGap(compBase)) && compBase!=base)
same = false;
}
return !same;
} |
c0bceef6-7a34-4008-86a8-672fde6a4c58 | 7 | private boolean RevisarDatosEmpleado(Empleado entrada_Empleado){
boolean DatosFormularioEmpleadoCorrectos = true;
boolean DatosFormularioEmpleadoIncorrectos = false;
if( EsNombreCompletoCorrecto(entrada_Empleado.ObtenerNombreCompleto())
&& EsUsuarioCorrecto(entrada_Empleado.ObtenerNombreUsuario())
&& EsContrasenaCorrecta(entrada_Empleado.ObtenerContrasena())
&& EsRolEmpleadoCorrecto(entrada_Empleado.ObtenerRolEmpleado())
&& EsTelefonoCorrecto(entrada_Empleado.ObtenerTelefono())
&& EsDireccionCorrecta(entrada_Empleado.ObtenerDireccion())
&& EsCorreoElectronicoCorrecto(entrada_Empleado.ObtenerCorreoElectronico())
){
return DatosFormularioEmpleadoCorrectos;
}else{
JOptionPane.showMessageDialog(null, "Porfavor verifique que los "
+ "campos con asteriscos (*) no esten vacios o mal escritos y"
+ " que el Nombre de usuario y la contraseña esten "
+ "entre 4 y 16 caracteres.");
return DatosFormularioEmpleadoIncorrectos;
}
} |
0954cf5d-383d-45ae-b871-b93c0bd61fbf | 2 | private Mesh loadMesh(String fileName) {
String[] splitArray = fileName.split("\\.");
String ext = splitArray[splitArray.length - 1];
if (!ext.equals("obj")) {
System.err.println("Error: File format not supported for mesh data: " + ext);
new Exception().printStackTrace();
System.exit(1);
}
OBJModel test = new OBJModel("./res/models/" + fileName);
IndexedModel model = test.toIndexedModel();
model.calcNormals();
model.calcTangents();
ArrayList<Vertex> vertices = new ArrayList<Vertex>();
for (int i = 0; i < model.getPositions().size(); i++) {
vertices.add(new Vertex(model.getPositions().get(i),
model.getTexCoords().get(i),
model.getNormals().get(i),
model.getTangents().get(i)));
}
Vertex[] vertexData = new Vertex[vertices.size()];
vertices.toArray(vertexData);
Integer[] indexData = new Integer[model.getIndices().size()];
model.getIndices().toArray(indexData);
addVertices(vertexData, Util.toIntArray(indexData), true);
return null;
} |
04565828-c7ab-4688-b6c9-c1fc0c81a896 | 3 | public static boolean check(Point[] a) {
double k;
double z;
if (a.length < 1) return true;
k = ((double)a[0].x - (double)a[1].x) / ((double)a[0].y - (double)a[1].y);
for (int i = 1; i < a.length; i++) {
z = ((double)a[0].x - (double)a[i].y) / ((double)a[0].y - (double)a[i].y);
if (z != k) return false;
}
return true;
} |
17193703-b017-4235-bcd7-b6db97b5d5b0 | 4 | private void setupRandPartA() throws IOException {
if (this.su_i2 <= this.last) {
this.su_chPrev = this.su_ch2;
int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;
this.su_tPos = this.data.tt[this.su_tPos];
if (this.su_rNToGo == 0) {
this.su_rNToGo = Rand.rNums(this.su_rTPos) - 1;
if (++this.su_rTPos == 512) {
this.su_rTPos = 0;
}
} else {
this.su_rNToGo--;
}
this.su_ch2 = su_ch2Shadow ^= (this.su_rNToGo == 1) ? 1 : 0;
this.su_i2++;
this.currentChar = su_ch2Shadow;
this.currentState = RAND_PART_B_STATE;
this.crc.updateCRC(su_ch2Shadow);
} else {
endBlock();
initBlock();
setupBlock();
}
} |
813d9551-e6f8-4f49-9ebb-bbf53e744a5d | 3 | public static ItemObject getItemObjectByName( String itemName ) {
ItemObject result = null;
Iterator<ItemObject> iterItems;
ItemObject itemObject;
iterItems = _itemList.iterator();
while ( iterItems.hasNext() ) {
itemObject = (ItemObject) iterItems.next();
if ( itemObject != null ) {
if ( itemObject.getItemName().equals( itemName ) ) {
result = itemObject;
} // if
} // if
} // while
return result;
} // getItemObjectByName ----------------------------------------------------- |
dbfbc51b-f0f7-40a7-bf6a-2d6ed585c4d2 | 8 | public void paint(Graphics g){
this.setDoubleBuffered(true);
Insets in = getInsets();
g.translate(in.left, in.top);
//int[][] gameboard = logic.getGameBoard();
int cols = gameBoard.length;
int rows = gameBoard[0].length;
for (int c = 0; c < cols; c++){
for (int r = 0; r < rows; r++){
int player = gameBoard[c][r];
if(player == 0) // background
g.drawImage(background, 100+100*c, 100+100*r, this);
else if (player == 2) // red = player2
g.drawImage(redPion, 100+100*c, 100+100*r, this);
else // blue = player1
g.drawImage(bluePion, 100+100*c, 100+100*r, this);
g.drawImage(part, 100+100*c, 100+100*r, this);
if(c == 0){
g.drawImage(border_left, 0, 100+100*r, this);
g.drawImage(border_right, cols*100+100, 100+100*r, this);
}
}
g.drawImage(border_top, 100+100*c, 0, this);
if ( c == chosenColumn)
g.drawImage(arrow_active, 100+100*c, 10, this);
else
g.drawImage(arrow, 100+100*c, 10, this);
g.drawImage(border_bottom, 100+100*c, rows*100+100, this);
}
g.drawImage(corner_left_top, 0, 0, this);
g.drawImage(corner_left_bottom, 0, rows*100+100, this);
g.drawImage(corner_right_top, 100+100*cols, 0, this);
g.drawImage(corner_right_bottom, 100+100*cols, rows*100+100, this);
if (winner == IGameLogic.Winner.PLAYER1)
g.drawImage(blueWon, cols*100/2-50, rows*100/2+25, this);
else if (winner == IGameLogic.Winner.PLAYER2)
g.drawImage(redWon, cols*100/2-50, rows*100/2+25, this);
} |
129076c3-da65-4232-acc4-6ba30d21c3f7 | 0 | @Basic
@Column(name = "comment")
public String getComment() {
return comment;
} |
0c048e87-aea7-41cd-9360-5d3d936800ba | 0 | public StringPot(int channelNum) {
_channel = new AnalogChannel(channelNum);
} |
b31cbfb3-6086-40ed-8b1f-ad07b4486cc3 | 4 | public static Set<Integer> findSetIntersection(int[] array1, int[] array2) {
Set<Integer> set1 = new HashSet<Integer>();
Set<Integer> intersectionSet = new HashSet<Integer>();
for (int i : array1) {
set1.add(i);
}
for (int i : array2) {
if (set1.contains(i)) {
intersectionSet.add(i);
}
}
if (intersectionSet.isEmpty()) {
System.out.println("No intersection found.");
}
return intersectionSet;
} |
358bd8bd-3a54-4e37-8bde-28cd8276b5e3 | 4 | private void setMessage(WizardStatus level, String message) {
messageLabel.setText("<html>" + message + "</html>"); //$NON-NLS-1$ //$NON-NLS-2$
Icon icon = null;
switch (level) {
case OK:
icon = ResourcesLoader.getIcon("balloon", 24); //$NON-NLS-1$
content.setBorderColor(Color.BLACK);
break;
case INFO:
icon = ResourcesLoader.getIcon("balloon", 24); //$NON-NLS-1$
content.setBorderColor(Color.BLACK);
break;
case WARNING:
icon = ResourcesLoader.getIcon("exclamation-circle", 24); //$NON-NLS-1$
content.setBorderColor(new Color(238, 255, 112));
break;
case ERROR:
icon = ResourcesLoader.getIcon("button-cross", 24); //$NON-NLS-1$
content.setBorderColor(new Color(255, 79, 100));
break;
default:
break;
}
messageLabel.setIcon(icon);
content.repaint();
} |
0a13dbb6-8cc1-4c6d-a736-99834b807471 | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Cashflow other = (Cashflow) obj;
return Math.abs(amount - other.amount) <= ACCURACY && date == other.date;
} |
1ae6983b-3254-4a6b-87ea-c636f130da93 | 1 | public void run( boolean outputContent ) throws Exception {
Configuration conf = new Configuration();
String output = Constants.WORD_OUTPUT_DIR;
FileSystem fileSystem = FileSystem.get(conf);
String input = Constants.POST_OUTPUT_DIR;
Path inputPath = new Path(input);
/*Path inputPath = new Path(input);
fileSystem.delete(inputPath, true);
fileSystem.mkdirs(inputPath);
Path sourcePath = new Path(Constants.POST_OUTPUT_DIR + "/" + Constants.POST_OUTPUT_FILE);
fileSystem.copyFromLocalFile(false, true, sourcePath, inputPath);*/
Path outputPath = new Path(output);
fileSystem.delete(outputPath, true);
Job job = new Job(conf);
job.setJobName("analysisjob");
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setJarByClass(PostAnalyzer.class);
job.setMapperClass(MapClass.class);
//job.setCombinerClass(ReduceClass.class);
job.setReducerClass(ReduceClass.class);
//job.setPartitionerClass(PartitionerClass.class);
//job.setNumReduceTasks(2);
FileInputFormat.setInputPaths(job, inputPath);
FileOutputFormat.setOutputPath(job, outputPath);
Date startTime = new Date();
System.out.println("Job started: " + startTime);
job.waitForCompletion(true);
if (outputContent) {
Path sourceFile = new Path(output + "/" + Constants.OUTPUT_FILE);
Path copyDest = new Path(ClassLoader.getSystemResource("").getFile() + Constants.WORD_OUTPUT_DEST_FILE);
fileSystem.copyToLocalFile(sourceFile, copyDest);
}
Date end_time = new Date();
System.out.println("Job ended: " + end_time);
System.out.println("The job took "
+ (end_time.getTime() - startTime.getTime()) / 1000
+ " seconds.");
} |
ede3b98c-1e52-42e9-9eb8-39f136831934 | 6 | public int compareTo(Object o) {
Handler second = (Handler) o;
/* First sort by start offsets, highest address first... */
if (start.getAddr() != second.start.getAddr())
/* this subtraction is save since addresses are only 16 bit */
return second.start.getAddr() - start.getAddr();
/*
* ...Second sort by end offsets, lowest address first... this will
* move the innermost blocks to the beginning.
*/
if (endAddr != second.endAddr)
return endAddr - second.endAddr;
/* ...Last sort by handler offsets, lowest first */
if (handler.getAddr() != second.handler.getAddr())
return handler.getAddr() - second.handler.getAddr();
/*
* ...Last sort by typecode signature. Shouldn't happen to often.
*/
if (type == second.type)
return 0;
if (type == null)
return -1;
if (second.type == null)
return 1;
return type.getTypeSignature().compareTo(
second.type.getTypeSignature());
} |
e145a18e-f6e2-4a50-bd12-a47b43ebce20 | 7 | private static void randomQueueOp( Random rand, Queue<Integer> a, int range ) {
int op = rand.nextInt( 6 );
switch( op ) {
case 0:
case 1:
case 5:
{
Integer val = rand.nextInt( range );
a.offer( val );
break;
}
case 2:
{
a.poll();
break;
}
case 3:
{
if( a.size() > 0 ) {
a.remove();
}
break;
}
case 4:
a.peek();
break;
}
} |
19e6364d-1c8e-432e-83c4-5a29455cc86a | 6 | public static boolean isItemInList(int var0, int var1, String var2)
{
if (var2.trim().length() != 0)
{
String[] var3 = var2.split(";");
String[] var4 = var3;
int var5 = var3.length;
for (int var6 = 0; var6 < var5; ++var6)
{
String var7 = var4[var6];
String[] var8 = var7.split(",");
if (parseInt(var8[0]) == var0)
{
if (var8.length == 1)
{
return true;
}
if (var8.length == 2 && parseInt(var8[1]) == var1)
{
return true;
}
}
}
}
return false;
} |
4eac285a-8054-4978-aec2-2559db47db79 | 0 | protected void onEntering() {
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.