method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
256661ea-a872-4f2d-811b-756ba263bfe8 | 9 | private void loadWordArrayFromZal(String fileName)
{
wordList = new ArrayList<String>();
try
{
FileInputStream file = new FileInputStream(fileName);
BufferedInputStream bis = new BufferedInputStream(file);
int cnt = 0;
Scanner sc = new Scanner(bis);
System.out.println("Loading dictionary...");
... |
ede1581d-3d0c-43c2-b9b7-e71f50ce87c3 | 4 | public void mutation(ArrayList<Solve> population) {
Random rand = new Random();
Solve slv;
ArrayList<Integer> clr;
for (int i = 0; i < populationsize; i++) {
if (rand.nextDouble() < mutationchomosome) {
clr = population.get(i).Colors;
for (int ... |
2a2f44cb-0b6e-4944-a7f4-3e1a6be60326 | 4 | public static String binaryFind(String target, String[] list)
{
int start = 0;
int end = list.length - 1;
int checkpoint = 0;
while (start <= end)
{ //While there are more to search
// find the middle
checkpoint = (int)((start+end)/2.0);
System.out.println("Checking at: "+
... |
d843740b-949a-4ecd-8f8e-9cdb42bf85dd | 4 | private boolean is_valid(int target, int[][] square,int row,int col)
{
for(int i=0;i<row;i++)
{
if(square[i][col]==target)
return false;
}
for(int i=0;i<col;i++)
{
if(square[row][i]==target)
return false;
}
return true;
} |
92ec2cbe-ab72-4ab8-955e-2cb495df1c74 | 4 | private boolean read() {
try {
final URLConnection conn = this.url.openConnection();
conn.setConnectTimeout(5000);
if (this.apiKey != null) {
conn.addRequestProperty("X-API-Key", this.apiKey);
}
conn.addRequestProperty("User-Agent", "U... |
b8b7aefd-32cc-4442-bb8f-c956b73ef4c0 | 4 | @Override
public void run() {
while (this.isRunning) {
try {
// Tell model to update, send next key press.
// or 0 if no new keypress since last update.
if (updateSpeed > 0) {
Thread.sleep(updateSpeed);
this.gameModel.gameUpdate(nextKeyPress());
}
} catch (GameOverException... |
8011d53f-673d-43ba-aef7-3f43826096aa | 2 | public boolean exists( int key )
{
final int i = relativeIndex( key );
return (i >= 0 && i < values.length && values[i] != null);
} |
9d9ac532-1d2a-422d-a402-626d71a06c5e | 4 | private void sendToClientFileTree(IoSession session) throws IOException {
InputStream openStream = null;
try {
URL resource = this.getClass().getClassLoader()
.getResource("flume.properties");
openStream = resource.openStream();
Properties properties = new Properties();
properties.load(openStream);... |
7ce8ada1-bd54-4d49-ae80-1329448a8330 | 5 | public BackupChunk getChunk(byte[] fileID, int chunkNo) {
String recID = Packet.bytesToHex(fileID);
for(BackupChunk chunk : backedUpChunks) {
String comID = Packet.bytesToHex(chunk.getFileID());
if(comID.equals(recID) && chunk.getChunkNo() == chunkNo) {
byte[] body = new byte[BackupChunk.maxSize];
tr... |
f18141c1-91b8-4d22-bb22-ba0a1db107a0 | 4 | public int cdlMatHoldLookback( double optInPenetration )
{
if( optInPenetration == (-4e+37) )
optInPenetration = 5.000000e-1;
else if( (optInPenetration < 0.000000e+0) || (optInPenetration > 3.000000e+37) )
return -1;
return ((( (this.candleSettings[CandleSettingType.BodyShort.ord... |
40ab77a0-ee2a-4146-b85a-692833b1ad01 | 6 | public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equals... |
3d597b0c-f222-4238-a31c-986e5bed93b1 | 3 | private static int[] min(int a, int b, int c) {
int[] res = {a, INSERT};
if (b < a) {
res[MINIMUM] = b;
res[POSITION_MINIMUM] = DELETE;
if (c < b) {
res[MINIMUM] = c;
res[POSITION_MINIMUM] = SUBSTITUTION;
}
} else {
... |
45ee1c37-5d26-472b-acce-50879e1e9eba | 9 | public static void main(String[] args) throws Exception {
String code = null;
String file = "<eval>";
Boolean launchREPL = false;
/* parsing args */
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-e")) code = args[++i];
else if (args[i].equa... |
ecfa3c6a-0b71-490b-a1a0-53270466d5a8 | 8 | public ArrayList<Card> checkFull(ArrayList<Card> cards) {
ArrayList<Card> rm = new ArrayList<Card>();
ArrayList<Card> cs = cardsIn(cards);
int[] sofar = new int[ins.length];
for (int i=0;i<sofar.length;i++) {
if (ins[i]==null)
sofar[i] = 1;
else
sofar[i] = 0; //set blank
}
for (Card... |
b8f8387c-9737-47df-9dc8-53d56e9ee0d2 | 3 | private synchronized void populateRoot() {
if (nodes.get("/") == null) {
try {
System.out.println("[" + Thread.currentThread()
+ "Populating root..");
Stat stat = new Stat();
ZVNodeImpl root = new ZVNodeImpl("/", zk.getData("/",... |
9e7e38c8-27f1-44c7-b8c5-8d46d8c7ff2b | 2 | public static ArrayList<String> getParsedDisplayStrings(String str) {
String[] strings = str.split(";");
ArrayList<String> retList = new ArrayList<String>();
for (int i = 0; i < strings.length; i++) {
if (!strings[i].trim().isEmpty())
retList.add(strings[i].trim());
}
return retList;
} |
ddebca4a-35cb-451b-98b6-7a2b182c9eee | 1 | public void visitInnerClass(
String name,
String outerName,
String innerName,
int access)
{
super.visitInnerClass(remapper.mapType(name),
outerName == null ? null : remapper.mapType(outerName),
innerName, // TODO should it be changed?
... |
6a667687-f459-4da8-b107-57185b167590 | 1 | @Override
public void setCurrentHp(int hp) {
if (hp >= this.maxHP) {
this.curHP = this.maxHP;
} else {
this.curHP = hp;
}
} |
3dc3653f-78f7-4032-a88e-d956cf671f8a | 1 | @Override
public void completed(Object result, Object attachment) {
try {
fileChannel.close();
String path = (String) attachment;
worker.writeFile(socketChannel, buffer, path);
}
catch (IOException exc) {
exc.printStackTrace();
}
} |
b4d07650-a7f3-43c3-8caa-03e377a8199f | 8 | public static List<Intersection> getHandicapPoints(int boardSize, int handicap) {
List<Intersection> starPoints = getStarPoints(boardSize);
if (handicap == 2) {
return Arrays.asList(starPoints.get(6), starPoints.get(2));
} else if (handicap == 3) {
return Arrays.asList(starPoints.get(6), starPoints.get(2),... |
5d1d6782-8976-45c4-9ee9-c69ce5050055 | 5 | public void renderPortionWithOffset(int sx, int sy, int rWidth, int rHeight, float xOff, float yOff, ArrayList<SpriteSheet> sh) {
for (int i = sy; i < rHeight + sy; i++) { // cols
for (int j = sx; j < rWidth + sx; j++) { // rows
int xt;
int yt;
if (tiles[i][j].getTileID() != 0) {
if (tiles[i][j].... |
78c852c5-466a-4a7d-bd8b-55331c1d946b | 7 | private void init(Component c, AttributeSet initial) {
m_app = (JWP) c;
JPanel main = new JPanel();
JPanel buttonPanel = new JPanel();
JPanel listPanel = new JPanel();
JPanel fontPanel = new JPanel();
JPanel optionPanel = new JPanel();
JPanel previewPanel = new JPanel();
main.setLay... |
0372eff6-a4de-4b44-b32e-02179b33b070 | 9 | static BigInteger fillCount(int m, int n)
{
BigInteger totalSum = BigInteger.ZERO;
BigInteger[][] arrangements = new BigInteger[n+1][n];
for (int i = 0; i <= n; i++)
for (int j = 0; j < n; j++)
arrangements[i][j] = BigInteger.ZERO;
arrangements[1][0] = BigInteger.ONE;
for (int i = 1; i < n; i++)
{
... |
c3ac7886-d95d-4eb2-8211-add06f3cafee | 8 | public NBTEdit(final JTree tree, final NBTFrame frame) {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
name = new JLabel(" ");
text = new JTextField();
cur = null;
add(name);
add(text);
final Action action = new AbstractAction("Edit") {
private static final long serialVersionUID =... |
5610cbdb-b62a-4d5f-b26d-c3dbf055e8ae | 5 | public int GetCLFletching(int ItemID) {
if (ItemID == 10740) {
return 100;
}
if (ItemID == 10742) {
return 100;
}
if (ItemID == -1) {
return 1;
}
String ItemName = GetItemName(ItemID);
if (ItemName.startsWith("Fletching cape")) {
return 100;
}
if (ItemName.startsWith("Fletching hood")) {
re... |
a72dd674-cb69-45ce-bd43-cab0e190d89c | 2 | public static void assignFloaters(int floaterNum) {
int tableCounter = 0;
int stuIndex;
for (int i = 0; i < floaterNum; i++) {
stuIndex = R.nextInt(StuIDs.size() - 1);
assignStudent(25, (String) StuIDs.get(stuIndex));
StuIDs.remove(stuIndex);
if (tableCounter >= 25) // if we're at the last table, re... |
5056826f-273f-4ce0-bf5f-6ca67af41550 | 9 | public void run()
{
// システム情報取得
String str = System.getProperty("os.name");
mOSName = str;
str = System.getProperty("os.arch");
mOSArch = str;
str = System.getProperty("os.version");
mOSVersion = str;
str = System.getProperty("user.name");
mUserName = str;
DebugLog("user name:" + str);
DebugLo... |
52163ed5-a929-48c0-b1b3-726c8523ff57 | 7 | protected void appendLodging(StringBuilder req, LodgingRequest lodging) {
if (lodging != null) {
if (lodging.getCheckinTime() != null) {
this.appendParam(req, LodgingRequest.Field.checkinTime.getValue(),
new SimpleDateFormat(DATE_FORMAT).format(lodging.getChec... |
1b8a35b4-3f6f-4c0a-966a-cb94b9090846 | 3 | public void run () {
// se realiza el ciclo del juego mientras hasta que se cierre
while (true) {
/* mientras dure el juego, se actualizan posiciones de jugadores
se checa si hubo colisiones para desaparecer jugadores o corregir
movimientos y se vuelve a pintar ... |
5243265a-1d21-426d-801c-2bf17b88c8d7 | 5 | private static int recalculateEnemySupply() {
int enemySupply = 0;
for (Unit enemy : MapExploration.getEnemyUnitsDiscovered()) {
UnitType type = enemy.getType();
if (!type.isBuilding() && !type.isSpiderMine() && !type.isLarvaOrEgg()) {
enemySupply += type.getSupplyRequired();
// Probes are counted x... |
a5513fb2-ff3e-4ba1-8279-3c8b2989d1de | 9 | public void checkMove(int originLetter, int originNum, int newLetter, int newNum)
{
if(n.compareTo(knight) == 0)
{
//black
if(originNum - newNum == 2)
{
move1Black(originLetter, originNum, newLetter, newNum);
}
else if(originNum - newNum == 1)
{
move2Black(originLetter, originNum, newLett... |
d68556dc-88bd-4420-8356-74666c5a2309 | 8 | @Override
public int castingQuality(MOB mob, Physical target)
{
if(mob!=null)
{
if(mob.isInCombat())
return Ability.QUALITY_INDIFFERENT;
if(target instanceof MOB)
{
if((((MOB)target).amDead())||(!CMLib.flags().canBeSeenBy(target,mob)))
return Ability.QUALITY_INDIFFERENT;
final Item w=mob... |
3981d7eb-434c-4051-91c0-8d2b41d9b6b4 | 5 | private void countClass(Class<?> type) {
Integer quantity = get(type);
put(type, quantity == null ? 1 : quantity + 1);
Class<?> superClass = type.getSuperclass();
if (superClass != null && baseType.isAssignableFrom(superClass))
countClass(superClass);
} |
131d4f22-57ff-4a31-8ce8-ef23627cbf53 | 0 | public void setProperties(Map<String, Object> properties)
{
this.properties = properties;
} |
022e44ff-452e-4029-ab97-f6196f8c120e | 3 | public String toString() {
StringBuffer localStringBuffer = new StringBuffer("AnimationComponent[");
localStringBuffer.append(getSize());
localStringBuffer.append(",CurrentIndex:");
localStringBuffer.append(this.CurrentIndex);
localStringBuffer.append(",Indexes:");
if (this.Indexes == null)
... |
20966704-fe91-4feb-9bd4-2e15d12fda2e | 3 | public void test_19_score_threshold_rand() {
int thresholdMax = 5;
int changesMax = 6;
int minLen = thresholdMax + changesMax + 10; // Big enough so that we don't run into problems creating random changes
System.err.print("\nScore (threshold) random test:\n");
Random rand = new Random(20100821);
for( int m... |
0c3f4267-e8c4-4ca7-83cc-49dd15c7a5b1 | 1 | private void writeObject(ObjectOutputStream stream) throws java.io.IOException {
stream.defaultWriteObject();
if (!isProperList) {
stream.writeBoolean(false);
stream.writeObject(this.dottedElement);
} else {
stream.writeBoolean(true);
}
} |
7c32f078-3eae-4f62-8689-6af9c43d4882 | 4 | public boolean invokeExecute(boolean valid)
{
// If execution can occur right now...
if (canExecute())
{
// Adjust validation based on remaining executions
valid &= (remainingExecutes == -1 || --remainingExecutes >= 0);
// If the service state is valid, notify listeners.
if (valid) {
// Quicker... |
dc6ba6a1-5f83-4f18-b448-fdf9708a844a | 6 | public Tree(int depth, COLOR myColor, Board mainBoard){
this.root = new Board(mainBoard);
/*
if (root==null)
System.out.println("root is null");
else System.out.println("root is not null");
*/
//this.root.computeUtility();
ArrayList<Board> parentList = new ArrayList<Board>();
parentList.add(this.roo... |
8a4152d1-2d12-4dfd-83be-db78d2e579f3 | 5 | private void handleKillProcess(String[] cmdLine){
int procId=-1;
if(cmdLine.length < 2){
System.out.println("invalid argument number, please type help for more information");
return;
}
try{
procId=Integer.valueOf(cmdLine[1]);
}catch(Exception e... |
edc23fea-a869-4a55-b5c7-25ce8884a0d7 | 9 | public String eyeRoll(Ghost ghost){
int x = (int)ghost.getX();
int y = (int)ghost.getY();
String ret = "left";
if(x < 247){
ret = "right";
}
else if(x > 307 ){
ret = "left";
}
else if(y > 286){
ret = "up";
}
else if(y < 286){
ret = "down";
}
if (x < 27 || x > 547 || y== 286){
g... |
53e45fa5-7c39-46cb-9f18-ccf38620dcda | 7 | * @Post: No changes
* @Return: Whether or not the attacks on the King can be blocked
*/
private boolean canBlockAttack(ArrayList<Piece> piecesAttacking) {
if(piecesAttacking.size()>1)
{
return false;//can't block two different paths
}
Piece pieceAttacking = piecesAttacking.get(0);
if(pieceAttacking i... |
c237030f-7d95-48bf-afd6-5867ecb2811b | 1 | private void setRunningIndicator(boolean show) {
runner.setIcon(show ? RUNNING : null);
} |
07a30fd1-9577-40dc-a853-5bb890dd9508 | 9 | private static void readVersions( Element versionsElement,
MVD mvd ) throws Exception
{
TreeMap<Short,Version> versions = new TreeMap<Short,Version>();
NodeList nl = versionsElement.getChildNodes();
for ( int i=0;i<nl.getLength();i++ )
{
Node versionNode = nl.item( i );
if ( versionNode.getNodeType() ... |
cd1d4e85-6213-4ec6-9a3c-14aa8ae66c61 | 5 | @Override
public int read() throws IOException {
int c;
// If we have a block in here, start feeding that out.
if ((c = outBuffer.read()) != -1)
return c;
// Otherwise, time to make a block.
while (inBuffer.size() < ConCh.BLOCK_LIMIT
... |
104c3472-c549-4b8e-b647-1a9ec39b0208 | 9 | protected void move(double xm, double ym) {
if (xm == 0 && ym == 0) {
moving = false;
return;
}
if (slowed()) {
xm *= 0.5;
ym *= 0.5;
}
moving = true;
if (ym > 0) dir = dirDown;
else if (ym < 0) dir = dirUp;
... |
6daafbf5-908f-4c58-94ad-53bf878a0d2a | 0 | public InputStreamHandler_ass(InputStream is, OutputStream os,
ClientListManager list_pt, String t_ip, ClientSocketHandler pa) {
reader = new DataInputStream(is);
writer = new DataOutputStream(os);
list = list_pt;
ip = t_ip;
parent = pa;
builder = new SAXBuilder();
} |
91dac807-38fe-420a-b7ed-015688685603 | 9 | public static String connectPunctuations(String sentence)
{
int i,j;
i = sentence.length() - 1;
//leave one space at end
if (sentence.charAt(i) == ' ')
{
i--;
}
j=i;
//connect , and .
while (i > 0)
{
while (j >= 0 && sentence.charAt(j) != ' ')
{
j--;
}
char ch = sentence.charAt(... |
7906dc92-60ec-41ff-9bcf-20565f512b64 | 1 | private static int[] byteBufferToInt(int[] data, ByteBuffer buffer,
int width, int height) {
for (int i = 0; i < width * height; i++) {
int r = buffer.get() & 0xFF;
int g = buffer.get() & 0xFF;
int b = buffer.get() & 0xFF;
int a = buffer.get() & 0xFF;
data[i] = Color.makeARGB(a, r, g, b);
}
retu... |
1e2ed595-a53d-42e6-9feb-4cafed6ca470 | 4 | private void notifyAvailableAuthService(String type) {
for (ComponentEntry ac : this.accessControllers.values()) {
if (ac.activeType == null && (ac.preferredType.equals(type) || ac.altType.equals(type))) {
ac.activeType = type;
Message msg = new Message(Message.Type.CHANGE_AUTH, ac.id, Message.MANAGER);
... |
fdc2604d-1010-4971-86cc-2c72d1c017a8 | 8 | private static String box(String i) {
switch (i) {
case "int":
return "Integer";
case "boolean":
return "Boolean";
case "char":
return "Character";
case "long":
return "Long";
case "short":
return "Short";
case "byte":
return "Byte";
case "float":
return "Float";
case "double":
... |
207d8e01-21bb-416d-816e-512a2104ddd9 | 8 | private static Principal resolvePrincipal(String groupName,
String className) {
Exception e = null;
try {
Class clazz = Class.forName(className);
if (Principal.class.isAssignableFrom(clazz)) {
Constructor c = clazz.getConstructor(STR_ARG);
return (Principal) c
.new... |
4f819132-c6c1-4bbe-89ab-7654bd8248b3 | 4 | public int deleteEntry(String lineToRemove) {
String currentLine = null;
ArrayList<String> lines = new ArrayList<String>();
File file = new File("Calendar.txt");
try {
BufferedReader br = new BufferedReader(new FileReader(file));
while ((currentLine = br.readLine... |
b041088a-2c13-487c-bf05-0e55adc791ae | 6 | private ColumnComparator makeColumnComparator(Element elColumn) throws Exception
{
NumberName numberName = new NumberName(elColumn);
String type = elColumn.getAttribute("type").toLowerCase();
boolean ascending = !(elColumn.getAttribute("order").toLowerCase().equals("descending"));
String defaultString... |
8d8a57df-fa08-475d-8bd0-015780246f44 | 2 | protected void setValue(Object value) {
if (value != null && value instanceof Number) {
formatter.setMaximumIntegerDigits(integer);
formatter.setMaximumFractionDigits(fraction);
formatter.setMinimumFractionDigits(fraction);
setText(formatter.format(((Number) value).doubleValue()));
} else {
super.set... |
281fcf2e-d0ba-4ad5-8cef-99761043c320 | 7 | public void enemyKilled(int wordLength) {
// Only do something if the word entered has characters.
if (wordLength > 0){
// Increments the total number killed and number consecutively killed.
Settings.totalKilled++;
numberConsecutive++;
// Sets the number consecutive bonuses.
if (numberConsecutive < ... |
aef8bd8f-622a-4813-a6c2-94d469af4f1a | 9 | public Board chooseMove() throws Exception{
int ties = 1;
double bestValue = Double.NEGATIVE_INFINITY, currentValue;
Board bestMove = null, currentMove;
double[] results = new double[TaTeTi.MAX_CELLS*TaTeTi.MAX_CELLS];
LinkedList<Board> availableMoves = eg.getAvailableMovesForPla... |
fd9eb7bb-6a1b-438e-a16a-5da61bebcee6 | 1 | public void testNormalizedStandard_periodType_weekDay2() {
Period test = new Period(0, 0, Integer.MAX_VALUE, 7, 0, 0, 0, 0);
try {
test.normalizedStandard((PeriodType) null);
fail();
} catch (ArithmeticException ex) {}
} |
b5d4c7c9-7dd1-4f61-aa93-34bc88ed8145 | 9 | @SuppressWarnings("unchecked")
protected List<String> getLyrics()
{
Map<String,List<String>> lyricMap=(Map<String,List<String>>)Resources.getResource("SYSTEM_SONG_LYRICS");
if(lyricMap==null)
{
lyricMap=new TreeMap<String,List<String>>();
List<String> lines=Resources.getFileLineVector(new CMFile(Resources... |
b194d6ee-7f28-45f8-b6a0-3d1fda6fa72c | 8 | public int maximumGap(int[] num) {
if (num == null || num.length <= 1)
return 0;
int max = num[0], min = num[0];
for (int n : num) {
max = Math.max(max, n);
min = Math.min(min, n);
}
int size = (int) Math.ceil((max - min) * 1.0 / (num.length - 1));
int n = (max - min) / size + 1;
List<List<Integ... |
151f4f7b-c3d4-472b-b54d-b1d68180be53 | 5 | private final void method659(int i) {
if (aClass353Array5524 != null) {
aHa_Sub3_5419.C(!aBoolean5428);
aHa_Sub3_5419.method3866(false, true);
aHa_Sub3_5419.method3849((byte) 47, 1,
Class348_Sub40_Sub39.aClass70_9485);
aHa_Sub3_5419.method3885(1, true,
Class348_Sub40_Sub39.aClass7... |
68f64464-ab81-4219-a92f-9dcf88432499 | 8 | public static void main(String[] args) {
JSONParser parser = new JSONParser();
try {
Object obj = parser.parse(new FileReader("Heroes.json"));
JSONObject jsonObject = (JSONObject) obj;
// Isim listeleme
Iterator<String> typeIterator = jsonObject.keySet().iterator();
while (typeIterator.hasNext()) {
... |
0967e04d-6a0f-4f5b-857d-c2aa4c239b7e | 4 | public static void highlightTokens(JTextArea resultsPane, ArrayList<String> tokens) {
Highlighter highlighter = resultsPane.getHighlighter();
for (int j = 0; j < tokens.size(); j++) {
String textFromPane = resultsPane.getText();
for (int i = 0; i <= textFromPane.length(); i++) {
... |
1d03cce1-1f00-4279-b319-d5d4d19a4fb2 | 3 | public Especificacion getEspecificacionesProd(producto prod){
Especificacion esp = new Especificacion();
Conexionbd.conexion bd = new Conexionbd.conexion();
bd.conectarBase();
try {
ResultSet rs = bd.sentencia.executeQuery("SELECT * FROM ESPECIFICACIONESxPROD WHERE NOMBRE_PRO... |
ea610819-9252-4653-9b0a-8ac123ba288e | 4 | double getEdgeSpeed() {
switch (edge.getSpeed()) {
case -2:
return 0;
case -1:
return 0.3;
case 1:
return 3.0;
case 2:
return 50.0;
}
return 1.0;
} |
db05032f-41d3-4c81-b13f-b4ff0aae8a5b | 5 | @Override
public void doAction(String choice) {
Location currentLocation = Survivalist.getCurrentGame().getCurrentLocation();
switch (choice) {
case "H": // display the help menu
HelpMenuView helpMenu = new HelpMenuView();
helpMenu.display();
... |
10b993cb-1792-449e-bef1-56f0319e4f7e | 4 | public static final boolean isVowel(char ch) {
ch = Character.toLowerCase(ch);
return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
} |
5c69e5f8-13f9-4dfa-8c75-3b5716c3ace1 | 7 | public boolean intersects(ImageMask other) {
if(other == null)
return false;
for(int i = 0; i < width; i++)
for(int j = 0; j < height; j++)
for(int k = 0; k < other.getWidth(); k++)
for(int l = 0; l < other.getHeight(); l++)
... |
742dfa75-0f62-444a-a993-7318c66a18ca | 0 | public synchronized void start() {
running = true;
new Thread(this).start();
} |
fd7cf09f-8921-4a56-8bc0-dc8083ee89d1 | 6 | public String getOptionsXML()
{
StringBuffer sb = new StringBuffer();
if( bar.fStacked )
{
sb.append( " Stacked=\"true\"" );
}
if( bar.f100 )
{
sb.append( " PercentageDisplay=\"true\"" );
}
if( bar.fHasShadow )
{
sb.append( " Shadow=\"true\"" );
}
if( bar.pcOverlap != 0 )
{
sb.appen... |
d97d4626-9212-42bd-b2c0-478ed3829411 | 4 | public Stats getStatsByModeAndDate(int mode, long date, Stats defaultStats)
{
if(date < 0)
return defaultStats;
try
{
HashMap<Long, Stats> stats = getAllStats(mode);
for(Stats stat : stats.values())
{
String temp = String.valueOf(stat.getDate());
String tempp = String.valueOf(date);
if(te... |
99425f0d-5189-4b9f-80dd-ef9c26a77681 | 5 | protected void handleInput(int key, boolean down)
{
KeyBinding binding = KeyBinding.getBinding(key);
switch (binding)
{
case FORWARD: movement.setMovingForward(down); break;
case BACKWARD: movement.setMovingBackward(down); break;
case LEFT: movement.setMovingLeft(down); break;
case RIGHT: movement.s... |
26284b63-3fbe-4413-bd71-881e1538ce7a | 9 | @Override
public void compile(Possession possession, Team home, Team away, TimeStamp timeStamp)
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch b... |
7d01c4a7-b6f9-4331-b30c-b36133c8d967 | 7 | @Override
public void drawLine(int startX, int startY, int endX, int endY, MapColor color) {
int lengthX = Math.abs(startX - endX);
int lengthY = Math.abs(startY - endY);
int motionX = 1;
int motionY = 1;
int error = lengthX - lengthY;
int e2;
if (startX > end... |
7c0c4b29-1e35-49a5-856b-556f61a7d731 | 4 | public void removeItem(String referenceToRemove){
boolean foundItem = false;
for(int i=0; i < libraryItems.size(); i++){
if(libraryItems.get(i).getReference().equals(referenceToRemove)){
foundItem = true;
if(libraryItems.get(i).getInLibrary()){
... |
e5a3dd73-560f-42fc-90ae-76e34aa67a4f | 1 | public void addPorts(Port ports[]){
for(int i=0;i<ports.length;i++)
addPort(ports[i]);
} |
cb9c825f-2642-4d7d-b282-8bfa2c0b47ed | 5 | * @param fontWidth
* the width of the font (size) to print with
* @param fontName
* the name of the font you are using
*/
public static void print(int xPos, int yPos, String message, int fontWidth,
String fontName) {
// If font was not loaded, load the new font
if (fontListBase ==... |
6a69fbce-e91d-4bc8-99fb-799fa93ff504 | 2 | public String getParameter(String name){
String[] params = this.requestParameters.get(name);
if (null != params && params.length >= 1) {
return params[0];
} else {
return null;
}
} |
ecb78e2e-b2cb-462f-90f7-fb42eae3d78c | 2 | public long getLong(String key) throws JSONException {
Object object = get(key);
try {
return object instanceof Number ?
((Number) object).longValue() :
Long.parseLong((String) object);
} catch (Exception e) {
throw new JSONExceptio... |
4d307452-3e5a-472f-a18f-482d787185a5 | 0 | public void setId(int id) {
this.id = id;
} |
bcdec87c-1af5-4fa4-95da-86caffa385ba | 9 | public static SimpleDateFormat getDateTimeConvert(int fileType)
{
if(fileType == MANIFEST)
{
return new SimpleDateFormat("yyyyMMddHHmmss");
}
else if(fileType == STATS)
{
return new SimpleDateFormat("yyyyMMdd");
}
else if(fileType == PD... |
a7f57578-b670-4b37-9134-59bbfc8870ee | 4 | @Test
public void testcheckRepartition() {
try {
@SuppressWarnings("unused")
MealRepartition mr = new MealRepartition(0.5, 0.35, 0.15, true, 4000);
} catch (BadCarbohydratePercentageException
| BadLipidPercentageException | BadProteinPercentageException e) {
fail("Unexpectd exception catch !");
} ca... |
301e6f53-597c-47b4-b885-b6a7f9e42b92 | 4 | public int add(Student student) {
int i;
boolean error = false;
for (i = 0; i < list.size(); i++) {
if (list.get(i).getId() == student.getId()) {
error = true;
}
}
if (error) {
System.out.println("Error : Same ID in the Promotion !");
} else {
list.add(student);
if (student.getP() != null... |
6d328202-3c6e-4ac3-8808-fb224ef74000 | 6 | public boolean mkdirs(String remoteDirectory) throws IOException {
boolean dirExists = true;
//tokenize the string and attempt to change into each directory level. If you cannot, then start creating.
String[] directories = remoteDirectory.split("/");
directories = Arrays.copyOfRange(di... |
f3cda103-dabd-4d2f-bff2-fe5c6b1d91fb | 4 | @Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Product that = (Product) o;
if (!upc.equals(that.upc)) return false;
return true;
} |
fc7164e4-84f8-4501-849a-8335b90faaeb | 0 | public static String Get(String[] args)
{
System.out.println(GgkCodePage936HeadLetter.getGBKpy(args[0]).toUpperCase().toString());
return GgkCodePage936HeadLetter.getGBKpy(args[0]).toUpperCase().toString();
} |
58ad82b1-8d65-4010-bb9a-3195e3ab4bd3 | 7 | public String toString() {
StringBuffer sb = new StringBuffer("<class>" + getClass().getName() + "</class>\n");
if (uid != null)
sb.append("<uid>" + uid + "</uid>\n");
sb.append("<width>" + (widthIsRelative ? (widthRatio > 1.0f ? 1 : widthRatio) : getWidth()) + "</width>\n");
sb.append("<height>" + (heightIs... |
135fcd15-a232-4b6e-8d00-290f08e4eb50 | 6 | private static Node findSuccessor(Node r, Node t) {
if (t.right != null) {
Node p = t.right;
while (p.left != null) {
p = p.left;
}
return p;
} else {
Node p = r;
Node prev = null;
while (p != t) {
if (p == null)
return null;
if (p.v > t.v) {
prev = p;
p = p.left;
... |
76a58eec-7cf0-46e2-90ad-a08b4f010c4c | 7 | public void updateReferences(Set<DomainObject> objects)
throws XMLParsingException {
for (Activity act : this.activities) {
act.updateObjectReferences(objects);
if (act.hasUnresolvedReferences()) {
throw new XMLParsingException("Could not resolve object references for activity" + act.getName());
}
... |
b74a3c03-8ade-442e-8d03-2d7a0d896a7c | 2 | private int hasPresence( Pattern p )
{
return p == null || p.pattern().length()>0 ? 1 : 0;
} |
17f55c27-b130-478c-9fa0-9b017af0c5d6 | 8 | final public void PrintExp() throws ParseException {/*@bgen(jjtree) PrintExp */
SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTPRINTEXP);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(WGGPRINT);
SingleExpression();
} catch (Throwable jjte000) {
i... |
e3fe7400-3826-47ba-8121-f1127becd653 | 2 | public static void start(){
if(gt==null || !gt.running){
gt = new GameThread();
gt.running=true;
t = new Thread(gt);
t.start();
}
} |
207b0873-faa3-45e1-a105-b7ff68cc1e66 | 3 | void createExampleWidgets () {
/* Compute the widget style */
int style = getDefaultStyle();
if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY;
if (borderButton.getSelection ()) style |= SWT.BORDER;
if (wrapButton.getSelection ()) style |= SWT.WRAP;
/* Create the example widgets */
spinner1... |
159c7afb-c3e7-41a6-a297-a44a6f75053b | 6 | public static int term(){
// Start of the term is the current last state
int start = state;
// Increment state to make space for a branching machine
state++;
// Terms are a literal
int fact = literal();
// If we have run off the end or finished the term
if(isLiteral()||j>=expression.length()){
// The... |
a6f48713-f5d3-41f3-96cd-ebe3f988ec80 | 2 | public void generateFileSystem() {
fsGenerator.createFolders();
int minFileSize = Config.getMinSize();
int maxFileSize = Config.getMaxSize();
try {
this.files = fsGenerator.fillFoldersWithFiles(minFileSize, maxFileSize);
} catch (FoldersNotCreated e) {
logger.error("Folders not created yet.");
e.... |
cbf09f10-bbc0-4825-bcbf-90c1d3fad882 | 6 | private void configure(URL xmlURL) throws IOException, SAXException {
//Local Variables
Document avTransportXML = descriptionTool.parseXML(xmlURL);
Node serviceStateTable = XMLTool.search(avTransportXML, "serviceStateTable");
Node actionList = XMLTool.search(avTransportXML, "actionList");
//Any state var... |
a7725fa5-ec4e-45e3-8c38-625662cd17d0 | 8 | public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
// fires laser
if (key == KeyEvent.VK_SPACE) {
if (rateOfFireRemaining <= 0) {
lasers.add(ship.fire());
rateOfFireRemaining = rateOfFire;
}
}
if (key == KeyEvent.VK_UP)
ship.setAccelerating(true);
if (key == KeyEvent.VK_RIGHT)
... |
4ca7b7cc-4492-4356-a4bc-644560745148 | 6 | public static void main(String[] args) throws Exception
{
HashMap<String, String> map = getBarcodeToSampleMap();
BufferedReader reader = new BufferedReader(new FileReader(new File(
ConfigReader.getIanLongitudnalDec2015Dir() + File.separator +
"BEHAVBUGS_NoIndex_L001_R2_001.fastq")));
long numAssign... |
2b3a2435-f29a-475d-945b-2a3040fd8114 | 0 | public Ball(String ballColor) {
this.ballColor = ballColor;
} |
c5137c6f-b4d4-4b1b-aa55-76ee8c89394a | 1 | public boolean endAuction() {
try {
endedInt = "1";
return true;
} catch (Exception e) {
return false;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.