text stringlengths 14 410k | label int32 0 9 |
|---|---|
private void find(int opened, int closed, int n, String validPath)
{
//finish
if(opened == n && closed == n)
{
if(!validCombinations.contains(validPath))
validCombinations.add(validPath);
return;
}
//first pass or can we add a "(" ?
if(opened == 0 || opened<n)
{
validPath += "(";... | 7 |
private void reshapeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reshapeButtonActionPerformed
try {
JViewport viewport = spriteSheetScrollPane.getViewport();
SpriteSheetPane ssPane = (SpriteSheetPane) viewport.getView();
ButtonModel selectedModel =... | 9 |
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
String line = null;
StringBuilder sb = new StringBuilder();
StringBuilder alertDiv = new StringBuilder();
String advisory = "";
try {
URL url =... | 7 |
public int getPlayerIndexByID(int id) {
for (Player player : players) {
if (player.getPlayerID() == id)
return player.getPlayerIndex();
}
return -1;
} | 2 |
@Override
public void actionPerformed(ActionEvent event) {
if (event.getSource()== m_generateBarButton){
generateBarChart();
} else if (event.getSource()== m_generatePieButton){
generatePieChart();
... | 7 |
public int firstMissingPositive(int[] a) {
if (a == null || a.length==0){
return 1;
}
int i=0;
while(i<a.length){
if(a[i] >0 && a[i]<a.length &&
a[a[i]-1] != a[i] && a[i] != i+1){
swap(a, i, a[i]-1);
}
else{... | 9 |
private boolean isValidNumber(final int aNumber) {
boolean res = false;
return !(Integer.toString(aNumber).endsWith("5"));
} | 0 |
public int threeSumClosest(int[] num, int target) {
Arrays.sort(num);
int min = Math.abs(num[0] + num[1] + num[2] - target);
int rst = num[0] + num[1] + num[2];
for (int i = 0 ; i < num.length - 2; i++ )
{
int k = num.length -1;
for ( int j = i +1; j< num.length -1; j++... | 8 |
public String comparer(Carte carteAdverse){
if (puissance > carteAdverse.puissance){
return "gagne";
}
else if (puissance < carteAdverse.puissance){
return "perdu";
}
else return "bataille";
} | 2 |
private Socket connect () {
Socket s = null;
int attempts = 0;
do {
attempts ++;
try {
s = new Socket(host, port);
s.setKeepAlive(true);
s.setSoTimeout(0);
} catch (Exception e) {
String msg =
String.format("Warning: connection attempt %d to %s failed.",
attempts, ge... | 3 |
public void rotarAdelante() {
if (direccion.equals(Direccion.derecha)) {
rotar(tipoTrans.enZ, 90);
} else if (direccion.equals(Direccion.izquierda)) {
rotar(tipoTrans.enZ, -90);
} else if (direccion.equals(Direccion.atras)) {
rotar(tipoTrans.enZ, 180);
... | 7 |
private void writeToFile(
final MultiProcessor executor,
final Map<String, ByteClass> byteClasses,
final List<Pair<ZipEntry, byte[]>> fileEntries,
final BiMap<String, String> nameMaps,
final... | 7 |
public String getDescription() {
StringBuffer result = new StringBuffer(String.valueOf(addr))
.append('_').append(Integer.toHexString(hashCode()))
.append(": ").append(opcodeString[opcode]);
if (opcode != opc_lookupswitch) {
if (hasLocalSlot())
result.append(' ').append(getLocalSlot());
if (succs ... | 6 |
@Override
public void run() {
if (bot.hasMessage()) {
message = bot.getMessage();
channel = bot.getChannel();
sender = bot.getSender();
}
if (this.message.startsWith("~vote")) {
tokenize(false, 5, this.message);
try {
... | 7 |
@Test
public void getContactsWithIdsNormalTest() {
contacts3 = generateListOfContacts3();
Contact steve = null;
Contact jane = null;
Contact tim = null;
int idSteve = 0;
int idJane = 0;
int idTim = 0;
for (Contact curr : contacts3) {
if (... | 4 |
public void setCoordinate(Coordinate a) {
boolean test = false;
if (test || m_test) {
System.out.println("Grid :: setCoordinate() BEGIN");
}
m_Grid[a.getX()][a.getY()] = a.getValue();
if (test || m_test) {
System.out.println("Grid :: setCoordinate() END");
}
} | 4 |
private static boolean isUnique(String input)
{
if(input==null || input.isEmpty())
return false;
HashSet<Character> uniqueChars = new HashSet<Character>();
char[] inputStrArray = input.toCharArray();
for(char c: inputStrArray)
{
... | 4 |
@Test
public void storeTestInvalidUserId() {
try {
assertFalse(new Transaction().store(123, 56342));
} catch (IOException e) {
System.out.println("Invalid data");
}
} | 1 |
public static int calcularFatorial(int numero){
if (numero <= 0) {
return 1;
}else{
return (numero * calcularFatorial(numero-1));
}
} | 1 |
@Override
boolean accepts(A value) {
switch (polarity) {
case Pos:
return this.value.equals(value);
case Neg:
return !this.value.equals(value);
}
throw new IllegalStateException();
} | 2 |
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT)
{ dx = -1;
}
if (key == KeyEvent.VK_RIGHT) {
dx = 1;
}
if (key == KeyEvent.VK_UP) {
dy = -1;
}
if (key == KeyEvent.VK_DOWN) {
dy = 1;
}
if (key == KeyEvent.VK_SPACE) {
move();
... | 5 |
void frameControl(Token token, boolean isSubCmd) throws ScriptException {
switch (token.tok) {
case Token.playrev:
viewer.reverseAnimation();
case Token.play:
case Token.resume:
viewer.resumeAnimation();
return;
case Token.pause:
viewer.pauseAnimation();
return;
case Token.next:
viewer.set... | 7 |
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 |
private void valid(int depth50m, int depth10m, int depth1m)
throws AxisWithoutMeaningErrorException {
if (depth50m < min50m || depth50m > max50m) {
throw new AxisWithoutMeaningErrorException();
}
if (depth10m < min10m || depth10m > max10m) {
throw new AxisWith... | 6 |
public boolean containsMatchingLoad(CombineableOperator comb) {
Operator combOp = (Operator) comb;
if (comb.getLValue().matches(this)) {
if (subsEquals((Operator) comb.getLValue()))
return true;
}
for (int i = 0; i < subExpressions.length; i++) {
if (subExpressions[i].containsMatchingLoad(comb))
r... | 4 |
public boolean impacto(Disparo pDisparo) {
boolean impactado = false;
if((pDisparo.getX() >= x && pDisparo.getX() <= x + 90.0) && (pDisparo.getY() >= y && pDisparo.getY() <= y+90.0)) {
impactado = true;
}
if(impactado) {
toquesRecibidos++;
}
return impactado;
} | 5 |
LeagueError valid() {
// check for lock
if (!teamDivVector.isLocked()) {
return LeagueError.NOTHING_EDITED;
}
// check nof teams
for (int div = 1; div <= modus.getNofDivisions(); div++) {
if (modus.getNofTeams() != teamDivVector.getNofTeams(div)) {
// wrong nof teams for division teams (but don't c... | 6 |
public ListNode deleteDuplicates(ListNode head) {
if(head == null || head.next == null) {
return head;
}
ListNode firstHead = new ListNode(Integer.MIN_VALUE);
ListNode lastDistinct = firstHead;
ListNode slow = head;
ListNode fast = head.next;
boolean inDuplicated = false;
while(fast != nu... | 6 |
public boolean equals(Object obj)
{
if(obj instanceof Element)
if(protons == ((Element)obj).protons && quantity == ((Element)obj).quantity)
return true;
return false;
} | 3 |
@Override
public List<Student> getStudent(int courseId) throws SQLException {
List<Student> studentList = new ArrayList<>();
Connection connect = null;
PreparedStatement statement = null;
try {
Class.forName(Params.bundle.getString("urlDriver"));
connect = Dri... | 5 |
public void setText(String text) {
Assert.isNotNull(text);
this.text = LegacyActionTools.escapeMnemonics(text);
if (label != null && !label.isDisposed()) {
label.setText(this.text);
}
if (this.text.length() == 0) {
if (isVisible()) {
setVisible(false);
IContributionManager contributionManager... | 8 |
@Override
public boolean equals (Object obj)
{
if (!(obj instanceof PollItem))
return false;
PollItem target = (PollItem) obj;
if (socket != null && socket == target.socket)
return true;
if (getRawSocket () != null && getR... | 5 |
public UpdateFrame getFrame() {
return frame;
} | 0 |
public void getRollInfo(gamelogic.PublicGameBoard pub, boolean exp) {
List<Integer> data = pub.rollData();
for (int i = 0; i < data.size(); i++) {
Tile active = (exp)? getTileByIntExp(i):getTileByInt(i);
if (active == null) return;
if (active.resource() == TileType.Desert || data.get(i) < 2 || data.get(i) ... | 6 |
public void ackRecieved(UtpTimestampedPacketDTO pair) {
int seqNrToAck = pair.utpPacket().getAckNumber() & 0xFFFF;
// log.debug("Recieved ACK " + pair.utpPacket().toString());
timeStampNow = timeStamper.timeStamp();
lastAckRecieved = timeStampNow;
int advertisedWindo = pair.utpPacket().getWindowSize() & 0xFFFF... | 8 |
public static boolean generateItemFile(String fileName, Set<String> set, List<Set> listTree) {
boolean ret = false;
BufferedWriter bw = null;
FileWriter fw = null;
File file = null;
PrintWriter pw = null;
OutputStreamWriter osw = null;
FileOutputStream fo = null;... | 9 |
public List<TipoCultivo> ObtenerTipoCultivo(String consulta){
List<TipoCultivo> lista=new ArrayList<TipoCultivo>();
if (!consulta.equals("")) {
lista=cx.getObjects(consulta);
}else {
lista=null;
}
return lista;
} | 1 |
public Timenode getnode(int id, ArrayList<Object> list) {
Timenode node = new Timenode();
for (Object tmp : list) {
node = (Timenode) tmp;
if (node.getId() == id)
return node;
}
return node;
} | 2 |
public String nextToken()
throws Exception
{
// Skip blanks.
while (Character.isWhitespace(ch))
{
nextChar();
}
while (ch == ';')
{
line = reader.readLine();
nextChar();
}
// At EOF?
if (ch == 0)
{
return nul... | 5 |
public Set<String> getPermissions() {
return this.permissions;
} | 0 |
static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... | 7 |
public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.opt(i... | 4 |
public void rotarDerecha() {
if (direccion.equals(Direccion.izquierda)) {
rotar(tipoTrans.enZ, 180);
} else if (direccion.equals(Direccion.adelante)) {
rotar(tipoTrans.enZ, -90);
} else if (direccion.equals(Direccion.atras)) {
rotar(tipoTrans.enZ, 90);
... | 7 |
public void setEffects()
{
switch(type)
{
case 0: typeString = "Splash";
splashRadius = 50*level;
phrase1 = "Splash Radius: " + splashRadius;
range = 300;
damage = 2*level;
reloadCount = 200-5*level;
break;
case 1: typeString = "Gold";
extraGold = 50*level;
phrase1 = "Gold/Kil... | 9 |
public short getType(String name)
{
name = String.valueOf(name).toUpperCase();
if (name.equals("HUFFMAN"))
return HUFFMAN_TYPE;
if (name.equals("ANS"))
return ANS_TYPE;
if (name.equals("FPAQ"))
return FPAQ_TYPE;
if (name.equals("P... | 8 |
private static QuoteOrigin getOrigin(String text) {
if (text.contains("/אונקלוס")) {
return QuoteOrigin.ONKELOS;
}
if (text.contains("/בבלי")) {
return QuoteOrigin.BAVLI;
}
if (text.contains("/ירושלמי")) {
return QuoteOrigin.YERUSHALMI;
... | 7 |
private void init() {
for (int x = 0; x < 10; x++) {
int randx = random.nextInt(10);
int randy = random.nextInt(10);
addActor(ActorType.chicken,
new Point(25000 + randx, 25000 + randy));//THis should add chickens
}
// for (int x = 0; x < 10;... | 1 |
public void startServer(){
ServerSocket server=null;
try {
try{
fetchUsers();
}
catch (FileManagerException e){
FileManager.placeToLog(e.getMessage());
users=new ConcurrentLinkedDeque<>();
}
serve... | 6 |
public void dropNew() {
// Get all available items
String[] playerItems = player.getInventory().getItemTexts();
if (playerItems.length == 0) {
log.println("You have nothing to drop.");
} else {
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(0, 1));
final JCheckBox[] checkBoxes = new JCh... | 7 |
private String prevediIzLatiniceUCirilicu(String rec) {
String recLatinica = "";
String slovo = "";
char c;
niz:
for (int i = 0; i < rec.length(); i++) {
//provera da li su u pitanju dvoslovna slova
if ((i != rec.length() - 1 && String.valueOf(rec.charAt... | 9 |
public double[] columnVariances(){
double[] variances = new double[this.numberOfColumns];
for(int i=0; i<this.numberOfColumns; i++){
double[] hold = new double[this.numberOfRows];
for(int j=0; j<this.numberOfRows; j++){
hold[i] = this.matrix[j]... | 2 |
public String getStrada() {
return strada;
} | 0 |
public void manger(Aliment mange, int quantite, Loft plateau){
if (plateau.plateauCase.get(this.getPosition()).contenuNeuneu.size() >1){
int k=0;
for (Neuneu neuneu : plateau.plateauCase.get(this.getPosition()).contenuNeuneu ){
while (k==0){
if (neuneu.getId_joueur() != this.getId_joueur()){
... | 8 |
public void setPersonId(int personId) {
this.personId = personId;
} | 0 |
public static void saveToFile(String fileName, InputStream in) {
FileOutputStream fos = null;
BufferedInputStream bis = null;
byte[] buf = new byte[BUFFER_SIZE];
int size = 0;
bis = new BufferedInputStream(in);
try {
fos = new FileOutputStream(fileName);
... | 8 |
private static List<Cards> choose2(Cards cards) {
// Given a list of cards, give me back a list of the
// complete list of subsets of size num
int size = cards.size();
List<Cards> subsets = new ArrayList<Cards>();
for (int i1 = 0; i1 < size - 1; i1++) {
Cards subset =... | 2 |
@Override
protected void parseSelf(Document doc) throws ProblemsReadingDocumentException {
List<?> result = queryXPathList(TITLE_XPATH, doc);
if ((result != null) && (result.size()>0))
setTitle(((Element) result.get(0)).getText());
else
throw new ProblemsReadingDocumentException("Can't read discography ti... | 5 |
private boolean register(String id) {
ConnectionConfiguration config = new ConnectionConfiguration(
XMPP_SERVER, XMPP_PORT);
Connection connection = new XMPPConnection(config);
if (registeredLastTime && REGISTRATION_DELAY > 0) {
System.out.println("Sleeping for " + REGISTRATION_DELAY
+ " minutes. Need... | 6 |
private void parseCommand(String command) {
// Commands:
// !new-bid <description>
// !auction-ended <winner> <amount> <description>
String cmdRegex = "![a-zA-Z-]+";
String tmp;
Scanner sc = new Scanner(command);
sc.useDelimiter("\\s+");
sc.skip("\\s*");
if (!sc.hasNext(cmdRegex))
return;
tm... | 9 |
@Override
public void Area(double dx) {
this.hight+=dx;
this.rad+=dx;
this.area = 2*Math.PI*rad*(rad+hight);
} | 0 |
public static void stop() {
try {
System.out.println("main: stop the program");
// eventually write the statistics
if (!win) {
Gui.writeStatus();
}
System.out.println("main: statistics written");
// Wait for the images to complete
while (Gui.pro.size() != 0) {
Gui.pro.get(0).join();
... | 4 |
public void set_order_to()
{
if(Idx!=null)
{
if(Idx.fidx!=null)
{
try { Idx.fidx.close(); }
catch (IOException e) { e.printStackTrace(); }
}
Idx = null;
}
order = "";
if(Cdx!=null) Cdx.I = -1;
} | 4 |
private int neighbors(int row, int col) {
int count = 0;
for(int r = row-1; r <= row+1; r++)
for(int c = col-1; c <= col+1; c++) {
if(r < 0 || r >= map.length ||
c < 0 || c >= map[0].length)
continue;
if(map[r][c] =... | 8 |
public MBB3D getMBB() { // Dag
if (size() > 0) {
Iterator<Point3D> it = this.iterator();
it.hasNext();
Point3D p = it.next();
double xMin = p.getX();
double yMin = p.getY();
double zMin = p.getZ();
double xMax = xMin;
double yMax = yMin;
double zMax = zMin;
double value;
while (it.h... | 8 |
String classToType(Class cls) {
if (cls==Point.class) {
return "int2";
} else if (cls==Integer.TYPE
|| cls==Integer.class ) {
return "int";
} else if (cls==Double.TYPE
|| cls==Double.class ) {
return "double";
} else if (cls==String.class) {
return "String";
} else if (cls==Boo... | 8 |
private void validate(Match match) {
if (match == null) {
throw new ValidationException("match is null");
}
if (match.getHomeTeam() == null || match.getAwayTeam() == null) {
throw new ValidationException("match team is null");
}
if (match.getResult() == nu... | 6 |
public String get(String path,String fsxml,String mimetype) {
if (auth==null) {
auth = getAuth();
}
String url = "http://"+ipnumber+":"+port+"/"+name+"/proxy/"+path;
if (url.indexOf("?")!=-1) {
url+= "&spw="+auth;
} else {
url+= "?spw="+auth;
}
System.out.println("PROXY URL: " + url);
Response ... | 8 |
private void delete() throws SQLException {
if (gui.connected) {
int row = table.getSelectedRow();
if (row != -1) {
rslt.absolute(++row);
try {
rslt.deleteRow();
reload();
} catch (SQLException e) {
state("cant delete insert row");
gui.handleSQLException(e);
}
} else {
... | 3 |
public void run() {
String s;
try {
System.out.println(timeStamp.getCurrentTime() + "::" +"Starting Status thread");
statusSocket = new ServerSocket(statusPort);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (true) {
try {
statusAcceptSocket = ... | 4 |
@RequestMapping("/startQuiz")
public ModelAndView startQuiz(@ModelAttribute QuizQuestion question, HttpServletRequest request)
{
System.out.println("In startQuiz");
ModelAndView mv = new ModelAndView("viewQuizQuestion");
String courseId = request.getParameter("courseId");
String quizId = request.getPar... | 6 |
@Test(expected = ParkException.class)
public void out_a_car_when_park_is_empty() {
Park park = new Park(10);
park.out(new Ticket());
} | 0 |
Class318_Sub7(AbstractToolkit var_ha, Class129 class129, Class318_Sub10 class318_sub10,
long l) {
((Class318_Sub7) this).aClass284_6444 = new Class284();
aClass284_6449 = new Class284();
aBoolean6453 = false;
try {
aLong6435 = l;
((Class318_Sub7) this).aClass129_6436 = class129;
((Class318_Sub7) ... | 6 |
protected void getClosePlants() {
Thread radarThread = new Thread(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
// True if this creature is alive
while (isAlive()) {
// clone the Grid.plants, the centralised repository of
// plants, so there will less concurrent... | 5 |
public static void updateFonts() {
font = new Font(Preferences.getPreferenceString(Preferences.FONT_FACE).cur, Font.PLAIN, Preferences.getPreferenceInt(Preferences.FONT_SIZE).cur);
readOnlyFont = new Font(Preferences.getPreferenceString(Preferences.FONT_FACE).cur, Font.ITALIC, Preferences.getPreferenceInt(Prefer... | 0 |
private void createRootWindowProperties(GradientTheme theme) {
rootProperties.getTabWindowProperties().getTabbedPanelProperties().addSuperObject(theme.getTabbedPanelProperties());
rootProperties.getTabWindowProperties().getTabProperties().getTitledTabProperties().addSuperObject(
theme.getTitledTabProper... | 8 |
private String getVersionfinal (Class classe) {
String version = "";
try {
ClassLoader cl = this.getClass().getClassLoader();
String threadContexteClass = classe.getName().replace('.', '/');
URL url = cl.getResource(threadContexteClass + ".class");
if ( url != null ) {
String path = url.getPath();
... | 4 |
public RoomEventType(final String name) {
super(name);
} | 0 |
public void remover(long pesquisaId) throws Exception
{
String sql = "DELETE FROM Pesquisainstituicoes_cooperadoras WHERE id1 = ?";
try
{
PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql);
stmt.setLong(1, pesquisaId);
stmt.execute();
}
catch (SQLException e)
{
... | 1 |
public List<AngularBond> getBends() {
if (model == null)
return null;
if (model.bends == null || model.bends.isEmpty())
return null;
List<AngularBond> list = null;
AngularBond aBond = null;
synchronized (model.bends.getSynchronizationLock()) {
for (Iterator it = model.bends.iterator(); it.hasNext();)... | 8 |
public void setOrderList() {
listModel.clear();
for (Order order : driver.getOrderDB().getCustomerOrderList()) {
if(order.isStatus())
listModel.addElement(textAlignment(" " + order.getId(), "" + order.getDateString(), ""
+order.getPerson().getName(), ""
+order.getCurrentlyLoggedInStaff().getN... | 2 |
@EventHandler
public void SlimeSpeed(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getSlimeConfig().getDouble("Slime.Speed.DodgeC... | 6 |
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Dataset)) {
return false;
}
Dataset other = (Dataset) object;
if ((this.key == null && other.key != null) || (t... | 5 |
public InferenceIdentifier getInferenceIdentifier() {
if (inferenceWorker != null) {
return inferenceWorker.getInferenceIdentifier();
}
return null;
} | 1 |
public String getPartnerName()
{
if(conProt == null && internetCon == null)
return "";
if(conProt != null)
{
if(conProt.getConnectedName().equals("null") && getLANConnections())
return "Unidentified System";
if(!conProt.getConnectedName().equals(""))
return conProt.getConnectedName();
}
if(i... | 8 |
public void setPrice(String price) {
this.price = price;
} | 0 |
private void trySetUTFEncoding() {
try {
setEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
System.err.println("Cannot set UTF-8 encoding.");
}
} | 1 |
public SessionListPanel() {
final SessionTableModel dm = new SessionTableModel();
final JTable t = new JTable(dm);
dm.setTable(t);
t.getColumnModel().getColumn(1).setCellRenderer(
new DefaultTableCellRenderer() {
/**
*
*/
private static final long serialVersionUID = -61631797930767600... | 9 |
private int berekenIndex(boolean top, boolean right, boolean bottom, boolean left){
int index = 0;
if(top) index += 1;
if(right) index += 2;
if(bottom) index += 4;
if(left) index += 8;
return index;
} | 4 |
@Override
public List<IllnessDTO> getAllIllnesses() throws SQLException {
Session session = null;
List<IllnessDTO> illnesses = new ArrayList<IllnessDTO>();
try {
session = HibernateUtil.getSessionFactory().openSession();
illnesses = session.createCriteria(IllnessDTO.c... | 3 |
private String padTo(String padee, int length)
{
if (padee.length() >= length)
return padee;
StringBuilder builder = new StringBuilder();
for (int i = padee.length(); i < length; i++)
{
builder.append(" ");
}
builder.append(padee);
return builder.toString();
} | 2 |
public static long getDate(String buffer) {
if (buffer != null) {
buffer = buffer.trim();
for (int i = DateFormat.FULL; i <= DateFormat.SHORT; i++) {
try {
return DateFormat.getDateInstance(i).parse(buffer).getTime();
} catch (Exception exception) {
// Ignore
}
}
}
return System.cur... | 3 |
protected Name parseName(String contents) {
int firstSlash = contents.indexOf('/');
int lastSlash = contents.indexOf('/', firstSlash + 1);
String surname = null;
String givenname = null;
if (firstSlash >= 0 && lastSlash > firstSlash) {
surname = contents.substring(firstSlash + 1,
lastSlash);
surna... | 4 |
public void log(String message)
{
//skip if no writer
if (this.bufferedWriter == null)
return;
try
{
//write message
String logMessage = String.format("[%s] %s", Logger.FORMATTER.format(LocalDateTime.now()), message);
this.bufferedWriter.write(logMessage + System.lineSeparator());
this.buffer... | 2 |
private static ArrayList<NumberToken> toTokens(ArrayList<String> in){
assert (in != null);
ArrayList<NumberToken> toReturn = new ArrayList<NumberToken>(in.size()-1);
for (String s : in){
NumberToken toAdd = new NumberToken(s);
// If we could... | 3 |
public List<Cineplex> getCineplexes(int month) {
cineplexes = new ArrayList<Cineplex>();
for(Cineplex cineplex : cineplexDAO.getCineplexes()) {
for(Cinema c : cineplex.getCinemas()) {
for(ShowTime st : c.getShowTimes()) {
calendar.setTime(st.getTime());
int sMonth = calendar.get(Calendar.MONTH);
... | 5 |
protected boolean isValidDrop(GameState state, int x, int y) {
boolean nifu = true;
for (int i = 0; nifu && i < 9; i++) {
nifu = !(state.getPieceAt(x, i) instanceof Pawn
&& state.getPieceAt(x, i).getAllegiance() == this.getAllegiance());
}
Piece tempRep = s... | 9 |
private static ArrayList<String[]> makeGeneration(int poolSize) {
ArrayList<String[]> decks = new ArrayList<String[]>();
for (int i = 0; i < poolSize; i++) {
decks.add(Game.makeDeck());
}
return decks;
} | 1 |
public void filter(byte[] samples, int offset, int length) {
if (source == null || listener == null) {
// nothing to filter - return
return;
}
// calculate the listener's distance from the sound source
float dx = (source.getX() - listener.getX());
float ... | 5 |
public void sincronizaClientes(){
PhpposAppConfigEntity appConfig = getAppConfig("id_pos");
if (appConfig != null) {
List<VPosFuncionarios> vPosFuncionarios = facOracleDAO.getVPosFuncionarios(
Integer.parseInt(appConfig.getValue()));
for(VPosFuncionarios funci... | 7 |
@Override
protected boolean perform(final CommandSender sender, final Command command, final String label, final List<String> args, final Region region) {
String access = RegionExecutor.parse(args, 0, "<Access>", sender);
if (access == null) return false;
if (region.access.contains(access))... | 4 |
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.