method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
e43e4af2-3888-4953-a470-f3acd184c0df | 5 | public static HashMap<String, String> getMeta(Class<?> cl) {
HashMap<String, String> ret = new HashMap<String, String>();
FileSystemResource resource = new FileSystemResource(META_FILE_NAME);
File text = resource.getFile();
try{
BufferedReader br = new BufferedReader(new Inpu... |
4a96b39e-cce0-4651-9a07-2c7169881ff7 | 5 | @Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
//TODO: Get sprites
Image[] mUP = {new Image("res/Zornespritefs.png"), new Image("res/Zornespritefs.png")};
Image[] mDown = {new Image("res/Zornespritefs.png"), new Image("res/Zornespritefs.png")};
Image[] mLeft = {new Im... |
52ad723b-dc41-488a-9c66-ba88fc3f3125 | 9 | public String getAddTransPhysical(MemPartition b, int logicalAddr, List<MemPartition> memory) {
// logicalAddr belongs to process logical space
ProcessComplete p = b.getAllocated().getParent();
// Segment ?
int startsegment = 0;
ProcessComponent programSegment = null;
boolean found = false;
int i = 0;
... |
f3e139b2-b624-4dbd-9435-32e7787d1497 | 9 | public String getCommandTypeName(int commandType)
{
Integer commandTypeKey = getCommandTypeKey(commandType);
if (null == commandTypeKey)
{
return "UNKNOWN COMMAND TYPE 0x" + Integer.toHexString(commandType);
}
switch(commandTypeKey.intValue())
{
... |
0cc8a4cc-0d14-4c43-bb9a-a27a6c6739fc | 8 | private void create(Shell parent, int inSym) {
result = -1;
FormLayout layout = new FormLayout();
layout.marginTop = 5;
layout.marginBottom = 5;
layout.marginLeft = 5;
layout.marginRight = 5;
layout.spacing = 5;
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
shell.setText("Sym L... |
62e16e9e-e499-4043-8840-8a7ef41ed0a9 | 7 | public void update_MessageTrace(String msg){
if(reorder_msg==0 || reorder_msg==1){
synchronized(test_network.MessageTrace){
String whoamI="";
if(test_index<test_network.numProposers())
whoamI="Proposer - "+test_index;
if(test_index>=test_network.numProposers() && test_index<... |
fe7959e6-de7a-47dd-8e8e-818ab2b05f5f | 6 | public static boolean banPlayer(String[] args, CommandSender s) {
//Various checks
if(Util.isBannedFromGuilds(s) == true){
//Checking if they are banned from the guilds system
s.sendMessage(ChatColor.RED + "You are currently banned from interacting with the Guilds system. Talk to your server admin if you beli... |
f93d3a20-f424-4ee2-9799-3b10093c6dae | 2 | public boolean ExistsInVector(Vector<Move> moves){
for (int i = 0; i<moves.size(); i++){
if (this.Equals(moves.elementAt(i))){
return true;
}
}
return false;
} |
14dbc8a6-8996-4b84-a800-5de20f394496 | 5 | @Override
public void run() {
do {
try {
getNextChar();
if (isEndOfStream())
closeRemainingStreams();
else if (isSeperatorMet())
checkSeparator();
else if (shouldCheck)
ch... |
70686479-7a91-4812-b59c-180324e4cdc5 | 4 | public static boolean checkInputs(String startingAmount, String goalAmount, DateTime beginDate, DateTime endDate )
{
boolean valid = true;
if(!GeneralUtill.stringToBigDecimalCheck(startingAmount)){
GuiUtill.showError("Incorrect input", "please put in the correct in put in your starting amount");
valid = f... |
d0151071-35de-43cb-a0cc-4ade3896eb3d | 8 | public static void main(String[] args) throws Exception {
String env = null;
if (args != null && args.length > 0) {
env = args[0];
}
if (! "dev".equals(env))
if (! "prod".equals(env)) {
System.out.println("Usage: $0 (dev|prod)\n");
... |
d828b5de-6102-4981-93ca-2b7d40a20109 | 7 | public static void main(String[] args)throws Exception {
DerbyHelper db = new DerbyHelper("Library", 1527,"app","app");
// List<String> cmd = Files.readAllLines(Paths.get("DataBook.txt"), StandardCharsets.UTF_8);
// for(String s : cmd){
// List<String> params = Arrays.asList(s.split(",... |
182b5694-bd6c-4077-b1a9-381cbdb903a3 | 3 | private Expression rest( List<Expression> args, String caller ) {
if ( args.size() != 1 ) {
System.err.println("rest/tail expected exactly one argument and got " + args.size() );
return new Void();
}
Expression expr = args.get(0).eval(defSubst, caller);
if ... |
c7a1d343-8406-494e-a1c4-5baa5f3da307 | 0 | public File getConfigFile() {
return this.config_file;
} |
c0728da5-b6b9-4018-a4c4-bf5f7706547e | 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(Boolean.T... |
933da435-6861-41b4-b243-fdc7969ff171 | 2 | private void checkType(String key, Class<? extends Object> clazz) throws NoConfigException, DataWrongTypeException {
List<String> keys = this.config(clazz);
if (!keys.contains(key)) {
throw new DataWrongTypeException(String.format("%s got the wrong type[%s].", key, clazz.getName()));
}
} |
14638328-04da-4d76-8719-93a5d36a1e5d | 2 | public final void setEnd() {
panel.setBackground(Color.BLACK);
String text;
if (correct > incorrect || correct == incorrect) {
text = "<h1>YOU WIN!</h1>";
} else {
text = "<h1>YOU LOSE!</h1>";
}
text += "<h2>You answered " + (int) (correct) + " of ... |
68f87cbd-84a9-42d2-b1a5-83d14d6cdf17 | 3 | @Override
public String toString() {
String board = "===\n";
for (int i = 7; i >= 0; i--) {
board += " ";
for (int j = 0; j < 8; j++) {
board += " " + _contents[i][j].textName();
}
board += "\n";
}
String t = turn().toSt... |
1a70f528-f0fb-4ad0-ba42-26ca08369f58 | 5 | int getCountCorrect()
{
int count = 0;
for(int i=0;i<sudokuSize;i++) {
for(int j=0;j<sudokuSize;j++) {
if(cells[i][j].valueState == intializedByServer || cells[i][j].valueState == acceptedByAgent || cells[i][j].valueState == acceptedByUser)
count++;
}
}
return count;
} |
07b3f386-3e7c-417d-a86c-e20f46c41f47 | 7 | public int showPlayerSelect() {
JPanel panel = new JPanel();
JLabel chooseText = new JLabel();
panel.add(chooseText);
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
ButtonGroup buttongroup = new ButtonGroup();
JRadioButton[] buttons = new JRadioButton[6];
// makes radio button for eac... |
554ff30e-5c05-49c8-b155-20a2efb19c8e | 8 | private int percolateDown(int hole, E value){
while(hole*4 + 1 <= index){
// compare the four children of the given hole find out the one with smallest value
// for the index i, its parent index is (i-1)/4, its children are 4i+1,..,4i+4
int target = hole*4 + 1; // first child
int second = hole*4 + 2; // s... |
52063817-fb20-4ae4-8523-ffa2d1a4524e | 5 | private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed
String searchString = txtFieldSearch.getText();
ArrayList<Staff> foundStaff = new ArrayList<Staff>();
if (searchString.isEmpty()) {
foundStaff = Controller.Instance().g... |
a1a20fd3-c72d-45eb-9682-c36215cff681 | 6 | public void waitForConnect()
{
// fire off an action even to tell the GUI to display the waiting for
// client dialogue
// Start up a ServerSocket on port PORTNUM.
try {
serverSocket = new ServerSocket(PORTNUM);
} catch (IOException e) {
// Should be an action... |
cee1e056-604b-474f-a4a6-522ab50e977f | 1 | private static void restartMIFU(){
try {
@SuppressWarnings("unused")
Process proc = Runtime.getRuntime().exec("java -jar "+CONSTS.UDIR+"/MIFU.jar");
} catch (IOException e) {
e.printStackTrace();
}
System.exit(0);
} |
fbb9446d-6a92-45b3-b71e-f05aba83bbe4 | 6 | public NationOptions(Specification specification, Advantages advantages) {
this.specification = specification;
setNationalAdvantages(advantages);
if (specification != null) {
int counter = 0;
Map<Nation, NationState> defaultNations = new HashMap<Nation, NationState>();
... |
dee8cce8-7e79-407e-a980-d3c24945952a | 3 | * @Post: The appropriate rook is moved to the point that the king jumped over
* @Return:
*/
private void moveCastlingRook(Point p) {
if(chosenPiece.getX()-p.x>0)//left castle, move rook two right
{
Piece theRookToMove = getPiece(new Point(0,chosenPiece.getY()));
if(! (theRookToMove instanceof Rook))
... |
f135c777-dd61-4b0f-a0a6-cae03812a70c | 7 | public void loadMapData(boolean enableBWTA) {
String mapName = new String(getMapName());
map = new Map(getMapWidth(), getMapHeight(), mapName, getMapFileName(), getMapHash(),
getHeightData(), getBuildableData(), getWalkableData());
if (!enableBWTA) {
return;
}
// get region and choke point data
File... |
a0636381-6d21-4ac0-a8ca-54cd9296e4c6 | 8 | public void rechPeriodique(String livre) {
Integer issn = this.getIdentifiant(livre);
Periodique per = this.getPeriodique(issn);
if (this.getVueConsulterPeriodique() != null) {
per.addObserver(getVueConsulterPeriodique());
getVueConsulterPeriodique().setPeriodique(per);
per.notifierObservateurs();
... |
47ed0c29-1d43-407d-a71e-cd4b9cf66aea | 1 | public static void main(String[] args) {
if (args.length == 2) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
double c = Math.sqrt(a * a + b * b);
System.out.println(c);
}
} |
faa6f514-94c8-465f-8181-acc72ba52120 | 3 | public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_N){
reset();
}
if(e.getKeyCode() == KeyEvent.VK_D && cardStack.size() > 0){
dealNewRow();
}
repaint();
} |
ef2c0cb9-5323-4a34-a750-3cc6d9d9e097 | 1 | public void addCommand(Command _command) {
if(!this.hasCommand(_command)) {
this.commands.add(_command);
}
} |
1cd9ff73-2a1d-424e-aa68-5627009676e3 | 8 | public PlanBooster(JSONObject object, Object boost) throws FatalError {
super("Booster");
if (boost != null && boost instanceof Integer) {
booster = (Integer) boost;
} else {
throw new ConfigError("Booster");
}
switch (this.booster) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
bre... |
4a30c9f8-a756-4102-8b22-d7cc96cd673c | 0 | public void setSector(String sector) {
Sector = sector;
} |
22c93ad4-76a3-446f-b3ea-49b8da86ee1e | 7 | private Instances assignClassValue(Instances dataSet) {
if (dataSet.classIndex() < 0) {
if (m_logger != null) {
m_logger.
logMessage("[ClassValuePicker] "
+ statusMessagePrefix()
+ " No class attribute defined in data set.");
m_logger.statusMessage(statusMessagePrefix()
+ "WARNING: N... |
a8c66527-a182-40a0-956c-b2b751759286 | 2 | public String join(String separator) throws JSONException {
int len = this.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i += 1) {
if (i > 0) {
sb.append(separator);
}
sb.append(JSONObject.valueToString(this.myArrayL... |
99f01a45-fa9b-4630-a4b0-174e5ad6a311 | 6 | public void onCommand(CommandSender sender, ChunkyCommand command, String label, String[] args) {
if (!(sender instanceof Player)) {
Language.IN_GAME_ONLY.bad(sender);
return;
}
if (args.length == 0) {
Language.CMD_CHUNKY_PLAYER_SET_MODE_HELP.bad(sender);
... |
685d9350-7b77-4795-a070-fb2a25ba1a0e | 0 | protected double getBreedingProbability()
{
return BREEDING_PROBABILITY;
} |
a1d1b8ec-2327-4a2f-9358-87c3f1a2596f | 1 | public synchronized HashMap<String, GameObjectInformation> updateGameObjects(int userID, Integer[] actions, HashMap<String, GameObjectInformation> clientPlayerObjects, int gameID) throws UnknownHostException, IOException, SocketTimeoutException, ClassNotFoundException {
if(actions == null){
actions = new Integer[0... |
7bc492ef-045b-4a94-9644-16e0ac82b1b8 | 5 | public void addUnits(int x, int y, char ch) {
if (units.isEmpty()) {
left = right = x;
top = bottom = y;
} else {
if (x < left)
left = x;
else if (x > right)
right = x;
if (y < top)
top = y;
else if (y > bottom)
bottom = y;
}
units.add(new Unit(x, y, ch));
} |
25f580bb-00e8-459d-be2b-9ce8fde3fdc4 | 7 | public List<Team> simulateGroupStage(int nWinners, boolean verbose, int nTimeSteps) {
if(teams.size() < 2) return null;
//Get all 2 element combinations of all teams in group,
//simulate match.
for(int i = 0; i < teams.size()-1; i++)
for(int j = i+1; j < teams.size(); j++) {
Team A = teams.get... |
490417df-1a94-4a8c-ba40-07d1635c9102 | 9 | public void loadBanPhraseList() {
banPhraseLists = new HashMap<Integer, List<Pattern>>();
File f = new File("bannedphrases.cfg");
if (!f.exists())
try {
f.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
... |
1788cd9c-2808-48f0-9d26-71f9777d388d | 0 | private void setWeight(double m) {
this.weight = m;
} |
b758f42c-4b37-45e5-98dd-e5b9a0e575d8 | 4 | @Override
public boolean checkActivated(String user) throws SQLException,
ClassNotFoundException {
sqlClass();
sqlCon();
if (!customField.isEmpty()) {
query = "SELECT user_id FROM " + tablePref
+ "profile_fields_data WHERE pf_" + customField + "='"
+ user + "'";
ResultSet rs = SELECT(query);
... |
dbc9f586-edf3-416d-8d33-6a528ce84c07 | 4 | public boolean updateOrderStatus(String orderNumber, String status) {
try {
Connection conn = UtilDAO.getConn();
if (!status.equals("OK") && !status.equals("NOK") && !status.equals("undefined")) {
return false;
}
int numeroPedido = Integer.parseIn... |
bf271b01-37e5-431c-8fc9-df6651134ab1 | 3 | private void whoisonline(ServerClient activeclient) throws IOException
{
ArrayList<String> clientsOnline = new ArrayList<String>();
for (ServerClient sc : connectedClients)
{
if (sc != activeclient) // dont ask active client for its name he knows that already ^^
{
clientsOnline.add(sc.getNickname());
... |
e22b3c74-c4d0-44e4-8896-bd1e9398f5f7 | 7 | @Override
public State run(final String program, final State s) {
Map<String, Integer> methodMap = Utils.getMethods(program);
ClassWriter cw = new ClassWriter(0);
FieldVisitor fv;
MethodVisitor mv;
cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, CLASS_NAME, null, "java/lang/Object", ... |
ea8b6b50-c170-4f9b-a467-abc209dfb521 | 9 | public Object getProperty(String name,
Object opNode) {
validate(name, opNode);
if(opNode instanceof RenderedOp &&
name.equalsIgnoreCase("roi")) {
RenderedOp op = (RenderedOp)opNode;
ParameterBlock pb = op.getParameterBlock();
// Retrieve... |
4c6f8005-b4c4-4000-9482-6cf9d0bd9c20 | 5 | public int trap(int[] height) {
if(height==null||height.length<=2)
return 0;
int len = height.length-1;
int sum = 0;
int start = 0;
if(height[1]>height[0])
start = findNextHighPoint(height,0);
// if(isLog)
// System.out.println("start "+start);
for(int i=start;i<len-1;i++){
int left = i;
int... |
84acac4a-c65e-496c-bf82-3a64366d1a85 | 8 | public static int BSLargerThanSearch_solution2(int[] array, int key, boolean print) {
if(key<array[0]) {
if(print) System.out.println("Result is " + array[0]);
return 0;
}
if(key>array[array.length-1]) {
if(print) System.out.println("No Result");
return -1;
}
int start = 0;
int end = array.le... |
6b04d289-9361-45e0-bee8-5c85bafbdd2e | 6 | private ArrayList<Integer> getUpdSeedSet(DatasetPattern pattern){
ArrayList<Integer> updSeedIndex = new ArrayList<Integer>();
for (int i = 0; i < this.dataset.size(); i++) {
DatasetPattern p = this.dataset.get(i);
if(pattern.getID() == p.getID()) continue;
if(!p.isVisited()) break;
double distance = Euc... |
5704ee20-2b96-4af4-adda-44bbb0f8fb77 | 8 | public Double getDeterminant() {
double positivo = 0.0;
if (rows == 2 && cols == 2) {
return values[0][0] * values[1][1] - values[1][0] * values[0][1];
}
for (int i = 0; i < rows; i++) {
double mult = 1.0;
for (int j = 0; j < cols; j++) {
... |
2e34a98f-64fc-4372-8a89-cf2aaa063279 | 2 | public static String createDeploymentDiagram(SoftwareSystem system, String id, String name, boolean withRespectToEP) {
String deploymentDiagram = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
deploymentDiagram += "<uml:Model xmi:version=\"" + Utils.getVersionFromDate() + "\" xmlns:xmi=\"http://www.omg.org/spec/XM... |
d320f78b-fd97-43c9-bdc2-d79a8ec3eacb | 7 | public static long insert(User newUser) throws SQLException {
PreparedStatement s = null;
long rowCount = 0;
try {
// Connect to database and try to insert newUser into the database
try { Class.forName("org.postgresql.Driver");} catch (ClassNotFoundException e) {}
currentCon = DriverManager.getConnection... |
d6f760eb-a2ad-405b-bf4e-137b7704212c | 7 | public static Vector localSearch(Vector v) {
// Incrementally optimize this vector
v = v.clone(); // don't modify the original
double bestLength = Double.MAX_VALUE;
Vector bestVector = v.clone();
int[] increments = new int[] { -4, 1, 1, 1, 1, 1, 1, 1, 1, -4 };
boolean improved = t... |
f0388e50-fd5e-4b57-8044-6a71eb33242c | 1 | @Override
public void setSoTimeout(int timeout) {
try {
mySocket.setSoTimeout(timeout);
} catch (SocketException e) {
e.printStackTrace();
}
} |
0fb97c49-64c5-47a5-8ba0-cb083357b348 | 5 | public static void cloneFileFromJar(String jarPath, String fileToMove, String pathTo) throws IOException {
notNull(jarPath, "String jarPath");
notNull(fileToMove, "String fileToMove");
notNull(pathTo, "String pathTo");
notEmpty(jarPath, "String jarPath");
notEmpty(fileToMove, "St... |
379f905a-ae3d-48b7-9edd-89ea029ce9ff | 7 | static Handler remove(Handler h, Label start, Label end) {
if (h == null) {
return null;
} else {
h.next = remove(h.next, start, end);
}
int hstart = h.start.position;
int hend = h.end.position;
int s = start.position;
int e = end == null ?... |
60dd51ae-7ef0-4134-bde6-653f8a7f95e9 | 8 | public Integer evaluate(ArrayList<String> needle, ArrayList<String> haystack) {
if (needle == null) {
return Integer.valueOf(-1);
}
if (haystack == null) {
return null;
}
for (int ii = 0; ii < haystack.size() - needle.size() + 1; ++ii) {
boolean found = true;
for (int jj = 0;... |
182c8503-dfa9-4042-9176-05089a6cd4cc | 4 | void setTile(int x, int y, Tile tile)
{
// Extract the position within the chunk
x = x % Chunk.width;
y = y % Chunk.height;
// Make sure the tile is within bounds
if( x >= Chunk.width || y >= Chunk.height || x < 0 || y < 0)
{
return;
}
contents[x][y] = tile;
} |
81e0e78b-3658-422f-bcda-e8e38912dc78 | 7 | public static void main(String[] args) throws Throwable{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
num = new HashMap<Integer, Integer>();
StringTokenizer st = new StringTokenizer(in.readLine());
boolean valid = true;
int cont = 0;
fo... |
74bb11b3-c8e7-455b-aae3-930c9b3250ea | 8 | public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5)
{
if (par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 < 30000000)
{
if (par3 >= 0)
{
if (par3 < 256)
{
if (th... |
a70fb4f7-e73e-4056-b5f7-b1974e887179 | 5 | protected void updateAmount(int newAmount) {
final int oldAmount = this.amount ;
if (oldAmount == newAmount) return ;
clearAllAttachments() ;
//
// First, determine how many crates and packets of the good should be
// shown-
int numPacks = (int) Math.ceil(newAmount * 1f / ITEM_UNIT), numCr... |
59356a41-8013-41fc-801a-1d4a3953bfc6 | 8 | public int readCompass()
{
if (!isConnected())
{
error("Robot is not connected!", "RXTXRobot", "readCompass");
return -1;
}
try
{
this.attemptTryAgain = true;
... |
b7f7a699-e248-4976-b6cd-1887a39ff965 | 3 | public static Object getUIDefaultOfClass(Class clazz, String property) {
Object retVal = null;
UIDefaults defaults = getUIDefaultsOfClass(clazz);
List<Object> listKeys = Collections.list(defaults.keys());
for (Object key : listKeys) {
if (key.equals(property)) {
return defau... |
c6a9c01e-7f92-49c0-977d-a027bbdbf9eb | 4 | public void paint(Graphics g){
// if(!set) return;
Graphics2D g2 = (Graphics2D)g;
for(int i = 0; i < map.length; i++){
for(int j = 0; j < map[0].length; j++){
float x = map[i][j];
if(x > 1) x = 1;
else if (x < 0) x = 0;
g2.setColor(new Color(x,x,x));
g2.fillRect(i*scale,j*scale,scale,sc... |
eda8f19c-402f-4118-8a47-da87c863643a | 4 | public String getConteudoCarta(int i, int j)
throws PosicaoDeCartaInvalidaException {
if (i > 3 || i < 0 || j > 3 || j < 0)
throw new PosicaoDeCartaInvalidaException(
"Posição de carta fora dos limites do tabuleiro!");
return tabuleiro[i][j].getHistoria();
} |
10655ab9-6dd6-41de-946b-5a555c9bf0ea | 1 | public void makeNonVoid() {
if (type != Type.tVoid)
throw new alterrs.jode.AssertError("already non void");
type = subExpressions[0].getType();
} |
094ecfe6-a553-40b8-af1a-abd94050f54b | 8 | public boolean checkFinalState(PhysicsEvent event)
{
boolean filter = true;
int pc = event.countByCharge(+1);
int pm = event.countByCharge(-1);
int pn = event.countByCharge( 0);
if(pc<this.getMinimumByCharge(+1)||pc>this.getMaximumByCharge(+1))
r... |
c1607dbb-161b-4eb2-8755-fb25a8eda4a9 | 4 | public void disconnect(int frameNo) {
switch (frameNo) {
case 1:
jCheckBox1.setSelected(false);
bpmValue1.setText("Not connected");
minValue1.setText("");
maxValue1.setText("");
lastUpdateValue1.setText("... |
c45fc3e4-260f-4400-bb52-1a816e03709a | 6 | protected CycList unescape(CycList cycList) {
CycList unescapedCycList = new CycList();
final int cycList_size = cycList.getProperListSize();
for (int i = 0; i < cycList_size; i++) {
Object obj = cycList.get(i);
if (obj instanceof CycList)
unescapedCycList.add(unescape((CycList) obj));
... |
2c0f2a71-a7d3-41f9-99b0-3fc2e9d16822 | 5 | public void update(){
totalTime++;
if(totalTime > 200 && !(component.getScreen() instanceof MainMenu)) setScreen(new MainMenu(component, this, input));
boolean switchScreen = false;
if(logoTransparancy < 1.0f){
logoTransparancy += (float) RTSComponent.MS_PER_TICK / 2000;
}else{
logoTransparancy = ... |
66620a8c-d318-4b3f-b6a6-8c5ce12be303 | 1 | private int hash(String input) {
int output = 0;
for(int i = 0; i < input.length(); i++) {
output += (int)input.charAt(i);
}
output %= this.size;
return output;
} |
4223ddc8-a7ad-4e89-9f84-32772c5aff20 | 7 | public static void gameOn() {
int numOfPlayers = Integer.parseInt(JOptionPane.showInputDialog("Number of players?")),
playerTurn = 0;
Player currentPlayer;
Deck selectedCard;
ArrayList<Deck> currentPlayerCards;
String resultMessage = "", catMessage = "";
createPlayers(numOfPlayers);
scarec... |
192a2127-bb0b-4f57-9134-c82d39974365 | 6 | public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == 'a' || e.getKeyChar() == 'A') {
theMap.getCharacter().setDirection(-1);
} else if (e.getKeyChar() == 'd' || e.getKeyChar() == 'D') {
theMap.getCharacter().setDirection(1);
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.exit(0);
} els... |
6c6f7f1d-5328-4971-a816-52ec635c8a5e | 6 | public double GetItemShopValue(int ItemID, int Type, int fromSlot) {
double ShopValue = 1;
double Overstock = 0;
double TotPrice = 0;
for (int i = 0; i < server.itemHandler.MaxListedItems; i++) {
if (server.itemHandler.ItemList[i] != null) {
if (server.itemHandler.ItemList[i].itemId == ItemID) {
Sho... |
8186338f-e51d-42f1-b89b-e0e424c5fd1a | 6 | protected void tickEntities()
{
for(int i = 0;i<entities.size();i++)
{
Entity e = entities.get(i);
if(e != null)
{
if(e.world != this)
{
entities.remove(e);
}
else
... |
3ff60333-e406-4977-a5f5-22900de16062 | 3 | private static int dividers(int n){ // assumes n >= 1
int count=1; // 1 is always a divider
int i=0;
for (i=2;i<=Math.sqrt(n);i++){
if (n%i == 0){
if (i == Math.sqrt(n))
count+=1;
else
count+=2;
}
}
return count;
} |
b27c36df-36cd-4a8c-b111-8eb791ed1c31 | 3 | private void getAlarmList() {
try {
List<Alarm> alarms;
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeBytes(ServerFrame.getAlarmListCmd + "\n");
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
alarms = (List<Alarm>) ois.readObject();
... |
fa9df6d9-4f35-4836-8370-be902b75599b | 8 | public static int getRecommendedExpansionDeployment(BotState state) {
int out = 0;
String gameState = GameStateCalculator.calculateGameState(state);
if (gameState.equals("open")) {
out = getRecommendedExpansionDeploymentGameOpen(state);
} else if (gameState.equals("stalemate")) {
out = getRecommendedExpan... |
3c041894-26e0-4f96-a14e-24135dd3d975 | 3 | @Override
public List<Product> getAll() throws SQLException {
List<Product>products = null;
Session session=null;
try{
session=HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
products = session.createCriteria(Product.class).list();
session.getTransaction().commit();
... |
09227f25-8858-4e56-804c-e3dc0e4431a7 | 9 | private java.util.ArrayList<Element> getAttributes(Node attributeGroup){
java.util.ArrayList<Element> elements = new java.util.ArrayList<Element>();
String name = DOM.getAttributeValue(attributeGroup, "name");
String ref = DOM.getAttributeValue(attributeGroup, "ref");
if (name.length()>0... |
558ee70c-e2ce-4a21-9130-1960bf158f9c | 8 | public void addPlayer(String name , PlayerData player) {
if( player == null ) {
player = new PlayerData(this) ;
}
// Register the MBean
ObjectName oName ;
try {
oName = new ObjectName("org.dkhenry.minejmx:type=PlayerData,name="+name);
if( mbs.isRegistered(oName) ) {
mbs.unregisterMBean(oName) ;
... |
eb0703a2-3189-45e8-9f96-aeae6d2f2379 | 3 | public boolean checkInput()
{
for (JTextField i : components)
if((i.getText() == null) || (i.getText().equals(""))) return false;
return true;
} |
2ed390ac-c907-4479-afa1-2cd080d56ecb | 8 | protected boolean fillOutCopyCodes(final Modifiable E, List<String> ignoreStats, String defPrefix, XMLTag piece, Map<String,Object> defined) throws CMException
{
final String copyStatID = findOptionalStringNow(E,ignoreStats,defPrefix,"COPYOF",piece,defined, false);
if(copyStatID!=null)
{
final List<String> V=... |
bf1d0f2d-aed7-4e28-877a-1ed0d4fccd21 | 9 | @Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
Paint p = new Paint();
Point point_to_draw = new Point();
//Projection projection = mapView.getProjection();
//p.setColor(Color.BLUE);
p.setARGB(255, 0, 0, 0);
if(isVisible())
if(shadow==false)
{
... |
51d49513-e226-48ad-9934-f24adaafba6f | 6 | private void parseDirectory(WZDirectoryEntry dir) {
int entries = WZTool.readValue(lea);
for (int i = 0; i < entries; i++) {
byte marker = lea.readByte();
String name = null;
@SuppressWarnings("unused")
int dummyInt;
int size, checksum;
switch (marker) {
case 0x02:
name = WZTool.readDec... |
52502c12-d333-4aae-84d8-436228c25001 | 9 | public void reduce(IntWritable docId, Iterable<Text> termFrequencies,
Context context)
throws IOException {
/* Dont collect to reduce rather write straight-away to $OUTPUT_FOLDER/Index/TermIndex/ */
int[] finalTermFrq = new int[2];
boolean mtTypeIncdence = false;
Configuration conf = context.getConfi... |
ebdf26fd-ed02-47d4-956c-35697fceb7cd | 5 | public boolean containsMappings() {
if (this.mapping != null) {
return true;
}
for (int i = 0; i < propertyCount(); i++) {
if (getProperty(i).getMapping() != null) {
return true;
}
}
for (int i = 0; i < sectionCount(); i++) {
if (getSection(i... |
f9205b98-8bfb-44c7-88c6-3d08cc9f9ce8 | 9 | @Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if((found!=null)&&(!aborted)&&(mob.location()!=null))
{
final CMMsg msg=CMClass.getMsg(mob,found,this,getCompletedActivityMessageType(),null);
msg.setValue(CMLib.dice().... |
dc8f3c0e-94da-4740-9c18-dc7a48c955a8 | 1 | public GraphicsConnection(Socket clientSocket, GraphicsContainer containerArg){
messages = new ConcurrentLinkedQueue<JSONObject>();
container = containerArg;
socket = clientSocket;
try {
inputReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
catch (IOException e){
Debug.erro... |
6240c3b8-83a8-420c-9cb1-167be2fd8b48 | 5 | public static void main(String args[]) {
//prompt
System.out.println("Convert your weight on earth to:");
//output list
for (Destination d : Destination.values()) {
System.out.print(d.getChoice() + ". " + d.name() + "\n");
}
//prompt for user input
System.out.print("Select a destination by number: ");
... |
4a7fad99-e0f2-4f0f-9219-8fd0a3c2718e | 0 | public void setId(long Id) {
this.Id = Id;
} |
2cce820f-0cfd-4181-8d55-3c40c297cf8a | 6 | double[][] graySmooth(BufferedImage image) {
double[][] graySmoothed = new double[image.getWidth()][image.getHeight()];
for(int x = 0; x < graySmoothed.length; ++x) {
for(int y = 0; y < graySmoothed[x].length; ++y) {
if(x < 1 || x >= graySmoothed.length - 1 || y < 1 || y >= graySmoothed[x].length - 1) {
... |
0977d4e5-93dc-450c-b433-a127a53d6669 | 8 | public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int num1, num2, num3, num4, num5, menor, mayor;
System.out.print("Escriba el primer entero: ");
num1 = entrada.nextInt();
menor = num1;
mayor = num1;
System.out.print("Escriba el segundo entero: ");
num2 = entrada.next... |
b9f93a7b-cf83-4504-b784-bcd8091abaf4 | 6 | protected UVW computeUVW() {
Vector3 w = subtract(eye, look).normalize();
Vector3 up = rotate(this.up, w, roll);
// take care of the singularity by hardwiring in specific camera orientations
if (eye.getX() == look.getX() && eye.getZ() == look.getZ() && eye.getY() > look.getY()) { // cam... |
ccf4b783-37c3-4ec3-a33f-1f89b192d012 | 9 | protected void loadFields(com.sforce.ws.parser.XmlInputStream __in,
com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException {
super.loadFields(__in, __typeMapper);
__in.peekTag();
if (__typeMapper.isElement(__in, CreatedBy__typeInfo)) {
... |
79050fe0-d42c-422f-9c07-483465bd5343 | 0 | @Test
public void convertGameStateToStringTest2() {
City_Graph city_graph2 = new City_Graph();
city_graph2.loadMap("res/test2.mp");
assertEquals(city_graph2.convertGameStateToString(),"CRNNNNRNNC");
} |
e4be4f57-d9e3-44b1-90e4-7ea6a2da2f3f | 9 | private int countNeighbours(Point p) {
int count = 0;
for(int dx = -1; dx <= 1; dx++)
for(int dy = -1; dy <= 1; dy++) {
Point neighbour = new Point(p.x + dx, p.y + dy);
if ((dx != 0 || dy != 0) && neighbour.x >= 0 && neighbour.x < size.height
&& neighbour.y >= 0 && neighbour.y < size.w... |
35c31561-5869-466c-9061-250fe26aab4c | 2 | public static Menu getInstance() {
if (uniqueInstance == null) {
synchronized (Orders.class) {
if (uniqueInstance == null) {
uniqueInstance = new Menu(Storage.getInstance());
}
}
}
return uniqueInstance;
} |
2d2db8ea-2609-4ad2-ad19-77d6c117d097 | 9 | public static void setDynEffects(Modifiable M, HTTPRequest httpReq)
{
final QuadVector<String,String,String,String> theclasses=new QuadVector<String,String,String,String>();
boolean supportsRoles=CMParms.contains(M.getStatCodes(), "GETREFFROLE");
if(httpReq.isUrlParameter("REFFS1"))
{
int num=1;
String b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.