method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5ccfa236-aff4-478b-9254-dc697ec594b2 | 1 | protected void execute() {
double time = _timer.get();
if(time >= _period){
Robot.ledStrip.setColor(_colors[index].getRed(), _colors[index].getGreen(), _colors[index].getBlue());
index = (index + 1) % _colors.length;
_timer.reset();
}
} |
6c1af564-c28e-4d8d-8d55-0b45734210cd | 4 | private long getCPtrAddRefContact(Contact element) {
// Whenever adding a reference to the list, I remove it first (if already there.)
// That way we never store more than one reference per actual contained object.
//
for(int intIndex = 0; intIndex < elementList.size(); intIndex++)
{
Object theObject = elementLi... |
445602d0-bdb9-4b71-b3e9-1d8b8dd50cd2 | 4 | public void reset() {
switch(ws.level) {
case 1:
ws.circuitList.clear();
tileManager.clear();
entityList.clear();
darknessAlpha = 1;
loadLevel();
break;
case 2:
ws.circuitList.clear();
tileManager.clear();
entityList.clear();
darknessAlpha = 1;
loadLevel();... |
f615ce5b-b861-4d59-b4cc-630dcdd937cc | 7 | public Stmts() {
// while (true) {
/* The program may have already reach it's end. */
int lexResult = 0;
boolean breakLoop = false;
if (Lexer.nextToken == Token.KEY_END || GlobalAttributes.braceEncounteredPreviously) {
lexResult = Lexer.nextToken;
GlobalAttributes.braceEncounteredPreviously = false;
... |
50609e94-ea7f-41f1-b7d5-642fb6e8222f | 9 | public static void algoritmoRetropropagacion(long epocas, double error, double[] salidasPatrones, double[][] entradasPatrones, RedNeuronal rnap){
int iteraciones=0;
boolean fin=true, fallo;
double errorPatron=0.0, errorMinimo=0.0, ecm=0.0, salidas[], errores[];
CapaNeuronal capa;
ArrayList<CapaNeuronal> perce... |
1c170b21-5ae3-465d-9245-c7d9e8ca36cb | 8 | private void kingMove(Point currentPoint, Piece currentPiece) {
addToMovesLocal(currentPoint, currentPiece);
Point targetPoint = pieceMove(currentPoint, 1, 0);
if (isOpenOrEnemy(targetPoint, currentPiece.getColor())) {
addToMovesTo(targetPoint, currentPiece, currentPoint);
}
targetPoint = pieceMove(current... |
1233582e-b8ec-415f-85e3-f2f048f23005 | 2 | public void startUpdate() {
if(updateThread == null) {
updateThread = new Thread(instance);
updateThread.start();
} else if(!updateThread.isAlive()) {
updateThread.start();
}
} |
854857ff-c820-4d98-998e-69af12f6d357 | 0 | public void setI(int num)
{
i = num;
} |
d1e41db3-d8b0-4161-a35c-3d77733e689c | 3 | public Site retonarDadosSite(int _id){
Site st = new Site();
StringBuilder sb = new StringBuilder();
ConexaoMySql cn = new ConexaoMySql();
sb.append("Select loja_cliente_Id, loja_cliente_nome, "
+ "loja_cliente_web_site, loja_cliente_caminho_foto "
+ "From... |
1ddc7197-842f-4bd9-909a-631831e62f66 | 1 | @Override
public void crearFichero(String ruta)
{
try
{
File outputfile = new File(ruta + this.getMetadato("nombre") + this.getMetadato("extension"));
ImageIO.write(this.imagen,this.getMetadato("formato"), outputfile);
} catch (IOException e) {
... |
b1b0cd21-0f2f-4008-bfbc-5db984945715 | 7 | private void loadImages(){
try
{
File directory = new File("src/resources/images/tiles/backtiles/");
File[] fileList = directory.listFiles();
for(File file : fileList)
{
String[] name = file.getName().split("\\.");
tileImageMap.put(Integer.parseInt(name[0]), new ImageIcon(file.getAbsolutePath(... |
8869c31b-cdef-4a07-9546-f44ea29f65ac | 3 | public Wall(int courtWidth, int courtHeight, int INIT_X) {
super(INIT_VEL_X, INIT_VEL_Y, INIT_X, INIT_Y, SIZE, SIZE, courtWidth,
courtHeight);
try {
img1 = ImageIO.read(new File(img_file1));
} catch (IOException e) {
System.out.println("Internal Error:" + e.getMessage());
}
try {
img2 = ImageIO.r... |
c6698a80-6da4-4b59-955f-dc01dc46baaa | 9 | public static int[] rotationArray(CharSequence S) {
int n = S.length();
Integer[] order = new Integer[n];
for (int i = 0; i < n; i++)
order[i] = i;
Arrays.sort(order,
comparador);
int[] sa = new int[n];
int[] classes = new int[n];
for (int i = 0; i < n; i++) {
sa[i] = order[i];
... |
3e86e912-460e-40fb-952d-0807d5c9280c | 9 | public void runGame() throws IOException {
// nameInitialisation();
fieldsInitialisation();
boolean finishGame = false;
while (finishGame == false) {
printCurrentStatus();
String choise = getChoise();
int x, y;
try {
y = Character.getNumericValue(choise.charAt(2));
x = Character.getNume... |
5326610c-3533-4725-a8f6-1b402b60db41 | 1 | public double bonusDefense(Peuple attaquant){
if(attaquant instanceof PeupleRats){
return 0.0;
}
return 1.0;
} |
4c4eb79f-b161-40b1-8420-09269184b50c | 3 | protected void loadKey()
{
File[] fileNames;
FileDialog dlgLoad = new FileDialog( this, "Load keystore...", FileDialog.LOAD );
dlgLoad.setFile( "*.ks" );
String psw = this.edPswLoad.getText().trim();
try {
this.pnlData.setVisible( false );
thi... |
d51a9d59-3d92-434a-b1e3-6c2b57091fb4 | 7 | public void simulatePopulation(String args){
ArrayList<String[]> players = new ArrayList<String[]>();
players.add(null);
players.add(null);
for (int i = 0; i < this.population.length; i += 2) {
players.set(0, this.population[i]);
players.set(1, this.population[i + 1]);
for (int j = 0; j < this.tri... |
5f3495ff-b8f0-43da-81b4-967a2ddb9e00 | 8 | private void addResponseHeaders() {
connection.getResponse().getHeaders().addParam(new Param<String, Object>(ResponseKeys.PROTOCOL.getValue(), connection.getRequest().getParams().get(RequestKeys.PROTOCOL.getValue()).getValue()));
connection.getResponse().getHeaders().addParam(new Param<String, Object>(R... |
e7ff7c8b-ea7c-4ef1-b97c-c41e095c293b | 4 | static private boolean jj_3R_18() {
Token xsp;
xsp = jj_scanpos;
if (jj_3_12()) {
jj_scanpos = xsp;
if (jj_3_13()) {
jj_scanpos = xsp;
if (jj_3_14()) {
jj_scanpos = xsp;
if (jj_3_15()) return true;
}
}
}
return false;
} |
b8f3d969-acc6-4c52-8715-e1fd0e616564 | 5 | public boolean getTileCollision(int r, int c)
{
// If it does not exist
if (r >= collisionMap.length || c >= collisionMap[0].length || r < 0 || c < 0)
return false;
if (collisionMap[r][c] == 1)
return true;
else
return false;
} |
40dfdb4a-9039-4cd3-9495-e1f315d77daa | 4 | private void sliderNbrPointsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderNbrPointsStateChanged
if (sliderNbrPoints.getValue() == 0){
nbrPointsAff = sliderNbrPoints.getValue()+1;
}
if (sliderNbrPoints.getValue() ... |
cb47e8ff-3c62-47fa-a576-594ab39d0044 | 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... |
23881db2-3fb6-44a2-a4df-9b3a729bf57e | 0 | public void setId(String value) {
this.id = value;
} |
49199b6f-6e6e-4339-877d-c0a488a39fb5 | 7 | final void printOut(String linePrefix) {
if (!Double.isNaN(informationDensity)) {
System.out.printf(linePrefix + "Estimated information density: %.1f%% (%.2f b/B)\n",
new Double(informationDensity * 100),
new Double(informationDensity * 8));
} else {
... |
33d75858-da0f-4cd0-9c79-4d302846ff1c | 6 | private void acceptOperation (SocketChannel socketChannel) {
Connection connection = newConnection();
connection.initialize(serialization, writeBufferSize, objectBufferSize);
connection.endPoint = this;
UdpConnection udp = this.udp;
if (udp != null) connection.udp = udp;
try {
SelectionKey selectionKey =... |
0fd1c5b6-842c-4502-b446-06c28c525aca | 5 | public void setOpen(boolean open) {
if (mOpen != open && (!open || open && canHaveChildren())) {
mOpen = open;
if (mOwner != null) {
mOwner.rowOpenStateChanged(this, mOpen);
}
}
} |
d09d52d8-b61d-4f01-81a1-b858bb4a8f2e | 7 | private String my_text()
{
String screen_text = construct.screen_text();
if(screen_text != null)
{
final String child_string = "$(node)";
StringBuilder builder = new StringBuilder();
FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
int lastChildEnd = 0;
int n... |
0353a595-2d34-4818-87ae-49bbcbd679a9 | 2 | public Lista<Rama_Hoja> getEntradas(){
Lista<Rama_Hoja> resp = null;
for (Nodo<Rama_Hoja> i = arrayIO.getHead(); i != null; i=i.getSiguiente()){
if(i.getIndex().split("_")[2]=="I")
resp.insertar(i.getDato());
}
return resp;
} |
f6a6a886-9d56-48c8-8afd-5dda3c84a054 | 4 | @Override
public void ejecutar(Stack<Valor> st, MemoriaDatos md, Cp cp)
throws Exception {
if (st.size() < 2)
throw new Exception("Y: faltan operandos");
Valor op1 = st.pop();
Valor op2 = st.pop();
if (op1 instanceof Booleano && op2 instanceof Booleano) {
st.push(new Booleano(((boolean) op1.getValo... |
e2db9727-5246-4154-8a43-c2897b2d3d68 | 8 | @Override
public List<String> generate(final String aValue) {
final List<String> result = new ArrayList<String>();
if (aValue == null || aValue.isEmpty()) {
return result;
}
if (aValue.length() == 1) {
result.add(aValue);
return result;
}
... |
b1ea40ec-8bb9-4ca9-aca0-c5cea460f739 | 3 | public List<String> formatMultiple(List<? extends Object> objList) {
final String command = buildFormatMultipleCommand(objList);
List<String> resultList = new ArrayList<String>();
CycList rawResult;
try {
rawResult = getCycAccess().converseList(command);
} catch (Exception ex) {
throw ne... |
20db8ba7-b3b5-4b52-9be1-dd708494b246 | 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... |
369a5ff5-abf7-4712-8fdd-f97b47c0674f | 2 | public GranosSimulator() {
addMouseListener(this);
addMouseMotionListener(this);
try {
granoImage = ImageIO.read(this.getClass().getResourceAsStream("/pruebagranos/grano.png"));
grano2Image = ImageIO.read(this.getClass().getResourceAsStream("/pruebagranos/grano2.png"));... |
dd4d015d-b8d6-46b5-8786-94ebe0189116 | 4 | private static int selectTableCount (final int mtfLength) {
if (mtfLength >= 2400) return 6;
if (mtfLength >= 1200) return 5;
if (mtfLength >= 600) return 4;
if (mtfLength >= 200) return 3;
return 2;
} |
259772e2-f6fa-4c8e-8930-e082438b487c | 7 | int getMedian(int start1, int start2, int n)
{
int m1,m2;
if(n < 0)
{
return -1;
}
if(n == 1)
{
return (arr1[start1] + arr2[start2])/2;
}
if(n == 2)
{
return max(arr1[start1] , arr2[start2]) + min(arr1[start1+1] , arr2[start2+1])/2;
}
m1 = median(arr1,start1,n);
m2 = media... |
d273ce10-0fc3-4eb6-8199-447b36732a76 | 8 | public void checkTableStructure(TableRegistration table) {
// TODO Update table structure
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM ")
.append(table.getName())
.append(" LIMIT 1");
try {
ResultSetMetaData meta = conn.prepareStatement(query.toString()).executeQuery().getMe... |
2dfc0b57-cd43-4a31-a838-a31d761dc277 | 4 | public Gerador(ExpressaoGeradora[] cartucho){
this.cartucho = cartucho;
distribuicao = new int[cartucho.length - 1];
int total = 0;
for (int i = 0; i < cartucho.length; i++)
if (cartucho[i].getPeso() > 0)
total += cartucho[i].getPeso();
if (t... |
2313e642-59b9-4fde-8814-8bf311d8a202 | 3 | private void paintInfoForAllEnemies(Graphics2D g2) {
for (int y = 0; y < Board.getHeight(); y++ ) {
for (int x = 0; x < Board.getWidth(); x++) {
if (!board.getPriorityMap().isEmpty(x,y)) {
g2.setColor(Color.BLACK);
g2.drawString(stringConverter... |
1a7fff72-b9d3-4fa5-901a-5ef7cedad028 | 0 | public void update(long elapsedTime) {
// do nothing
} |
e0161504-b39d-4c55-a6b9-68066fc2a380 | 7 | public void PostConnect() {
this.WriteLogtoConsole("looking for autosave.config to read camera parameters");
if (LoadConfigFile("autosave.config")) {
this.WriteLogtoConsole("autosave.config loaded successfully");
} else {
this.WriteWarningtoConsole("autosave.config not found, falling back to default.config... |
b015fb0c-ed6b-4d33-99af-9d770df7bece | 6 | public int calcSprite(int x, int y, int bgIndex) {
// System.out.println("Sprite calc:" + x + " , " + y);
for (int i = 0; i < 8; i++) {
int yVal = 1 + spriteScanline[i * 4] & 0xFF;
int offY = y - yVal;
int xVal = spriteScanline[i * 4 + 3] & 0xFF;
i... |
d21eaf4f-56c9-4187-9fce-1350553c2515 | 3 | public void drawWorld(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
World world = universe.getWorld();
int width = world.getWidth();
int height = world.getHeight();
for(int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
Color color = world.getCellAt(i, j) == Cell.LIVING ? Color.DARK_GRAY: ... |
49f5da5e-ffc2-4ec0-826b-e4812978da82 | 4 | @Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
String login = loginField.getText().trim();
String password = passwordField.getText().trim();
if (!checkFields(login, password)) {
return;
}
User user = null;
i... |
74cc0d7b-f0a2-4f62-8e50-8e51e6c4a05e | 8 | private void registerKeyPressedEvent(KeyPressedEvent e, MapDef m) {
if (e.getID() == KeyPressedEvent.KEY_RELEASED) {
keysCurrentlyDown.remove(e.getCharCode());
if ((option.isCapsSendsUpAndDownNotEnabled())
) {
//logger.debug("Turning CAPSLOCK off - key... |
6e8f81d5-ddb0-4616-beba-a7b324fcfd8a | 8 | private void logBindInfo(Method method) {
boolean debugEnable = LOGGER.isDebugEnabled();
if (cacheDefinition != null && debugEnable) {
LOGGER.debug("绑定" + getCacheDescription(cacheDefinition) + "到方法[" + method + "]成功");
}
if (cacheDeleteDefinitions != null && debugEnable) {
for (CacheDeleteDefinition de... |
268107e9-6f50-4d3e-84b7-ffbef6000f3c | 1 | public int instructionDecode() { //Returns int value of opcode
Instruction instr = getIR().read();
int opcodeValue = instr.getOpcode().getValue(); //Gets instruction opcode as int value
getPC().incrementPC(); //Increment PC; done here so that with pipelining, the next instruction can be fetched at this point
th... |
49b74821-595a-49be-a4b9-a5ec43ca7853 | 8 | public void checkTableStructure(TableRegistration table) {
// TODO Update table structure
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM ")
.append(table.getName())
.append(" LIMIT 1");
try {
ResultSetMetaData meta = connection.prepareStatement(query.toString()).executeQuery()... |
5496ddaa-c9e8-4fcc-8dad-d7431110576f | 8 | public void cargar_check(String name) throws SQLException {
if (name == null) {
return;
}
rs = MiConexionBD.getSql().executeQuery("SELECT permission FROM perfil WHERE name = '" + name + "'");
if (rs.next()) {
int value = rs.getInt("permission");
limpia... |
1efbe327-cc9a-401e-9898-33e3c1d68fe4 | 2 | public static Commercial selectById(int id) throws SQLException {
String query = null;
Commercial util = new Commercial();
ResultSet resultat;
try {
query = "SELECT * from COMMERCIAL where ID_COMMERCIAL=? ";
PreparedStatement pStatement = ConnectionBDD.getInsta... |
50eb932a-1e6c-451c-a2ca-7e2e0ed30c99 | 8 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (colonized ? 1231 : 1237);
result = prime * result + (containsRobot ? 1231 : 1237);
result = prime * result
+ ((elements == null) ? 0 : elements.hashCode());
result = prime * result + ((holes == null) ? 0 ... |
732aa8d0-d121-43f0-8a6f-8e06df91b69a | 4 | private static List<String> ips(List<Integer> a, List<Integer> b, List<Integer> c, List<Integer> d) {
List<String> ip = new ArrayList<String>();
for (Integer ai : a) {
for (Integer bi : b) {
for (Integer ci : c) {
for (Integer di : d) {
... |
8e4d2902-a4f6-4bd8-b7a3-e184690681a2 | 2 | public void drawCard(Graphics g, JComponent theJPanelInstance) {
Image cardPic;
int fileNumber;
if (hasBeenRemoved) {
return;
}
if (isFaceUp) {
fileNumber = suit * KPanel.CARDS_IN_EACH_SUIT + value;
cardPic = CardImageLoadU... |
7174911e-a48f-438b-902e-691f1c4d5a78 | 1 | void reset() {
Set<VoieEnum> voies = voituresEnAttentes.keySet();
for (VoieEnum voie : voies) {
voituresEnAttentes.put(voie, new AtomicInteger(0));
attenteParVoie.put(voie, new AtomicLong(0));
voituresEngageesParVoies.put(voie, new AtomicInteger(0));
voituresEntrees.put(voie, new AtomicInteger(0));
v... |
4c4efaeb-c7a2-4dc0-b59b-ce8921d7045d | 6 | public int[] plusOne(int[] digits) {
int len = digits.length;
if (len == 0) {
return digits;
}
if (digits[len - 1] != 9) {
digits[len - 1] = digits[len - 1] + 1;
return digits;
}
int index = len - 1;
while (index >= 0 && digits[index] == 9) {
index--;
}
if (index == -1) {
// digits =... |
733cfdb0-d29a-42d6-ae1a-94d22c1c4b43 | 6 | private Location findFood()
{
Field field = getField();
List<Location> adjacent = field.adjacentLocations(getLocation());
Iterator<Location> it = adjacent.iterator();
while(it.hasNext()) {
Location where = it.next();
Object animal = field.getObjectAt(where);
... |
47d92ad5-4900-4221-963f-2f07d5e41c37 | 2 | @Override
public Action putAction(Action a) throws JSONException, BadResponseException {
Representation r = new JsonRepresentation(a.toJSON());
r = serv.putResource("intervention/" + interId + "/action", null, r);
Action action = null;
try {
action= new Action(new JsonRepresentation(r).getJsonObject()... |
551c20ab-a613-4a2d-9eb2-8e18a58358c7 | 1 | public static void main(String[] args) throws Exception {
Scanner //sc = new FastScanner(System.in);
sc = new Scanner(System.in);
String in = sc.nextLine();
if(isPangram(in)) System.out.println("pangram");
else System.out.println("not pangram");
} |
6a6b8843-2f0b-43bb-9667-df41212b942f | 9 | public boolean searchMatrix(int[][] matrix, int target) {
if (matrix == null) {
return false;
}
int row = matrix.length;
int col = matrix[0].length;
if (row == 0 || col == 0) {
return false;
}
int i = 0;
int j = col - 1;
while (i >= 0 && i < row && j >= 0 && j < col) {
if (matrix[i][j] == tar... |
d8ab93fd-0c0a-483a-a03b-9af4bab2a1e5 | 6 | @Override
public void draw(Graphics g) {
//Draw Score Card
g.setFont("Arial", Graphics.BOLD, 25);
g.setColor(Color.WHITE.getRGB());
g.drawString("Score:",GamePanel.GAMEWIDTH+20,70);
g.setFont("Arial",Graphics.PLAIN,15);
g.setColor(Color.G... |
94eb9abc-4dde-43c8-972c-270da76899ad | 3 | private void loadTexture(String pTextureUrl, GL2 gl) {
if (pTextureUrl != null) {
Path texture = FileSystems.getDefault().getPath(pTextureUrl);
if (texture.toFile().exists()) {
try {
planeTexture = TextureIO.newTexture(texture.toFile(), true);
... |
dba2eba8-a6b7-4988-948e-51f2ae14ad33 | 7 | public int getDamage(){
int dmg = 0;
int rand = (int) (Math.random() * 100);
if(rand < 50){
dmg = level;
}else if(rand < 60){
dmg = (int) (level * 1.2);
}else if(rand < 70){
dmg = (int) (level * 1.4);
}else if(rand < 80){
dmg = (int) (level * 1.6);
}else if(rand < 90){
dmg = (int) (level * ... |
5f701d98-11a7-4143-a889-747dfbad5ea0 | 4 | public void update(int deltaTime) {
stateTime += deltaTime;
// Animate animation
if (animating) {
// Cycles through each image in animation
while (stateTime > timeBtwnImages) {
stateTime -= timeBtwnImages;
currentIndex++;
if (currentIndex >= images.length) {
onAnimationComplete();
... |
502b4c57-13b8-4c59-89a7-89508f0fbe38 | 2 | public void taBort(String hornNamn)
{
Punkt[] h = new Punkt[this.horn.length - 1];
int i = 0;
int i2 = 0;
for(i = 0; i < this.horn.length; i++)
{
if(this.horn[i].getName() == hornNamn)
{
continue;
}else
{
h[i2] = this.horn[i];
i2++;
}
}
} |
dfdbfaa6-7cd0-4923-aa8f-d36bc25c7209 | 7 | public byte tmat(String fileName) throws IOException {
initialize(fileName);
FileOutputStream fos = null;
DataOutputStream dos = null;
try{
// create file output stream
fos = new FileOutputStream("tmat_bin");
// create data output stream
dos = new DataOutputStream(fos);
St... |
3ae9857c-d483-47cc-ab98-c64b6b66513f | 8 | public List<T> find(T start, T goal, StopDemander stop) {
Node<T> startNode = new Node<T>(start, null, estimator.estimate(start, goal));
if (start.equals(goal)) {
return startNode.getPathElements();
}
Map<Integer,Node<T>> queue = new TreeMap<Integer,Node<T>>();
Map<T,Node<T>> visited = new HashMap<T,Nod... |
b4bf94bf-9fb6-48b5-a545-05e5106c0533 | 3 | @Override
public void run() {
// TODO Auto-generated method stub
CImedWrapper wrapper = new CImedWrapper(this.getProxy(), this.getUsername(), this.getPwd());
boolean bServiceAvailable = false;
boolean bReportingAvailable = false;
try{
bServiceAvailable = wrapper.CheckServiceAvailable();
... |
dc3be83d-8987-45bb-9c34-393014a7899f | 7 | public static Account getAccount(String login, String password) throws LoginLogicException {
Connection connection = null;
try {
MessageDigest digest = MessageDigest.getInstance(ALGORITHM);
digest.update(password.getBytes(ENCODING));
String encryptedPassword = DatatypeConverter.printHexBinary(digest.di... |
e093efec-6829-4f1b-a7cf-404a70e30938 | 4 | public double getUnigramTokenToEntityCount(String token,String rawToken,String entity) {
String str;
if (token==null || entity==null) {
return 0;
}
Double d=UnigramTokenToEntityCounts.get(token, entity);
if (d==null) {
str=getMysteryString(rawToken);
d=UnigramTokenToEntityCounts.get(str, entity); ... |
1912ae31-1318-4e7b-ac78-a019394633ee | 7 | public boolean moveNorth(int w)
{
boolean moved = false;
if(!isFighting && isConcious() && getEnergy()>0)
{
if(w==3 || w==4)
{
setY(getY()-1);
moved = true;
}
else if(w>=10)
{
updateLocation... |
8c465bea-023f-41cf-80b8-4bb88345bf38 | 5 | private void addDetails( Node thisNode, String key )
{
StringBuffer buffer;
buffer = new StringBuffer();
NodeList detailNodes = thisNode.getParentNode().getChildNodes();
for ( int i = 0; i < detailNodes.getLength(); i++ )
{
if ( ( detailNodes.item( i ).getNodeName().equalsIgnoreCase( "unitti... |
e859ffd1-6ad9-4692-84a8-e47ba754bc06 | 2 | public static ReservedSpaceFacilityEnumeration fromValue(String v) {
for (ReservedSpaceFacilityEnumeration c: ReservedSpaceFacilityEnumeration.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
} |
0069e57a-adad-43d3-a60b-94c3bfd1db8b | 0 | public double[] getThermConst() {
return this.tc;
} |
5be5be3d-2c71-46c9-94eb-c0824ebb3afb | 4 | public void compute() {
// Find nearest enemy
Opponent nearest = null;
float nearestDistance = 9999999f;
Opponent[] opponents = getOpponents();
for (int i = 0; i<opponents.length; i++) {
float distance = Vector3D.subtract(opponents[i].getLocation(), getLocation()).getMagnitude();
if (distance < nearestD... |
8345075c-cb8a-47c2-a602-f76c6ce992f0 | 5 | public static String getJSON(String url) throws IOException {
BufferedReader bis = null;
InputStream is = null;
try {
URLConnection connection = new URL(url).openConnection();
is = connection.getInputStream();
// warning of UTF-8 data
bis = new BufferedReader(new InputStreamReader(is... |
42acd498-45a4-434a-8a6b-85233a38c820 | 3 | int NextClientId()
{
int clientId = 0;
for(ClientHandler client : clientFramework)
{
if(clientId == client.clientId)
{
clientId++;
}
else if(clientId < client.clientId)
{
return clientId;
}
}
return clientId;
} |
d0af9ac6-cdb8-4027-b853-4d6a64896194 | 4 | private int PayFine() {
String date = new java.text.SimpleDateFormat("yyyy/MM/dd").format(new java.util.Date());
int rate = 1;
int duration = 0;
int timeLimit = 0;
int borid = 0;
boolean a = false;
try {
timeLimit = LibraryDB.getManager().getTimeLimit(bid);
} catch (SQLException e) {
System.out... |
690515d1-e6d3-47b9-bf3c-40b4540ea4ea | 2 | public void writeToken(String token) throws Throwable
{
File file = new File("token.txt");
if (!file.exists())
{
file.createNewFile();
}
if (token == null)
{
file.delete();
return;
}
PrintWriter bw = new PrintWriter(file);
bw.println(token);
bw.close();
} |
d77d619f-49d1-49ae-832d-2f1d88d5da3b | 6 | private void getSaisieCryptanalyseCle() {
ISaisieCryptanalyseCle s=new SaisieCryptanalyseCle(this, this.menu);
while(s.estEnCours() && !this.stop) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
s.masquer();
if(!this.stop) {
if(s.getType()!=null) {
IMessage m=s.getMessage... |
3538098a-1a45-4c50-bf38-a05ddf24ad6d | 0 | @Id
@Column(name = "PCA_SUBGRU")
public Integer getPcaSubgru() {
return pcaSubgru;
} |
af32beee-0167-4867-9e01-d2634fc558ba | 8 | public Ast.AstDeclaration parse_Declaration(SpecObject specObject, String property)
{
int at = m_current;
if (!ok())
{
return null;
}
Ast.AstBasicDeclaration dnode = parse_BasicDeclaration(specObject, property);
if (dnode != null)
{
... |
ffe319b9-839a-42a8-b5a9-7b2091defca4 | 1 | public int getElementContentType(String name)
{
Object element[] = (Object[]) elementInfo.get(name);
if (element == null) {
return CONTENT_UNDECLARED;
} else {
return ((Integer) element[0]).intValue();
}
} |
cba3f400-e9c3-47eb-baab-14a2f83626ed | 4 | public String getApplicationPath() {
String sep = File.separator;
String osName = System.getProperty("os.name");
//String path = System.getProperty("file.separator");
String programPath = System.getenv("ProgramFiles");
if (osName.equalsIgnoreCase("Mac OS X")) {
File f = new File(sep + "Applications" + sep ... |
183df328-c520-4f87-a54b-05abd047a67e | 1 | @Test
public void tosiPieniEsteVasemmalla() {
laitetaasPariPientaEstetta();
t.lisaaEste(new Este(0, 92, 1000, 200));
pe.siirra(900, 0);
pe.liikuVasemmalle();
for (int i = 0; i < 100; i++) {
pe.eksistoi();
}
assertTrue("Hahmo ei päässyt matalan est... |
f3f81d9d-997c-4024-a7a3-c71ea8ce5569 | 5 | private void heapify(int i) {
int smallest;
int left = leftChild(i);
int right = rightChild(i);
if (right <= heap_size) {
if (ar[left].getKey() < ar[right].getKey()) {
smallest = left;
} else {
smallest = right;
}
... |
49e8375a-1006-43cb-97d6-b5058d1b00f2 | 3 | public static Missile getMissileById(String id, War war) {
Vector<Launcher> missileLaunchers = war.getMissileLaunchers();
int size_launcher = missileLaunchers.size();
for (int i = 0; i < size_launcher; i++) {
Launcher l = missileLaunchers.elementAt(i);
int size_missile = l.getMissiles().size();
for (int ... |
6d922707-966e-41a2-9b42-34e80ccd8b12 | 0 | @Test
public void testDirFromString() {
System.out.println("dirFromString");
String name = "LEFT";
Turn.direction expResult = Turn.direction.LEFT;
Turn.direction result = Turn.dirFromString(name);
assertEquals(expResult, result);
name = "RIGHT";
expRe... |
913b43e2-a740-4c8a-b76e-03e3ae84d278 | 4 | public String generate() {
String error = "No errors.";
if (details)
System.out.println("Forest flags: PRODUCE="+ioflags.PRODUCE+", SAVE="+ioflags.SAVE+", LOAD="+ioflags.LOAD);
if (Utils.flagsCheck(ioflags) != 0) {
System.out.println("ERROR: IOFlags object is corrupted, error: "+Utils.flagsCheck(iofla... |
fce19a0c-654f-464d-ad78-1178bfff3510 | 6 | public boolean maior(Tempo t){
if ( hora>t.hora ||
(hora==t.hora && minuto>t.minuto) ||
(hora==t.hora && minuto==t.minuto && segundo>t.segundo ))
return true;
return false;
} |
86369748-83f9-4840-9915-87baeb6a8b2b | 5 | public SolutionItem solve(SolutionItem puzzleToSolve)
{
//determine what is the first number to insert the puzzle:
puzzleToSolve.nextToInsert = getNextNumToInsert(puzzleToSolve.puzzle, 1);
puzzlesList.addLast(puzzleToSolve);
while( true )
{
++numSteps;
... |
35e69c6c-d8c1-4982-9c65-1a93545fd474 | 8 | private Collection<? extends CRL> getCRLs(String crlf) throws IOException, CRLException,
CertificateException {
File crlFile = new File(crlf);
if (!crlFile.isAbsolute()) {
crlFile = new File(System.getProperty("catalina.base"), crlf);
}
Collection<? extends CRL> crls = null;
InputStream is = null;
tr... |
2fd559c4-397d-4b0a-895f-6575e171a37f | 8 | private void DelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DelButtonActionPerformed
if (FocusOwnerIndex == 1) {
if (NumberField1.getCaretPosition() != NumberField1.getText().length()) { // only do something if the caret is not the at the end
int tmpcaret... |
23656ff9-5756-462f-9dfd-38212904ad37 | 5 | public boolean check(BattleFunction iface, PokeInstance user, PokeInstance target, Move move) {
if (valid) {
if (target.battleStatus.lastMove == -1) {
iface.print("The move failed...");
return false;
}
if (target.getPP(target.battleStatus.lastMove) == 0) {
iface.print("The move failed...");
r... |
5d685a05-ead4-44a2-85f8-0325d99af136 | 3 | public void writeRawDataToFile(String filename)
{
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filename), false));
bw.write("X,Y,R,Count");
bw.newLine();
for(Map.Entry<Coordinate2D, Map<Integer, MutableFloat>> coordEntry : data.entrySet())
{
Coordinate2D c = coordE... |
94c82b78-d7b3-4cd8-80b0-aed8b86d6a49 | 3 | public static void getPlayer() {
// TODO
try {
Statement s1 = conn.createStatement();
ResultSet rs = s1
.executeQuery("Exec getRegion");
if (rs != null) {
while (rs.next()) {
int regionID = rs.getInt("regionID");
String controlling = rs.getString("controlling");
int controlValue ... |
14f46b7b-9d17-4e95-9978-8243fd573c9a | 3 | public void selectNewPoint(Player player, Location blockLoc, boolean isLeftClick)
{
msgLib = new MessageLib(player);
if (isLeftClick == true)
{
if (blockLoc1.containsKey(player))
blockLoc1.remove(player);
blockLoc1.put(player, blockLoc);
msgLib.standardMessage("Succ... |
fa0102d0-1a1c-4f00-9708-0c99485d6d4a | 2 | public static void main(String argv[])
{
int port_number = Integer.parseInt(argv[0]);
try
{
ServerSocket serv = new ServerSocket (port_number);
Socket clientSock = serv.accept();
System.out.print("Client accepted \n");
PrintWriter out = new PrintWriter(clientSock.getOutputStream(),true);
BufferedR... |
46fca9c1-a1fe-4c06-8eb1-5dd8a0841d36 | 2 | public static boolean isRegularGrammar(Grammar grammar) {
if (isRightLinearGrammar(grammar) || isLeftLinearGrammar(grammar))
return true;
return false;
} |
9f775b03-aa6e-4338-bd3b-d37314852b1a | 0 | public CommandHandler getCommandHandler() {
return this.chandle;
} |
9f488f47-6965-4113-abec-4425a04cc8e6 | 2 | boolean pressSystemKey(int keyValue){
try{
Robot r = new Robot();
r.keyPress(keyValue);
if( isSound==true ){
Sound s = new Sound();
s.play("ARROW.WAV");
}
return true;
}catch(Exception e){
System.out.... |
496783d2-d413-4484-bce8-27da69104e26 | 8 | public void clearRecipeSlots(){
if(recipeSlot1.getItem() != null){
if(!inventory.add(recipeSlot1.getItem())){
Entity.getPlayer().itemsPending.add(recipeSlot1.getItem());
}
recipeSlot1.setItem(null);
recipeSlot1.findIcon();
}
if(recipeSlot2.getItem() != null){
if(!inventory.add(recipeSlot2.getIt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.