text stringlengths 14 410k | label int32 0 9 |
|---|---|
private static String solve(int Gp, int Gc, int Gf, int N, int[][] foods) {
int itr = (int) Math.pow(2, N); // number of iterations required
for (int mask = 0; mask < itr; mask++) {
int GpSum = 0, GcSum = 0, GfSum = 0;
for (int i = 0; i < N; i++)
if ... | 9 |
boolean setAs(String to_search) {
if(parents.size() == 0) {
if(name.equals(to_search))
return true;
ClassMeta c = EntityMeta.getDependencyTo(id);
if(c == null || !c.name.equals(to_search))
return false;
else {
return true;
}
}
else {
for(int i = 0; i < parents.size(); ++i) {
... | 6 |
public boolean validarLicencia(LicenciaConductor licencia, Persona p, EntityManager manager) {
boolean resultado = false;
if (licencia != null) {
if (manager.find(LicenciaConductor.class, licencia.getNumero()) != null) {
resultado = true;
System.out.println("N... | 5 |
@Override
public void setBloc(BlocService b, int i, int j) {
if(!(0<=i && i<super.getNombreColonnes() && 0<=j && j<super.getNombreLignes()))
throw new PreConditionError("unboud i or j");
checkInvariants();
super.setBloc(b, i, j);
checkInvariants();
if(!(super.getBloc(i, j)==b))
throw new PostConditionE... | 5 |
public void loadPuzzle(String difficulty)
{
File file;
if(difficulty.equals("Easy"))
{
file = new File("easy16x16.txt");
}
else if(difficulty.equals("Medium"))
{
file = new File("medium16x16.txt");
}
else if(difficulty.equals("Hard"))
{
file = new File("hard16x16.txt");
}
else
{
fil... | 9 |
public static String[] removeDuplicateStrings(String[] array) {
if (SpringObjectUtils.isEmpty(array)) {
return array;
}
Set<String> set = new TreeSet<String>();
for (String element : array) {
set.add(element);
}
return toStringArray(set);
} | 2 |
public void setPcaPosId(BigInteger pcaPosId) {
this.pcaPosId = pcaPosId;
} | 0 |
public PlanBoeseBeute(JSONObject object) throws FatalError {
super(object, "BoeseBeute");
if (PlanBoeseBeute.list == null) {
PlanBoeseBeute.list = new OpponentList();
}
} | 1 |
@After
public void tearDown() {
userInput = null;
nlgResults = null;
dmResults = null;
//deleting new userData
File newFile = new File("resources/files/UserData/" + userDataCount + ".json");
userDataCount++;
while(newFile.exists()) {
// System.out.println("deleting");
newFile.delete();
newFile... | 5 |
public static void main(String... args) {
// Get params for Rubiks Cube size
int size = 3;
if (args.length != 0) {
try {
size = Integer.valueOf(args[0]);
}
catch (NumberFormatException e) {
System.out.println("Bad parameter format : you must provide a numeric size for the Rubik's Cube");
}
}... | 6 |
public static void main(String[] args)
{
In in = new In(args[0]);
try
{
Digraph g = new Digraph(in);
System.out.println(args[0] + " \n" + g);
Digraph dg = new Digraph(g);
System.out.println("Duplicate graph of the above\n" + dg);
System.out.println("Reversed graph of the above\n" + g.reverse(... | 1 |
public static void main(String[] args){
LinkedList<Integer> testResults = new LinkedList<Integer>();
LinkedList<Integer> actualValues = new LinkedList<Integer>();
if (args.length > 0){
if (args.length == 1){
System.out.println(isQuestion(args[0]));
System.out.println(questionContent(args[0]));
} els... | 9 |
public void write5bytes(long n) throws IOException {
long b0 = n & 0xff;
long b1 = (n & 0xff00) >> 8;
long b2 = (n & 0xff0000) >> 16;
long b3 = (n & 0xff000000) >>> 24;
long b4 = (n & 0xff00000000L) >> 32;
if (le) {
write(b0); write(b1); write(b2); write(b3); write(b4);
} else {
write(b4); write(b3)... | 1 |
private void handleMimePart(BufferedReader reader) throws IOException {
// Since we just shifted to a new section we want to read in the headers to determine which section it is.
String headerLine;
boolean stopParsingHeaders = false;
while ((headerLine = reader.readLine()) != null && !st... | 8 |
String toStringVcfInfo(Collection<String> strs) {
// Sort strings
ArrayList<String> list = new ArrayList<String>(strs);
Collections.sort(list);
// Add the all
StringBuffer sb = new StringBuffer();
for (String str : list)
if (!str.isEmpty()) sb.append(str + ",");
if (sb.length() > 0) sb.deleteCharAt(s... | 3 |
public int getWidth() {
return width;
} | 0 |
private String compareToAll(String possibleKw) {
ArrayList<Keyword> keywordList = (ArrayList<Keyword>) dictionary.getKeywordList();
String mostProbableKeyword = "";
int shortestDistance = 100;
for(int i = 0; i < keywordList.size(); i++) {
Levenshtein levenDistance = new Levenshtein(... | 3 |
public void setMessage(String message) {
this.message = message;
} | 0 |
public void start() {
if (this.tracker == null || !this.tracker.isAlive()) {
this.tracker = new TrackerThread();
this.tracker.setName("tracker:" + this.address.getPort());
this.tracker.start();
}
if (this.collector == null || !this.collector.isAlive()) {
this.collector = new PeerCollectorThread();
... | 4 |
public Color getDefaultColor() {
return defaultColor;
} | 0 |
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BonsHotels other = (BonsHotels) obj;
if (quotaFixa == null) {
if (other.quotaFixa != null)
return false;
} else if (!quotaFixa.equals(other.quotaFi... | 9 |
public boolean canAcceptTrade() {
TradeOffer offer = serverModel.getTradeOffer();
//If there is not an offer don't consider further
if (offer != null) {
Player receiver = serverModel.getPlayers().get(serverModel.getTradeOffer().getReceiver());
//For the trade, need to check offer, any positive (I thi... | 6 |
static public String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String s = Double.toString(d);
if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
... | 7 |
public void run() {
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input;
while(Util.ServerRunning && (input=br.readLine())!=null){
Stream.PutString(input);
}
br.close();
}catch(IOException i... | 3 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof MovableEntity))
return false;
MovableEntity other = (MovableEntity) obj;
if (dead != other.dead)
return false;
if (multiplier != other.multipl... | 7 |
public void addUsed(int localSlot) {
if (usedLocals.get(localSlot))
return;
usedLocals.set(localSlot);
if (dependent instanceof StackLocalInfo)
((StackLocalInfo) dependent).enqueue();
else if (dependent instanceof JSRTargetInfo)
((JSRTargetInfo) dependent).addUsed(localSlot);
else if (depend... | 5 |
private boolean checkCommands(String command)
{
String sCommand;
if (command.startsWith("/"))
{
sCommand = command.substring(1);
}
else
{
sCommand = command;
}
List<String> aliases;
for (DNCCommands cmd : DNCCommands.values())
{
if (cmd.getName().equalsIgnoreCase(sCommand))
{
... | 8 |
private static void test_abs(TestCase t) {
// Print the name of the function to the log
pw.printf("\nTesting %s:\n", t.name);
// Run each test for this test case
int score = 0;
for (int i = 0; i < t.tests.length; i += 3) {
int exp = (Integer) t.tests[i];
int arg1 = (Integer) t.tests[i + 1];
int arg... | 2 |
public int[][] addTownAreas(int[][] newBlockArray, int[] wg, BlockManager bm, int numTownAreas, int townSize, int minX, int maxX){
Game.loadingText = "Building a Cabin";
EIError.debugMsg("addTownAreas Start", EIError.ErrorLevel.Notice);
//build start town
for(int x = 0; x < townSize; x++... | 7 |
public void setAlive(boolean alive) {
this.alive = alive;
} | 0 |
private static boolean checksumValid(File libPath, List<String> checksums)
{
try
{
byte[] fileData = Files.toByteArray(libPath);
boolean valid = checksums == null || checksums.isEmpty() || checksums.contains(Hashing.sha1().hashBytes(fileData).toString());
if(!vali... | 5 |
public Iterator<Field> getGreedy(Field f) {
PriorityQueue<Field> greedy = new PriorityQueue<>(8);
this.updateBoard(f.x, f.y, false);
//add next fields
for(int i = 0; i < springer.length;i+=2)
{
int newX = f.x+ springer[i]; //x position of next jump point
int newY = f.y+ springer[i+1];
if(fi... | 4 |
private void updateGlunStatus() {
String text = this.glGlun.getText();
String allowedCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/_-";
if(text.length() == 0) {
this.glGlunStatus.setText("<html>Enter your GL_GLUN. It is <b>case sensitive.</b></html>");... | 4 |
private boolean readGZIPFile(String fileName)
{
boolean success = false;
BufferedReader reader = null;
try
{
FileInputStream file = new FileInputStream(fileName);
GZIPInputStream gz = new GZIPInputStream(file);
reader = new BufferedReader(new Inpu... | 5 |
public void go_bottom()
{
if(order.length()>0)
{
if(Idx!=null)
{
Idx.goBottom();
go_recno( Idx.found ? Idx.sRecno : reccount+1 );
}
else
{
Cdx.goBottom();
go_recno( Cdx.found ? Cdx.sRecno : reccount+1 );
}
}
else go_recno( reccount );
} | 4 |
public static String doFormat( String format, Calendar cal ) throws IllegalArgumentException {
int fidx = 0;
int flen = format.length();
StringBuilder buf = new StringBuilder();
while(fidx<flen) {
char fch = format.charAt(fidx++);
if(fch!... | 9 |
@EventHandler(priority = EventPriority.HIGHEST)
public void blockPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
if (player.hasPermission(Permissions.PERM_ADMIN))
return;
String username = player.getName();
Chunk chunk = event.getBlock().getChunk();
if (!CP.getWGInstance().canBuild(p... | 6 |
public static System getSystem(String name) {
System system = null;
if(listSystems.containsKey(name)) {
system = listSystems.get(name);
}
return system;
} | 1 |
@Override
public void setVisible(boolean visible) {
if (visible) {
Main main = (Main) super.getTopLevelAncestor();
cancel.setVisible(main.hasMatch());
}
super.setVisible(visible);
} | 1 |
@Override
public void buildFloralComposition(String fileName) throws DAOException {
FileInputStream inputStream = null;
XMLStreamReader reader = null;
try {
inputStream = new FileInputStream(new File(fileName));
reader = factory.createXMLStreamReader(inputStream);
... | 8 |
public static boolean initialize(File file)
{
try
{
mStream = new PrintWriter(new FileOutputStream(file, true));
return true;
}
catch(IOException e)
{
return false;
}
} | 1 |
public static boolean isRightLinearProductionWithVariable(
Production production) {
if (!isRestrictedOnLHS(production))
return false;
String rhs = production.getRHS();
/**
* if only one variable on rhs and it is last char on rhs.
*/
String[] variables = production.getVariablesOnRHS();
if (variable... | 3 |
public static void loadFusions(File fin) {
YamlConfiguration config = YamlConfiguration.loadConfiguration(fin);
Set<String> keys = config.getConfigurationSection("type").getKeys(false);
Set<String> keys2 = null;
Iterator<String> iterator = keys.iterator();
Iterator<String> iterator2 = null;
String s;
Stri... | 8 |
private void jButton_OutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OutActionPerformed
try {
OpenTransactionAccount otAccount = new OpenTransactionAccount();
String basket = otAccount.showBasket(jTextField_ServerID.getText(), jTextField_NymID.getText(), jTe... | 3 |
public static Protagonista buildProtagonista(ClassePersonagem classe, JSONObject jsonObject) {
Protagonista protagonista = null;
switch(classe) {
case ANAO:
protagonista = new Anao(jsonObject);
break;
case BARBARO:
protagonista = new Barbaro(jsonObject);
break;
ca... | 6 |
@Override
public void parseCommandLine(CommandLine line)
{
if ( line.hasOption("resolution") )
{
String[] parts = line.getOptionValue("resolution").split("x");
if ( parts.length == 2 )
{
try
{
mResoWidth = Integer.parseInt(parts[0]);
mResoHeight = Integer.parseInt(parts[1]);
}
... | 5 |
public void mouseReleased(MouseEvent evt) {
if (mousein == 1 && evt.getSource()==newspaper){
showNewspaper();
}
if (mousein == 2 && evt.getSource()==map){
showMap();
}
if (mousein == 3 && evt.getSource()==close){
setVisible(false); //you can't see me!
dispose(); //Destroy the JFrame objec... | 6 |
private void construirPuntosDeAlcance(Tablero tablero){
for (int i = this.posicion.obtenerX() - this.alcance; i <= this.posicion.obtenerX() + this.alcance; i++) {
for (int j = this.posicion.obtenerY() - this.alcance; j <= this.posicion.obtenerY() + this.alcance; j++) {
if( ( (i >= tablero.getInicioDeColumnas()... | 8 |
public static void main(String[] args) {
try {
GpxFile gpx = GpxFile.ReadGPXFile(new File(args[0]));
System.out.println(gpx.toString());
} catch (FileNotFoundException ex) {
Logger.getLogger(GPXView.class.getName()).log(Level.SEVERE, null, ex);
} catch (XMLStreamException ex) {
Logger.getLogger(GPXVie... | 9 |
private static void handleGetCommand(final String nick, final String args)
{
if(!Conf.config.getProperty("enable-get", "true").equals("true")) {
Cmd.sayToPlayer(nick, "get is disabled.");
return;
}
int count = 64;
int id = 0;
final String[] parts = args.split(" ", 2);
if(parts.length == 2) {
int tmp = 0;
... | 9 |
@Override
public boolean uploadImage(BufferedImage image, String filename, String fileType)
{
if (mClient == null && !connect())
{
return false;
}
if (mClient != null)
{
try
{
if (!ImageIO.write(image, fileType, new File(filename)))
{
System.err.println("Could not save the image to di... | 9 |
public static BufferedImage get(String filename){
//If the image already exists then return
if(images.containsKey(filename)){
return images.get(filename);
//Else load the image and return
}else{
try{
//Loads the image
File file = new File(Constants.ASSETS+ File.separatorChar +filename);
if(fil... | 3 |
public String[] getDownloadSN(){
String[] result = null;
if(sncalendars!=null && sncalendars.keySet().size()>0){
result = new String[sncalendars.keySet().size()];
}
else return null;
int index=0;
for(String sn: sncalendars.keySet()){
if(sncalendars.get(sn)!=null && sncalendars.get(sn)[1]!=null)
re... | 6 |
public void visitTree(final Tree tree) {
final ListIterator iter = tree.stmts().listIterator(
tree.stmts().lastIndexOf(previous));
if (iter.hasPrevious()) {
final Stmt p = (Stmt) iter.previous();
check(p);
}
/*
* Object prev = iter.previous(); if (prev instanceof LocalExpr)
* check(prev);
*... | 1 |
public void updateDisplays() {
seat1Label.setText(model.getSeat(1).toString());
seat2Label.setText(model.getSeat(2).toString());
seat3Label.setText(model.getSeat(3).toString());
seat4Label.setText(model.getSeat(4).toString());
seat5Label.setText(model.getSeat(5).toString());
... | 7 |
static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future) {
int diff = 0;
long savedDate = fromDate.getTimeInMillis();
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate))) {
savedDate = fromDate.getTimeInMillis();
fromDate.add(type, future ? 1 : -1);
... | 5 |
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
Dimension size = button.getSize();
int labelX = label.getX();
int labelY = label.getY();
int buttonX = button.getX();
int buttonY = button.getY();
int buttonPosX = buttonX / size.width;
int buttonPosY = buttonY / si... | 8 |
public void run()
{
TcpConnection.field_74469_b.getAndIncrement();
try
{
while (TcpConnection.func_74462_a(field_74501_a))
{
boolean flag;
for (flag = false; TcpConnection.func_74451_d(field_74501_a); flag = true) { }
... | 7 |
@Override
public int compareTo(Bookmark data) {
//return (Long.parseLong(getTimestamp()) <= Long.parseLong(data.getTimestamp()) ? - 1 : 1);
if (this.userID < data.getUserID()) {
return -1;
} else if (this.userID > data.userID) {
return 1;
} else {
if (!this.timestamp.isEmpty() && !data.timestamp.isEmp... | 6 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public boolean getBoolean(String key) throws JSONException {
Object o = get(key);
if(o==null) return false;
if (o.equals(Boolean.FALSE) ||
(o instanceof String &&
((String)o).equalsIgnoreCase("false"))) {
return false;
} else if (o.equals(Bool... | 7 |
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// On vide le dossier img
File del = new File("img");
delRecursif(del, true);
}//GEN-LAST:event_formWindowClosing | 0 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
} | 1 |
public void putAll( Map<? extends K, ? extends Float> map ) {
Iterator<? extends Entry<? extends K,? extends Float>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
... | 8 |
public void addLink(int fromID, int toID, String cardinality, String name) {
// add the link
linkData.add(new LinkData(fromID, toID, cardinality, name));
// find the name of the class the link is coming from and index of the
// class the link is going to
String fromName = "";
int toIndex = 0;
for (int i =... | 9 |
protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
try {
org.apache.axis.client.Call _call = super._createCall();
if (super.maintainSessionSet) {
_call.setMaintainSession(super.maintainSession);
}
if (super.cachedU... | 8 |
@Override
public boolean accept(File f) {
return (f.isDirectory()) || (f.getAbsolutePath().toLowerCase().endsWith(".ab") && f.getAbsolutePath().toLowerCase().contains(device.getSerial().toLowerCase()));
} | 2 |
private boolean giveForum(){ // Donne une ressource au forum (si le villageois est sur la bonne case) retourne Vrai s'il a reussit , faux sinon.
if (this.curent.objet instanceof Forum){
Forum b ;
b = (Forum) this.curent.objet;
b.addStock();
this.quantite --;
if (this.quantite <1){
this.plein = fal... | 2 |
@Override
public List<Campus> Buscar(Campus obj) {
String sql = "select a from Campus a";
String filtros = "";
if(obj != null){
if(obj.getId() != null){
filtros += "a.id = " + obj.getId();
}
if(obj.getNome() != null){
... | 7 |
@Override
public void run() {
Scanner sc = new Scanner(System.in);
while (true) {
int choice;
while (true) {
showMenu();
try {
String input = sc.next();
choice = Integer.parseInt(input);
... | 7 |
@Test
public void testPutTrackingID()throws Exception{
Tracking tracking = new Tracking("whatever");
tracking.setId("539fc1d68a6157923f0a9284");
tracking.setTitle("another title");
Tracking tracking2 = connection.putTracking(tracking);
Assert.assertEquals("Should be equals ... | 1 |
public static void showDialog(final Object obj) {
if (obj == null)
return;
EventQueue.invokeLater(new Runnable() {
public void run() {
if (obj instanceof Atom) {
createDialog((Atom) obj).setVisible(true);
}
else if (obj instanceof RBond) {
createDialog((RBond) obj).setVisible(true);
... | 7 |
public void maulSpec()
{
if(IsAttackingNPC && playerEquipment[playerWeapon] == 4153)
{
setAnimation(1667);
actionTimer = 4;
SpecDamgNPC(30);
DDS2Damg = true;
DDStimer = 1;
resetAnimation();
teleportToX = absX;
teleportToY = absY;
... | 4 |
protected void initDefaultCommand() {
setDefaultCommand(new TankDrive());
} | 0 |
public Animal[][] getSurrounding(Animal animal) {
if (animal == null) {
return null;
}
// Scan entire Grid for animal
for (int i = 0; i < grid.length; i++) {
for (int j = 0; i < grid[0].length; j++) {
if (animal.equals(grid[i][j])) {
// Animal found, get surrounding
Animal surroundingGri... | 6 |
private static void createDoubleParameters()
{
doubleArray = new double[PARAMETERS];
for (int i = 0; i < PARAMETERS; i++)
{
double doubleValue = i * 10.1;
doubleArray[i] = doubleValue;
}
} | 1 |
public static void main(String[] args) {
try {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File(ClassLoader.getSystemResource(runXMLAUTHORITY).getFile());
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConf... | 6 |
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
if (par1 == 0)
{
return Block.planks.blockIndexInTexture;
}
else
{
int var3 = getDirection(par2);
int var4 = Direction.bedDirection[var3][par1];
return isBlockF... | 8 |
public void createBookSql(String ver) throws ParseException, IOException {
StringBuilder sb = new StringBuilder();
sb.append("-- \n");
sb.append("-- generated by 2nd2go.org\n");
sb.append("-- \n\n");
// Charset charset = Charset.forName("US-ASCII");
Charset charset = Chars... | 3 |
public VerifyInfo initInfo() {
VerifyInfo info = new VerifyInfo();
int pos = 1;
int slot = 0;
if (!mi.isStatic()) {
String clazzName = ci.getName().replace('.', '/');
if (mi.getName().equals("<init>"))
info.locals[slot++] = Type.tType("N" + clazzName + ";", null);
else
info.locals[slot++] = Typ... | 5 |
private void processFileAttrRequest(Sim_event ev)
{
if (ev == null) {
return;
}
int requesterID = -1;
int size = 0;
FileAttribute attr = null;
try
{
Object[] obj = (Object[]) ev.get_data();
if (obj == null) {
... | 5 |
@Override
protected void read(InputBuffer b) throws IOException, ParsingException {
VariableLengthIntegerMessage vLength = getMessageFactory().parseVariableLengthIntegerMessage(b);
b = b.getSubBuffer(vLength.length());
long length = vLength.getLong();
if (length < 0 || length > Options.getInstance().getInt("p... | 3 |
public static void listSalariesOrder(EntityManager entityManager) {
TypedQuery<Employee> query = entityManager.createQuery(
"select e from Employee e order by e.salary desc",
Employee.class);
List<Employee> resultList = query.getResultList();
entityManager.close();
for (Employee employee : resultList)... | 1 |
public void createPlayersProjectile(int x, int y, int offX, int offY, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time) {
synchronized(c) {
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
Player p = Server.playerHandler.players[i];
if(p != null) {
Client person =... | 6 |
public void open() {
Display display = Display.getDefault();
createContents();
shlWAU.open();
shlWAU.layout();
//
shlWAU.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
System.out.println("Interrompendo threads...");
try{
mapMgr.close();
... | 3 |
public void delete() {
TextGrid.DataGridCel cel;
TextGrid.DataGridCel nextCel;
cel = grid.getCel(currentRow + rowOffset, currentCol + colOffset);
if (currentRow + rowOffset == numberOfRows - 1) {
nextCel = grid.getCel(currentRow + rowOffset, currentCol
+ ... | 4 |
public static String getExtractor(LinkedList<String> parts) {
String tmp = next(parts);
if (tmp == null)
return null;
if (tmp.equals("array")) {
return getArrayExtractor(parts);
}
parts.addFirst(tmp);
String baseExtractor = getStreamExtractor(parts);
if (baseExtractor == null)
return null;
Stri... | 4 |
public static int getIntegerParameter(String key) throws CorruptConfigurationEntryException {
key = key.toLowerCase();
if(parameters.containsKey(key)) {
try {
return Integer.parseInt(parameters.get(key));
} catch(NumberFormatException e) {
throw new CorruptConfigurationEntryException("The entry '" + k... | 2 |
public int inserir(Loja l){
Connection conn = null;
PreparedStatement pstm = null;
int retorno = -1;
try{
conn = ConnectionFactory.getConnection();
pstm = conn.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS);
pstm.setString(1, l.getNome());
... | 3 |
public int korasiDamage(Client o) {
double hitMultiplier = random.nextDouble() + 0.5;
int damage = (int)(calculateMeleeMaxHit() * hitMultiplier);
if(damage > 750) {
damage = 20;
}
if (o != null && o.curseActive[c.curses().DEFLECT_MAGIC] && System.currentTimeMillis() - o.protMageDelay > 1500)
damage = (... | 7 |
public static void main(String[] args) {
final int GOAL = 3;
int count1 = 0, count2 = 0;
Coin coin1 = new Coin();
Coin coin2 = new Coin();
while (count1 < GOAL && count2 < GOAL) {
coin1.flip();
coin2.flip();
Syste... | 6 |
public void run()
{
// on mac os x 10.5.x, when i run a 'sudo' command, i need to write
// the admin password out immediately; that's why this code is
// here.
if (sudoIsRequested)
{
//doSleep(500);
printWriter.println(adminPassword);
printWriter.flush();
}
BufferedReade... | 5 |
public static void main(String[] args)
{
try
{
String fname = "Assignment04.txt";
Scanner scnr = new Scanner(new File(fname));
// read initial data from file
int numCities = scnr.nextInt();
int numFlights = scnr.nextInt(... | 8 |
public InputListener keyRotateListener(String id)
{
if (id.equals("analog"))
return new AnalogListener()
{
@Override
public void onAnalog(String name, float value, float tpf)
{
if (name.equals(MAP_ROTATE))
rotateBoardCam(value * (isShiftPressed ? -1 : 1));
}
... | 5 |
public int getAnzahlLaender(Fraktion f) {
int res = 0;
Iterator<Land> it = iterator();
while(it.hasNext()) {
if(it.next().getOwner().equals(f)) {
res++;
}
}
return res;
} | 2 |
@Override
public void service(HttpServletRequest
request, HttpServletResponse response)
throws ServletException, IOException {
String url = request.getPathInfo();
IContext context = createContext(request, response);
IAction action = router.find(url, context);
properties.put("context", request.getCon... | 4 |
public ArrayList<Account> pay(Account buyer, Account seller, String amount){
buyer.pay(amount);
seller.receive(amount);
ArrayList<Account> accounts = new ArrayList<Account>();
accounts.add(seller);
accounts.add(buyer);
return accounts;
} | 0 |
private void conectar(){
Properties configuracion = new Properties();
try {
configuracion.load(new FileInputStream("configuracion"));
} catch (FileNotFoundException e) {
defecto(configuracion);
} catch (IOException e) {
e.printStackTrace();
}
try {
// para Mysql
if(configuracion.... | 8 |
public static String fixName(String user)
{//System.out.println("fixName");
String username = user;
for (int i = 0; i < username.length(); i++)
{//System.out.println("fixName username: " + username + "; username.charAt(" + i + "): " + username.charAt(i));
if (username.charAt(i) == ' ' || username.c... | 6 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.