method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0ce9dd13-f1b1-4c4a-9f83-8b5e30339c84 | 2 | public void startServer(String serverPort) {
int port = 8080;
if (!serverPort.isEmpty()) {
port = Integer.parseInt(serverPort);
}
try {
sleep(100);
socket = new ServerSocket(port);
} catch (Exception e) {
// TODO Автоматически созданный блок catch
e.printStackTrace();
}
serverIsRaning = true;
start();
} |
31d5db76-0be3-4075-880c-c874b5e77ab8 | 8 | private void btonaceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btonaceptarActionPerformed
//yyyy-MM-dd HH:mm:ss
java.util.Date fecha = new Date();
String fecreg1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(fecha);
fecreg1 = (PROCE.fechasys(fecreg1));
// Agregar Registro
if (opcion == 1) {
try {
fecha();
sql.executeUpdate("insert into admg01 (edo_reg," +
"cod_cia,"+
"slo_cia," +
"den_cia," +
"ciu_cia," +
"edo_cia," +
"pai_cia," +
"dir_cia," +
"rif_cia," +
"nit_cia," +
"tlf_cia," +
"par_cia," +
"logo," +
"fec_reg)" +
"values('A'," +
"txtcod_cia.getText()," +
"txtslo_cia.getText().toUpperCase()," +
"txtden_cia.getText().toUpperCase()," +
"txtciu_cia.getText().toUpperCase()," +
"txtedo_cia.getText().toUpperCase()," +
"txtpai_cia.getText().toUpperCase()," +
"txtdir_cia.getText()," +
"txtrif_cia.getText().toUpperCase()," +
"txtnit_cia.getText().toUpperCase()," +
"txttlf_cia.getText()," +
"txtpar_cia.getText().toUpperCase()," +
"txtlogo.getText().toUpperCase()," +
"fecreg1");
JOptionPane.showMessageDialog(this, "OPERACION EXITOSA", "A T E N C I O N.", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
}
}
Date Xfecha;
if (opcion == 2) {
// Actualizar el Registro
int a=JOptionPane.showConfirmDialog(this,"Desea Modificar el Registro" +
"","A T E N C I O N",JOptionPane.ERROR_MESSAGE);
if (a == 0) {
try {
fecha();
sql.executeUpdate("update admg01 " +
" set cod_cia = '"+txtcod_cia.getText().trim()+"'"+
",slo_cia = '"+txtslo_cia.getText().toUpperCase().trim()+"'"+
",den_cia = '"+txtden_cia.getText().toUpperCase().trim()+"'"+
",ciu_cia = '"+txtciu_cia.getText().toUpperCase().trim()+"'"+
",edo_cia = '"+txtedo_cia.getText().toUpperCase().trim()+"'"+
",pai_cia = '"+txtpai_cia.getText().toUpperCase().trim()+"'"+
",dir_cia = '"+txtdir_cia.getText().toUpperCase().trim()+"'"+
",rif_cia = '"+txtrif_cia.getText().toUpperCase().trim()+"'"+
",nit_cia = '"+txtnit_cia.getText().toUpperCase().trim()+"'"+
",tlf_cia = '"+txttlf_cia.getText().toUpperCase().trim()+"'"+
",par_cia = '"+txtpar_cia.getText().toUpperCase().trim()+"'"+
",logo = '"+txtlogo.getText().toUpperCase().trim()+"'"+
",fec_reg = '"+PROCE.Gfecha(txtfec_reg.getDate())+"'"+
"where id = '"+Nregistro+"'");
// sql.executeUpdate("UPDATE admg01 " +
// " set cod_cia =" + txtcod_cia.getText().trim() +
// ",slo_cia =" + txtslo_cia.getText().toUpperCase().trim() +
// ",den_cia =" + txtden_cia.getText() +
// ",ciu_cia =" + txtciu_cia.getText() +
// ",edo_cia =" + txtedo_cia.getText() +
// ",pai_cia =" + txtpai_cia.getText() +
// ",dir_cia =" + txtdir_cia.getText() +
// ",rif_cia =" + txtrif_cia.getText() +
// ",nit_cia =" + txtnit_cia.getText() +
// ",tlf_cia =" + txttlf_cia.getText() +
// ",par_cia =" + txtpar_cia.getText() +
// ",logo =" + txtlogo.getText() +
// ",fec_reg =" + fecreg1+
// " WHERE id ='" + Nregistro + "' ");
// ",fec_reg =" + cs(Mfecha) +
JOptionPane.showMessageDialog(this, "OPERACION EXITOSA", "A T E N C I O N.", JOptionPane.INFORMATION_MESSAGE);
opcion = 0;
aviso.setText(" ");
limpiar();
} catch (Exception e) {
}
}
}
if (opcion == 3) {
// Eliminacion del Registro
int a=JOptionPane.showConfirmDialog(this,"Desea Eliminar El Registro" +
"","A T E N C I O N",JOptionPane.ERROR_MESSAGE);
if (a == 0) {
try {
sql.executeUpdate("Update admg01 set edo_reg = 'D' where id = '" + Nregistro + "'");
JOptionPane.showMessageDialog(this, "OPERACION EXITOSA", "A T E N C I O N.", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
}
}
}
limpiar();
buscar();
}//GEN-LAST:event_btonaceptarActionPerformed |
18868ec5-e1f2-4111-95ce-df5fc1e6bee2 | 5 | public static Map<String, UIObject> parsePageUIObjects(String pageName) {
String objectFile = ConfigReader.getInstance().getObjectsFile();
Map<String, UIObject> pageUIObjectsMap = new HashMap<String, UIObject>();
try {
File fXmlFile = new File(objectFile); //TODO : read from class path
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
Node pageNode = doc.getElementsByTagName(pageName) != null ? doc.getElementsByTagName(pageName).item(0) : null;
NodeList nodesList = pageNode.getChildNodes();
for (int i=0 ; i<nodesList.getLength(); i++) {
Node currentNode = nodesList.item(i);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)currentNode;
if (element != null) {
pageUIObjectsMap.put(element.getNodeName(), new UIObject(element.getNodeName(), element.getAttribute("id"),
element.getAttribute("type"), element.getAttribute("name"), element.getAttribute("value"), element.getAttribute("identifier"),
element.getAttribute("xpath"), element.getAttribute("cssselector"), element.getAttribute("text"),
element.getAttribute("classname"), element.getAttribute("index")));
}
}
}
} catch(Exception ex) {
ex.printStackTrace();
}
return pageUIObjectsMap;
} |
7a715c4b-778c-4aae-97bb-19c8196dc1ce | 8 | @EventHandler(priority = EventPriority.NORMAL)
public void onBlockDestroy(final BlockBreakEvent event)
{
if (event.isCancelled() || event.getPlayer() == null
|| event.getBlock() == null)
{
return;
}
final Player player = event.getPlayer();
// Check for ignore permission node
if (plugin.getPermissionsHandler().checkPermission(player,
PermissionNode.IGNORE))
{
return;
}
// check if in applicable world
if (!plugin.getConfigHandler().getRootConfig().worlds.contains(player
.getWorld().getName()))
{
return;
}
if (plugin.getConfigHandler().getRootConfig().debugEvents)
{
plugin.getLogger().info(
"valid world: " + player.getWorld().getName());
}
final ApplicableRegionSet regionSet = plugin.getWorldGuard()
.getRegionManager(event.getBlock().getWorld())
.getApplicableRegions(event.getBlock().getLocation());
if (plugin.getConfigHandler().getRootConfig().debugEvents)
{
plugin.getLogger().info("regionSet size = " + regionSet.size());
}
// Check if its not in a region
if (regionSet.size() <= 0)
{
// Deny
event.setCancelled(true);
player.sendMessage(ChatColor.RED + AmazoCreative.TAG
+ " Cannot destroy outside of a region.");
}
} |
23a7fd72-b896-4339-b391-5959017e1652 | 1 | public void nextImage() {
if (historyIndex >= history.size() - 1) {
textArea.append("No images left!\n");
} else {
historyIndex++;
imagePanel.updatePanel(history.get(historyIndex));
imagePanel.update(imagePanel.getGraphics());
}
} |
4c7bd539-c4d7-48d1-b484-5037877f7e15 | 0 | public FSAConfiguration(State state, FSAConfiguration parent, String input,
String unprocessed) {
super(state, parent);
myInput = input;
myUnprocessedInput = unprocessed;
} |
39aeefe3-9ef3-4d15-9c91-3e9c9871fd0c | 4 | * @return Returns the edge that has been flipped.
*/
public Object flipEdge(Object edge)
{
if (edge != null && alternateEdgeStyle != null)
{
model.beginUpdate();
try
{
String style = model.getStyle(edge);
if (style == null || style.length() == 0)
{
model.setStyle(edge, alternateEdgeStyle);
}
else
{
model.setStyle(edge, null);
}
// Removes all existing control points
resetEdge(edge);
fireEvent(new mxEventObject(mxEvent.FLIP_EDGE, "edge", edge));
}
finally
{
model.endUpdate();
}
}
return edge;
} |
1a18d650-a3b3-40eb-996c-aa59c5757d8b | 6 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Pair)) return false;
Pair pair = (Pair) o;
if (a != null ? !a.equals(pair.a) : pair.a != null) return false;
if (b != null ? !b.equals(pair.b) : pair.b != null) return false;
return true;
} |
a3739b3e-6782-4555-a450-0e2747184d84 | 2 | public Object read(ByteReader reader)
{
Object output = null;
try {
InputStream is = new ByteReaderStream(reader);
ObjectInputStream ois = new ObjectInputStream(is);
output = ois.readObject();
}
catch (RuntimeException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException( e );
}
return output;
} |
404f6866-1a46-410d-87e5-d2ac846b941d | 5 | private String scanBlockScalarBreaks (int indent) {
StringBuilder chunks = new StringBuilder();
while (column < indent && peek() == ' ')
forward();
while (FULL_LINEBR.indexOf(peek()) != -1) {
chunks.append(scanLineBreak());
while (column < indent && peek() == ' ')
forward();
}
return chunks.toString();
} |
04529597-fd21-410d-89de-dbb84290e426 | 2 | public void valorarSerie(String idUsuario, String idSerie, float puntuacion) throws Exception{
if (puntuacion < 0 || puntuacion > 10){
throw new Exception("Puntuación no válida.");
}
Serie serie = buscarSerie(idSerie);
UsuarioRegistrado usuario = buscarUsuario(idUsuario);
serie.incluirValoracion(usuario, puntuacion);
} |
aea39b21-9c83-4e98-be3f-e7d6312f847b | 1 | private static boolean canRemove(int patientID) {
boolean canRemove = false;
Models.DatabaseModel.Bill bill = new Models.DatabaseModel.Bill();
ArrayList<Models.DatabaseModel.Bill> patientOutstandingBills = bill.findUserOutstandingBill(patientID);
if (!patientOutstandingBills.isEmpty()) {
canRemove = false;
} else {
canRemove = true;
}
return canRemove;
} |
c8ec8827-0c49-462a-8cce-bf651bb364e1 | 3 | public void generateRandoms()
{
// Number of stations Zone #2
n = new Random().nextInt(10) + 1;
// Number of stations Zone #3
m = new Random().nextInt(10) + 1;
XtoZoneOne = new int[m]; // Ui (1 < i < m)
ZoneTwotoZoneThree = new int[m][n]; //Bij
ZoneThreetoY = new int[n];
for(int i = 0; i < m; i++)
{
XtoZoneOne[i] = new Random().nextInt(10) + 1;
// Print length of the paths
System.out.println("Path: X to Zone #1: " + XtoZoneOne[i]);
for(int i2 = 0; i2 < n; i2++)
{
ZoneTwotoZoneThree[i][i2] = new Random().nextInt(10) + 1;
// Print length of the paths
System.out.println("\n Path: Zone #2 to Zone #3: " + ZoneTwotoZoneThree[i][i2]);
}
}
for(int i = 0; i < n; i++)
{
ZoneThreetoY[i] = new Random().nextInt(10) + 1;
System.out.println("\n Path from Zone #3 to Y: " + ZoneThreetoY[i]);
}
System.out.println("\n Number of stations: Zone #1: " + m + " Zone #2: " + n);
} |
46cd1512-4e96-47c9-a816-fd5fa69b1c15 | 5 | private void initLineWriter() {
lineWriter = new Thread() {
public void run() {
byte[] data = new byte[1024];
try {
while(!killThread) {
if(playing) {
if(ais.available() > 0) {
ais.read(data);
soundLine.write(data, 0, data.length);
}
else if(repeating) {
resetAudio();
}
else {
SoundStream.this.stop();
}
}
else {
threadPause();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
};
lineWriter.start();
System.out.println("running!");
} |
6fcbb19b-a61a-492f-b1a3-d6d52a9dac75 | 4 | public ConnectToDatabase()
{
p = new Properties();
(new File(ResourceLoader.dir)).mkdirs();
if (new File(ResourceLoader.dir+"login.xyz").exists())
{
try {
p.load(new FileInputStream(new File(ResourceLoader.dir+"login.xyz")));
} catch (Exception ex) {
Logger.getLogger(APPLET.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (p.isEmpty())
{
p.setProperty("servers", "Enter IP,enterip,0");
p.setProperty("spells", "");
p.setProperty("xp", "0");
p.setProperty("outfit", "");
p.setProperty("unlocks", "");
try {
p.store(new FileOutputStream(new File(ResourceLoader.dir+"login.xyz")), "");
} catch (Exception ex) {
Logger.getLogger(APPLET.class.getName()).log(Level.SEVERE, null, ex);
}
}
defaultBase();
} |
51de4dfc-aa77-4391-97f5-847299faeec2 | 5 | private boolean etsiRuutuJaLiiku(Robotti robo, int i, int suunta) {
for (int j = 0; j < i; j++) {
Set<Ruutu>ruudut= new HashSet<>();
ruudut.add(robo.getRuutu());
Ruutu seuraava=lauta.seuraavaRuutu(robo.getRuutu(), suunta);
ruudut.add(seuraava);
if (lauta.getSeinat().contains(ruudut)) {
return false;
} else if (lauta.onRobotti(seuraava)&&!robo.isHolo()) {
Robotti tiella=seuraava.getRobotti();
if (!etsiRuutuJaLiiku(tiella,1,suunta)) {
return false;
}
}
liiku(seuraava, robo);
}
return true;
} |
ce7ed50f-2d97-49f7-820b-4d1570471aed | 7 | @Override
public String toString() {
if (etat == Etat.vide) {
return "0";
}
if (etat == Etat.jeunePousse) {
return "1";
}
if (etat == Etat.arbuste) {
return "2";
}
if (etat == Etat.arbre) {
return "3";
}
if (etat == Etat.feu) {
return "4";
}
if (etat == Etat.cendre) {
return "5";
}
if (etat == Etat.infecte) {
return "6";
}
return " E ";
} |
a7cf4aa5-8d73-45a9-8c87-8f9244baaf08 | 6 | @Override
public double[] computeValue(final char refBase, FastaWindow window, AlignmentColumn col) {
value[0] = 0;
double counted = 0;
if (col.getDepth() > 0) {
Iterator<MappedRead> it = col.getIterator();
while(it.hasNext()) {
MappedRead read = it.next();
if (read.hasBaseAtReferencePos(col.getCurrentPosition())) {
char b = (char)read.getBaseAtReferencePos(col.getCurrentPosition());
if (b == 'N' || refBase == 'N')
continue;
value[0] += read.getMismatchCount(window);
counted++;
}
}
}
if (counted > 0)
value[0] = value[0] / counted;
return value;
} |
e5916845-bb0a-4ef1-afd4-73068ca2defa | 7 | public void updateUserInfo(UserInfo user) throws Exception {
Connection conn = null;
// get connection from data source
try {
conn = datasource.getConnection();
} catch (SQLException e) {
throw new RuntimeException("Could not get JDBC Connection", e);
}
PreparedStatement stmt = null;
try {
boolean auto = conn.getAutoCommit();
LOG.info("default connection auto commit state is {}.", auto);
// set auto commit is false, begin transaction
conn.setAutoCommit(false);
String sql = "update user set name=?, age=? where user_id=?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, user.getName());
stmt.setInt(2, user.getAge());
stmt.setInt(3, user.getUserId());
stmt.executeUpdate();
// commit transaction
conn.commit();
} catch (Exception e) {
try {
conn.rollback();
} catch (SQLException se) {
}
throw e;
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {
}
try {
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
}
}
} |
06bfae73-9411-45ff-a1b6-2316d5f0342f | 9 | public Object[][] getCells() {
int i;
int n;
Vector<Object[]> result;
Object[] row;
int rowCount;
boolean proceed;
initialize();
result = new Vector<Object[]>();
try {
// do know the number of rows?
rowCount = getRowCount();
if (rowCount == -1) {
rowCount = getMaxRows();
proceed = m_ResultSet.next();
}
else {
proceed = m_ResultSet.first();
}
if (proceed) {
i = 0;
while (true) {
row = new Object[getColumnCount()];
result.add(row);
for (n = 0; n < getColumnCount(); n++) {
try {
// to get around byte arrays when using getObject(int)
if (getColumnClasses()[n] == String.class)
row[n] = m_ResultSet.getString(n + 1);
else
row[n] = m_ResultSet.getObject(n + 1);
}
catch (Exception e) {
row[n] = null;
}
}
// get next row, if possible
if (i == rowCount - 1) {
break;
}
else {
// no more rows -> exit
if (!m_ResultSet.next())
break;
}
i++;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return result.toArray(new Object[result.size()][getColumnCount()]);
} |
ede4be91-d3b2-4e36-a5ec-552de65b642a | 6 | public boolean saveProdutos( Produtos produtos ){
this.getConectaBanco();
try {
if (this.getConn() != null || !this.getConn().isClosed()) {
this.getConn().setAutoCommit(false);
this.setStmt(this.getBuscaProdutos());
this.getStmt().setInt(1, produtos.getIdProduto());
this.setResultSetProdutos(this.getStmt().executeQuery());
if ( ! this.getResultSetProdutos().next() ) {
this.setStmt(this.getInsertProdutos());
this.getStmt().setString(1, produtos.getNomeProduto());
this.getStmt().setString(2, produtos.getDescricaoProduto());
this.getStmt().setString(3, produtos.getImagemProduto());
this.getStmt().setInt(4, produtos.getCategoriaProduto());
this.getStmt().setInt(5,produtos.getTipoProduto());
this.getStmt().setInt(6, produtos.getEmpresaProduto());
this.getStmt().execute();
this.setSucesso(VERDADEIRO);
this.getConn().commit();
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (this.getConn()!= null ){
try {
this.getConn().rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
this.stopConectaBanco();
}
return this.isSucesso();
} |
037e4d2e-9586-4040-a45d-b9fa53e72bc3 | 8 | private void parseDayWordDetails(int i, String checkWord) {
int firstOccurance = 0;
for (int j=i-1; j>=0; j--) {
if (parts[j].equals("next") || parts[j].equals("following") ) {
isCommandDetails[j] = false;
} else {
firstOccurance = j+1;
break;
}
}
if (firstOccurance!=i) {
isCommandDetails[i] = false;
if ((firstOccurance > 0)
&& getConnectorWords().contains(parts[firstOccurance-1])) {
isCommandDetails[firstOccurance-1] = false;
if ((firstOccurance > 1)
&& getConnectorWords().contains(parts[firstOccurance-2])) {
isCommandDetails[firstOccurance-2] = false;
}
}
}
} |
71b6a462-8258-4cfe-9e4a-71da0a5dda03 | 3 | public static boolean setNumTeams(int n)
{
if ((n >= 1) && (n <= players.length))
{
teams = new Team[n];
//initializing the teams
for (int i = 0; i < n; i++)
{
teams[i] = new Team();
}
return true;
}
else
return false;
} |
b38ea46f-9a31-4aea-8755-214d2a7e4537 | 0 | @Override
public void buildSauce() { pizza.setSauce("mild"); } |
8077babd-ced8-4a6c-8285-567be0df4d1b | 2 | public void setMsgLabel(String txt) {
if (t == null || !t.isRunning()) {
resetColor();
msgLabel.setText(txt);
}
} |
672125ae-261c-4ccc-b72b-c59627ecd079 | 2 | @Test
public void test() throws InterruptedException {
for (int i = 0; i < 100; i++) {
for (ChildData data : PathCacheFactory.getBabyDuncanPathData()) {
System.out.println(data.getPath() + " = " + new String(data.getData()));
}
Thread.sleep(1000);
System.out.println("+++++++++++++++++++++++++");
}
} |
1f026ea3-effb-409c-bfdc-6697056b4c74 | 3 | public static void selectInverse(Node currentNode, JoeTree tree, OutlineLayoutManager layout) {
// select all siblings
Node parent = currentNode.getParent();
for (int i = 0, limit = parent.numOfChildren(); i < limit; i++) {
Node child = parent.getChild(i);
if (child.isSelected()) {
tree.removeNodeFromSelection(child);
} else {
tree.addNodeToSelection(child);
}
}
if (tree.getNumberOfSelectedNodes() == 0) {
// This is kind of a freak case since we have to change focus.
// Change to text node if all nodes were deselected.
tree.setCursorPosition(0);
tree.getDocument().setPreferredCaretPosition(0);
tree.setComponentFocus(OutlineLayoutManager.TEXT);
tree.clearSelection();
layout.draw(currentNode,OutlineLayoutManager.TEXT);
} else {
// Redraw and Set Focus
layout.draw(currentNode, OutlineLayoutManager.ICON);
}
} |
9a0db19a-8bfd-465f-9576-e3eface1d6ed | 8 | public void Move(int dir)
{
switch(dir)
{
case 0:
if(cube.getLoc()%4 != 0)
{
cube.Left();
}
break;
case 1:
if(cube.getLoc()%4 != 3)
{
cube.Right();
}
break;
case 2:
if(cube.getLoc() > 3)
{
cube.Down();
}
break;
case 3:
if(cube.getLoc() < 12)
{
cube.Up();
}
break;
}
State();
} |
bd1758de-29b6-4564-8951-cac90df485de | 3 | static void testJogger()
{
Scanner in = new Scanner(System.in);
Board b = Board.readBoard(in);
ArrayList<Integer> nextPiece = new ArrayList<Integer>();
while(in.hasNextInt())
nextPiece.add(in.nextInt());
Searcher s;
for (int i = 2; i <7; i++){
for(int j= 1; j < i; j++){
s = new Jogger(new LinearWeightedSum(), i, j);
s.playGame(b, new ArrayList<Integer>(nextPiece));
}
}
} |
39e7a0c8-ed09-47ce-b955-bf49d86717a4 | 5 | @Override
public boolean equals(Object other){
if (other == null) return false;
if (other == this) return true;
if (!(other instanceof PairInt))return false;
PairInt otherMyClass = (PairInt)other;
if (otherMyClass.x.equals(this.x) && otherMyClass.y.equals(this.y))
{
return true;
}
else
{
return false;
}
} |
def5eb10-5642-4926-8240-cfaff87fda04 | 4 | public void recibirConnection(String updateId, int precio, long id, long adyacente) {
if (!updateIdsList.find(updateId)) {
updateIdsList.append(updateId);
if (id == this.id)
for (int i = 0; i < connections.getLength(); i++) {
Connection connection = connections.get(i);
if (connection.getUpdateId().equals(updateId)) {
connection.setTarget(adyacente);
}
}
difusion(XmlToolkit.newConnection(id, adyacente, precio, updateId));
}
} |
5392255d-5c6c-48bc-87bd-b74c9a8ebdd5 | 7 | public byte[] extract() {
List<Byte> bitData = new ArrayList<Byte>();
// 获得Y的colorid
Integer colorid = (Integer) mImg.getColorIDs().toArray()[0];
// 获得Y的color unit
JPEGDataUnits dataUnits = mImg.getDataUnits();
List<int[]> YUnits = dataUnits.getColorUnit(colorid);
for (int acIndex=1; acIndex != 2; ++acIndex){
for (int unitIndex=0; unitIndex != YUnits.size(); ++unitIndex){
int val = dataUnits.get(colorid, unitIndex, acIndex);
if (val == -1){
bitData.add((byte)0);
}else if (val == 1){
bitData.add((byte)1);
}
}
}
byte[] data = new byte[bitData.size()>>3];
for (int i=0; i!= bitData.size(); ++i){
data[i>>3] <<= 1;
if (bitData.get(i) == -1){
data[i>>3] |= 0;
}else if (bitData.get(i) == 1){
data[i>>3] |= 1;
}
}
return data;
} |
2474b109-a000-4c60-8255-0a6f61d21c31 | 2 | private void siftDown(int pos) {
if (2 * pos >= size) return;
int maxI = getMaxInd(2 * pos, 2 * pos + 1);
if (heap.get(maxI).compareTo(heap.get(pos)) > 0) {
swap(pos, maxI);
siftDown(maxI);
}
} |
a09e7bc8-0437-4673-a542-77cfd2fd1632 | 6 | public ArrayList<String> recListaAmigos(String nick) {//ok
//verificar logueo
ArrayList<String> amigos;
amigos = new ArrayList<String> ();
System.out.println(nick);
try {
String queryString = "select nick2 from serAmigos where nick1=?";
connection = getConnection();
ptmt = connection.prepareStatement(queryString);
ptmt.setString(1, nick);
resultSet = ptmt.executeQuery();
while (resultSet.next()) {
amigos.add(resultSet.getString("nick2"));
}
System.out.println("Data Recovery Successfully");
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (ptmt != null) {
ptmt.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return amigos;
} |
87b8bd7d-35cd-44c4-8e71-38e2254cc659 | 3 | public boolean saveSign(Location signLoc, int doorID){
int i=1;
while(signConfig.get("signs." + i)!=null){
if(signConfig.get("signs." + i + ".DoorID")!=null){
i++;
}else{
break;
}
}
signConfig.set("signs." + i + ".DoorID", doorID);
signConfig.set("signs." + i + ".location.world", signLoc.getWorld().getName());
signConfig.set("signs." + i + ".location.X", signLoc.getBlockX());
signConfig.set("signs." + i + ".location.Y", signLoc.getBlockY());
signConfig.set("signs." + i + ".location.Z", signLoc.getBlockZ());
try {
signConfig.save(signFile);
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
} |
b7bdcb30-ee70-4f7d-93e7-7ed721914198 | 7 | @Override
public ArrayList<Locations> getPath(Locations begin, Locations end) {
int startRow = begin.getRow();
int startColumn = begin.getColumn();
int endRow = end.getRow();
int endColumn = end.getColumn();
ArrayList<Locations> list = new ArrayList<Locations>();
if (startRow < endRow) {
if (startColumn < endColumn) {
for (int i = 1; i <= endRow - startRow; i++) {
list.add(new Locations(startRow + i, startColumn + i));
}
} else {
for (int i = 1; i <= endRow - startRow; i++) {
list.add(new Locations(startRow + i, startColumn - i));
}
}
} else {
if (startColumn < endColumn) {
for (int i = 1; i <= startRow - endRow; i++) {
list.add(new Locations(startRow - i, startColumn + i));
}
} else {
for (int i = 1; i <= startRow - endRow; i++) {
list.add(new Locations(startRow - i, startColumn - i));
}
}
}
return list;
} |
297eb918-228f-460c-a378-1251d23eea30 | 2 | private void signalEditorDelSignal() {
if(se_signal.getSelectionIndex() == -1) return;
if(signals == null) signals = new SignalBundle();
Contact contact = new Contact(se_signal.getText());
signals.getSignals().remove(contact);
signalEditorSelectionChanged();
signalEditorSignalsChanged();
} |
2e45a199-912d-4279-a83a-e810bebdc3f2 | 0 | public static void main(String[] args) {
// TODO code application logic here
Menu menu = new Menu();
menu.setVisible(true);
} |
b47d8a81-01df-4e16-b2f1-dae82e1ef8f5 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final CreateObjectRequest other = (CreateObjectRequest) obj;
if (listOfInitialValues == null) {
if (other.listOfInitialValues != null)
return false;
}
else if (!listOfInitialValues.equals(other.listOfInitialValues))
return false;
if (objectSpecifier == null) {
if (other.objectSpecifier != null)
return false;
}
else if (!objectSpecifier.equals(other.objectSpecifier))
return false;
return true;
} |
240ad927-4c6a-4df9-adc8-c3c99e9ca95e | 8 | public Registration readClass (Input input) {
int classID = input.readInt(true);
switch (classID) {
case Kryo.NULL:
if (TRACE || (DEBUG && kryo.getDepth() == 1)) log("Read", null);
return null;
case NAME + 2: // Offset for NAME and NULL.
return readName(input);
}
if (classID == memoizedClassId) return memoizedClassIdValue;
Registration registration = idToRegistration.get(classID - 2);
if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2));
if (TRACE) trace("kryo", "Read class " + (classID - 2) + ": " + className(registration.getType()));
memoizedClassId = classID;
memoizedClassIdValue = registration;
return registration;
} |
d5b81b89-94cb-44f7-8282-31897bde13c4 | 9 | public int pit2(Block set, Material m, BlockFace bf)
{
int x = 1;
int a = gen.nextInt(30);
if (a < 12) {
a = 12;
}
while (x < a) {
int newx = x - 1;
Block otherset = set.getRelative(bf, newx);
Block clr10 = otherset.getRelative(BlockFace.DOWN, 1);
Block clr20 = otherset.getRelative(BlockFace.DOWN, 2);
Block clr30 = otherset.getRelative(BlockFace.DOWN, 3);
Block clr40 = otherset.getRelative(BlockFace.DOWN, 4);
Block clr50 = otherset.getRelative(BlockFace.DOWN, 5);
Block clr60 = otherset.getRelative(BlockFace.DOWN, 6);
Block clr70 = otherset.getRelative(BlockFace.DOWN, 7);
Block set1 = otherset.getRelative(BlockFace.SOUTH, 1);
Block clr1 = set1.getRelative(BlockFace.DOWN, 1);
Block clr2 = set1.getRelative(BlockFace.DOWN, 2);
Block clr3 = set1.getRelative(BlockFace.DOWN, 3);
Block clr4 = set1.getRelative(BlockFace.DOWN, 4);
Block clr5 = set1.getRelative(BlockFace.DOWN, 5);
Block clr6 = set1.getRelative(BlockFace.DOWN, 6);
Block clr7 = set1.getRelative(BlockFace.DOWN, 7);
Block set2 = set1.getRelative(BlockFace.SOUTH, 1);
Block clr11 = set2.getRelative(BlockFace.DOWN, 1);
Block clr21 = set2.getRelative(BlockFace.DOWN, 2);
Block clr31 = set2.getRelative(BlockFace.DOWN, 3);
Block clr41 = set2.getRelative(BlockFace.DOWN, 4);
Block clr51 = set2.getRelative(BlockFace.DOWN, 5);
Block clr61 = set2.getRelative(BlockFace.DOWN, 6);
Block clr71 = set2.getRelative(BlockFace.DOWN, 7);
Block set1111 = set2.getRelative(BlockFace.SOUTH, 1);
Block clr111 = set1111.getRelative(BlockFace.DOWN, 1);
Block clr211 = set1111.getRelative(BlockFace.DOWN, 2);
Block clr311 = set1111.getRelative(BlockFace.DOWN, 3);
Block clr411 = set1111.getRelative(BlockFace.DOWN, 4);
Block clr511 = set1111.getRelative(BlockFace.DOWN, 5);
Block clr611 = set1111.getRelative(BlockFace.DOWN, 6);
Block clr711 = set1111.getRelative(BlockFace.DOWN, 7);
Block set2111 = set1111.getRelative(BlockFace.SOUTH, 1);
Block clr1111 = set2111.getRelative(BlockFace.DOWN, 1);
Block clr2111 = set2111.getRelative(BlockFace.DOWN, 2);
Block clr3111 = set2111.getRelative(BlockFace.DOWN, 3);
Block clr4111 = set2111.getRelative(BlockFace.DOWN, 4);
Block clr5111 = set2111.getRelative(BlockFace.DOWN, 5);
Block clr6111 = set2111.getRelative(BlockFace.DOWN, 6);
Block clr7111 = set2111.getRelative(BlockFace.DOWN, 7);
Block set3111 = set2111.getRelative(BlockFace.SOUTH, 1);
Block clr11111 = set3111.getRelative(BlockFace.DOWN, 1);
Block clr21111 = set3111.getRelative(BlockFace.DOWN, 2);
Block clr31111 = set3111.getRelative(BlockFace.DOWN, 3);
Block clr41111 = set3111.getRelative(BlockFace.DOWN, 4);
Block clr51111 = set3111.getRelative(BlockFace.DOWN, 5);
Block clr61111 = set3111.getRelative(BlockFace.DOWN, 6);
Block clr71111 = set3111.getRelative(BlockFace.DOWN, 7);
Block set4111 = set3111.getRelative(BlockFace.SOUTH, 1);
Block clr5111111 = set4111.getRelative(BlockFace.DOWN, 5);
Block set3 = otherset.getRelative(BlockFace.SOUTH, 1);
Block clr111111 = set3.getRelative(BlockFace.DOWN, 1);
Block clr211111 = set3.getRelative(BlockFace.DOWN, 2);
Block clr311111 = set3.getRelative(BlockFace.DOWN, 3);
Block clr411111 = set3.getRelative(BlockFace.DOWN, 4);
Block clr511111 = set3.getRelative(BlockFace.DOWN, 5);
Block clr611111 = set3.getRelative(BlockFace.DOWN, 6);
Block clr711111 = set3.getRelative(BlockFace.DOWN, 7);
int other = gen.nextInt(3);
set3.setType(m);
set3.setData((byte)other);
int ran2 = gen.nextInt(3);
otherset.setType(m);
otherset.setData((byte)ran2);
int ran = gen.nextInt(3);
set1.setType(m);
set1.setData((byte)ran);
int ran1 = gen.nextInt(3);
set2.setType(m);
set2.setData((byte)ran1);
int ran1111 = gen.nextInt(3);
set1111.setType(m);
set1111.setData((byte)ran1111);
int ran2111 = gen.nextInt(3);
set2111.setType(m);
set2111.setData((byte)ran2111);
int ran3111 = gen.nextInt(3);
set3111.setType(m);
set3111.setData((byte)ran3111);
int ran4111 = gen.nextInt(3);
set4111.setType(m);
set4111.setData((byte)ran4111);
Block set5 = set4111.getRelative(BlockFace.DOWN, 1);
Block set6 = set5.getRelative(BlockFace.DOWN, 1);
Block set7 = set6.getRelative(BlockFace.DOWN, 1);
Block set8 = set7.getRelative(BlockFace.DOWN, 1);
Block set51 = set8.getRelative(BlockFace.DOWN, 1);
Block set61 = set51.getRelative(BlockFace.DOWN, 1);
Block set71 = set61.getRelative(BlockFace.DOWN, 1);
Block set81 = set71.getRelative(BlockFace.DOWN, 1);
int ran3 = gen.nextInt(3);
int ran7 = gen.nextInt(3);
int ran5 = gen.nextInt(3);
int ran6 = gen.nextInt(3);
set5.setType(m);
int rtorch1 = gen.nextInt(5);
if (rtorch1 == 1) {
byte flags = 5;
set5.setType(Material.TORCH);
set5.setTypeIdAndData(50, flags, true);
}
set5.setData((byte)ran3);
set6.setType(m);
set6.setData((byte)ran7);
set7.setType(m);
set7.setData((byte)ran5);
set8.setType(m);
set8.setData((byte)ran6);
int ran31 = gen.nextInt(3);
int ran71 = gen.nextInt(3);
int ran51 = gen.nextInt(3);
int ran61 = gen.nextInt(3);
set51.setType(m);
int rtorch11 = gen.nextInt(5);
if (rtorch11 == 1) {
byte flags = 5;
set5.setType(Material.TORCH);
set5.setTypeIdAndData(50, flags, true);
}
set51.setData((byte)ran31);
set61.setType(m);
set61.setData((byte)ran71);
set71.setType(m);
set71.setData((byte)ran51);
set81.setType(m);
set81.setData((byte)ran61);
Block set9 = set81.getRelative(BlockFace.NORTH, 1);
Block set10 = set9.getRelative(BlockFace.NORTH, 1);
Block set11 = set10.getRelative(BlockFace.NORTH, 1);
Block set12 = set11.getRelative(BlockFace.NORTH, 1);
Block set91 = set12.getRelative(BlockFace.NORTH, 1);
Block set101 = set91.getRelative(BlockFace.NORTH, 1);
Block set111 = set101.getRelative(BlockFace.NORTH, 1);
Block set121 = set111.getRelative(BlockFace.NORTH, 1);
Block set122 = set1.getRelative(BlockFace.NORTH, 2);
int ran11 = gen.nextInt(3);
int ran8 = gen.nextInt(3);
int ran9 = gen.nextInt(3);
int ran10 = gen.nextInt(3);
set9.setType(m);
set9.setData((byte)ran11);
set10.setType(m);
set10.setData((byte)ran8);
set11.setType(m);
set11.setData((byte)ran9);
set12.setType(m);
set12.setData((byte)ran10);
int ran91 = gen.nextInt(3);
int ran101 = gen.nextInt(3);
int ran111 = gen.nextInt(3);
int ran121 = gen.nextInt(3);
set91.setType(m);
set91.setData((byte)ran91);
set101.setType(m);
set101.setData((byte)ran101);
set111.setType(m);
set111.setData((byte)ran111);
set121.setType(m);
set121.setData((byte)ran121);
set122.setType(m);
set122.setData((byte)ran1);
Block set13 = set121.getRelative(BlockFace.UP, 1);
Block set14 = set13.getRelative(BlockFace.UP, 1);
Block set15 = set14.getRelative(BlockFace.UP, 1);
Block set16 = set15.getRelative(BlockFace.UP, 1);
Block set17 = set16.getRelative(BlockFace.UP, 1);
Block set18 = set17.getRelative(BlockFace.UP, 1);
Block set19 = set18.getRelative(BlockFace.UP, 1);
Block set20 = set19.getRelative(BlockFace.UP, 1);
int ran12 = gen.nextInt(3);
int ran13 = gen.nextInt(3);
int ran14 = gen.nextInt(3);
int ran15 = gen.nextInt(3);
set13.setType(m);
set13.setData((byte)ran12);
set14.setType(m);
set14.setData((byte)ran13);
set15.setType(m);
set15.setData((byte)ran14);
set16.setType(m);
set16.setData((byte)ran15);
int ran17 = gen.nextInt(3);
int ran18 = gen.nextInt(3);
int ran19 = gen.nextInt(3);
int ran20 = gen.nextInt(3);
set17.setType(m);
set17.setData((byte)ran17);
set18.setType(m);
set18.setData((byte)ran18);
set19.setType(m);
set19.setData((byte)ran19);
set20.setType(m);
set20.setData((byte)ran20);
if (x == 1) {
clr1.setType(Material.SMOOTH_BRICK);
clr10.setType(Material.SMOOTH_BRICK);
clr11.setType(Material.SMOOTH_BRICK);
clr111.setType(Material.SMOOTH_BRICK);
clr1111.setType(Material.SMOOTH_BRICK);
clr11111.setType(Material.SMOOTH_BRICK);
clr111111.setType(Material.SMOOTH_BRICK);
clr2.setType(Material.SMOOTH_BRICK);
clr20.setType(Material.SMOOTH_BRICK);
clr21.setType(Material.SMOOTH_BRICK);
clr211.setType(Material.SMOOTH_BRICK);
clr2111.setType(Material.SMOOTH_BRICK);
clr21111.setType(Material.SMOOTH_BRICK);
clr211111.setType(Material.SMOOTH_BRICK);
clr3.setType(Material.SMOOTH_BRICK);
clr30.setType(Material.SMOOTH_BRICK);
clr31.setType(Material.SMOOTH_BRICK);
clr311.setType(Material.SMOOTH_BRICK);
clr3111.setType(Material.SMOOTH_BRICK);
clr31111.setType(Material.SMOOTH_BRICK);
clr311111.setType(Material.SMOOTH_BRICK);
clr4.setType(Material.SMOOTH_BRICK);
clr40.setType(Material.SMOOTH_BRICK);
clr41.setType(Material.SMOOTH_BRICK);
clr411.setType(Material.SMOOTH_BRICK);
clr4111.setType(Material.SMOOTH_BRICK);
clr41111.setType(Material.SMOOTH_BRICK);
clr411111.setType(Material.SMOOTH_BRICK);
int w = 1;
while (w < 8) {
Block clearer = set122.getRelative(BlockFace.DOWN, w);
clearer.setType(Material.SMOOTH_BRICK);
w++;
}
clr5.setType(Material.SMOOTH_BRICK);
clr50.setType(Material.SMOOTH_BRICK);
clr51.setType(Material.SMOOTH_BRICK);
clr511.setType(Material.SMOOTH_BRICK);
clr5111.setType(Material.SMOOTH_BRICK);
clr51111.setType(Material.SMOOTH_BRICK);
clr511111.setType(Material.SMOOTH_BRICK);
clr5111111.setType(Material.SMOOTH_BRICK);
clr6.setType(Material.SMOOTH_BRICK);
clr60.setType(Material.SMOOTH_BRICK);
clr61.setType(Material.SMOOTH_BRICK);
clr611.setType(Material.SMOOTH_BRICK);
clr6111.setType(Material.SMOOTH_BRICK);
clr61111.setType(Material.SMOOTH_BRICK);
clr611111.setType(Material.SMOOTH_BRICK);
clr7.setType(Material.SMOOTH_BRICK);
clr70.setType(Material.SMOOTH_BRICK);
clr71.setType(Material.SMOOTH_BRICK);
clr711.setType(Material.SMOOTH_BRICK);
clr7111.setType(Material.SMOOTH_BRICK);
clr71111.setType(Material.SMOOTH_BRICK);
clr711111.setType(Material.SMOOTH_BRICK);
} else if (x + 1 == a) {
clr1.setType(Material.IRON_FENCE);
clr10.setType(Material.IRON_FENCE);
clr11.setType(Material.IRON_FENCE);
clr111.setType(Material.IRON_FENCE);
clr1111.setType(Material.IRON_FENCE);
clr11111.setType(Material.IRON_FENCE);
clr111111.setType(Material.IRON_FENCE);
clr2.setType(Material.IRON_FENCE);
clr20.setType(Material.IRON_FENCE);
clr21.setType(Material.IRON_FENCE);
clr211.setType(Material.IRON_FENCE);
clr2111.setType(Material.IRON_FENCE);
clr21111.setType(Material.IRON_FENCE);
clr211111.setType(Material.IRON_FENCE);
clr3.setType(Material.IRON_FENCE);
clr30.setType(Material.IRON_FENCE);
clr31.setType(Material.IRON_FENCE);
clr311.setType(Material.IRON_FENCE);
clr3111.setType(Material.IRON_FENCE);
clr31111.setType(Material.IRON_FENCE);
clr311111.setType(Material.IRON_FENCE);
clr4.setType(Material.IRON_FENCE);
clr40.setType(Material.IRON_FENCE);
clr41.setType(Material.IRON_FENCE);
clr411.setType(Material.IRON_FENCE);
clr4111.setType(Material.IRON_FENCE);
clr41111.setType(Material.IRON_FENCE);
clr411111.setType(Material.IRON_FENCE);
int w = 1;
while (w < 8) {
Block clearer = set122.getRelative(BlockFace.DOWN, w);
clearer.setType(Material.IRON_FENCE);
w++;
}
clr5.setType(Material.IRON_FENCE);
clr50.setType(Material.IRON_FENCE);
clr51.setType(Material.IRON_FENCE);
clr511.setType(Material.IRON_FENCE);
clr5111.setType(Material.IRON_FENCE);
clr51111.setType(Material.IRON_FENCE);
clr511111.setType(Material.IRON_FENCE);
clr5111111.setType(Material.IRON_FENCE);
clr6.setType(Material.IRON_FENCE);
clr60.setType(Material.IRON_FENCE);
clr61.setType(Material.IRON_FENCE);
clr611.setType(Material.IRON_FENCE);
clr6111.setType(Material.IRON_FENCE);
clr61111.setType(Material.IRON_FENCE);
clr611111.setType(Material.IRON_FENCE);
clr7.setType(Material.IRON_FENCE);
clr70.setType(Material.IRON_FENCE);
clr71.setType(Material.IRON_FENCE);
clr711.setType(Material.IRON_FENCE);
clr7111.setType(Material.IRON_FENCE);
clr71111.setType(Material.IRON_FENCE);
clr711111.setType(Material.IRON_FENCE);
} else {
clr1.setType(Material.AIR);
clr10.setType(Material.AIR);
clr11.setType(Material.AIR);
clr111.setType(Material.AIR);
clr1111.setType(Material.AIR);
clr11111.setType(Material.AIR);
clr111111.setType(Material.AIR);
clr2.setType(Material.AIR);
clr20.setType(Material.AIR);
clr21.setType(Material.AIR);
clr211.setType(Material.AIR);
clr2111.setType(Material.AIR);
clr21111.setType(Material.AIR);
clr211111.setType(Material.AIR);
clr3.setType(Material.AIR);
clr30.setType(Material.AIR);
clr31.setType(Material.AIR);
clr311.setType(Material.AIR);
clr3111.setType(Material.AIR);
clr31111.setType(Material.AIR);
clr311111.setType(Material.AIR);
clr4.setType(Material.AIR);
clr40.setType(Material.AIR);
clr41.setType(Material.AIR);
clr411.setType(Material.AIR);
clr4111.setType(Material.AIR);
clr41111.setType(Material.AIR);
clr411111.setType(Material.AIR);
int w = 1;
while (w < 8) {
Block clearer = set122.getRelative(BlockFace.DOWN, w);
clearer.setType(Material.AIR);
w++;
}
clr5.setType(Material.AIR);
clr50.setType(Material.AIR);
clr51.setType(Material.AIR);
clr511.setType(Material.AIR);
clr5111.setType(Material.AIR);
clr51111.setType(Material.SMOOTH_BRICK);
clr511111.setType(Material.AIR);
clr5111111.setType(Material.SMOOTH_BRICK);
clr6.setType(Material.WATER);
clr60.setType(Material.WATER);
clr61.setType(Material.WATER);
clr611.setType(Material.WATER);
clr6111.setType(Material.WATER);
clr61111.setType(Material.WATER);
clr611111.setType(Material.WATER);
clr7.setType(Material.WATER);
clr70.setType(Material.WATER);
clr71.setType(Material.WATER);
clr711.setType(Material.WATER);
clr7111.setType(Material.WATER);
clr71111.setType(Material.WATER);
clr711111.setType(Material.WATER);
}
newx++;
x++;
}
return a;
} |
849d19a6-d956-4529-8ab8-9b3b6070c5e9 | 3 | public synchronized static void deleteBlob(String fullPath) {
String blobName = FileFunctions.getRelativePath(fullPath);
if (blobName.contains("\\")) {
blobName = blobName.replace("\\", "/");
}
System.out.println("Blob is " + blobName);
try {
CloudStorageAccount storageAccount = CloudStorageAccount
.parse(Connection.storageConnectionString);
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
CloudBlobContainer container = blobClient
.getContainerReference(containerName);
EnumSet<BlobListingDetails> details = EnumSet
.of(BlobListingDetails.METADATA);
System.out.println("Blob name is " + blobName);
for (ListBlobItem blobItem : container.listBlobs(blobName, true,
details, null, null)) {
CloudBlob blob = (CloudBlob) blobItem;
System.out.println("Blob name found is " + blob.getName());
blob.delete();
}
} catch (URISyntaxException | InvalidKeyException | StorageException ex) {
Logger.getLogger(BlobManager.class.getName()).log(Level.SEVERE,
null, ex);
}
} |
782fb75f-c2e1-4214-a5a6-2fbe1d012a60 | 2 | public String stringApiValue() {
StringBuffer buf = new StringBuffer(bytes.length*4);
buf.append( "(read-from-string \"#(");
for (int i = 0; i < bytes.length; i++) {
buf.append( ' ');
int value = bytes[i];
if (value < 0) {
value += 256;
}
buf.append( value);
}
buf.append( ")\")");
return buf.toString();
} |
7901d4c0-adaf-49ee-abb6-7a5f5d1a4c24 | 2 | public String toString(){
String ss = "";
ss = ss + this.coeffCopy(0).toString();
if(this.deg>0)ss = ss + " + (" + this.coeffCopy(1).toString() + ").x";
for(int i=2; i<=this.deg; i++){
ss = ss + " + (" + this.coeffCopy(i).toString() + ").x^" + i;
}
return ss;
} |
2e750863-330d-4697-b78c-ad11d1ebb09d | 2 | public void setBtn_Std_Font(String font) {
if ((font == null) || font.equals("")) {
this.buttonStdFont = UIFontInits.STDBUTTON.getFont();
} else {
this.buttonStdFont = font;
}
somethingChanged();
} |
1107dd25-1b4b-4ccb-ba1d-7d5d176553c0 | 2 | private static boolean isSpatialMaxima(double[][] hmap, int x, int y) {
int n = 8;
int[] dx = new int[] { -1, 0, 1, 1, 1, 0, -1, -1 };
int[] dy = new int[] { -1, -1, -1, 0, 1, 1, 1, 0 };
double w = hmap[x][y];
for (int i = 0; i < n; i++) {
double wk = hmap[x + dx[i]][y + dy[i]];
if (wk >= w)
return false;
}
return true;
} |
734c6f73-b456-4aac-a007-0e778ce54839 | 9 | public static short getAgeClass1(int age) {
if (age < 16) {
return 0;
}
if (age < 20) {
return 16;
}
if (age < 25) {
return 20;
}
if (age < 30) {
return 25;
}
if (age < 45) {
return 30;
}
if (age < 60) {
return 45;
}
if (age < 65) {
return 60;
}
if (age < 70) {
return 65;
}
if (age < 75) {
return 70;
}
return 75;
} |
16841e19-e6a1-430b-bbce-ea052c2765e9 | 5 | private final short method683(int i, int i_97_, long l, int i_98_,
Model class124, int i_99_, float f,
int i_100_, int i_101_, float f_102_) {
try {
anInt5599++;
int i_103_ = anIntArray5528[i_101_];
int i_104_ = anIntArray5528[1 + i_101_];
int i_105_ = i_100_;
for (int i_106_ = i_103_;
(i_106_ ^ 0xffffffff) > (i_104_ ^ 0xffffffff); i_106_++) {
short i_107_ = aShortArray5649[i_106_];
if (i_107_ == 0) {
i_105_ = i_106_;
break;
}
if (l == Class258_Sub2.aLongArray8530[i_106_])
return (short) (i_107_ - 1);
}
aShortArray5649[i_105_] = (short) (anInt5529 + 1);
Class258_Sub2.aLongArray8530[i_105_] = l;
aShortArray5564[anInt5529] = (short) i_98_;
aShortArray5583[anInt5529] = (short) i;
aShortArray5576[anInt5529] = (short) i_97_;
aByteArray5594[anInt5529] = (byte) i_99_;
aFloatArray5552[anInt5529] = f;
aFloatArray5571[anInt5529] = f_102_;
return (short) anInt5529++;
} catch (RuntimeException runtimeexception) {
throw Class348_Sub17.method2929(runtimeexception,
("paa.R(" + i + ',' + i_97_ + ','
+ l + ',' + i_98_ + ','
+ (class124 != null ? "{...}"
: "null")
+ ',' + i_99_ + ',' + f + ','
+ i_100_ + ',' + i_101_ + ','
+ f_102_ + ')'));
}
} |
c7c3c0dd-d658-44fb-80e1-ebc25134afa7 | 0 | @Override
public void start(Stage stage) throws Exception {
AnchorPane main = FXMLLoader.load(PosApplication.class.getResource("main.fxml"));
stage.setTitle("みせっこくちない専用POSシステム");
stage.setScene(new Scene(main, 800, 600));
stage.show();
} |
5d4ecbb1-4957-4624-8d3c-7200eb75448b | 2 | public void paintComponent(Graphics g) {
if (getCreator().automaton.getEnvironmentFrame() !=null)
if (!((AutomatonEnvironment)(getCreator().automaton.getEnvironmentFrame().getEnvironment())).shouldPaint())
return;
// EDebug.print(Thread.currentThread().getName());
super.paintComponent(g);
toolbar.drawTool(g);
Graphics2D g2 = (Graphics2D) g;
double newXScale = 1.0/transform.getScaleX();
double newYScale = 1.0/transform.getScaleY();
g2.scale(newXScale, newYScale);
g2.translate(-transform.getTranslateX(), -transform.getTranslateY());
} |
9566e273-6fa4-40bb-8cc3-273662601775 | 0 | public void setProtocol(FileProtocol protocol) {
this.protocol = protocol;
setText(protocol.getName());
} |
8492c772-6098-4453-bcb2-e23991d8169a | 8 | public FieldPanel(DataStore datastore) {
super();
addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
fields = ds.getFields();
classtypes = ds.getTypes();
}
@Override
public void componentHidden(ComponentEvent e) {
ds.setFields(fields);
ds.setTypes(classtypes);
}
});
this.ds = datastore;
this.classtypes = ds.getTypes();
this.fields = ds.getFields();
this.setMinimumSize(new Dimension(450, 325));
JLabel lblTypes = new JLabel(" Types");
JSplitPane splitPane_1 = new JSplitPane();
JPanel panel_1 = new JPanel();
splitPane_1.setRightComponent(panel_1);
panel_1.setLayout(new GridLayout(5, 3, 10, 10));
JLabel lblNom = new JLabel("Nom");
panel_1.add(lblNom);
typeName = new JTextField();
typeName.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
//System.out.println("typeName");
checkEnableButtons();
}
});
panel_1.add(typeName);
typeName.setColumns(10);
JLabel lblType_1 = new JLabel("Type de Salle");
panel_1.add(lblType_1);
roomType = new JTextField();
panel_1.add(roomType);
roomType.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
//System.out.println("roomType");
checkEnableButtons();
}
});
JLabel lblTempsMinimum = new JLabel("Temps Minimum");
panel_1.add(lblTempsMinimum);
JPanel panel_2 = new JPanel();
panel_1.add(panel_2);
panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.X_AXIS));
minHour = new JSpinner();
minHour.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
//System.out.println("minHour");
checkEnableButtons();
}
});
panel_2.add(minHour);
JLabel lblHeures = new JLabel("heures");
panel_2.add(lblHeures);
minMin = new JSpinner();
panel_2.add(minMin);
minMin.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
//System.out.println("minMin");
checkEnableButtons();
}
});
JLabel lblMinutes = new JLabel("minutes");
panel_2.add(lblMinutes);
JLabel lblTempsMaximum = new JLabel("Temps Maximum");
panel_1.add(lblTempsMaximum);
JPanel panel_3 = new JPanel();
panel_1.add(panel_3);
panel_3.setLayout(new BoxLayout(panel_3, BoxLayout.X_AXIS));
maxHour = new JSpinner();
panel_3.add(maxHour);
maxHour.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
//System.out.println("maxHour");
checkEnableButtons();
}
});
JLabel lblHeures_1 = new JLabel("heures");
panel_3.add(lblHeures_1);
maxMin = new JSpinner();
panel_3.add(maxMin);
maxMin.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
//System.out.println("maxMin");
checkEnableButtons();
}
});
JLabel lblMinutes_1 = new JLabel("minutes");
panel_3.add(lblMinutes_1);
JLabel label = new JLabel("");
panel_1.add(label);
addType = new JButton("Ajouter");
addType.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String name = typeName.getText();
String shortName = roomType.getText();
int hmin = (Integer) minHour.getValue();
int mmin = (Integer) minMin.getValue();
int hmax = (Integer) maxHour.getValue();
int mmax = (Integer) maxMin.getValue();
if (name.length() > 0 && shortName.length() > 0 && hmin + mmin > 0 && hmax + mmax > 0)
try {
ClassType ct = new ClassType(name, shortName, new Slot(new Time(hmin * 100 + mmin), new Time(hmax * 100 + mmax)));
classtypes.add(ct);
typeName.setText("");
roomType.setText("");
minHour.setValue(0);
minMin.setValue(0);
maxHour.setValue(0);
maxMin.setValue(0);
typesList.setListData(classtypes.toArray());
fieldType.addItem(ct);
} catch (Exception e) {
e.printStackTrace();
System.out.println("GUI.FieldPanel : tried to add an unavalid ClassType");
}
checkEnableButtons();
}
});
panel_1.add(addType);
JPanel panel_4 = new JPanel();
splitPane_1.setLeftComponent(panel_4);
panel_4.setLayout(new BorderLayout(0, 0));
typesList = new JList(classtypes.toArray());
panel_4.add(new JScrollPane(typesList), BorderLayout.NORTH);
//
// ListModel ctList = new javax.swing.DefaultListModel();
//
// list_1.setModel(ctList);
//
JButton rmType = new JButton("Enlever");
rmType.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int[] sel = typesList.getSelectedIndices();
for (int i = sel.length - 1 ; i >= 0 ; i--)
classtypes.remove(sel[i]);
typesList.setListData(classtypes.toArray());
fieldType.removeAllItems();
for (ClassType ct : classtypes)
fieldType.addItem(ct);
}
});
panel_4.add(rmType, BorderLayout.SOUTH);
JLabel lblMatires = new JLabel(" Matières");
JSplitPane splitPane = new JSplitPane();
JPanel panel = new JPanel();
splitPane.setRightComponent(panel);
panel.setLayout(new GridLayout(3, 3, 10, 10));
JLabel lblNewLabel = new JLabel("Nom");
panel.add(lblNewLabel);
fieldName = new JTextField();
panel.add(fieldName);
fieldName.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
checkEnableButtons();
}
});
JLabel lblType = new JLabel("Type");
panel.add(lblType);
fieldType = new JComboBox(classtypes.toArray());
fieldType.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
checkEnableButtons();
}
});
panel.add(fieldType);
JLabel label_3 = new JLabel("");
panel.add(label_3);
this.addField = new JButton("Ajouter");
addField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Field f = new Field((ClassType)fieldType.getSelectedItem(), fieldName.getText());
fields.add(f);
fieldsList.setListData(fields.toArray());
}
});
panel.add(addField);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(lblTypes);
JPanel fieldsPanel = new JPanel();
splitPane.setLeftComponent(fieldsPanel);
fieldsList = new JList(this.fields.toArray());
//addField = new JButton("Ajouter");
JButton rmField = new JButton("Enlever");
rmField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int [] sel = fieldsList.getSelectedIndices();
for (int i = sel.length - 1 ; i >= 0 ; i--)
fields.remove(sel[i]);
fieldsList.setListData(fields.toArray());
}
});
fieldsPanel.setLayout(new BorderLayout(0, 0));
fieldsPanel.add(new JScrollPane(fieldsList), BorderLayout.NORTH);
fieldsPanel.add(rmField, BorderLayout.SOUTH);
JLabel label_1 = new JLabel("");
add(label_1);
add(splitPane_1);
JLabel label_4 = new JLabel("");
add(label_4);
add(lblMatires);
add(splitPane);
JLabel label_5 = new JLabel("");
add(label_5);
this.checkEnableButtons();
this.setVisible(true);
} |
ecc52266-8555-49b5-a192-239f3d3432e7 | 5 | private List<String> cleanOfNotPossibleKeywords(List<String> possibleKeywords) {
LinkedList<String> result = new LinkedList<String>();
LinkedList<String> finalResult = new LinkedList<String>();
for(int i = 0; i < possibleKeywords.size(); i++) {
if(possibleKeywords.get(i).matches(".*;.*;[0-9]+")) { result.add(possibleKeywords.get(i)); }
}
for(int i = 0; i < result.size(); i++) {
String[] triple = result.get(i).split(";");
int distance = Integer.parseInt(triple[2]);
if(distance / (float) triple[1].length() <= (float) 0.5
&& distance / (float) triple[1].length() >= 0.0001) {
finalResult.add(result.get(i));
}
}
return finalResult;
} |
9a7d685e-d298-4fe2-99d3-46b0023e0af9 | 7 | private void processKilnExchange(int componentId, int packetId) {
int itemId = StealingCreation.SACRED_CLAY[index];
int amount = 0;
if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
amount = 1;
else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
amount = 5;
else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET) {
player.getTemporaryAttributtes().put("scIndex", index);
player.getTemporaryAttributtes().put("scComponentId", componentId);
player.getTemporaryAttributtes().put("scItemId", itemId);
player.getTemporaryAttributtes().put("scAmount", amount);
player.getTemporaryAttributtes().put("kilnX", true);
player.getPackets().sendRunScript(108, new Object[] { "Enter Amount:" });
} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
amount = player.getInventory().getNumerOf(itemId);
if (StealingCreation.checkSkillRequriments(player, StealingCreation.getRequestedKilnSkill(componentId - 37), index)) {
if ((amount != 0 && StealingCreation.proccessKilnItems(player, componentId, index, itemId, amount)))
return;
}
} |
0591493b-286f-46a7-b1a0-bcd876879c32 | 5 | public Vector<Card> whichCardsShouldISwap() {
/** Here we calculate the possible difference in rank for swapping
* 1,2 or 3 cards. The double returns the effect on rank of the current
* hand for making the specified number of changes
*/
if (currentrank >= 4)
return swapcardsnocards;
Double bestrankdiffonecard = rankDiffSwapOneCard();
Double bestrankdifftwocards = rankDiffSwapTwoCards();
Double bestrankdiffthreecards = rankDiffSwapThreeCards();
if ((bestrankdiffonecard > bestrankdifftwocards) && (bestrankdiffonecard > bestrankdiffthreecards))
return swapcardsonecard;
else if (bestrankdifftwocards > bestrankdiffthreecards)
return swapcardstwocards;
else if (bestrankdiffthreecards != 0)
return swapcardsthreecards;
else return swapcardsnocards;
} |
22e53b01-246c-4620-9893-a13d6472169a | 2 | private void showMessage(String typeMessage, String text, String title){
if(typeMessage.equals("error")){
JOptionPane.showMessageDialog(this, text, title,JOptionPane.ERROR_MESSAGE);
}
if(typeMessage.equals("info")){
JOptionPane.showMessageDialog(this, text, title,JOptionPane.INFORMATION_MESSAGE);
}
} |
84aece37-3d81-4f62-b0fd-070fb457fa8f | 4 | public void mouseReleased(MouseEvent e)
{
mouseReleasedX = e.getX();
if(mouseDragged)
{
mousePressed = mousePressedX;
mouseReleased = mouseReleasedX;
if (mousePressed > mouseReleased)//selected right to left
{
int temp = mousePressed;
mousePressed = mouseReleased;
mouseReleased = temp;
}
startFrame = (int)(mousePressed * framesPerPixel);
stopFrame = (int)(mouseReleased * framesPerPixel);
//stopped dragging outside the window.
if(stopFrame >= sound.getLengthInFrames())
stopFrame = sound.getLengthInFrames();
//stopped dragging outside the window
if(startFrame < 0)
startFrame = 0;
//new values for the labels
startIndexLabel.setText(startIndexText + (startFrame));
stopIndexLabel.setText(stopIndexText + (stopFrame));
//for highlighting the selection
selectionStart = mousePressed;
selectionStop = mouseReleased;
soundPanel.repaint();
playSelectionButton.setEnabled(true);
clearSelectionButton.setEnabled(true);
mouseDragged = false;
}
} |
d515a967-326b-44a3-8be7-53d47faeb060 | 2 | public void dbConnect(String db_connect_string,
String db_userid,
String db_password) {
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
System.out.println("connected");
Statement statement = conn.createStatement();
String query = "SELECT dateTimeOrigination,callingPartyNumber,finalCalledPartyNumber,dateTimeConnect,dateTimeDisconnect,destCause_value"
+ ",origCause_value,duration FROM [CDR].[dbo].[CallDetailRecord] WHERE dateTimeOrigination > '" + lastRTime + "' AND"
+ " callingPartyNumber LIKE '2%' AND LEN(callingPartyNumber) = 4 AND finalCalledPartyNumber LIKE '2%' "
+ " AND (LEN(finalCalledPartyNumber) = 4 or LEN(finalCalledPartyNumber) = 1) ORDER BY dateTimeOrigination ASC ";
ResultSet rs = statement.executeQuery(query);
while (rs.next()) {
System.out.println(
"\t" + rs.getString("dateTimeOrigination")
+ "\t" + rs.getString("callingPartyNumber")
+ "\t" + rs.getString("finalCalledPartyNumber")
+ "\t" + rs.getString("dateTimeConnect")
+ "\t" + rs.getString("dateTimeDisconnect")
+ "\t" + rs.getString("destCause_value"));
//dbInsert(rs.getString("SDA"), rs.getString("DirectoryNumber"));
//lastRTime = Long.valueOf(rs.getString("dateTimeOrigination"));
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
} |
86b2bb5f-2ef4-4b3b-94f8-0f0d92a8b795 | 2 | public static void main(String[] args) {
Image[] input = {new IR(), new IR(), new LS(), new IR(), new LS(), new LS()};
Processor[] procs = {new Processor(), new Processor(), new Processor()};
for (int i = 0, j; i < input.length; ++i) {
j = 0;
while (!procs[j].handle(input[i])) {
j = (j + 1) % procs.length;
}
}
} |
d82b2d52-ca13-4089-b610-ecc857378d3f | 9 | public void connect(TreeLinkNode root) {
if(root==null) {
return;
}
if(root.left != null && root.right !=null) {
root.left.next = root.right;
}
if(root.next!=null) {
TreeLinkNode left, right=null;
left = root.right==null?root.left:root.right;
for(TreeLinkNode p=root.next; p!=null; p=p.next) {
if(p.left!=null) {
right = p.left;
break;
}
if(p.right!=null) {
right = p.right;
break;
}
}
if(left!=null) {
left.next = right;
}
}
connect(root.right);
connect(root.left);
} |
78a4350a-6ad9-46a3-8380-3801c98efce5 | 9 | public void update(final Protocol update)
{
switch(update.command) {
case USERSINROOM:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String room = update.textField;
synchronized(messagePane) {
int tabIndex = messagePane.indexOfTab(room);
if (tabIndex != -1) {
ConversationPanel convo = (ConversationPanel) messagePane.getComponentAt(tabIndex);
convo.update(update);
}
}
}
});
break;
case TRANSCRIPT:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String room = update.nameField;
synchronized(messagePane) {
int tabIndex = messagePane.indexOfTab(room);
if (tabIndex != -1) {
ConversationPanel convo = (ConversationPanel) messagePane.getComponentAt(tabIndex);
convo.update(update);
}
}
}
});
break;
case USERLIST:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (int i = 0; i < messagePane.getTabCount(); i++) {
ConversationPanel convo = (ConversationPanel) messagePane.getComponentAt(i);
convo.update(update);
}
}
});
break;
case COLOR_CLICK:
//perform coloring updates
break;
case COLOR_MOVE:
//perform coloring updates
//System.err.println("in chat->COLOR_MOVE");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String room = update.nameField;
synchronized(messagePane) {
int tabIndex = messagePane.indexOfTab(room);
if(tabIndex != -1 ){
ConversationPanel convo = (ConversationPanel) messagePane.getComponentAt(tabIndex);
convo.update(update);
}
}
}
});
break;
default:
System.err.println("Warning, client cannot parse command, "+update.command);
break;
}
} |
d46f4567-75ae-4ac5-9bd8-7a1be5c8a27b | 4 | public InformationLine(String[] line, Headline headline) throws EndOfCSVFileException, BrokenCSVFileException {
if (line == null) {
throw new EndOfCSVFileException("CSV File completely parsed");
}
if (headline == null) {
throw new BrokenCSVFileException("The given headline was null");
}
if (line.length -1 != headline.getCount()) {
throw new BrokenCSVFileException("Could not create information line because line length<" + line.length + ">was less than headline length<" + headline.getCount() + ">");
}
//-1 because last element is "empty"
for (int i = 0; i < line.length - 1; i++) {
map.put(headline.get(i), line[i]);
}
} |
8bde95af-13ca-4f10-a81b-03d99ce4c40f | 3 | @Override
public void manageInput(InputEvent e) {
if (e.isKeyInput()) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
Launcher.exit();
}
for (Item m : menuItems) {
m.manageInput(e);
}
} |
361afaa6-6222-411b-94c6-d4a176c43794 | 3 | public void setAvalie(PExp node)
{
if(this._avalie_ != null)
{
this._avalie_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._avalie_ = node;
} |
ece6d209-623a-4ad9-85e9-d4f549092244 | 3 | public void close() {
try {
if (read != null)
read.close();
if (write != null)
write.close();
} catch (IOException e) {
e.printStackTrace();
}
} |
aec7e8c4-864c-452a-9d86-91f4853166ac | 1 | @Test
public void testGenerate() {
byte[] key = ByteHelper.convertBinaryStringToByteArray("00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001".replace(" ", ""));
String[] expectedSubKeysStrings = new String[] {
"000110 110000 001011 101111 111111 000111 000001 110010",
"011110 011010 111011 011001 110110 111100 100111 100101",
"010101 011111 110010 001010 010000 101100 111110 011001",
"011100 101010 110111 010110 110110 110011 010100 011101",
"011111 001110 110000 000111 111010 110101 001110 101000",
"011000 111010 010100 111110 010100 000111 101100 101111",
"111011 001000 010010 110111 111101 100001 100010 111100",
"111101 111000 101000 111010 110000 010011 101111 111011",
"111000 001101 101111 101011 111011 011110 011110 000001",
"101100 011111 001101 000111 101110 100100 011001 001111",
"001000 010101 111111 010011 110111 101101 001110 000110",
"011101 010111 000111 110101 100101 000110 011111 101001",
"100101 111100 010111 010001 111110 101011 101001 000001",
"010111 110100 001110 110111 111100 101110 011100 111010",
"101111 111001 000110 001101 001111 010011 111100 001010",
"110010 110011 110110 001011 000011 100001 011111 110101"
};
//byte[][] expectedSubKeys = Arrays.stream(expectedSubKeysStrings)
// .map((s) -> convertBinaryStringToByteArray(s.replace(" ", "")))
// .collect(Collectors.toList())
// .toArray(new byte[16][6]);
byte[][] expectedSubKeys = new byte[16][6];
for(int i = 0; i < expectedSubKeys.length; i++) {
expectedSubKeys[i] = ByteHelper.convertBinaryStringToByteArray(expectedSubKeysStrings[i].replace(" ", ""));
}
byte[][] subKeys = KeyCalculator.generateSubKeys(key);
Arrays.stream(expectedSubKeys).forEach((bytes) -> ByteHelper.printByteArray(bytes));
System.out.println();
Arrays.stream(subKeys).forEach((bytes) -> ByteHelper.printByteArray(bytes));
System.out.println();
assertArrayEquals(expectedSubKeys, subKeys);
} |
365e4e15-754b-4770-98d5-55683f687ce7 | 3 | @Override
public void allocate(JobMetaData job) {
if (job.getNumFiles() < CUTOFF) {
// We dont split so just use the regular allocator
IAllocator onejob = new JobPerVMAllocator(pool, monitor);
onejob.allocate(job);
} else {
int vmsneeded = 3;
ArrayList<SlaveVM> vms = pool.requestVMs(vmsneeded);
Allocation alloc = new Allocation();
ArrayList<HashMap<Integer, String>> filelists = sliceMap(
job.getFiles(), vmsneeded - 1);
boolean first = true;
int i = 0;
int vmid = 0;
for (SlaveVM vm : vms) {
if (first) {
alloc.allocate(vm, null);
first = false;
vmid = vm.getId();
System.out.println("DEBUG: Last VM is: " + vm.getId());
} else {
alloc.allocate(vm, filelists.get(i));
i++;
}
}
System.out.println("Allocation: " + alloc.getAllocations());
createActivity(job, alloc, vmid);
}
} |
4803f332-0520-49e3-b496-0e895ffad6bd | 8 | public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new FileReader("stamps.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("stamps.out")));
int n, k;
int[] coins;
StringTokenizer st = new StringTokenizer(f.readLine());
k = Integer.parseInt(st.nextToken());
n = Integer.parseInt(st.nextToken());
int[] config = new int[k*10000+1];
coins = new int[n];
int count = 0;
while(f.ready()) {
st = new StringTokenizer(f.readLine());
while(st.hasMoreTokens()) {
coins[count] = Integer.parseInt(st.nextToken());
count++;
}
}
// run DP algorithm
for(int i=1; i<k*10000+1; i++) {
boolean canMake = false;
for(int j=0; j<n; j++) {
// make sure coin value isn't greater than total
if(i-coins[j]>=0) {
if(config[i-coins[j]]+1<=k) {
if(config[i]==0) {
config[i] = config[i-coins[j]]+1;
}
else {
config[i] = Math.min(config[i], config[i-coins[j]]+1);
}
canMake = true;
}
}
}
// couldn't make i with change
if(!canMake) {
System.out.println(i-1);
out.write((i-1)+"\n");
break;
}
}
out.close();
System.exit(0);
} |
bb5aa106-8838-4d75-a1c5-ed527bc82b2f | 2 | public void damage(int amt) {
if (health > MAX_HEALTH)
health = MAX_HEALTH;
health -= amt;
System.out.println(health);
if (health <= 0) {
MainComponent.isRunning = false;
System.out.println("GAME OVER!");
}
} |
e06ff09f-2ae1-4b32-a022-c3f76c99fa88 | 3 | public void physics( PhysicObject object, float delta )
{
PhysicalProperties properties = object.getPhysicalProperties();
if ( properties.getFloat( "gravity" ) != 0 )
{
float gravity = (float) Math.sqrt( ( 2 * properties.getFloat( "mass" ) * NEWTON ) / ( AIR_DENSITY * properties.getFloat( "surface" ) * properties.getFloat( "dragCoefficient" ) ) );
gravity *= properties.getFloat( "gravity" );
object.getVelocity().setY( object.getVelocity().getY() - gravity * delta );
}
if ( properties.getFloat( "dragCoefficient" ) != 0 )
{
Vector3f dragForce = object.getVelocity().mul( object.getVelocity() ).mul( properties.getFloat( "dragCoefficient" ) * AIR_DENSITY * properties.getFloat( "surface" ) );
if ( dragForce.length() <= object.getVelocity().length() )
object.setVelocity( object.getVelocity().add( dragForce ) );
else
object.setVelocity( new Vector3f( 0, 0, 0 ) );
}
} |
0d20cfe9-574f-4502-bac2-4dd20aa77887 | 5 | private void changeTrack(int x){
int tempBid=(x-10)/70;
System.out.println("Dans ChangeTrack : temp ="+tempBid);
if(selectedBid==tempBid){//cancel the selected bid
selectedBid=-1;
}else if(selectedBid==-1 && tempBid<bidding.getTrack().length){ //select a family
selectedBid=tempBid;
}else if(tempBid<bidding.getTrack().length && bidding.getTrack()[tempBid].getBid()==bidding.getTrack()[selectedBid].getBid()){//chage the order
bidding.interchange(selectedBid, tempBid);
selectedBid=-1;
}
repaint();
} |
0eedb17c-1f3b-4e35-aa46-d506521aaca7 | 0 | public Set keySet() {
return map.keySet();
}//keySet |
1b250fce-a127-49b6-b9a0-2854a97f519a | 8 | private long readNumber ( int db, int l )
{
long r = 0, b = 1;
int q=0;
RandomAccessFile f = ( db==0 ? fdbf : db==1 ? ffpt : fcdx );
byte[] g = new byte[l];
try { f.read(g); }
catch (IOException e) { e.printStackTrace(); }
if(db>0 && l>1) b<<=((l-1)<<3);
for(int i=0;i<l;i++)
{
q = g[i]; if(q<0) q+=0x100;
r|= b*q;
if(db>0) b>>=8; else b<<=8;
}
return r;
} |
138b701a-17d0-475e-89f1-1fbfad9f7443 | 9 | private DisplayMode findDisplayModeInternal(DisplayMode[] displayModes, int requestedWidth, int requestedHeight, int requestedDepth, int requestedRefreshRate) {
DisplayMode displayModeToUse = null;
for (int i = 0; i < displayModes.length; i++) {
DisplayMode displayMode = displayModes[i];
if ((requestedWidth == DONT_CARE || displayMode.getWidth() == requestedWidth) &&
(requestedHeight == DONT_CARE || displayMode.getHeight() == requestedHeight) &&
(requestedHeight == DONT_CARE || displayMode.getRefreshRate() == requestedRefreshRate) &&
(requestedDepth == DONT_CARE || displayMode.getBitDepth() == requestedDepth)) {
displayModeToUse = displayMode;
}
}
return displayModeToUse;
} |
ae0fef17-406d-4ba5-ad95-55eb4e459b89 | 2 | public static void sumNegativeBalances() {
// External iteration
BigInteger total = BigInteger.ZERO;
for (BankAccount account: christmasBank.getAllAccounts())
if (account.getBalance().signum() < 0)
total = total.add(account.getBalance());
System.out.println("Total of negative balances (ext): " + total);
// Internal iteration
Optional<BigInteger> totalAlt = christmasBank.getAllAccounts().stream().
filter(account -> account.getBalance().signum() < 0).
map(account -> account.getBalance()).
reduce((BigInteger left, BigInteger right) -> left.add(right));
System.out.println("Total of negative balances (int): " + total);
} |
59d88d51-20b8-45cc-8965-abdb6b101cab | 6 | public static void main(String[] args) {
if(args.length == 0) {
System.err.println("No command input");
System.exit(1);
}
HashMap<String, String> cmd;
try {
//SETUP PHASE
MFESetup setup= new MFESetup();
cmd= setup.getCommands();
if(cmd.isEmpty()) {
System.err.println("No command present in setup.xml file");
System.exit(1);
}
//START PROGRAM PHASE
String userCommand= args[0];
String clazz= cmd.get(userCommand);
if(clazz == null || clazz.equals("")) {
System.err.println("This command is not correct, please try -help");
System.exit(1);
} else {
//creation of the corresponding class is done on the fly
Constructor<?> con= Class.forName(clazz).getConstructor(CommandParameter.class);
//for now only one command at time can be run.
Command c= (Command) con.newInstance(new CommandParameter(args, setup));
c.start();
}
} catch(Exception e) {
System.err.println(e.getMessage());
System.err.println("MFE is shutting down");
}
} |
1d816cd9-ff70-4491-9fc6-d162a4339c6b | 7 | private void startCut()
{
btnPause17.setEnabled(true);
btnFinish18.setEnabled(true);
try
{
txtStartTime17.setText(jodaTimeFormat.print(startTime));
startTime = jodaTimeFormat.parseDateTime(txtStartTime17.getText());
GregorianCalendar startTimeCalendar = startTime.toGregorianCalendar();
sleeve.setStartTime(startTimeCalendar);
managerSleeve.updateSleeveStartTime(sleeve);
}
catch (Exception e)
{
String message = "Unable to update sleeve with id " + sleeve.getId();
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
}
if (txtTimeSpent17.getText().isEmpty())
{
elapsedHour = 0;
elapsedMin = 0;
elapsedSec = 0;
timer = new Timer(1000, new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
elapsedSec++;
if (elapsedSec > 59)
{
elapsedSec = 0;
elapsedMin++;
}
if (elapsedMin > 59)
{
elapsedMin = 0;
elapsedHour++;
}
String displayTimer = String.format("%02d:%02d:%02d", elapsedHour, elapsedMin, elapsedSec);
txtTimeSpent17.setText(displayTimer);
}
});
timer.setInitialDelay(0);
timer.start();
}
else
{
timer.start();
}
String option = "Pending";
String option2 = "Paused";
if (ord.getStatus().equalsIgnoreCase(option) || ord.getStatus().equalsIgnoreCase(option2))
{
String status = "in Progress";
ord.setStatus(status.toUpperCase());
try
{
managerOrder.updateStatus(ord);
}
catch (Exception e)
{
String message = "Unable to update order";
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
}
}
else
{
String message = "Production Order " + ord.getOrderId() + "'s status is already: In progress.";
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
}
} |
822b9352-09f2-4dd3-9b03-301f04f5f21c | 1 | private void toggleShowOutPut() {
this.showOutput = !this.showOutput;
if (this.showOutput) {
this.panel_1.add(txtrResultats);
this.lblConsole.setText("vvv Console :");
}
else {
this.panel_1.remove(txtrResultats);
this.lblConsole.setText(">>> Console :");
}
} |
cfd21e52-8c66-4679-9774-de86193a7e37 | 3 | private void makeDirs(final String key) throws IOException {
if (dirs == null) {
dirs = new HashSet();
}
int idx = 0;
int last = 0;
while ((last = key.indexOf('/', idx + 1)) != -1) {
final String aDir = key.substring(0, last + 1);
if (!dirs.contains(aDir)) {
dirs.add(aDir);
this.putNextEntry(new ZipEntry(aDir));
this.closeEntry();
}
idx = last;
}
} |
4a11590d-68ac-4a0f-8ab3-58370d17c670 | 9 | public void codeProcess() {
if (!player.isFreezed) {
// atualizar x e y da classe Robo para o user usar
Proto.x = (int) (player.x / 50) + 1;
Proto.y = (int) (player.y / 50) + 2;
//System.out.println("Coordenadas do Robo: [" + Robo.x + ", " + Robo.y + "]");
//zera actions
InfoCenter.zeraRobotActions();
try {
bsh.eval(Universal.currentCode);
} catch (EvalError ex) {
//Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
//JOptionPane.showMessageDialog(null, "Seu código contém algum erro.", "Erro", JOptionPane.ERROR_MESSAGE);
flagExit = true;
}
if(InfoCenter.moverDireita){
player.moveRight();
} else if (InfoCenter.moverEsqueda){
player.moveLeft();
} else if (InfoCenter.pularDireita){
player.jumpRight();
} else if (InfoCenter.pularEsquerda){
player.jumpLeft();
} else if (InfoCenter.pular){
player.jump();
} else if (InfoCenter.subir){
player.climbUp();
} else if (InfoCenter.descer){
player.climbDown();
}
}
} |
bb61ce57-38a7-40ec-8b0a-0a969445673c | 0 | public void shutdown() {
interrupt();
socket.close();
} |
214947ae-b722-4597-987c-a16512129321 | 9 | private void moveColumn(Board b, int caller) {
int posNr = 0;
Position tmp = null;
int i, j;
int foundPos = -1;
i = j = 1;
while (i <= b.getWidth()) {
j = 1;
while (j + 1 <= b.getHeight()) {
if (b.isFree(i, j) && b.isFree(i, j + 1)) {
b.set(i, j);
b.set(i, j + 1);
foundPos = pos.search(b.flatten());
tmp = new Position(b);
if (isSymmetrien() && foundPos == -1) {
foundPos = findSymmetricPosition(b);
}
if (foundPos == -1) {
if (!pos.get(caller).hasChildren(tmp)) {
posNr = pos.add(tmp);
pos.get(caller).addChild(pos.get(posNr));
moveCurrentColumn(b, caller, i);
move(b, posNr);
}
} else {
if (!pos.get(caller).hasChildren(pos.get(foundPos)))
pos.get(caller).addChild(pos.get(foundPos));
moveCurrentColumn(b, caller, i);
}
b.clear(i, j);
b.clear(i, j + 1);
}
j++;
}
i++;
}
} |
4527e358-8a06-4c25-9071-d3735276d29b | 2 | @Override
public void main() {
cleanOutput();
Element[] elements = {new ElementOne(), new ElementTwo(), new ElementThree()};
VisitorOne visOne = new VisitorOne();
VisitorTwo visTwo = new VisitorTwo();
for (Element el : elements) {
el.accept(visOne);
}
for (Element el : elements) {
el.accept(visTwo);
}
super.main("Visitor");
} |
5b40f1d0-d983-4426-abad-17310eed72d2 | 7 | public GUIAltaEmpleado(){
final ControlErrores control=new ControlErrores();
this.setTitle("Alta Empleado");
setBounds(100, 100, 500, 400);
this.setLocationRelativeTo(null);
this.setLayout(new BorderLayout());
ArrayList<Departamento> depts = FactoriaSA.obtenerInstancia().generaSADepartamento().mostrarListaDepartamentos();
ArrayList<String> departments = new ArrayList<>();
for (int i = 0; i < depts.size(); i++)
{
if (depts.get(i).isDisponible())
departments.add(depts.get(i).getNombre());
}
combos = new JComboBox(departments.toArray());
panelSuperior.setLayout(new GridLayout(8,2));
//añadimos el Jlabel y el Jtextfield para el DNI del empleado
panelSuperior.add(labDNI);
panelSuperior.add(textDNI);
//añadimos el Jlabel y el Jtextfield para el Nombre
panelSuperior.add(labNombre);
panelSuperior.add(textNombre);
//añadimos el Jlabel y el Jtextfield para los Apellidos
panelSuperior.add(labApellidos);
panelSuperior.add(textApellidos);
//añadimos el Jlabel y el Jtextfield para la Direccion
panelSuperior.add(labDireccion);
panelSuperior.add(textDireccion);
panelSuperior.add(labDepartamento);
//panelSuperior.add(textDepartamento);
//para lineas futuras, se puede poner el comboBox
panelSuperior.add(combos);
//añadimos el Jlabel y el Jtextfield para el sueldo
panelSuperior.add(labSueldo);
panelSuperior.add(textSueldo);
textSueldo.setText("1000");
//añadimos los radiobuttons al panelRadios para indicar si es empleado es Supervisor o Trabajador
panelRadios.add(radioTrabajador);
panelRadios.add(radioSupervisor);
//los radiobuttons se encuentran dentro de un ButtonGroup
grupoRadios.add(radioTrabajador);
grupoRadios.add(radioSupervisor);
//Añadimos el campo de especialidad
panelRadios.add(labProductividad);
panelRadios.add(textProductividad);
panelRadios.add(labHoras);
panelRadios.add(textHoras);
labHoras.setVisible(false);
textHoras.setVisible(false);
// Añadimos cajas de texto ocultas para cuadrar mejor el espacio
panelRadios.add(textOculto1);
panelRadios.add(textOculto2);
textOculto1.setVisible(false);
textOculto2.setVisible(false);
//añadimos los botones aceptar y cancelar al panelBotones
panelBotones.add(boton_ok);
panelBotones.add(boton_cancelar);
//Añadimos actionlintener de los botones
radioTrabajador.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
labProductividad.setVisible(false);
textProductividad.setVisible(false);
labHoras.setVisible(true);
textHoras.setVisible(true);
}
});
radioSupervisor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
labHoras.setVisible(false);
textHoras.setVisible(false);
labProductividad.setVisible(true);
textProductividad.setVisible(true);
}
});
//Añadimos el actionlistener
boton_ok.addActionListener(new ActionListener() {
private Departamento encuentraDepPorNombre(ArrayList<Departamento> deps, String nombre)
{
Departamento d = null;
for (Departamento dep : deps)
if (dep.getNombre().equalsIgnoreCase(nombre))
d = dep;
return d;
}
@Override
public void actionPerformed(ActionEvent e) {
if (radioTrabajador.isSelected())
{
ArrayList<Departamento> depts2 = FactoriaSA.obtenerInstancia().generaSADepartamento().mostrarListaDepartamentos();
t.setDni(textDNI.getText());
t.setNombre(textNombre.getText());
t.setApellidos(textApellidos.getText());
t.setDireccion(textDireccion.getText());
Departamento dummy = encuentraDepPorNombre(depts2, (String)combos.getSelectedItem());
t.setDepartamento(dummy);
t.setSueldo(((double)(Double.parseDouble(textSueldo.getText()))));
t.setTipo(radioTrabajador.getText());
t.setDisponible(true);
t.setHoras_trabajadas((double) Double.parseDouble(textHoras.getText()));
if(control.controlErroresEmpleado(t))
{
Controlador.getInstance().accion(EventoNegocio.ALTA_EMPLEADO, t);
}
else
{
System.out.println("Formato erroneo o falta de datos");
Controlador.getInstance().accion(EventoNegocio.MOSTRAR_INFORMACION_ERROR, null);
}
}
else
{
ArrayList<Departamento> depts2 = FactoriaSA.obtenerInstancia().generaSADepartamento().mostrarListaDepartamentos();
s.setDni(textDNI.getText());
s.setNombre(textNombre.getText());
s.setApellidos(textApellidos.getText());
s.setDireccion(textDireccion.getText());
Departamento dummy = encuentraDepPorNombre(depts2, (String)combos.getSelectedItem());
s.setDepartamento(dummy);
s.setSueldo(((double)(Double.parseDouble(textSueldo.getText()))));
s.setTipo(radioSupervisor.getText());
s.setDisponible(true);
s.setFactor_productividad((double) Double.parseDouble(textProductividad.getText()));
if(control.controlErroresEmpleado(s))
{
Controlador.getInstance().accion(EventoNegocio.ALTA_EMPLEADO, s);
}
else
{
System.out.println("Formato erroneo o falta de datos");
Controlador.getInstance().accion(EventoNegocio.MOSTRAR_INFORMACION_ERROR, null);
}
}
}
});
boton_cancelar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
//añadimos a este panel Altaempleado cada panel independiente
this.add(panelRadios, BorderLayout.CENTER);
this.add(panelSuperior,BorderLayout.NORTH);
this.add(panelBotones,BorderLayout.SOUTH);
// this.setBorder(new TitledBorder(new TitledBorder(""), "Alta empleado",
// TitledBorder.CENTER, TitledBorder.TOP ));
this.setVisible(true);
} |
4c885fb5-ca8c-48af-959a-7a1590a8dd45 | 7 | public int solution(int[] H) {
int blocks = 1;
Stack stack = new Stack(H.length);
stack.push(H[0]);
for (int i = 1; i < H.length; i++) {
if (stack.peek() < H[i]) {
stack.push(H[i]); //increase of wall height, which adds the need of a new block
blocks++;
} else if (stack.peek() > H[i]) {
while (stack.pop() > H[i]) { //pop elements until you reach lower or equal height
if (stack.isEmpty() || stack.peek() < H[i]) { //we reached lower height, so we can push our new height and we need a new block
stack.push(H[i]);
blocks++;
break;
} else if (stack.peek() == H[i]) break; //we reached same height, stop loop, no need of new block
}
}
}
return blocks;
} |
16bb02d1-43ca-45fb-b9ca-96c483144f8f | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ReadNode other = (ReadNode) obj;
if (prompt == null) {
if (other.prompt != null)
return false;
} else if (!prompt.equals(other.prompt))
return false;
return true;
} |
57fceb56-02ee-4d6a-96dd-63eefd2a7cc9 | 9 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Cube cube = (Cube) o;
if (permutationId != null ? !permutationId.equals(cube.permutationId) : cube.permutationId != null)
return false;
if (root != null ? !root.equals(cube.root) : cube.root != null) return false;
if (value != null ? !value.equals(cube.value) : cube.value != null) return false;
return true;
} |
16d81563-07ed-46dc-891d-5e55c118c692 | 2 | public static String getStreamID(String streamerName) {
for (int i = 0 ; i < streamName.size(); i++) {
if (streamName.get(i).equalsIgnoreCase(streamerName)) {
return streamList.get(i);
}
}
return null;
} |
c8c52c17-a54e-44c0-be52-49a4b9608a7d | 3 | public void playersMove(Value player) {
boolean fault = true;
while (fault) {
Scanner in = new Scanner(System.in);
System.out.println(player + ": Введите число от 1 до " + field.sizeField);
try {
int x = in.nextInt()-1;
int y = in.nextInt()-1;
if (field.isCellEmpty(x, y)) {
field.setFieldCell(player, x, y);
fault = false;
} else System.out.println("Поле занято, попробуйте ещё раз, " + player + "!!");
} catch (Exception e) {
System.out.println("Неверный ввод, попробуйте ещё раз, " + player + "!!");
}
}
} |
e6423545-7e70-4814-8f41-22b432d9ff1d | 7 | public static StorageNodeMetadata getNode(int key){
StorageNodeMetadata nodeMeta;
int hashKey = key % moduloRange;
if (storageNodes.isEmpty())
return null;
else
{
nodeMeta = null;
int diff = moduloRange;
for (int i=0; i<storageNodes.size(); i++){
StorageNodeMetadata node = storageNodes.get(i);
int nodeId = node.getID();
if ((nodeId > hashKey) && (nodeId - hashKey < diff))
{
nodeMeta = node;
diff = nodeId - hashKey;
}
}
if (nodeMeta == null)//when the key is store on the first node
{
//find the node with the smallest id
nodeMeta = storageNodes.get(0);
for (int i=1; i<storageNodes.size(); i++)
if (storageNodes.get(i).getID()< nodeMeta.getID())
nodeMeta = storageNodes.get(i);
}
return nodeMeta;
}
} |
01ffb6fa-b3de-4831-8a41-a0619fc7a9ce | 5 | public void setStatement(Integer i, PreparedStatement stmt, Object stuff) throws SQLException {
switch (this.s_to_int(this.campos[i][1])) {
case 0:
stmt.setInt(i, (Integer) stuff);
break;
case 1:
stmt.setString(i, (String) stuff);
break;
case 2:
java.util.Date date = (java.util.Date) stuff;
stmt.setDate(i, new java.sql.Date(date.getTime()));
break;
case 3:
stmt.setBoolean(i, (Boolean) stuff);
break;
case 4:
stmt.setFloat(i, (Float) stuff);
}
} |
fa83c3fd-e75b-46b0-8e55-43cbfee8858e | 1 | @SuppressWarnings("unchecked")
public List<BEValue> getList() throws InvalidBEncodingException {
if (this.value instanceof ArrayList) {
return (ArrayList<BEValue>)this.value;
} else {
throw new InvalidBEncodingException("Excepted List<BEvalue> !");
}
} |
9b03118b-2f6c-40f0-b917-d7eb81faf7f5 | 2 | public PhasorMatrix subarray_as_Phasor_rowMatrix(int start, int end){
if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
Phasor[] pp = this.getArray_as_Phasor();
Phasor[] retArray = new Phasor[end-start+1];
for(int i=start; i<=end; i++)retArray[i-start] = pp[i];
PhasorMatrix mat = PhasorMatrix.rowMatrix(retArray);
return mat;
} |
81e6684a-d3dc-4eba-8e99-6fffa9ca2345 | 8 | public static void main(String[] args) {
Set<String> digits = permutate("0123456789");
Set<Long> total = new HashSet<>();
for (String s : digits) {
if (getDigits(s, 2) % 2 != 0) continue;
if (getDigits(s, 3) % 3 != 0) continue;
if (getDigits(s, 4) % 5 != 0) continue;
if (getDigits(s, 5) % 7 != 0) continue;
if (getDigits(s, 6) % 11 != 0) continue;
if (getDigits(s, 7) % 13 != 0) continue;
if (getDigits(s, 8) % 17 != 0) continue;
total.add(Long.parseLong(s));
}
long result = total.stream().reduce(0L, (a, b) -> a + b);
System.out.println(result);
} |
e1ae58c7-6991-4903-a13a-78650c297b84 | 8 | public Class getObjectClass() {
if (_wrapperObject instanceof Boolean)
return boolean.class;
else if (_wrapperObject instanceof Integer)
return int.class;
else if (_wrapperObject instanceof Float)
return float.class;
else if (_wrapperObject instanceof Double)
return double.class;
else if (_wrapperObject instanceof Long)
return long.class;
else if (_wrapperObject instanceof Character)
return char.class;
else if (_wrapperObject instanceof Byte)
return byte.class;
else if (_wrapperObject instanceof Short)
return short.class;
else
return null;
} |
3edc117a-6038-40db-855a-d5b62a3b8c7d | 4 | public void update() {
up = keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W];
down = keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S];
left = keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A];
right = keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D];
} |
81e3ac5d-fde6-4b59-8410-3e3a4137ac98 | 0 | public void updatePanel() {
repaint();
} |
129e626a-ac95-4df1-b346-077dcc11888d | 1 | public void setUserlistImageOverlay_Width(int width) {
if (width <= 0) {
this.userlistImgOverlay_Width = UISizeInits.USERLIST_IMAGEOVERLAY.getWidth();
} else {
this.userlistImgOverlay_Width = width;
}
somethingChanged();
} |
d7bbbb92-73c7-4489-aab5-4136f118d793 | 4 | public static void main(String[] args){
try{
TestClass to = new TestClass();
String s = to.toString();
System.out.println(s);
registerEvents();
Class<?> c = MyJsonUtils.findClass("TestClass");
System.out.println(c);
for(Class<?> cl: ClassFinder.find("bluefrost.serializable.objects.v1.json")){
System.out.println(cl);
}
/*
System.out.println("Setting up UserManager DataBase...");
ub1 = UserBase.setup(new File("C:\\JavaResources\\Simple.db"));
System.out.println("UserManager DataBase is setup!");
ub1.createUser("root", "toor");
System.out.println("Please Standby, Generating RSA Keyset...");
Crypto.genKeys();
System.out.println("RSA Keyset Generated!");
registerEvents();
System.out.println("Registered Events!");
//*
NIOS.Worker worker = new NIOS.Worker();
new Thread(worker).start();
nios = new NIOS(null, 9090, worker);
new Thread(nios).start();
Thread.sleep(10000);
System.out.println("Test!");
ClientManager.say(new CM("Test").toByteArray());
// System.out.println("END");
//nios.end();
//*/
}catch(Exception e){e.printStackTrace();}
} |
0538d044-2f8f-4b0b-ad1f-9079bc4b484e | 7 | private static String getDay(Calendar c) {
int day = c.get(Calendar.DAY_OF_WEEK);
switch (day) {
case 1:
return "Sunday";
case 2:
return "Monday";
case 3:
return "Tuesday";
case 4:
return "Wednesday";
case 5:
return "Thursday";
case 6:
return "Friday";
case 7:
return "Saturday";
}
return null;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.