method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
3171d392-fdbf-4ebe-bbcc-93ef21b2d72c | 8 | public static void main(String[] args) throws Throwable{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
boolean[] p=new boolean[1120];primos=new int[187];
p[0]=p[1]=true;int c=0;mem=new int[1121][187][15];
for(int [][]m:mem)for(int []r:m)Arrays.fill(r,-1);
for(int i=0;i<p.length;i++)... |
7109de64-6320-43eb-8594-c0b007bc899f | 0 | @Test(expected=TestException.class)
public void testInvokeZeroArgMethod_exception()
{
ReflectUtils.invokeZeroArgMethod(new Bean(), "exceptionalMethod");
} |
27e04ab6-7a27-40c6-98ce-32352d070712 | 9 | public boolean run()
{
tokenList = new ArrayList<Token>();
char[] input=fileContent.toCharArray();
int st=0,end;
while(st<input.length)
{
int mark=st+1;
if(__isBlock(input[st]))
while(mark<input.length&&__isBlock(input[mark])) ++mark;
else
while(mark<input.length&&!__isBlock(input[mark])) ++... |
c42b2e76-e371-4bb2-83c0-5c5740337756 | 8 | private static void convert() {
// create DBManagers for input and output
inputDBM = new DBManager(inputdbPath);
outputDBM = new DBManager(outputdbPath);
// get regests from database
List<classtypes.Regest> regestListOld = inputDBM.getResultList(
"SELECT r FROM Regest r", classtypes.Regest.class);
// ... |
7030ad83-59b5-4a75-afb4-b760c2af0df2 | 7 | @EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (!(e.getWhoClicked() instanceof Player))
return;
Player p = (Player) e.getWhoClicked();
int packs = 0;
for (ItemStack i : e.getWhoClicked().getInventory().getContents()) {
if (i == null || !i.hasItemMeta())
continu... |
cadd4505-aff7-41cc-a1e1-25106a13b6b2 | 0 | @Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + this.x;
hash = 97 * hash + this.y;
return hash;
} |
5182e529-4f0e-45d5-a65f-6a021124daf4 | 0 | @Override
public void simpleUpdate(float tpf) {
} |
bb1aeaf7-2fb9-4993-8eff-9f2948f2a283 | 3 | public void loadResources(InputStream is) throws SlickException {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null;
try {
docBuilder = docBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new SlickExce... |
1c6c8292-5610-44f6-9ebd-89307c030bfb | 3 | public static boolean deleteDirectory(File directory) {
if (directory.exists()) {
File[] files = directory.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
deleteDirectory(files[i]);
} else {
files[i].delete();
}
}
}
return (directory.delete());
} |
6085ad3a-b495-4b6f-ad2c-badbc1423a5e | 8 | @Override
public void run() {
try {
for (;;) {
byte b = in.readByte();
switch (b) {
case 'J':
String playerName = in.readUTF();
viewListener.join(ViewProxy.this, playerName);
break;
case 'H':
int playerNum = in.readInt();
int leftHand = in.readInt();
int ... |
ad3d7b71-ae2d-489a-a905-aeff118ace3a | 8 | public int findNextLeafMaxVersion() {
if (pos < 0) {
throw new RuntimeException("findNext called after exploration is finished");
}
int node = indices[pos];
if (ddmanager.isleaf(node)) {
throw new RuntimeException("findNext went too far");
}
int curValue = values[pos];
MDDVariable var = ddmanage... |
ad8e2a7d-d0e0-4188-8d05-ca6d31a74944 | 2 | public Spolka getActiveCompany(){
for(Spolka s : this.getSpolki())
{
System.out.println("active Company1" + " s.getSymbol(): " + s.getSymbol() + " this.getActiveCompanySymbol() " + this.getActiveCompanySymbol());
if(s.getSymbol().equals(this.getActiveCompanySymbol()))
{
... |
6427f43f-9de7-4502-8f35-65433230cecf | 7 | @Override
public ArrayList<Delta> apply(Color c, int x, int y, Color[][] colorArr) {
int count = 0;
int r = 0;
int g = 0;
int b = 0;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (x+i >= 0 && x+i < colorArr.len... |
8a658deb-ffe3-472e-8ae1-9cb211035c0e | 2 | public void setOption(DHCPOption opt) {
if (opt != null) {
if (opt.getValueFast() == null) {
this.removeOption(opt.getCode());
} else {
this.options.put(opt.getCode(), opt);
}
}
} |
5c0f3350-e1e3-4adb-a106-e2328d2b60a6 | 4 | public static void editMedia(Media m){
try {
if(conn == null || conn.isClosed()){
conn = DatabaseConnection.getConnection();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
conn.setAutoCommit(false);
PreparedStatement stmnt = co... |
18fa4b79-c90c-4bcd-abfd-b6f0a72f7e25 | 7 | private void searchForAssocs(ClassSubInstance c, ModelSubInstance m) throws RestrictionException{
Iterator<Map.Entry<Integer, AssociationSubInstance>> it = m.assocs.entrySet().iterator();
boolean found_source = false;
boolean found_target = false;
while(it.hasNext()) {
AssociationSubInstance a = it.next().ge... |
7839d477-3c67-46ef-af6c-fc6e26450634 | 5 | public final void method43(AbstractToolkit var_ha, int i) {
if (i != -14218)
aClass30_10082 = null;
anInt10068++;
Object object = null;
r var_r;
if (aR10094 == null && aBoolean10064) {
Class2 class2 = method2481(true, 262144, -4, var_ha);
var_r = class2 == null ? null : ((Class2) class2).aR118;
} e... |
b1472142-140f-43d5-90a4-4cf72086db8f | 6 | private List<Map<String, String>> getResults(int timeout) throws MikrotikApiException {
try {
synchronized (this) { // don't wait if we already have a result.
int waitTime = timeout;
while (!complete && (waitTime > 0)) {
long st... |
ae5e9085-2e64-4f26-a200-fbd434874a82 | 9 | private void testAdd() {
boolean answer = true;
thePuzzle.addPosition(0, 0, 1);
if (thePuzzle.getValueAtPosition(0, 0) != 1) {
System.out.println("Adding tests failed");
answer = false;
}
thePuzzle.addPosition(0, 0, 0);
if (thePuzzle.getValueAtPosition(0, 0) != 1) {
System.out.println("... |
b64d19ce-b6fe-46ba-ba71-da061048c15b | 8 | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == timer) {
if (comboState) {
comboState = false;
curCombo = 0;
if (playerID == Player.PLAYER1) {
fish.setMessage("PLAYER1");
... |
c614b92f-54a7-44e1-8d4b-f12c82aea115 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
tache other = (tache) obj;
if (id != other.id)
return false;
if (priorite == null) {
if (other.priorite != null)
return false;
} else if (!priori... |
6b131927-e64e-482f-8a21-97df1fac4ce5 | 7 | private Tile unmarshalTile(TileSet set, Node t, String baseDir)
throws Exception
{
Tile tile = null;
NodeList children = t.getChildNodes();
boolean isAnimated = false;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if ... |
65f9e1a0-a835-4089-a445-053bd9be9886 | 2 | public void uninitializeServices() throws Exception {
for (int i = this._list.size() - 1; i >= 0; i--) {
Object o = this._list.get(i);
if (o instanceof IService) {
((IService) o).uninitializeService();
}
}
} |
de530b48-50a8-4f71-9dd8-7ca77739c27d | 9 | public void swapButton(Bloque bloque1, Bloque bloque2) {
int auxX, auxY;
boardGrid[bloque1.y][bloque1.x] = bloque2;
boardGrid[bloque2.y][bloque2.x] = bloque1;
auxX = bloque1.x; auxY = bloque1.y;
bloque1.setCoords(bloque2.x, bloque2.y);
bloque2.setCoords(auxX, auxY);
BlockButton button1 = bloque1.getB... |
4f46109a-7da6-402a-9f0d-90ff12378a37 | 8 | @Override
public void mouseMoved(MouseEvent event) {
try {
Game game = Game.getInstance();
RealPlayer realPlayer = (RealPlayer)game.getPlayerManager().getRealPlayer();
if (realPlayer.isBuildingTower()) {
boolean acceptBuildTower = false;
int numArea = game.getMapManager().getNumAreaAtPositi... |
237f79f8-9455-4ec1-8c86-6dc9108f33d0 | 0 | public void onDisable() {
sendtoserver(" v" + getDescription().getVersion() + " by:"
+ getDescription().getAuthors() + " ѽ!");
} |
ce47f683-4a74-4650-a870-7752ea035ec3 | 6 | @Override
protected void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception {
final String targetParentPath = StringUtils.defaultIfEmpty(request.getParameter("folderPath"), null);
final String targetEntryPath = StringUtils.defaultIfE... |
055af057-1aef-4628-ba9f-d2f321904680 | 8 | @Override
public Complex getPixel(Complex pixel) {
/* LEFT */
if(parser[0].foundZ()) {
parser[0].setZvalue(pixel);
}
/* RIGHT */
if(parser[1].foundZ()) {
parser[1].setZvalue(pixel);
}
int result = expr[0].getValue().compare(e... |
6b251d45-30cf-4d4e-b471-01c9a305a231 | 1 | public static void draw(int scene_number)
{
if (SceneDivider.getTexture(scene_number) != null)
{
SceneDivider.getTexture(scene_number).bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(0,0);
GL11.glTexCoord2f(1,1... |
fb4b1783-4fb4-4b61-8c5e-f19360f7c93d | 5 | private void setUrlYahoo (String path)
{
//try (final Reader symbolList = new FilterNasdaq (new BufferedReader (new InputStreamReader (new URL (url).openStream()))))
try (Reader symbolList = new FilterNasdaq (new BufferedReader (new FileReader (new File (path)))))
{
String symbolLine = "";
int urlLimit = 0... |
f203b42b-29ce-4b9f-b79f-c900937c0c94 | 4 | public int length() {
if (n >= 0xFFFF_FFFFL || n < 0) {
return 9;
} else if (n >= 0xFFFF) {
return 5;
} else if (n >= 0xFD) {
return 3;
} else {
return 1;
}
} |
e48647ef-fa48-4486-9a32-d1421cada37c | 8 | public static Map getAssetList(String serverID, String nymID, List existingAssets) {
Map basketList = new HashMap();
/* TODO: This loop will be replaced by server call
which returns only those assets registered at the server */
List registeredAssets = getRegisteredAssets(serverID, nym... |
19d5e215-d67f-48d4-afcb-c06ef2cc2b51 | 1 | public Double getValorNeto() {
if (valorNeto==null) {
return 0.00;
}
return valorNeto;
} |
68d7b67f-a807-4aa7-8ca4-be613cce0fc5 | 5 | public static void takeTest(Document doc){
TestAttempt attempt = new TestAttempt(doc, InputHandler.getString("What is your name?"));
for (int i=0; i<doc.getQuestionCount(); i++){
Question question = doc.getQuestion(i);
question.display(false);
Object answer = question.promptForAnswer();
if ( doc.docType... |
58652eae-090f-46d0-b041-903c39b60d34 | 2 | @Override
public void setAIChoices(String[] value) {
java.util.List<String> choiceList = new ArrayList<String>();
for (String v : value) {
choiceList.add(v);
}
aiModel.setList(choiceList);
if (value.length > 0) {
aiChoices.setValue(value[0]);
}
} |
6af60804-06bd-449b-929a-b63c09266a56 | 7 | RoomsPanel(ResultsDisplay x){
rd = x;
setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(214, 5, 21, 21);
add(tabbedPane);
JButton btnQuery = new JButton("# of P");
btnQuery.setBounds(22, 52, 117, 29);
add(btnQuery);
btnQuery.addActionList... |
4ca5bc63-c3d5-45d0-9282-adde812b4a1b | 2 | @BeforeClass
public static void initPop(){
Properties prop = new Properties();
String filename = "config.properties";
try(InputStream input = TestPopulation.class.getClassLoader().getResourceAsStream(filename);) {
if (input == null){
System.out.println("File not found");
assert... |
221fc287-f73d-4e6a-8fa8-53d5ff099c3b | 1 | private static String getFileContents(String filename)
throws IOException, FileNotFoundException
{
File file = new File(filename);
StringBuilder contents = new StringBuilder();
BufferedReader input = new BufferedReader(new FileReader(file));
try {
String line = ... |
55dd0068-a37b-4005-96b3-ae726652f921 | 0 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
MenuBar = new javax.swing.JMenu();
combo_persons = new javax.swing.JComboBox();
jLabel1 = new javax.swing.JLabel();
label_prof... |
0db99e5f-ab43-42e6-8f9e-9040ca377950 | 9 | @Override
public void paintLayer(Graphics g, GameState state, InputManager input) {
if(letters == null ||
home && state.getHomeTurn() != teamTurn ||
!home && state.getAwayTurn() != teamTurn ||
lastStage != state.getGameStage()){
lastStage = state.getGameStage();
initLetters(state);
if ... |
e1761255-a3f3-45a4-a209-aa8e01791266 | 8 | private static void pGetBucketVersions() throws IOException
{
System.out.println("basic get bucket versions");
String bucketName="chttest1";
AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(putBucket.class.getResourceAsStream("AwsCredentials.properties")));
try
{
//list all verisons
... |
46613f06-3ac7-4d25-b88a-a29cea0f09cf | 7 | @EventHandler
public void onLogin(PlayerJoinEvent event) {
final Player p = event.getPlayer();
if (p.hasPermission("modreq.check")) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
new Runnable() {
@Override
public void run() {
... |
72e6d8f0-3db7-4e99-bf8c-95d32ed01949 | 2 | public double ana(){
int i = 0;
int nbarg = 0;
for(Operation op : this.operation){
nbarg = nbarg + op.getArg().size();
i++;
}
if(i == 0)return 0.0;
return ((double)nbarg/i);
} |
bb4c495f-9861-4720-ba43-c3574baad851 | 8 | private void buttonSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSubmitActionPerformed
// flag to add item
boolean added = false;
try {
if (filedNumber.getText().isEmpty() && filedManufacture.getText().isEmpty() && filedModel.getText... |
96ca80af-804f-4812-a33b-d2f164f99a54 | 4 | public static void main(String args[])
{
try
{
loc = System.getProperty("java.class.path");
}
catch(Exception e){}
try
{
loc = loc.substring(0, loc.lastIndexOf(".jar"));
loc = loc + "/";
}
catch(Exception e){}
try
{
if(loc.endsWith("bin"))
{
loc = loc.substring(0, loc.last... |
f36e3588-669f-4f14-9ef6-5c9c0b60ae24 | 2 | static private byte a2b(byte c){
if('0'<=c&&c<='9') return (byte)(c-'0');
return (byte)(c-'a'+10);
} |
902f172c-84c1-41ca-bf36-b7378a3597c7 | 1 | @Override
public String prepareLogMessage(int type, String msg, Throwable throwable) {
StringWriter stackTrace = new StringWriter();
if (throwable != null) {
throwable.printStackTrace(new PrintWriter(stackTrace));
}
return (getDate() + "\t" + Logger.MSG_TYPE_STRING[type] + ": " + msg + stackTrace.toString(... |
c1464698-50f4-43d6-a2a0-0c4641bd476d | 7 | public static void main(String args[]){
int resp;
Transito tran = new Transito();
Scanner lea = new Scanner(System.in);
do{
System.out.println("1- Agregar Esquela");
System.out.println("2- Pagar Esquela");
System.out.println("3- Listar Esquela... |
ff8cecbe-9b94-4190-b518-5e211355e104 | 3 | * @return Returns true if the cell is editable.
*/
public boolean isCellEditable(Object cell)
{
mxCellState state = view.getState(cell);
Map<String, Object> style = (state != null) ? state.getStyle()
: getCellStyle(cell);
return isCellsEditable() && !isCellLocked(cell)
&& mxUtils.isTrue(style, mxCons... |
845ee794-3aa2-440e-8a4b-3b5b71618cd9 | 5 | private boolean isAttackPlaceRightNotHarming(int position, char[] boardElements, int dimension) {
if (isPossibleToPlaceRight(position, dimension)) {
if (isPossibleToPlaceOnNextLine(boardElements, position + dimension)
&& isBoardElementAnotherFigure(boardElements[positionRightBelo... |
8419e17a-a9bb-4c19-85fc-414733c5d152 | 9 | @Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((deviceIdentifier == null) ? 0 : deviceIdentifier.hashCode());
result = PRIME * result + ((objectIdentifier == null) ? 0 : objectIdentifier.hashCode());
result = PRIME * result ... |
f892a8e0-4307-4d58-9189-c1fd6e809fad | 2 | public static void renameFolder(String srcPath, String aimPath) throws UtilException {
File srcFile = new File(srcPath);
if (!(srcFile.exists()))
throw new UtilException("原始文件夹不存在:" + srcPath);
File aimFile = new File(aimPath);
if (aimFile.exists())
throw new UtilException("目标文件夹已存在:" + aimPath);
srcF... |
08910bff-1fbc-4f4b-8c27-78cbe8befacd | 5 | public boolean isValid() {
if (type == PropertyType.KEY) {
return Keyboard.getKeyName((int) num) != null;
}
if (type == PropertyType.STRING) {
return str != null;
}
if (type == PropertyType.BOOLEAN || type == PropertyType.INT || type == PropertyType.DOUBLE) {
return true;
}
return false... |
25be224f-3496-4b50-bb8e-c88c344fc40c | 0 | public void setUserId(String userId) {
this.userId = userId;
} |
5405ddeb-492c-4dcf-bd28-112d75926a75 | 6 | public void onBlockRemoval(World var1, int var2, int var3, int var4) {
byte var5 = 4;
int var6 = var5 + 1;
if(var1.checkChunksExist(var2 - var6, var3 - var6, var4 - var6, var2 + var6, var3 + var6, var4 + var6)) {
for(int var7 = -var5; var7 <= var5; ++var7) {
for(int var8 = -var5; ... |
35c368d9-ed1d-4cd5-99cd-425623c1a647 | 6 | public boolean EmptyNewGenerators(Set<Element> table) {
List<Element> list = new ArrayList<Element>(table);
List<Set<Item>> newGenerators = new ArrayList<Set<Item>>();
//Création des nouveaux générateurs possibles
for (Element e : list) {
for (int i = list.indexOf(e) + 1; i < list.size()... |
ab1c260e-ce84-47f8-b6ed-4497d1337826 | 2 | public String getMethodrefName(int index) {
MethodrefInfo minfo = (MethodrefInfo)getItem(index);
if (minfo == null)
return null;
else {
NameAndTypeInfo n
= (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
if(n == null)
return n... |
04797f50-2888-42b5-9fdd-096c89f2ed72 | 3 | @Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
Campaign camp = (Campaign) session.get("campa");
CampaignDevice campdev = new CampaignDevice(camp, getPlatform());
getMyDao().getDbsession().sa... |
35c1851a-9b95-49b9-a5cc-70472f0c79cf | 8 | public void calcular() {
Calculo cal = new Calculo(this);
try {
tIrpf = Double.parseDouble(txtIrpf.getText());
if (chkJefeEquipo.isSelected()) {
JefeEquipo = salarioBase / 10;
} else {
JefeEquipo = 0;
}
if (chk... |
7e5d69a5-4e8b-4720-bc18-e0f98c5c775a | 2 | public void toggleQ2()
{
if (Q2Associated.equals(true))
{
pulseOximetryQuicImage.updateImage("src/com/anakena/freePcaInterlock/Q2InactiveQUIC.png");
o2Panel.updateValue("X");
pulseRatePanel.updateValue("X");
plethPanel.updateValue("X");
Q2Associated = false;
}
else if (Q2Associated.equals(false)... |
6f8e5954-b390-443f-af41-b8d733ae59c6 | 5 | public static byte [] extractHeader(int offset, int headerLen,
byte [] bytes) {
// null in = null out ?
if( bytes == null ) return null;
// negative in, empty array out
if( ( offset < 0 ) || ( headerLen < 0 ) ) return EMPTY_BYTE_ARRAY;
// verify that reque... |
03aa51dd-e21a-4ee8-8ce0-4080d3282312 | 9 | void run(){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n==0)break;
int m = sc.nextInt();
char[][] s = new char[n][8];
int[] p = new int[n];
for(int i=0;i<n;i++){
s[i]=sc.next().toCharArray();
p[i] = sc.nextInt();
}
int x = 0;
while(m--!=0){
char... |
118db6d1-22e6-47c4-bfe6-a00965f3badc | 8 | @Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if((buildingI!=null)&&(!aborted))
{
if(messedUp)
{
if(activity == CraftingActivity.LEARNING)
commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",... |
766a7839-8575-40ff-8f30-d04060557a60 | 0 | public void newBuffer() throws FileNotFoundException, UnsupportedEncodingException{
// 追記モード
csv = new FileOutputStream("logs/" + Calender.yyyymmdd_hh() + ".csv"); // CSVデータファイル
bufferedWriter
= new BufferedWriter(new OutputStreamWriter(csv, "UTF-8"));
} |
4f5d6150-2d48-4a0b-aa97-2c4612c5cd5b | 1 | @Override
public void swap(List<Integer> list, int left, int right) {
// checking input parameter for null
if (list == null) {
throw new IllegalArgumentException("swap error: disallowed value");
}
int temp = list.get(left);
list.set(left, list.get(right));
... |
13914acb-be81-45d8-ad7f-075aa4c16019 | 8 | private void visitObjectLiteral(Node node, Node child)
{
Object[] properties = (Object[])node.getProp(Node.OBJECT_IDS_PROP);
int count = properties.length;
// load array with property ids
addNewObjectArray(count);
for (int i = 0; i != count; ++i) {
cfw.add(ByteCo... |
2b819cfa-d8e8-48d2-9065-d5fe950f1018 | 6 | protected final Object computeRange() {
final List<Double[]> raRange = new ArrayList<Double[]>();
final double[] decRange = new double[2];
if (this.isPolesCollision()) {
decRange[MIN] = SimpleSpectralAccessProtocolLibrary.MIN_VALUE_FOR_DECLINATION;
decRange[MAX] = SimpleSpectralAccessProtocolLib... |
65f0bdfb-028b-4850-a437-2c56bcda13e3 | 2 | public ResultSet sqlQuery(String sql) {
Statement stat = null;
try {
stat = (Statement) conn.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResultSet rs = null;
try {
rs = stat.executeQuery(sql);
} catch (SQLException e) {
// TODO Au... |
d800b4ec-4630-4ba3-ae4f-a6e0357980fd | 4 | public void snapToGrid(JGPoint p,int gridsnapx,int gridsnapy) {
if (gridsnapx==0 && gridsnapy==0) return;
int xaligned = tilex*(int)
Math.floor(((p.x + tilex/2.0) / (double)tilex));
int yaligned = tiley*(int)
Math.floor(((p.y + tiley/2.0) / (double)tiley));
int gridofsx = Math.abs(p.x - xaligned);
int g... |
0656e72f-fe9b-4f07-9aca-f5fda53d5021 | 2 | public final static void deregisterAll( MListener ... listeners ){
try{
for( MListener listener : listeners ){
Thread.sleep( 10 );
ELIST.remove( listener );
LOGGER.debug("Deregistered message listener [{}].", listener.getName() );
}
}catch( Exception e){
LOGGER.warn("Exception while de... |
75c1d2c9-1b52-49c0-80bb-e35bb97b488f | 0 | public int[] area(int n) {
return new int []{x + 4 + (Game.TILESIZE + 2) * n, x + 4 + (Game.TILESIZE + 2) * n + Game.TILESIZE, y + 4, y + 4 + Game.TILESIZE};
} |
d371a135-61ba-4e33-96d4-d2ffbf25f308 | 1 | public static void main(String[] args) {
Stack stack = new Stack();
char[] name = { 'a', 'r', 'v', 'i', 'n' };
for (Character c : name) {
stack.push(c);
}
Object top = stack.peek();
System.out.println(top);
} |
e6b9fbb8-b82d-4248-af98-b5dba7d43e28 | 5 | private void loadTiles(){
int[] tileColors = this.image.getRGB(0,0,width,height,null,0,width);
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
tileCheck: for(Tile t : Tile.tiles){
if(t != null && t.getLevelColor() == tileColors[x+y*width]){
this.tiles[x+y*width]=t.getId();
b... |
846a8597-3e20-4b82-a2eb-b3a2d61c03a1 | 6 | public static PtgArea getRange( Ptg p ) throws IllegalArgumentException
{
if( p instanceof PtgArea )
{
return (PtgArea) p;
}
if( p instanceof PtgName )
{ // get source range
Ptg[] pr = null;
try
{
pr = ((PtgName) p).getName().getCellRangePtgs();
return (PtgArea) pr[0];
}
catch( E... |
a5e8f3ab-c46c-4a22-a196-f73360d9f800 | 2 | public String getChannelsAsSingleText() {
String text = "None";
if (channels.size() > 1) {
text = "More channels";
} else if (channels.size() == 1) {
text = channels.get(0);
}
return text;
} |
f3786ec1-2984-4911-a0f8-775f4ec4e7b6 | 4 | public EmptyMenu() {
stateLabels = new JCheckBoxMenuItem("Display State Labels");
stateLabels.addActionListener(this);
this.add(stateLabels);
layoutGraph = new JMenuItem("Layout Graph");
if (!(ArrowTool.this instanceof ArrowDisplayOnlyTool)) {
layoutGraph.addActionListener(this);
this.add(layoutG... |
ac58eea6-ea1d-4a70-ba14-44322a6a220b | 3 | private void startReaderTimer() {
new Thread(threadGroup, new Runnable() {
@Override
public void run() {
try {
while (true) {
Message msg = readQueue.poll(4 * 3, TimeUnit.SECONDS);
if (msg == null) {
... |
568e46b9-1d13-4d65-b730-49b3a7ac8d73 | 8 | public Lab6() {
selectMode();
loadDriver();
try {
setProperties();
createDB();
createTable();
setTools();
operation();
} catch (SQLException sqle) {
printSQLException(sqle);
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
} catch (SQLException sqle) {
... |
0efd1f70-cedf-4bb5-8be7-73635bb332a7 | 9 | public static HashMap<String, TreeMap<Double, String>> eParamsCalculator(
String fileName) throws IOException {
HashMap<String, TreeMap<Double, String>> emissionParams = new HashMap<String, TreeMap<Double, String>>();
FileReader in = new FileReader(fileName);
BufferedReader br = new BufferedReader(in);
Has... |
4753154f-5536-45cd-bdde-760ef50f7699 | 7 | public Expr Equ_Expr() throws ParseException {
Expr e, et;
Token tok;
e = Rel_Expr();
label_21:
while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case EQUAL:
case NOTEQUAL:
break;
default:
... |
20d03bde-2494-4fc2-9e34-42e001fc8c97 | 6 | @EventHandler
public void PlayerStrength(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getPlayerConfig().getDouble("Player.Streng... |
4ca52bf0-a4ca-4247-8380-e870b8d603fb | 2 | public void paint(Graphics g) {
super.paintComponent(g);
g.drawImage(backgroundPic, 0, 0, width, depth, null);
Graphics2D g2d = (Graphics2D) g;
synchronized (ocean.getOceanObjects()) {
if (ocean.getOceanObjects().size() > 0) {
for (int i = 0; i < ocean.getOceanObjects().size(); i++){
... |
41f410fd-21bb-49de-8428-4bcba26d6936 | 7 | private void checkScrollBar(AdjustmentEvent e)
{
// The scroll bar listModel contains information needed to determine
// whether the viewport should be repositioned or not.
JScrollBar scrollBar = (JScrollBar)e.getSource();
BoundedRangeModel listModel = scrollBar.getModel();
... |
fdf02ce7-3a70-4174-91d7-ff955e9dbf59 | 7 | private String plainToHTML(String source) {
String strResult = "";
String sourceText = "";
Integer srcLen = source.length();
// Cycle through each input character.
if (srcLen > 0) {
for (int i = 0; i < srcLen; i++) {
sourceText = source.substring(i,... |
e762b676-32f0-418d-9214-82942ab7b9b8 | 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... |
91e2bef0-6648-4ef6-af30-9dfda12ee7f2 | 1 | public static NormalDistributedStochasticLotsizingProblem generate(
int T, AbstractRealDistribution meanDistribution, double cv, long seed,
double setupCost, double inventoryHoldingCost,
float alpha, AbstractNormalLikeOrdersGenerator orderGenerator){
meanDistribution.reseedRandomGenerator(seed);
Norm... |
b8f7cbaa-549e-4942-aa04-47163a7baecd | 5 | @Test(expected = UnmatchingParenthesisException.class)
public void testInfixToPostfix9() throws BadNextValueException,
DAIllegalArgumentException, DAIndexOutOfBoundsException,
ShouldNotBeHereException, UnmatchingParenthesisException {
try {
infix.addLast("(");
QueueInterface<String> postFix = calc.infixT... |
aba53da3-d3be-43b4-957f-846bfbb10e56 | 9 | public static String getTypeByPath (String path) {
if (path == null) {
return "text/html";
}
final String ext = path.substring(path.lastIndexOf(".") + 1, path.length()).toLowerCase();
String extType = null;
if (ext.equals("html")) {
extType = "text/html";... |
160ce89e-8169-4c25-9668-87851c618128 | 4 | private static <T extends Comparable<? super T>> void insertionSort(T[] a, int low, int high) {
for (int i = low + 1; i <= high; i++) {
T temp = a[i];
int j = i;
while (j > 0 && compare(temp, a[j - 1]) < 0) {
a[j] = a[j - 1];
j--;
}... |
9a5cebd8-2715-4ff2-94e5-ad007004ef04 | 5 | private playObject nextCard(playObject playData,
int[][] actionCards,
Random random)
{
int[]cardData=playData.getCardData();
int[][]shuffledActionCards=playData.getShuffledActionCards();
int currentCard=cardData[0];
boo... |
ca73748c-4a62-4453-b11b-52cdd84a3bb8 | 0 | public void setBook(String book) {
this.book = book;
} |
991b3261-9c98-4b5d-93a4-8fa0708e0096 | 7 | private static int parseTime(String timeString)
{
String[] parts = timeString.split(":");
if (parts.length != 2)
return -1;
int time = 0;
try
{
time = Integer.parseInt(parts[0].trim()) * 10000;
if (time < 0 || time > 24000)
return -1;
}
catch (Exception e)
{
return -1;
}
try
... |
bb15c5f4-ab4f-4074-9d4c-feb3d13e7a56 | 7 | static int[] mergeArrays(int[] a, int[] b) {
int[] helperArr = new int[a.length + b.length];
int helperArrIndex = 0;
int aIndex = 0;
int bIndex = 0;
while(aIndex < a.length && bIndex < b.length){
if(a[aIndex] < b[bIndex]){
helperArr[helperArrIndex++] = a[aIndex++];
}
else if(b[bIndex] < a[aIndex... |
2f7075c9-d535-4362-904a-027614338b83 | 2 | public void mousePressed(MouseEvent event) {
if (getDrawer().getAutomaton().getEnvironmentFrame() !=null)
((AutomatonEnvironment)getDrawer().getAutomaton().getEnvironmentFrame().getEnvironment()).saveStatus();
first = getDrawer().stateAtPoint(event.getPoint());
if (first == null)
return;
hover = first.... |
911f4013-a1df-431d-9c9b-bb56c6fc58c0 | 9 | public static String deCapitalize(String input) {
String words[] = input.split(" ");
if (words.length > 0) {
int count = 0;
for (String word : words) {
if (count == 0) {
words[count] = WordUtils.capitalizeFully(word);
count++;
} else {
if (word.length() > 2) {
words[count] = word.... |
9e731d5d-6853-4426-b73f-4ab90c502dd2 | 3 | @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerPortal(PlayerPortalEvent event)
{
// if knockback is set to 0, or portal redirection is disabled, simply return
if (Config.KnockBack() == 0.0 || !Config.portalRedirection())
return;
Location newLoc = BorderCheckTask.c... |
e40b473e-69eb-4393-a6d0-2848177232fd | 1 | public String toString() {
String parameters = ":";
parameters += getStateParametersValueKeyPair();
String stateString = "";
try {
stateString = this.getClass().getTypeName()
.split("\\$ModelStates\\$")[1];
} catch (Exception e) {}
return stateString + parameters;
} |
63f8e5fa-c648-492d-a7d8-5ee19d48e4bd | 4 | @Override
protected int runTest() {
// TODO Auto-generated method stub
byte[] packet;
String testmessage = "Hello World!";
EncryptionHandler EH1 = new EncryptionHandler();
EncryptionHandler EH2 = new EncryptionHandler();
EncryptionHandler EH3 = new EncryptionHandler();
EH2.addPubKey((byte)1, EH1.ge... |
8ce82fd8-5044-46d7-b28d-aacb3e8ab4b3 | 1 | private static String jsonp2json (String jsonp) {
String json = null;
String regex = "^loaded\\((.*)\\)$"; //"loaded¥((.*)¥)$"; ^loaded.(.*).$
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(jsonp);
if (m.find()){
json = m.group(1);
}
return json;
} |
3a98e32e-0400-4bd5-969b-1f25960693e7 | 3 | private static int findminimumgreedyscorefortailvertex(int tailvertex) {
// TODO Auto-generated method stub
int temp = 0;
for(int j = 0 ; j<graph.get(tailvertex).size();j++){
if(!(exploredarray.contains(graph.get(tailvertex).get(j)))){
temp = pathlength[tailvertex] + edgewieght[tailvertex][graph.get(tail... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.