method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
196a1fb5-3d8d-4f73-b25e-6b00159f0c4c | 1 | public boolean hitRight()
{
if(nextX() >= xMin+xMax)
return true;
return false;
} |
7baf6eb0-de22-4c21-b212-c17a6dd8e9d0 | 8 | private void updateForces() {
keyForce.set(0.0, 0.0);
if (up && !down) {
keyForce.offset(0, SPEED);
} else if (down && !up) {
keyForce.offset(0, -SPEED);
}
if (left && !right) {
keyForce.offset(-SPEED, 0);
... |
61408401-af63-4cf7-8655-ea516e50cc34 | 6 | @Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors erros = new ActionErrors();
if(contato.getNome() == null || contato.getNome().isEmpty()) {
erros.add("nome", new ActionMessage("erro.campoNome"));
}
if(contato.getEndereco() == null || contato.getE... |
bd3b9cc9-6cb3-4a0d-afab-aaeb031653c4 | 1 | public void testWithField3() {
YearMonthDay test = new YearMonthDay(2004, 6, 9);
try {
test.withField(DateTimeFieldType.hourOfDay(), 6);
fail();
} catch (IllegalArgumentException ex) {}
} |
ea1aeba1-1a2f-46a5-a4d6-aee308456eda | 1 | private void readConfig() {
Properties p = new Properties();
try {
p.load(this.getClass().getClassLoader().getResourceAsStream("application.properties"));
clientVersion = p.getProperty("version");
} catch (IOException e) {
log.error(e.getMessage());
}
} |
2052ea62-ebc7-4f5f-b258-d8bd92027816 | 7 | public void run(){
try{
String msgIn = "";
//initialize board
for(i=0; i<4; i++){
for(j=0; j<10; j++){
this.board[i][j] = new Character();
}
}
while(true){
msgIn = conn.getMessage();
if(msgIn.equals("DONE")){
//get player's board
receiveBoard(conn, this.board, playerNum)... |
3c4a44d8-60e2-49f0-bfa9-0df439dcea42 | 0 | @Override
public boolean supportsAttributes() {return true;} |
b9e401ac-2067-4ec6-a8c0-4ded62f90cd4 | 3 | private void turnAction(Player user, TurnData data) {
synchronized(turnThread) {
if(!user.isTurnEnd()) {
if(data.isTurnAction()) {
if(user.getThrewDice() < 3) {
user.move();
} else {
user.setPosition(jail);
user.setInJail(true);
user.setTurnEnd(true);
turnThread.notify()... |
696814d6-e1be-4051-89d4-fb59e92d7561 | 1 | public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
pressed = false;
}
} |
997bcb6f-2e01-449d-9ed8-d4fe15fea4a5 | 1 | public int getIndexOfChild(Object parent, Object child) {
TreeElement[] childrens = getChildrens((TreeElement) parent);
int i = Arrays.binarySearch(childrens, child);
if (i >= 0)
return i;
throw new NoSuchElementException(((TreeElement) parent).getFullName()
+ "." + child);
} |
2cbdc248-179b-4116-8770-3678ca90bc8c | 6 | public static void main(String[] args) {
final Conditions conditions = new Conditions();
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
conditions.put(i);
}
}
}).st... |
9f9cc89b-662e-4fab-a704-03f07ded4a11 | 8 | public static void main(String[] args) {
String inputGenomeFilePath;
int kmerLength, kmerOverlapLength, deBruijnGraphDegree;
if (args.length == 4) {
inputGenomeFilePath = args[0];
if(!doesFileExist(inputGenomeFilePath)) {
System.out.println("Invalid input genome file path!");
printClosingAppMessage(... |
a14440af-18e9-4d32-875f-f1daf3adb269 | 0 | public Login(LoginMessage loginMessage,String ipaddress){
this.sequence_Id =loginMessage.getSequence_Id();
this.Account = loginMessage.getClientID();
this.Version = loginMessage.getClientVersion();
this.LoginMode = loginMessage.getLoginMode();
this.ipaddress = ipaddress;
this.timestamp = l... |
56fa6e7c-7e9b-42ef-9aa7-0fe313762d90 | 0 | public int getPopulationSize() {return population.size();} |
7cd3a88c-728e-4924-afb8-07b552e91c6f | 9 | public static boolean isReservedNot(String candidate) {
int START_STATE = 0;
int TERMINAL_STATE = 3;
char next;
if (candidate.length()!=3){
return false;
}
int state = START_STATE;
for (int i = 0; i < candidate.length(); i++)
... |
c02e51a7-24ea-4713-9733-ddf73b67c353 | 9 | public void paint1(Graphics g) {
if (carro != null && popo != null) {
g.drawImage(carro.getImagen(), carro.getPosX(), carro.getPosY(), this);
if (choco) {
popo.setMovimiento(false);
choco = false;
}
g.drawImage(pajaro.getImagen(), ... |
27f8f9cd-45f2-47df-ab3f-6e5c9d45df60 | 2 | public UserRole login(String userName, String password) {
UserRole userRole = null;
String query = "SELECT * FROM USER_ROLE WHERE USERNAME=? AND PASSWORD=?";
try {
PreparedStatement statement = connection.prepareStatement(query);
statement.setString(1, userName);
... |
659458f8-7ff7-4f92-8ed5-d95050bab8ff | 5 | @Override
public String getMCstring(){
String s = "";
for (int i = 0; i < mc.length; i++) {
if(mc[i] == true)
s = s.concat("1");
else
s = s.concat("0");
if (i == 5 || i == 10 || i == 15)
s = s.concat(" ");
}
... |
4645d572-4034-4db0-8f83-635e284a2135 | 9 | public void run() {
boolean properConnect = true;
boolean initName = false;
try {
inClient = new BufferedReader(new InputStreamReader(connect.getInputStream()));
outClient = new DataOutputStream(connect.getOutputStream());
} catch(IOException e) {
System.out.println("Could not establish proper IO at... |
a56312f8-98c8-41b8-ab4a-b80400f25dc2 | 3 | public static boolean writeFile(String filePath, String file)
{
//Declares new Buffered Writer object
BufferedWriter writer = null;
File textFile = new File(filePath);
try
{
//Sets the value of the buffered writer object, including the name of the output file
writer = new BufferedWriter(new FileWriter(... |
b49361df-6a0c-4715-9da4-5bd4ce261460 | 4 | public static void main(String[] args) {
// TODO Auto-generated method stub
if(args.length<4)
{
System.err.println("Argument error");
System.err.println("Argument: input_file output_file uni_gram_file bi_tri_gram");
System.exit(1);
}
SVMExtractor se=new SVMExtractor(args[2],args[3]);
try
... |
a8eefebf-474d-47e5-9028-c67056546fd8 | 5 | private static int format(final StringBuilder sb, final String s,
int lineLength) {
if (s.isEmpty()) {
return 0;
}
int l = lineLength;
final String[] parts = s.split(" ");
boolean front = sb.length() != 0;
for (final String part : parts) {
if ((l > 0) && ((l + part.length() + 1) >= Main.MAX_LENGTH... |
c292dbda-e29d-4702-ae56-b1f2675e8a3c | 2 | public static String readFile(String name) {
StringBuilder b = new StringBuilder();
try {
BufferedReader r = new BufferedReader(new FileReader(name));
String line;
while ((line = r.readLine()) != null) {
b.append(line).append('\n');
}
... |
d7458d58-1e1e-4f3d-8022-f76fec0d2d24 | 5 | private static void imprimir_lexema(Token token, int i) {
String lexema = token.getLexema();
//Formateamos de manera legible el EOF
if (token.getLexema().contains("\uffff") ) {
lexema = "eof";
}
//Formateamos de manera legible el salto de línea
if (to... |
1cda6e83-530c-45c9-9d69-a87cf3b24183 | 5 | public void addClickableFunction(final JFrame frame, int xLoc, int yLoc,int width, int height, final String type){
JLabel label = new JLabel();
label.setBounds(xLoc, yLoc, width, height);
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent me) {
if(type.e... |
ccd6b604-2a88-4ac3-9381-75b0d8383c1d | 8 | private static void sellToStation(AIPlayer player) {
Station station = player.getCurrentStar().getStation();
CargoHoldComponent hold = player.getShip().getCargoHold().get();
// find best value item to sell that player has in cargo and wasn't just
// bought
if (hold.getCargoSpace... |
274b1c0c-e118-4869-ba45-238966a92260 | 6 | void guess(int a, int b){
for (int i = 0; i < checkSet.length; i++) {
if (!checkSet[i]) {
continue;
}
int count = 0;
for (int j = 0; j < checkSet.length; j++) {
if (checkSet[j]) {
count++;
... |
fd03cf27-a639-4d2c-afc4-3983ccb60389 | 7 | public void applyBridgeMode(int x, int y) {
Ground tile = groundArray[0][x][y];
for (int z = 0; z < 3; z++) {
Ground _tile = groundArray[z][x][y] = groundArray[z + 1][x][y];
if (_tile != null) {
_tile.z--;
for (int e = 0; e < _tile.entityCount; e++) {
InteractiveObject entity = _tile.interactiveO... |
4ce1a888-7d39-4c42-927e-278ac4d61812 | 5 | public ROb<CompanyPerson> registerRelation (Long personCedule, Long companyId, String rolPerson, String passwordCompany){
System.out.println("++++++++++++ Registar relacion: Me han invocado");
ROb<CompanyPerson> rob = new ROb<CompanyPerson>();
try{
Person person = (Person) personFaca... |
5d14cafe-2279-4e9e-97aa-efaf7d4bcbc5 | 0 | public void setClick(int ttype, String tid, int twhichone)
{
type=ttype;
id=tid;
whichOne=twhichone;
} |
02a71aa7-540f-473b-9598-4b9ba211a1ed | 3 | public int findRightPositionOf(int i) {
for (int j = i; j < this.permutArray.length; j++) {
if (permutArray[j] == i || -permutArray[j] == i) {
return j;
}
}
return 0;
} |
0dc281ca-9e4e-491b-8c6b-21105f867194 | 1 | public int getLevel() {
if(level < 1) {
level = 1;
}
return level;
} |
53629234-acf8-44a4-8af0-0076c9a7eb1c | 5 | private void startButtonActionPerformed() {
startPressed = true;
final LogArtisanWorkshopOptions options = script.options;
options.status = "Setup finished";
//Context.get().getScriptHandler().log.info("Mode: " + tabbedPane.getTitleAt(tabbedPane.getSelectedIndex()));
String s = tabbedPane.getTitleAt(tabbedPa... |
c691f371-c64c-47f2-ade3-b2033e1f6701 | 7 | private String[] quoteAwareLineSplit(String line) {
boolean ignoreCommas = false; // used when quotes are found
StringBuffer buff = new StringBuffer();
List<String> data = new ArrayList<String>();
char prevChar = 0;
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == '\"') {
ignoreCommas... |
228e10d6-01e0-4448-b09b-e873f78dc692 | 0 | @Override
public void setDef(String value) {this.def = value;} |
6cf6aff1-9b0b-40b2-8638-887e6c1e2c56 | 5 | private void doubleClick(MouseEvent e) {
System.out.println("DOUBLE CLICK");
if (clickedOnDeck(e)) {
if (!game.getDeck().isEmpty()) {
Card toSendUp = game.getDeck().peek();
int pileIndex = pileIndexToSendTo(toSendUp);
if (pileIndex != -1) {
... |
1b48c400-2033-4ced-a8b2-56ffb8f5d78d | 4 | @Override
public void rawUpdate() throws Throwable
{
if (this.isPaused() || this.tasks.isEmpty())
{
Thread.sleep(1L);
return;
}
for (Task t : this.tasks)
{
if (t.completeTask())
{
this.tasks.remove(t);
}
}
} |
0a91b635-eef2-46a6-8824-714b4269de55 | 4 | private Direction getDirection(String inputCommand) {
Keys key = Keys.valueOf(inputCommand);
switch(key) {
case UP:
return Direction.NORTH;
case DOWN:
return Direction.SOUTH;
case LEFT:
return Direction.WEST;
case RIGHT:
return Direction.EAST;
de... |
5960d549-7872-4000-9b70-32aa7d668dc9 | 6 | PageUnitGUI() {
final JFrame jf = new JFrame("PageUnit Runner");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final Container cp = new JPanel();
jf.add(cp, BorderLayout.CENTER);
cp.setLayout(new FlowLayout());
cp.add(new JLabel("PageUnit Test File:"));
final JTextField tf = new JTextField(20);
... |
f4ec76ce-0069-4983-baac-0f529e2f7ed0 | 3 | public static boolean checkSpare(Frame frame) throws UnexpectedTypeException {
Integer firstScore = frame.getScore(ScoreType.FIRST);
Integer secondScore = frame.getScore(ScoreType.SECOND);
if(firstScore == null || secondScore == null) {
return false;
}
if((firstScore + secondScore) == IConstants.FRAME_PE... |
ad99c0c5-78a6-4995-b417-22d11413bac0 | 1 | public void zerarQuantidadeVendido(){
for (Produto p : produtos) {
p.setQuantidedeVendido(0.0);
}
} |
ad61dcaa-b337-4c91-9a09-3ebf67b91f20 | 5 | public static boolean validChoice(int row, int column) {
boolean isValid = true;
if (row < 0 || row > 2 || column < 0 || column > 2) {
isValid = false;
} else if (board[row][column] != '.') {
isValid = false;
}
return isValid;
} |
4106c081-07cc-4d01-928b-5968e6bf687b | 0 | @Override
public void setDescription(String description) {
this.description = description;
} |
c185b9f4-7f6c-40f8-a742-c3f608dea023 | 6 | boolean isExist(char[][] matrix, boolean[][] flag, int i, int j, String word) {
if (word.equals(""))
return true;
char x = word.charAt(0);
word = word.substring(1);
for (int k = 0; k < 4; k++) {
int m = i + d[k][0];
int n = j + d[k][1];
if (isValid(matrix, m, n) && matrix[m][n] == x && !flag[m][n]) ... |
0daa8720-7967-4009-970a-a098c5efe0ea | 2 | private static void calcPercentages() {
percentages = new ArrayList<Float>();
long sum = 0;
for (Long l : sums) {
sum += l;
}
for (int i = 0; i < sums.size(); i++) {
percentages.add(((float)sums.get(i))/((float)sum));
}
} |
a10ac5be-71ad-4f46-a460-83b6b24dff62 | 1 | public void shoot() {
this.performance = this.performance -1;
if (this.hasArrow){
this.setArrow(false);
this.performance = this.performance -10;
}
} |
8fcbbf06-1d29-4817-ad12-f361f01b3fdf | 6 | private void jump(int S) {
Color playerColor = _board[S].getColor();
if (_board[S].getSpots() > neighbors(S) && getWinner() == null) {
_board[S].setSpots(1);
if (col(S) < size()) {
jumpAddSpot(playerColor, row(S), col(S) + 1);
}
if (row(S) ... |
6966535f-a46b-4610-8faf-ced395de61fb | 8 | Set(LegacyRegister[] regs) {
registerSet = new HashSet(2 * regs.length);
for (int cntr = 0; cntr < regs.length; cntr++) {
registerSet.add(regs[cntr]);
}
StringBuffer buf = new StringBuffer("{");
for (int cntr = 0; cntr < regs.length; cntr++) {... |
884830e1-9fdd-4282-be30-8a8b81ddf6eb | 5 | static final void method358(int i, int i_3_, int i_4_, int i_5_, int i_6_,
int i_7_, int i_8_) {
if (i_8_ != -29494)
amountClanChatUsers = 32;
if (((Class348_Sub51) BitmapTable.aClass348_Sub51_3959)
.aClass239_Sub26_7272.method1838(-32350) != 0
&& i != 0 && Message.anInt2021 < 50 && (i_7_ ^ 0xffffffff... |
bd9135a4-ed99-490c-9551-184e9599f1b4 | 1 | private static Product ProductObject(ResultSet rs) {
Product newProduct = null;
try {
newProduct = new Product(rs.getInt(rs.getMetaData().getColumnName(1)),
rs.getString(rs.getMetaData().getColumnName(2)),
rs.getS... |
b9eb41cf-b97e-4631-b0f6-e33c52290785 | 2 | static boolean hascontained(ArrayList<Pair> list, Pair pr) {
for (int j=0; j<list.size(); j++){
if (list.get(j).equals(pr)) {
return true;
}
}
return false;
} |
c5a30966-a275-4abf-b3c8-228e3e76e70d | 0 | public boolean isEmpty() {
return first == null;
} |
adb99d95-f154-4ac4-9b02-81ea7ae8c7c1 | 3 | public void parseExpression(CharSequence expression, Handler handler) {
Matcher matcherMeta = EXPR_META.matcher(expression);
if(matcherMeta.find()) {
Map<String,String> meta = new HashMap<String, String>();
String inlined = matcherMeta.group(1);
parseStyles(meta, inli... |
ed96ca1e-6ebf-45da-8e7b-2657ccc12d4e | 3 | @Override
public void nextCard(){
CardImpl nextCard = null;
int boxToCheck = this.curBox;
boolean firstLoop = true;
while (nextCard == null){
nextCard = this.model.getTopic().getRandomCard(boxToCheck);
if (firstLoop){
boxToCheck = 0;
firstLoop = false;
} else {
boxToCheck +=1;
}
if (... |
0bd549ba-5bf2-4bb5-ba90-3f3838c70ff6 | 5 | private boolean func_151636_a(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_)
{
if (!compareBiomesById(p_151636_6_, p_151636_7_))
{
return false;
}
else
{
int k... |
83544ad4-c31b-49e4-b8fe-9fe3f3a0abe1 | 2 | static int[] heapSort(int[] A){
TreeSet<Integer> heap = new TreeSet<Integer>();
int[] ret = new int[A.length];
for(int i=0;i<A.length;i++){
heap.add(A[i]);
}
for(int i=0;i<A.length;i++){
ret[i]=heap.pollFirst();
}
return ret;
} |
eb622f38-e6e2-43d6-87ec-f2bd350939ed | 1 | public void visitExprStmt(final ExprStmt stmt) {
if (stmt.expr == from) {
stmt.expr = (Expr) to;
((Expr) to).setParent(stmt);
} else {
stmt.visitChildren(this);
}
} |
e99ca9ea-e3ea-4a32-ac4c-4abfd0a3d4ef | 8 | public int[] getInts(int par1, int par2, int par3, int par4)
{
int i = par1 - 1;
int j = par2 - 1;
int k = par3 + 2;
int l = par4 + 2;
int ai[] = parent.getInts(i, j, k, l);
int ai1[] = IntCache.getIntCache(par3 * par4);
for (int i1 = 0; i1 < par4; i1++)
... |
23a99bc0-12b7-487a-b626-76ee741fb5a2 | 3 | @Override
public void getOptions() {
for (Component p : getParent().getComponents()) {
if (p instanceof OptionsPanel) {
matrixOn = ((OptionsPanel) p).isMatrixOn();
type = ((OptionsPanel) p).getType();
}
}
if (matrixOn) {
st... |
cbc22130-8e40-4df3-a3fe-de680936ef28 | 9 | public void extendSchema() {
// Recursive method to add 1-1 Relationships from vicinity up to a
// defined level
System.out.println("Extending schema...");
logger.info("Extending schema");
for (Table table : schema.getTables()) {
Set<ColumnFamily> extendedColumnFamilies = extendAndMerge(table, 1,
"",... |
bd59fdaf-12c7-4b60-93b7-59265546b71d | 9 | protected void performChoice(int choice) {
if (choice == 1) {
HMMDefaultsMenu menu = new HMMDefaultsMenu();
menu.run();
}
else if (choice == 2) {
HMMConstructionMenu menu = new HMMConstructionMenu();
menu.run();
hmm = menu.getHMM();
}
else if (choice == 3) {
if (this.hmm != null) {
HMMUp... |
163cec32-a423-43e9-8937-c5aa5a6b56f0 | 0 | @Override
public String toString() {
final StringBuilder sb = new StringBuilder("Student{");
sb.append("number='").append(number).append('\'');
sb.append(", scores=").append(scores);
sb.append('}');
return sb.toString();
} |
a19c2826-fb96-4c69-9573-ce9d72b26aa5 | 3 | static String[] loadPlayerNames(String txtPath) {
ArrayList<String> namelist = new ArrayList<String>();
try {
// get file of players
BufferedReader in = new BufferedReader(new FileReader(new File(txtPath)));
String line;
while ( (line = in.readLine()) != n... |
10e523f1-9e84-47cb-a774-6e224cf9e6a8 | 8 | public void list()
{
//get all values
for(Exit e:exits.values())
{
//get pairs of keys and values
for (Entry<String, Exit> entry : exits.entrySet()) {
//if key is equal to the value
if (e.equals(entry.getValue())) {
if(e.isVisible())//and is visible
System.out.println(... |
03eaceb2-0011-47a8-a93b-645559f16a29 | 7 | public char getWinner()
{
char result;
if(gameOver)
return winner;
int blackCount=0;
int whiteCount=0;
if(surrendering){
for(char c : grid)
{
if(c=='B')
blackCount++;
if(c=='W')
whiteCount++;
}
if(blackCount>whiteCount)
setWinner('B');
else if(whiteCount>blackCoun... |
4b53804e-855a-4d38-9c00-7367f236d8a8 | 3 | public void compute() {
if (opponent == null)
return;
// Calculate the relative velocity between ourselves and the opponent
// This is called the closing velocity.
Vector3D velocityClosing = Vector3D.subtract(opponent.getVelocityVector(), getVelocityVector());
System.out.println("velocityClosing = " + ... |
1cb16ec3-e725-45e0-998e-3c65328fd016 | 7 | @Test
public void testNeighbour() {
// test
Parameters n = getSettings().getParameters().neighbour();
assertNotNull(n);
assertTrue(
"The neighbour of current Settings must not be the same object as Settings. - Expecting a slightly changed CLONE!",
!n.equals(getSettings().getParameters()));
// assert ... |
f7f48a1e-273d-4292-8c8d-52b8c2e1b6a9 | 5 | private void save() {
if (script == null) {
return;
}
final Properties settings = new Properties();
LinkedHashMap<Integer, List<String>> map = getTabContents(1);
JsonObject object = new JsonObject();
int i = 1;
for (Map.Entry<Integer, List<String>> entry : map.entrySet()) {
JsonArray values = new ... |
b2200320-b16c-44f0-a5b7-cd623c9756a8 | 0 | @Override
public String toString() {
return String.valueOf(name);
} |
5a491fde-6292-441d-9335-edf810c72cd3 | 8 | public void start() throws LWJGLException {
Display.create();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_ALPHA_TEST);
//glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, ... |
ecbb7818-3316-4bd2-8c7f-c431891e3df3 | 4 | private static void testBoxAddPosition(State state, Queue<State> nodes, Position player, int boxX, int boxY, int boxX2, int boxY2, Direction move, int index)
{
if (state.isFree(boxX, boxY) && state.isFree(boxX2, boxY2))
{
Position boxPos = state.boxes.get(index);
Result resul... |
e3f20540-06bb-47b5-a9da-fa66b021893b | 1 | public static CommonClassLib getInstance() {
if (commonClassLib == null) {
commonClassLib = new CommonClassLib();
}
return commonClassLib;
} |
042842ce-38ef-4284-ae6e-46a15d3f84bc | 9 | public void startElement(String uri, String localName,
String qName, Attributes attributes) throws SAXException {
// COLLECTIONS (START)
if (qName.equalsIgnoreCase("collections")) {
readCollections = true;
}
// COLLECTIONS :: COLLECTION (START)
else if (readCollections && qName.equalsIgnoreCase("... |
7657a359-cb7e-4def-965c-e299ce958c6b | 5 | public static boolean isLatinLetterOrDigit(char c) {
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
} |
0230f1f3-ab61-4310-a002-2a9c3615c1ea | 2 | public int getMaxRange(String minMatch, String maxMatch, int dataContentLength) {
if (maxMatch != null) {
if (minMatch == null) {
return dataContentLength;
} else {
return Integer.parseInt(maxMatch) + 1;
}
} else {
return dataContentLength;
}
} |
c03606cd-de84-40d6-b1c5-3fa4629f7be7 | 1 | public boolean isNan() {
return Double.isNaN(re) || Double.isNaN(im);
} |
83cea3fd-3fc6-4d5e-b782-6eea3eea18bc | 2 | public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("We are going to calculate Pie using the Leibniz formula.");
System.out.print("How many terms do you wish to use? ");
int termsCount = s.nextInt();
int terms... |
9e3609f0-dce7-447e-af3c-89f71e4eb06b | 2 | public BufferedImage getImage(int animation){
if(this.animation != animation){
this.animation = animation;
index = 0;
lastChange = System.currentTimeMillis();
} else if(System.currentTimeMillis() > lastChange + delay[animation]){
lastChange += delay[animation];
index = (index + 1) % length[animation]... |
0867dac7-4876-424f-ace6-d1292671ef26 | 1 | public boolean canInfo(CommandSender sender) {
if ( sender instanceof Player ) {
return this.hasPermission((Player)sender, "SheepFeed.info");
}
return true; // can info from console
} |
cdc426b8-a930-4a40-b075-f36107307230 | 5 | public void run() {
long lastTime = System.nanoTime();
long timer = System.currentTimeMillis();
final double ns = 1000000000.0 / 60.0;
double delta = 0;
int frames = 0;
int updates = 0;
requestFocus();
while (running) {
int missedUpdates = 0;
int missedRenders = 0;
long now = System.nanoTime()... |
0bc03eb7-c7d2-42c7-9213-4e18d7328144 | 0 | public static String getExecTime() {
return String.format("%.3f", (float)(new Date().getTime() - startedAt.getTime()) / 1000);
} |
54426e7c-2383-4252-9d8f-fd080342b805 | 8 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PersonAnnotated person2 = (PersonAnnotated) o;
if (age != person2.age) return false;
if (firstName != null ? !firstName.equals(person2.firstNam... |
2402f278-0da1-4a1e-8ad2-e3683ff407cf | 4 | public static byte[] Xdecode(String base64) {
// how many padding digits?
int pad = 0;
for (int i = base64.length() - 1; base64.charAt(i) == '='; i--)
pad++;
// we know know the lenght of the target byte array.
int length = base64.length() * 6 / 8 - pad;
byte[... |
2838df1b-ee8b-49e3-bee0-0465190c14a5 | 5 | public void playSong(Song song) throws NetworkException {
ApiMusicImpl apiMusic = Controller.getInstance().getApiMusic();
ApiProfileImpl apiProfile = ApiProfileImpl.getApiProfile();
SongLibrary localSongLibrary = ApiProfileImpl.getApiProfile().getSongLibrary();
SongLoader songLoader = ne... |
a2ae033b-be79-4fea-a6b6-a5cc66da3e92 | 1 | public static void main(String[] args)
{
char letter[] = { 'a', 'b', 'c', 'd', 'e', 'f' };
double frequency[] = { 0.45, 0.13, 0.12, 0.16, 0.09, 0.05 };
PrefixTree pt = new PrefixTree(letter, frequency);
for (int i = 0; i < letter.length; i++)
System.out.println(letter[i] + " : " + pt.getCode(letter[i]));
... |
7e0317ca-a9a6-4c70-8b95-2c0c0d9f2e27 | 0 | public void decoder(int[] octets_data){
} |
98a4b99c-8c63-46e0-85b8-e8609e8c6b1e | 1 | @Override
public ArrayList<String> getColumnsNames() throws Exception {
ArrayList<String> alColumns = null;
try {
oMysql.conexion(enumTipoConexion);
alColumns = oMysql.getColumnsName("cliente", Conexion.getDatabaseName());
oMysql.desconexion();
} catch (E... |
884d567f-ec26-4383-a9ba-b519f2ff8379 | 3 | @Override
public boolean equals(final Object o) {
if (!(o instanceof Color))
return false;
final Color c = (Color) o;
return r == c.r && g == c.g && b == c.b;
} |
4f86b580-7d45-4d64-bb21-0bfdf10ac250 | 2 | public int getNumberResourcesType(String str) {
if (str == null || str.equals("DESERT"))
return 0;
return resources.get(str).intValue();
} |
57165a46-e8c5-478d-bfc1-99318ab041a6 | 8 | private void btn_GuardarEnunciadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_GuardarEnunciadoActionPerformed
Autor autor1 = new Autor();
autor1.setCodigo((cbAutor.getSelectedIndex() +1));
en1.setAutor(autor1);
Area area = new Area();
area.setCodigo(cb_L... |
7d3154dc-53e0-460a-a1a3-66e4e9ece28e | 0 | public Destination destination(String s) {
// Local inner class
class PDestination implements Destination {
private String label;
private PDestination(String whereTo) {
label = whereTo;
}
public String readLabel() {
return label;
}
}
return new PDestination(s);
} |
eeb5c116-cbce-42d0-9e98-6dbc16ee6358 | 8 | public void actionPerformed(ActionEvent e)
{
if(e.getSource()==timerRandOper)
{
cleanList(Schedule.completeList);
cleanList(deadList);
int i=0;
int m=(int)(Math.random()*3);
if(m==0)
i=1;
switch (i)
{... |
90f176a5-c537-4d83-b069-5e5baec3a62a | 2 | @Override
public void onDisable() {
try {
TreasureManager.getInstance().savePossibleTreasure();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
TreasureManager.getInstance().saveTreasureSpots();
} catch (IOException e) {
// TODO Auto-gen... |
fc08596d-dc8c-41e3-aaec-7ba53de6eb12 | 2 | private void initializeRocks() {
for(int i = 0; i < 250; i++) {
Point point = getRandomLocationOnGrid(525);
if(model.getElements().contains(new Rectangle(point.x,
point.y, GameModel.UNIT, GameModel.UNIT))) {
i++;
continue;
} else {
model.addRock(point);
}
}
int UNIT4 = GameModel.UNIT ... |
1efa57a8-a213-4a11-8516-e0bc450a8948 | 8 | public void run()
{
projectileDie();
characterDie();
collision();
for (int i = 0; i < characters.size(); i++)
{
characters.get(i).move();
}
for (int i = 0; i < projectiles.size(); i++)
{
projectiles.get(i).move();
}
if (!characters.contains(player))
{
JOptionPane.showMessageDialog(null, ... |
54c88176-a7f6-4e57-86a5-d3b7ea188f93 | 3 | public static int findNewLine(byte[] arr, int offset) {
int len = arr.length - 1;
int i = offset;
for (; i < len; i++)
if (arr[i] == (byte) '\r' && arr[i + 1] == (byte) '\n')
return i;
return i;// the end of input will be handled like newline
} |
25c3f3c0-9248-4da3-b6c0-001f2f68c66a | 2 | private static HashMap<Integer, Integer> mapCorners(char[] state) {
HashMap<Integer, Integer> result = new HashMap<Integer, Integer>();
int[][] corners = Cube.CORNERS;
HashMap<String, Integer> goalCorners = initGoalCorners();
for(int j = 0; j < corners.length; j++) {
String needle = "";
for (int s : corne... |
89db5eac-0320-47c3-b400-fe2963a53a9b | 4 | public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
fillDP();
d: do {
line = br.readLine();
if (line == null || line.length() == 0)
break d;
int n = Integer... |
36957380-b54d-4c32-8282-bab840f22159 | 9 | public void search(CharSequence text, int start, WordDic wdic, List<ViterbiNode> result) {
final char ch = text.charAt(start);
final CharCategory.Category ct = category.category(ch);
if(result.isEmpty()==false && ct.invoke==false)
return;
final boolean isSpace = ct.id==spaceId;
final int limit = Math.min(t... |
d4acd169-2487-4ab8-8cb8-dc7a26b01012 | 5 | public static Connection getConnection() throws SQLException, IOException
{
Properties props = new Properties();
FileInputStream in = null;
try {
in = new FileInputStream("C:\\JavaProjects\\TelephoneBook-v2\\src\\com\\woolfer\\telephonebook\\db\\database.properties");
props.load(in);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.