text
stringlengths
14
410k
label
int32
0
9
public void initiallizeWithHtmlTemplate(){ if (isFileEmprtyAtStart) { String htmlTemplatePath = "C:\\GitRepos\\JavaToSVG\\Templates\\html_template.html"; String line; Path templatePath = Paths.get(htmlTemplatePath); try(BufferedReader reader = Files.newBufferedReader(templatePath)){ for (int i = 0; (line = reader.readLine()) != null; i++) { fileContent.add(line + "\n"); } } catch (IOException x) { System.err.format("IOException: %s%n", x); } writeToFile(fileContent); } }
3
public PropertyTree(Property property,PropertyTree parent) { this.property=property; this.parent=parent; this.children=null; if(parent!=null) parent.addChild(this); }
1
public static void main(String[] args) { System.out.println("hello".substring(0,3)); int val = 268435456; String inter = Integer.toBinaryString(val); while(inter.length()<32) { inter = 0+inter; } String highest4bits = inter.substring(0, 4); String lowest4bits = inter.substring(28, 32); System.out.println(highest4bits); System.out.println(lowest4bits); int diff = Integer.numberOfTrailingZeros(Integer.highestOneBit(256))-Integer.numberOfTrailingZeros(Integer.lowestOneBit(255)); System.out.println(diff>7); String dpiMnemonics[] = {"and","eor","sub","rsb","add","adc","sbc","rsc","tst","teq","cmp","cmn","orr","mov","bic","mvn"}; System.out.println(Integer.toBinaryString(10)); String regNum = Integer.toBinaryString(Integer.parseInt("r12".split("r")[1]))+""; System.out.println(regNum.charAt(2)); int[] encode = {0,0,0,0,0,0,0,0,0,0}; int pos=5; int j=0; for(int i=pos;i<pos+4;i++) { //System.out.println(regNum.charAt(j)); encode[i]=Integer.parseInt(regNum.charAt(j)+""); j++; } for(int i=0;i<encode.length;i++) System.out.print(encode[i]+" "); String rl="{r0-r2,pc}"; System.out.println(rl.substring(1,rl.length()-1)); }
3
static final void method3146(int i, int i_0_, byte i_1_, int i_2_, int i_3_, int i_4_, byte[] is, byte[] is_5_, int i_6_) { try { anInt9464++; int i_7_ = -(i_0_ >> -394325566); i_0_ = -(i_0_ & 0x3); if (i_1_ >= -12) method3148(true); for (int i_8_ = -i_3_; i_8_ < 0; i_8_++) { for (int i_9_ = i_7_; i_9_ < 0; i_9_++) { is[i_4_++] += -is_5_[i_6_++]; is[i_4_++] += -is_5_[i_6_++]; is[i_4_++] += -is_5_[i_6_++]; is[i_4_++] += -is_5_[i_6_++]; } for (int i_10_ = i_0_; (i_10_ ^ 0xffffffff) > -1; i_10_++) is[i_4_++] += -is_5_[i_6_++]; i_4_ += i; i_6_ += i_2_; } } catch (RuntimeException runtimeexception) { throw Class348_Sub17.method2929(runtimeexception, ("fd.D(" + i + ',' + i_0_ + ',' + i_1_ + ',' + i_2_ + ',' + i_3_ + ',' + i_4_ + ',' + (is != null ? "{...}" : "null") + ',' + (is_5_ != null ? "{...}" : "null") + ',' + i_6_ + ')')); } }
7
public ArrayList<ArrayList<String>> splitClauses(Sentence input) { tokenizedSentence = input.getSentence(); charIdentifier = input.getPosTags(); int previousIndex = 0; for (int index = 0; index < tokenizedSentence.size(); index++) { if ((tokenizedSentence.get(index).matches("[;:]") || (index == tokenizedSentence.size() - 1)) || (tokenizedSentence.get(index).equals(",") && (tokenizedSentence.get(index + 2).matches("[for|and|nor|but|or|yet|so]")))) { ArrayList<String> clauseHolder = new ArrayList<>(), identifierHolder = new ArrayList<>(); for (int i = previousIndex; i <= index; i++) { clauseHolder.add(tokenizedSentence.get(i)); identifierHolder.add(charIdentifier.get(i)); } clauses.add(clauseHolder); clauses.add(identifierHolder); previousIndex = index + 1; } } return clauses; }
6
@Override public void performInteraction(GameModel g, Unit myUnit) { if (!myUnit.hasAttribute("Attack")) return; AttributeAttack att = (AttributeAttack) myUnit.getAttribute("Attack"); ArrayList<Tile> tileList = g.getMap().getTilesList(); for (Tile t : tileList) { Tile myUnitTile = g.getMap().getTileByCoords(myUnit.getXTileLoc(), myUnit.getYTileLoc()); if(t.getDistance(myUnitTile)>att.getAttackRange()) continue; //out of range if (t.getUnit() == null) continue; Unit target = t.getUnit(); ArrayList<Unit> myUnitsList = g.getCurrentPlayer().getPlayerUnits() .getData(); if (myUnitsList.contains(target)) continue; // don't attack yourself or allied units. if (!target.hasAttribute("Health")) continue; AttributeHealth health = (AttributeHealth) target .getAttribute("Health"); health.decrementHP(att.getAttackDamage() / 5); // passive does 1/5 // the normal attack // damage if (health.getHP() <= 0) { target.beDestroyed(myUnit,g.getMap()); } } }
7
public void AddTlv(int tag, String value) { if (tag == TlvId.LinkID) { this.LinkID = value; } else if (tag == TlvId.Mserviceid) { this.ProductID = value; } else { if (this.OtherTlvArray == null) { Tlv[] tmp = new Tlv[1]; tmp[0] = new Tlv(tag, value); this.OtherTlvArray = tmp; } else { Tlv[] tmp = new Tlv[OtherTlvArray.length + 1]; System .arraycopy(OtherTlvArray, 0, tmp, 0, OtherTlvArray.length); tmp[OtherTlvArray.length] = new Tlv(tag, value); this.OtherTlvArray = tmp; } } }
3
public add() { this.info = "add a new venue"; this.addParamConstraint("name"); this.addParamConstraint("capacity", ParamCons.INTEGER); this.addRtnCode(201, "already exists"); }
0
@Override public String getName() { return NAME; }
0
public void setGameType(String game) { GameType = game; if (game.equals("matchcard")) { if (matchestowin == 6) { for (int i = 0; i < 6; i++) { list4x3.add(i); list4x3.add(i); } } else if (matchestowin == 10) { for (int i = 0; i < 10; i++) { list5x4.add(i); list5x4.add(i); } } else { for (int i = 0; i < 15; i++) { list6x5.add(i); list6x5.add(i); } } } }
6
private String getFloatValue(final Field field, final Object object) { Object result = getRawValue(field, object); if (result == null) { result = ""; } return result.toString(); }
1
private static String getValue(String value) { return (value == null || value.trim().length() == 0) ? null : value.trim(); }
2
* @return Kodierung des Konfigurationsverantwortlichen */ private short getAuthorityCoding(final ConfigurationConfigurationObject configurationObjectProperties) { final ConfigurationObjectElements[] datasetAndObjectSet = configurationObjectProperties.getDatasetAndObjectSet(); for(ConfigurationObjectElements element : datasetAndObjectSet) { if(element instanceof ConfigurationDataset) { // Datensatz ermitteln ConfigurationDataset dataset = (ConfigurationDataset)element; if(dataset.getPidATG().equals("atg.konfigurationsVerantwortlicherEigenschaften") && dataset.getPidAspect().equals( "asp.eigenschaften" )) { final DatasetElement[] data = dataset.getDataAnddataListAndDataField(); for(DatasetElement datasetElement : data) { if(datasetElement instanceof ConfigurationData) { final ConfigurationData configurationData = (ConfigurationData)datasetElement; if(configurationData.getName().equals("kodierung")) { return Short.valueOf(configurationData.getValue()); } } } } } } // Es konnte keine Kodierung ermittelt werden throw new IllegalStateException("Zum Konfigurationsverantwortlichen '" + configurationObjectProperties.getPid() + "' gibt es keine Kodierung."); }
7
public void setUp() throws Exception { try { d = new Database("dbauth.txt"); /*d = new Database("localhost", "postgres", "", "myapp_test"); //For travis-ci*/ try { d.initTables(); } catch(Exception e) { d.cleanTables(); d.initTables(); } } catch(Exception e) { e.printStackTrace(); throw new Exception("Error setting up database connection"); } }
2
@AnnotationTestTool public void method2() { System.out.println("method1"); }
0
public void steprun2() throws IOException { // FrontEnd.exceptionraised = 0; // handlers.clean_branchtable(); // handlers.clean_memtable(); FrontEnd.activepane.getHighlighter().removeAllHighlights(); //FrontEnd.activepane.setSelectionColor(new Color(1.0f, 1.0f, 1.0f, 0.0f)); Integer ct = new Integer(0); //System.out.println("ini_line ->" + ini_line + "fin_liine->" + fin_line + "f ->" + f); ct = backend.FirstPass.scan(backend.ScanFile.path); handlers.update_branchtable(ct); if (f == 0 && ini_line != fin_line) { //System.out.println("\n 0101010101010101"); for (int i = 1; i < ini_line; i++) { ScanFile.br.readLine(); } } if (debugMode == 0) { //System.out.println("1234 " + ini_line + "asdf" + fin_line); obj = new StepRun(backend.ScanFile.path, ini_line, fin_line, f); //System.out.println("steprun2()debugmode=0"); f = 1; obj.t.start(); } else if (debugMode == 1) { obj2 = new step_out(backend.ScanFile.path, ini_line, fin_line, f); obj2.t.start(); //System.out.println("steprun2()debugmode=1"); f = 1; debugMode = 0; } else if (debugMode == 2) { obj3 = new step_over(backend.ScanFile.path, ini_line, fin_line, f); obj3.t.start(); //System.out.println("steprun2()debugmode=2"); } (new handlers()).update(handlers.regMode); int memref_ct = Memory.getsize(); if (memref_ct > 0) { handlers.update_memorytable(memref_ct, handlers.regMode); } // if (FrontEnd.exceptionraised != 0) // { // FrontEnd.appendToPane(FrontEnd.statuswindow,"ERROR IN EXECUTION ",Color.BLACK); // FrontEnd.appendToPane(FrontEnd.statuswindow,FrontEnd.exceptionraised +" \n",Color.BLACK); //// FrontEnd.statuswindow.append("ERROR IN EXECUTION " + FrontEnd.exceptionraised + "\n"); // FrontEnd.exceptionraised = 0; // } //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());// TODO add your handling code here: }
7
public void setValuesWithMappingNameMap(final Map<String, Object> map, final ValueVisitor defaultVisitor) { Class<?> clazz = getClass(); final FieldDefinitionImpl thiz = this; try { SpringReflectionUtils.doWithFields(clazz, new SpringReflectionUtils.FieldCallback() { public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { if (!field .isAnnotationPresent(FieldDefinition.class)) { return; } FieldDefinition def = field .getAnnotation(FieldDefinition.class); String key = def.mappingName(); if (map.containsKey(key)) { field.setAccessible(true); Object value = map.get(key); Class<?> targetClass = field.getClass(); Map<String, Object> params = new HashMap<String, Object>( 1); params.put("escape", def.escape()); if (visitors.containsKey(targetClass)) { ValueVisitor visitor = visitors .get(targetClass); value = visitor.target(targetClass, value, params); } else if (defaultVisitor != null) { value = defaultVisitor.target( field.getClass(), value, params); } field.set(thiz, value); } } }, SpringReflectionUtils.COPYABLE_FIELDS); } catch (IllegalArgumentException e) { throw ExceptionFactory.wrapException("argument exception!", e); } }
7
public void onReceiveBid(MessageBid bid){ if (bid.getRound() == super.currentRound()) { if (bestBid == null) { bestBid = bid; synchronized (syncIncr) { shouldDecrease = true; } } else { if (bestBid.getRound() < bid.getRound()) { bestBid = bid; synchronized (syncIncr) { shouldDecrease = true; } } } } }
3
public ListNode deleteDuplicates(ListNode head) { if(null == head || head.next == null) return head; ListNode current = new ListNode(0); current.next = head; ListNode result = current; ListNode normal = current.next; ListNode compared = normal.next; boolean isDuplicated = false; while(null != compared) { if(normal.val == compared.val) { current.next = null; isDuplicated = true; }else { if(isDuplicated) { current.next = compared; normal = compared; isDuplicated = false; }else { current = normal; normal = current.next; } } compared = compared.next; } return result.next; }
5
private void initActions() { for (int i = 0; i < tools.length; ++i) { final Tool tool = tools[i]; String group = tool.group; if (group.equals("tool")) { tool.action = new Runnable() { public void run() { setPaintTool(tool.id); } }; } else if (group.equals("fill")) { tool.action = new Runnable() { public void run() { setFillType(tool.id); } }; } else if (group.equals("linestyle")) { tool.action = new Runnable() { public void run() { setLineStyle(tool.id); } }; } else if (group.equals("options")) { tool.action = new Runnable() { public void run() { FontDialog fontDialog = new FontDialog(paintSurface.getShell(), SWT.PRIMARY_MODAL); FontData[] fontDatum = toolSettings.commonFont.getFontData(); if (fontDatum != null && fontDatum.length > 0) { fontDialog.setFontList(fontDatum); } fontDialog.setText(getResourceString("options.Font.dialog.title")); paintSurface.hideRubberband(); FontData fontData = fontDialog.open(); paintSurface.showRubberband(); if (fontData != null) { try { Font font = new Font(mainComposite.getDisplay(), fontData); toolSettings.commonFont = font; updateToolSettings(); } catch (SWTException ex) { } } } }; } } }
9
public void warp(){ if(warped) return; random = false; destroyBodies(); scene = nextScene; scene.create(); if(warp!=null){ Vector2 w = warp.getLink().getWarpLoc(); createPlayer(w); if(warp.getLink().warpID==1 && !character.isFacingLeft()) character.setDirection(true); if(warp.getLink().warpID==0 && !character.isFacingLeft()) character.setDirection(false); } else { location.y-=1.5f*character.height; createPlayer(location); location = null; } initEntities(); cam.setBounds(Vars.TILE_SIZE*4, (scene.width-Vars.TILE_SIZE*4), 0, scene.height); b2dCam.setBounds((Vars.TILE_SIZE*4)/PPM, (scene.width-Vars.TILE_SIZE*4)/PPM, 0, scene.height/PPM); cam.removeFocus(); warped = true; }
6
private boolean message_ready() { // Message is completely read. Push it further and start reading // new message. (in_progress is a 0-byte message after this point.) if (msg_sink == null) return false; boolean rc = msg_sink.push_msg (in_progress); if (!rc) { return false; } next_step (tmpbuf, 1, one_byte_size_ready); return true; }
2
private void rotateUp(Node child) { assert child != null && child.parent() != null && child.parent().parent() != null; Node parent = child.parent(); Node grandparent = parent.parent(); if (grandparent.left() == parent) { grandparent.setLeft(child); } else { grandparent.setRight(child); } if (parent.left() == child) { parent.setLeft(child.right()); child.setRight(parent); } else { parent.setRight(child.left()); child.setLeft(parent); } }
4
public static void writeComment( StringBuffer buf, int depth, String line_ending, String comment ) { indent(buf, depth); buf.append("<!--"); buf.append(escapeXMLComment(comment)); buf.append("-->"); if (line_ending != null) { buf.append(line_ending); } }
1
private void doPaintBucketReg(int x, int y, Color newCol, Color currentCol) { // make sure it's on the image if (x > -1 && y > -1 && x < this.getDrawingWidth() && y < this.getDrawingHeight() && this.getPointColor(x, y).equals(currentCol)) { this.drawPoint(x, y, newCol); for (int ax = -1; ax < 2; ax++) for (int ay = -1; ay < 2; ay++) doPaintBucketReg(x + ax, y + ay, newCol, currentCol); } }
7
public MainView(Shell shell) { this.shell = shell; addFileDropTarget(shell); createMenubar(shell); SashForm sash = new SashForm(shell, SWT.NONE); this.fileList = new FileList(sash); Composite right = new Composite(sash, SWT.NONE); this.tabs = new CTabFolder(right, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; right.setLayout(gridLayout); tabs.setLayoutData(new GridData(GridData.FILL_BOTH)); createBottomBar(right); fileList.setFileSelectedCallback(new Callback<File>() { public void onCallback(File selected) { fileList.fileSelected(selected); for(CTabItem existing:tabs.getItems()) { if(existing.getData().equals(selected)) { tabs.setSelection(existing); return; } } final CTabItem tabItem = new CTabItem(tabs, SWT.NONE); tabItem.setText(selected.getName()); tabItem.setData(selected); tabs.setSelection(tabItem); tabItem.setShowClose(true); tabs.setSimple(false); tabs.setTabHeight(22); final FileView fileView = fileViews.get(selected); if(fileView.isEmpty()) { try { fileView.addLines(FileUtils.readLines(selected)); } catch(IOException e) { log.error("Error reading file: " + selected, e); } fileView.setTail(true); } Display.getCurrent().asyncExec(new Runnable() { public void run() { fileView.scrollToEnd(); } }); tabItem.setControl(fileView.getWidget()); } }); tabs.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { File file = (File)event.item.getData(); fileList.fileSelected(file); } }); tabs.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { if(event.stateMask == SWT.CONTROL && event.keyCode == 'w') { CTabItem selected = tabs.getSelection(); if(selected != null) { selected.dispose(); } } } }); sash.setWeights(new int[] { 30, 70 }); }
7
TestState(final String description, final char state) { this.description = description; this.state = state; }
0
List<Score> matchCouple(List<Person> ps, List<Person> left){ left.clear(); System.out.println("matching"); Map<Person, List<Score>> table = calculateAffinity(ps); // List<Score> result = matchCoupleRound(table); ps.stream() .filter(p -> result.stream().noneMatch(s -> s.self.equals(p) || s.target.equals(p))) .forEach(left::add); System.out.println("match " + result); System.out.println("left " + left); return result; }
1
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected && (-1 < index)) { list.setToolTipText(((File) list.getModel().getElementAt(index)).getPath()); } return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); }
2
private void nowaPaczka() { this.campaign.clearCampaign(); this.campaign.setGameDate(projectTabPane.getGameDate()); projectTabPane.initiateGameFields(); projectTabPane.updateGraph(); repaint(); }
0
public int clearLines() { int numClearedLines = 0; for (int curOldLine = board.length-1 ; curOldLine >= 0; curOldLine--) { if (curOldLine >= 2 && board[curOldLine] == 0x3ff) numClearedLines++; else board[curOldLine + numClearedLines] = board[curOldLine]; } for (int i = numClearedLines-1; i >= 0; i--) { if (i > 0) board[i] = board[0]; // Simulate GB Tetris line clear bug. else board[0] = 0; } return numClearedLines; }
5
public boolean setUserlistImageWidth(int width) { boolean ret = true; if (width <= 0) { this.userlistImg_Width = UISizeInits.USERLIST_IMAGE.getWidth(); ret = false; } else { this.userlistImg_Width = width; } somethingChanged(); return ret; }
1
@Test public void getIndexOutOfBoundsReturnsNull() { a.insert(v); assertEquals(null, a.get(Integer.MAX_VALUE)); assertEquals(null, a.get(-1)); }
0
public static void main(String[] args) { try { String f1 = "/home/mayank/DistributedSystems/test1.txt"; File file1 = new File(f1); FilePartition fp1 = new FilePartition(f1, 13, file1.length()); TextRecordReader reader = new TextRecordReader(fp1, null); Record<String, String> record; while( (record = reader.readNextRecord()) != null ) { System.out.println(record.getKey() + ":" + record.getValue()); } String f2 = "/home/mayank/DistributedSystems/test1.txt"; File file2 = new File(f2); FilePartition fp2 = new FilePartition(f2, 0, 13); reader = new TextRecordReader(fp2, null); while( (record = reader.readNextRecord()) != null ) { System.out.println(record.getKey() + ":" + record.getValue()); } String f3 = "/home/mayank/DistributedSystems/test1.txt"; File file3 = new File(f3); FilePartition fp3 = new FilePartition(f3, 14, file3.length()); reader = new TextRecordReader(fp3, null); while( (record = reader.readNextRecord()) != null ) { System.out.println(record.getKey() + ":" + record.getValue()); } String f4 = "/home/mayank/DistributedSystems/test2.txt"; File file4 = new File(f4); FilePartition fp4 = new FilePartition(f4, 0, file4.length()); reader = new TextRecordReader(fp4, "\t"); while( (record = reader.readNextRecord()) != null ) { System.out.println(record.getKey() + ":" + record.getValue()); } } catch (Exception e) { e.printStackTrace(); } }
5
public static synchronized User addUser(String username, ArrayList<User> users) { users = DataReader.getUsers(); // check if the user exists for (User u : users) { if (u.getUsername().equalsIgnoreCase(username)) { System.out.println("User already exists"); return u; } } // add the user to the user arraylist User u = new User(); u.setBalance(1000); u.setUsername(username); u.setUserStock(null); users.add(u); // write to the users file File f = new File("users.txt"); FileWriter fr = null; try { fr = new FileWriter(f); BufferedWriter br = new BufferedWriter(fr); String s = ""; for (User e : users) { s += e.getUsername() + " " + e.getBalance(); s += "\n"; } br.write(s); br.close(); } catch (IOException e) { e.printStackTrace(); } return u; }
4
@EventHandler public void onPlayerMove(PlayerMoveEvent e) { Zone zone = plugin.canPlayerWalkTo(e.getPlayer(), e.getTo()); if (zone != null) { if (!e.getPlayer().isDead()) e.getPlayer().sendMessage(zone.getOnEnter()); if (zone.isKillZone()) { if (!e.getPlayer().isDead()) e.getPlayer().setHealth(0); } else e.setCancelled(true); } }
4
@Override public String format(LogRecord record) { String throwable = ""; if (record.getThrown() != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println(); record.getThrown().printStackTrace(pw); pw.close(); throwable = sw.toString(); } String message = record.getMessage(); if (record.getParameters() != null && record.getParameters().length > 0) { message = MessageFormat.format(record.getMessage(), record.getParameters()); } return String.format("%1$tY%1$tm%1$td %1$tk:%1$tM:%1$tS.%1$tL,%2$d,%3$s,\"%4$s\",%5$s,%6$s%n" , new Date(record.getMillis()) , record.getThreadID() , record.getLevel() , message , record.getLoggerName() , throwable ); }
3
public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout) parent.getLayout(); } catch (ClassCastException exc) { System.err.println("The first argument to makeGrid must use SpringLayout."); return; } Spring xPadSpring = Spring.constant(xPad); Spring yPadSpring = Spring.constant(yPad); Spring initialXSpring = Spring.constant(initialX); Spring initialYSpring = Spring.constant(initialY); int max = rows * cols; //Calculate Springs that are the max of the width/height so that all //cells have the same size. Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)). getWidth(); Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)). getHeight(); for (int i = 1; i < max; i++) { SpringLayout.Constraints cons = layout.getConstraints( parent.getComponent(i)); maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth()); maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight()); } //Apply the new width/height Spring. This forces all the //components to have the same size. for (int i = 0; i < max; i++) { SpringLayout.Constraints cons = layout.getConstraints( parent.getComponent(i)); cons.setWidth(maxWidthSpring); cons.setHeight(maxHeightSpring); } //Then adjust the x/y constraints of all the cells so that they //are aligned in a grid. SpringLayout.Constraints lastCons = null; SpringLayout.Constraints lastRowCons = null; for (int i = 0; i < max; i++) { SpringLayout.Constraints cons = layout.getConstraints( parent.getComponent(i)); if (i % cols == 0) { //start of new row lastRowCons = lastCons; cons.setX(initialXSpring); } else { //x position depends on previous component cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring)); } if (i / cols == 0) { //first row cons.setY(initialYSpring); } else { //y position depends on previous row cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring)); } lastCons = cons; } //Set the parent's size. SpringLayout.Constraints pCons = layout.getConstraints(parent); pCons.setConstraint(SpringLayout.SOUTH, Spring.sum( Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)) ); pCons.setConstraint(SpringLayout.EAST, Spring.sum( Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)) ); }
6
public void clean(double time) { if (time <= 0 || jumpheight == 3) { return; } this.setDirtiness(this.getDirtiness() - time/length); }
2
@Override public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } if (args.length < 1) { player.sendMessage(ChatColor.YELLOW + "Deafened players:"); String plrs = ""; for (String plr : plugin.ignores) { plrs += plr + ", "; } player.sendMessage(ChatColor.YELLOW + plrs); player.sendMessage(ChatColor.YELLOW + "Use /deaf <player> to deafen someone."); return true; } else if (args.length == 1) { // One argument, mute the player String todeafenstring; Player todeafen = Bukkit.getServer().getPlayer(args[0]); if (todeafen != null) { todeafenstring = todeafen.getName(); } else { sender.sendMessage(ChatColor.RED + args[0] + " is not online."); return true; } if (todeafen == player) { if (plugin.ignores.contains(todeafenstring)) { plugin.ignores.remove(todeafenstring); todeafen.sendMessage(ChatColor.YELLOW + "You have been undeafened."); } else { plugin.ignores.add(todeafenstring); todeafen.sendMessage(ChatColor.YELLOW + "You have been deafened."); } } else if (player.hasPermission("warhub.moderator")) { if (plugin.ignores.contains(todeafenstring)) { plugin.ignores.remove(todeafenstring); player.sendMessage(ChatColor.YELLOW + todeafen.getName() + " has been undeafened."); todeafen.sendMessage(ChatColor.YELLOW + "You have been undeafened."); } else { plugin.ignores.add(todeafenstring); player.sendMessage(ChatColor.YELLOW + todeafen.getName() + " has been deafened."); todeafen.sendMessage(ChatColor.YELLOW + "You have been deafened."); } } else { player.sendMessage(ChatColor.RED + "You do not have permissions to deafen others."); } return true; } return false; }
9
public String [] toArray() { return new String [] {String.valueOf(id), String.valueOf(defaultPoints), defaultTime.toString(), name}; }
0
public static Move parseMove(String input) { Move rez = new Move(); int index = 0; while (index < input.length()) { char type = input.charAt(index++); switch (type) { case 'a': rez.addAttack(getArea(input, index++)); break; case 'b': rez.addBlock(getArea(input, index++)); break; case '.': case 'c': rez.setComment(input.substring(index)); index = input.length() + 1; break; case ' ': case '\t': case '\r': case '\n': continue; default: throw new IllegalArgumentException("Unrecognized input: " + type+ " "+(int)type); } } return rez; }
9
public double getWinningProbility(int c1,int c2){ if(!reduced){ if(!indexUpdated)updatePositionIndex(); return 1-position[c1*52+c2]; }else{ if(!rankUpdated)updateRank(); if(!positionUpdated)updatePosition(); int queryrank = 0; if(common == 3){ queryrank = FiveEval.getBestRankOf(c1, c2, comCard[0], comCard[1], comCard[2]); }else if(common == 4){ queryrank = FiveEval.getBestRankOf(c1, c2, comCard[0], comCard[1], comCard[2], comCard[3]); }else if(common == 5){ queryrank = FiveEval.getBestRankOf(c1, c2, comCard[0], comCard[1], comCard[2], comCard[3], comCard[4]); } int L = 0, R = len, M; while(L<R-1){ M=(L+R)/2; if(queryrank>hand[M].rank){ R = M; }else { L = M; } } return 1-hand[L].position; } }
9
private byte[] CreateData() { //create byte buffer for data byte[] buf = new byte[packetSize]; //holds the character bytes generated StringBuilder s = new StringBuilder(); char c; //generate data for the packet for(int x=0; x< (packetSize/26);x++) { for(int y=0; y<26; y++) { s.append( Character.toString((char)(y+65) )); } } for(int x=0; x< (packetSize%26);x++) { s.append(Character.toString((char)(x+65) )); } //return byte of characters return buf = s.toString().getBytes(); }
3
public String DELETE_Request(String url, String url_params) { StringBuffer response; String json_data = ""; HttpsURLConnection con = null; try { // url = "https://selfsolve.apple.com/wcResults.do"; // url_params = "sn=C02G8416DRJM&cn=&locale=&caller=&num=12345"; // URL obj = new URL(url); // con = (HttpsURLConnection) obj.openConnection(); con = (HttpsURLConnection) set_headers(url); con.setDoOutput(true); con.setRequestMethod("DELETE"); con.setRequestProperty("User-Agent", "Mozilla/5.0 ( compatible ) "); con.setRequestProperty("Content-Type", "application/json"); con.setRequestProperty("Accept", "application/json"); // con.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(url_params); wr.flush(); wr.close(); System.out.println(url_params); System.out.println(con.getResponseCode()); if (con.getResponseCode() == 500) System.out.println(con.getErrorStream()); if (con.getResponseCode() == 201) { BufferedReader in = new BufferedReader(new InputStreamReader( con.getInputStream())); String inputLine; response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); json_data = response.toString(); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { } catch (Exception e) { con.getErrorStream(); } return json_data; }
6
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SPKIData") public JAXBElement<SPKIDataType> createSPKIData(SPKIDataType value) { return new JAXBElement<SPKIDataType>(_SPKIData_QNAME, SPKIDataType.class, null, value); }
0
public CriterionGroup buildCriterionGroup() throws HqlBuildException { if(this.form == null || this.ruleScheme == null){ return new CriterionGroup(); } /** * 1. 生成CriterionResult */ CriterionGroup group = new CriterionGroup(); /** * 遍历Form对象所有属性 * 顺序是映射文件里面从上到下 */ Iterator<String> it = ruleScheme.keySet().iterator(); while(it.hasNext()){ String fieldName = it.next(); try { //如果是 serialVersionUID 属性就跳过 if("serialVersionUID".equals(fieldName)){ continue; } /** * 获取值对象 */ Object value = ReflectUtils.getFormValue(form, fieldName); /** * 如果 value == null 表示本次查询不对改条件限制 */ if(value==null){ continue; } /** * 根据field获取Rule对象,并通过rule和value获取CriterionItem对象 */ CriterionItem item = this.buildCriterionItem(ruleScheme.get(fieldName), value); /** * 添加CriterionItem 到 CriterionGroup中 */ group.addCriterionNode(item); } catch (SecurityException e) { e.printStackTrace(); continue; } } return group; }
6
@Override public void toggleEditability(int row, AttributeTableModel model) { Node node = doc.tree.getEditingNode(); String key = (String) model.keys.get(row); Object oldAndNewValue = node.getAttribute(key); boolean oldReadOnly = node.isReadOnly(key); boolean readOnly = !oldReadOnly; node.setReadOnly(key, readOnly); model.readOnly.set(row, new Boolean(readOnly)); // undo CompoundUndoable undoable = new CompoundUndoablePropertyChange(doc.tree); undoable.setName("Toggle Node Attribute Editability"); Undoable primitive = new PrimitiveUndoableAttributeChange(node, key, oldAndNewValue, oldReadOnly, key, oldAndNewValue, readOnly); undoable.addPrimitive(primitive); doc.getUndoQueue().add(undoable); update(); // [md] Added so that modification date updates. }
0
public static FileType getType(InputStream is) { String fileHead = getFileHeader(is); FileType[] fileTypes = FileType.values(); for (FileType fileType : fileTypes) { if (fileHead.startsWith(fileType.getValue())) { return fileType; } } return FileType.NOTSUPPORTED; }
2
@Override public void deserialize(Buffer buf) { super.deserialize(buf); targetId = buf.readInt(); startCellId = buf.readShort(); if (startCellId < -1 || startCellId > 559) throw new RuntimeException("Forbidden value on startCellId = " + startCellId + ", it doesn't respect the following condition : startCellId < -1 || startCellId > 559"); endCellId = buf.readShort(); if (endCellId < -1 || endCellId > 559) throw new RuntimeException("Forbidden value on endCellId = " + endCellId + ", it doesn't respect the following condition : endCellId < -1 || endCellId > 559"); }
4
private void drawLabels(double current_time) { // Draw take off button int opacity = (airport.is_active || airport.aircraft_hangar.size() == 0) ? 128 : 256; // Grey out if not clickable graphics.setColour(0, 128, 0, opacity); double y = y_position +height -division_height; if (!airport.is_active) { graphics.print("TAKE OFF", x_position + ((width - 70)/2), y + 9); } else { graphics.print("AIRPORT BUSY", x_position + ((width - 100)/2), y + 9); } graphics.setColour(graphics.white); // Draw aircraft in hangar double y_position = y + 12; double percentage_complete; for (int i = 0; i < airport.aircraft_hangar.size(); i++) { y_position -= division_height; graphics.setColour(graphics.white); graphics.print(airport.aircraft_hangar.get(i).getName(), x_position + ((width - 70)/2), y_position - 3); percentage_complete = barProgress(airport.time_entered.get(i), current_time); if (percentage_complete == 1) { graphics.setColour(graphics.red); } else { graphics.setColour(128, 128, 0); } graphics.line(x_position, y_position + 12, x_position + (width * percentage_complete), y_position + 12); } }
5
private void TfCodProdutoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TfCodProdutoKeyReleased if (!TfCodProduto.getText().equals("")) { prodcompravenda.getForneproduto().getProduto().setCodigo(Integer.parseInt(TfCodProduto.getText())); if (prodcompravenda.getForneproduto().getProduto().eprodutoativo() && !prodcompravenda.getForneproduto().getProduto().eservico()) { if (CbPessoa.getSelectedItem().toString().equals("Fornecedor") && prodcompravenda.getCompravenda().getOperacao().getTpestoque().equals("E")){ if(!TfCodPessoa.getText().equals("") && !TfPessoa.getText().equals("")){ if(prodcompravenda.getForneproduto().produtodestefornecedor()){ TfProduto.setText(prodcompravenda.getForneproduto().getProduto().retornadescricaoproduto()); TfQuantidade.setValue(BigDecimal.valueOf(0)); }else{ TfProduto.setText(""); TfQuantidade.setValue(BigDecimal.valueOf(0)); msg.CampoNaoPreenchido(LbNotificacao, "Este produto não pode ser adquirido com este fornecedor!"); } }else{ msg.CampoNaoPreenchido(LbNotificacao, "Digite o Fornecedor para que o sistema busque os produtos apenas deste Fornecedor!"); limpar.Limpar(jPanel3); TfCodPessoa.grabFocus(); } }else{ TfProduto.setText(prodcompravenda.getForneproduto().getProduto().retornadescricaoproduto()); TfQuantidade.setValue(BigDecimal.valueOf(0)); } } else { TfProduto.setText(""); TfQuantidade.setValue(BigDecimal.valueOf(0)); } } else { TfProduto.setText(""); TfQuantidade.setValue(BigDecimal.valueOf(0)); } }//GEN-LAST:event_TfCodProdutoKeyReleased
8
@Test public void testTop() { Random r = new Random(260379); ArrayList<Integer> workArr = new ArrayList<Integer>(); TreeMap<Integer, Integer> countToId = new TreeMap<Integer, Integer>(new Comparator<Integer>() { public int compare(Integer integer, Integer integer1) { return -integer.compareTo(integer1); } }); for(int i=1; i < 200; i+=2) { int n; do { n = r.nextInt(10000); } while (countToId.containsKey(n)); // Unique count keys countToId.put(n, i); insertMultiple(workArr, i, n); } DiscreteDistribution dist = new DiscreteDistribution(toIntArray(workArr)); IdCount[] top = dist.getTop(10); int j = 0; for(Map.Entry <Integer, Integer> e : countToId.entrySet()) { IdCount topEntryJ = top[j]; assertEquals((int)e.getValue(), topEntryJ.id); assertEquals((int)e.getKey(), topEntryJ.count); j++; if (top.length <= j) { assertEquals(10, j); break; } } }
4
private boolean r_postlude() { int among_var; int v_1; // repeat, line 75 replab0: while (true) { v_1 = cursor; lab1: do { // (, line 75 // [, line 77 bra = cursor; // substring, line 77 among_var = find_among(a_1, 4); if (among_var == 0) { break lab1; } // ], line 77 ket = cursor; switch (among_var) { case 0: break lab1; case 1: // (, line 78 // <-, line 78 slice_from("i"); break; case 2: // (, line 79 // <-, line 79 slice_from("u"); break; case 3: // (, line 80 // <-, line 80 slice_from("y"); break; case 4: // (, line 81 // next, line 81 if (cursor >= limit) { break lab1; } cursor++; break; } continue replab0; } while (false); cursor = v_1; break replab0; } return true; }
9
protected void configureCurrentConverter(int dialogType) { String filename; File currFile; if ( (getSelectedFile() == null) || (getSelectedFile().isDirectory()) ) return; filename = getSelectedFile().getAbsolutePath(); if (m_CurrentConverter == null) { if (dialogType == LOADER_DIALOG) m_CurrentConverter = ConverterUtils.getLoaderForFile(filename); else if (dialogType == SAVER_DIALOG) m_CurrentConverter = ConverterUtils.getSaverForFile(filename); else throw new IllegalStateException("Cannot determine loader/saver!"); // none found? if (m_CurrentConverter == null) return; } try { currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile(); if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename))) ((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename)); } catch (Exception e) { e.printStackTrace(); } }
9
@Override public String toString() { StringBuilder sb = new StringBuilder("User("); boolean first = true; sb.append("firstName:"); if (this.firstName == null) { sb.append("null"); } else { sb.append(this.firstName); } first = false; if (!first) sb.append(", "); sb.append("lastName:"); if (this.lastName == null) { sb.append("null"); } else { sb.append(this.lastName); } first = false; if (!first) sb.append(", "); sb.append("status:"); if (this.status == null) { sb.append("null"); } else { sb.append(this.status); } first = false; if (!first) sb.append(", "); sb.append("id:"); sb.append(this.id); first = false; sb.append(")"); return sb.toString(); }
6
public BreakPoint commitMinPenalty(int space, int lastSpace, int minPenalty) { if (startPos == -1 || lastSpace > endPos - startPos || minPenalty == 10 * (endPos - startPos - lastSpace)) { /* We don't have to break anything */ startPos = -1; childBPs = null; return this; } int size = childBPs.size(); if (size > 1 && options != DONT_BREAK) { /* penalty if we are breaking the line here. */ int breakPen = getBreakPenalty(space, lastSpace, minPenalty + 1); // pw.print("commit[bp="+breakPen+";"+minPenalty+";" // +space+","+lastSpace+"]"); if (minPenalty == breakPen) { commitBreakPenalty(space, lastSpace, breakPen); return this; } } /* penalty if we are breaking only one child */ for (int i = 0; i < size; i++) { BreakPoint child = (BreakPoint) childBPs.elementAt(i); int front = child.startPos - startPos; int tail = endPos - child.endPos; int needPenalty = minPenalty - (i < size - 1 ? 1 : 0); if (needPenalty == child.getMinPenalty(space - front, lastSpace - front - tail, needPenalty + 1)) { child = child.commitMinPenalty(space - front, lastSpace - front - tail, needPenalty); child.breakPos = breakPos; return child; } } pw.println("XXXXXXXXXXX CAN'T COMMIT"); startPos = -1; childBPs = null; return this; }
9
public static void write (org.omg.CORBA.portable.OutputStream ostream, pgrid.service.corba.repair.RepairIssue[] value) { ostream.write_long (value.length); for (int _i0 = 0;_i0 < value.length; ++_i0) pgrid.service.corba.repair.RepairIssueHelper.write (ostream, value[_i0]); }
1
public String getContenido(File file) throws IOException { String contenido = ""; if (file.exists()) { try { contenido = new Scanner(file).useDelimiter("\\Z").next(); } catch (FileNotFoundException ex) { } } return contenido; }
2
public int ladderLength(String start, String end, Set<String> dict) { if (dict.size() == 0) return 0; int curLevel = 1; int nextLevel = 0; int steps = 1; boolean isEndReached = false; Queue<String> bfsQueue = new LinkedList<String>(); Set<String> visited = new HashSet<String>(); bfsQueue.add(start); while (!bfsQueue.isEmpty()) { String cur = bfsQueue.remove(); curLevel -= 1; if (stringDiff(cur, end) == 1) { isEndReached = true; // Important - Need to add steps by 1 steps += 1; break; } StringBuffer sb = new StringBuffer(cur); for (int i = 0; i < sb.length(); i++) { char c = sb.charAt(i); for (int j = 0; j < 26; j++) { sb.setCharAt(i, (char) ('a' + j)); String oneStepStr = sb.toString(); if (dict.contains(oneStepStr) && !visited.contains(oneStepStr)) { bfsQueue.add(oneStepStr); visited.add(oneStepStr); nextLevel += 1; } } sb.setCharAt(i, c); } if (curLevel == 0) { curLevel = nextLevel; nextLevel = 0; steps += 1; } } return isEndReached ? steps : 0; }
9
public void update(double diff) { if (shootTimer <= diff) { shoot(); shootTimer = 500; } else shootTimer -= diff; if (path.isEmpty()) { int directionDiff = 300; if (Game.bounds.contains(left ? me.getX() - directionDiff : me.getX() + directionDiff, me.getY(), me.WIDTH, me.HEIGHT) && level.isTraversable(new Rectangle(left ? me.getX() - directionDiff : me.getX() + directionDiff, me.getY(), me.WIDTH, me.HEIGHT))) path.generatePath(me.getX(), me.getY(), left ? me.getX() - directionDiff : me.getX() + directionDiff, me.getY()); left = !left; } else me.traversePath(path); }
7
public int getInt(String key) throws JSONException { Object o = get(key); return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(key); }
1
public int getNodeID(int x, int y) { for(int i = 0; i < nodes.size(); i++) { if(x == nodes.get(i).getX() && y == nodes.get(i).getY()) return i; } return -1; }
3
public void propertyChange(PropertyChangeEvent e) { if(e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File newFile =(File)e.getNewValue(); if (newFile != null){ if ((newFile.isFile()) && (FileDialogs.isImage(newFile))) { String newPath = newFile.getAbsolutePath(); currentImageR = new ImageReference(newPath); isDir=false; } else if(newFile.isDirectory()) { currentImageR=null; isDir=true; } thumb.setToolTipText(newFile.getName()); } else { currentImageR=null; isDir=true; thumb.setToolTipText(""); } } RepaintManager.repaint(RepaintType.Preview); }
5
public static ItemStack setCustomBlockAmount(ItemStack item, int amount) { if ((amount <= 0) || (item == null) || (!item.hasItemMeta())) return null; ItemMeta meta = item.getItemMeta(); if ((meta == null) || (!meta.hasDisplayName())) return item; String title = meta.getDisplayName(); if ((title == null) || (!title.contains(" x "))) return item; item.setAmount(1); String name = title.substring(0, title.indexOf(" x ")); List<String> desc = meta.getLore(); ItemStack item2 = item.clone(); meta.setDisplayName(name + " x " + amount); meta.setLore(desc); item2.setItemMeta(meta); return item2; }
7
public static void main( String[] args) { if(args == null || args.length == 0) { System.err.println( "usage: java MappedPlaceholderResource <resourcefile basename> [[key] [value]] ..."); System.exit(1); } try { MappedPlaceholderResource mpr = new MappedPlaceholderResource(args[0]); Hashtable h = new Hashtable(); for(int i = 1; i < args.length - 1; i += 2) { h.put(args[i], args[i + 1]); } if(mpr.isSectionSeparatorsLoaded()) System.out.println("section separators loaded correctly: " + mpr.isSectionSeparatorsLoadedOk()); if(mpr.isSectionWordReplaceLoaded()) System.out.println("section wordreplace loaded correctly: " + mpr.isSectionWordReplaceLoadedOk()); if(mpr.isSectionValuesLoaded()) System.out.println("section values loaded correctly: " + mpr.isSectionValuesLoadedOk()); if(mpr.isSectionLinesLoaded()) System.out.println("section lines loaded correctly: " + mpr.isSectionLinesLoadedOk()); System.out.println("load errors:\n" + mpr.getLoadErrors()); System.out.println(mpr.mapPlaceholders(mpr.getTemplateBody(), h)); } catch(java.util.MissingResourceException mre) { System.err.println("Missing Resource Exception: " + mre.getMessage()); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); e.printStackTrace(); } }
9
@Test public void itShouldSerializeMultiPoint() throws Exception { MultiPoint lineString = new LineString(new LngLatAlt(100, 0), new LngLatAlt(101, 1)); Assert.assertEquals("{\"coordinates\":[[100.0,0.0],[101.0,1.0]],\"type\":\"LineString\"}", mapper.toJson(lineString)); }
0
private static void rsaEncrypterFile(CryptobyConsole console) { // Input Path to File for encryption scanner = new Scanner(System.in); scanner.useDelimiter("\n"); System.out.println("Enter Path to File for Encryption (Type '" + quit + "' to Escape):"); if (scanner.hasNext(quit)) { rsaCrypterFile(console); } plainFilePath = scanner.next(); // Get Bytes from PlainFile try { plainByte = CryptobyFileManager.getBytesFromFile(plainFilePath); } catch (IOException ex) { CryptobyHelper.printIOExp(); rsaCrypterFile(console); } // Input Path to save encrypted File scanner = new Scanner(System.in); scanner.useDelimiter("\n"); System.out.println("Enter Path to save encrypted File (Type '" + quit + "' to Escape):"); if (scanner.hasNext(quit)) { rsaCrypterFile(console); } cryptFilePath = scanner.next(); // Input Path to Public Key File for encryption scanner = new Scanner(System.in); scanner.useDelimiter("\n"); System.out.println("Enter Path to Public Key File (Type '" + quit + "' to Escape):"); if (scanner.hasNext(quit)) { rsaCrypterFile(console); } publicKeyPath = scanner.next(); // Get Bytes from Public Key File try { publicKeyByte = CryptobyFileManager.getKeyFromFile(publicKeyPath); } catch (IOException ex) { CryptobyHelper.printIOExp(); rsaCrypterFile(console); } catch (NumberFormatException nfex) { System.out.println("Key File format is not correct!"); rsaCrypterFile(console); } // Initial RSA Crypt Object initRSAKeyGen(console); // Encrypt the File with given Public Key System.out.println("\nEncryption in progress..."); cryptByte = console.getCore().getCryptAsym().encrypt(plainByte, publicKeyByte); System.out.println("\nEncryption successfull. Saving File now..."); // Put encrypted Bytes to File try { CryptobyFileManager.putBytesToFile(cryptFilePath, cryptByte); } catch (IOException ex) { CryptobyHelper.printIOExp(); rsaCrypterFile(console); } System.out.println("\nEncrypted File saved to this Path:"); System.out.println(cryptFilePath); // Reset Variables initRSAKeyGen(console); cryptByte = null; plainByte = null; publicKeyByte = null; // Back to Menu rsaCrypter with Enter (Return) Key System.out.println("\nGo back to RSA File Crypter Menu: Press Enter"); CryptobyHelper.pressEnter(); rsaCrypterFile(console); }
7
public List findRecords(String sqlString, boolean closeConnection) throws SQLException, Exception { Statement stmt = null; ResultSet rs = null; ResultSetMetaData metaData = null; final List list=new ArrayList(); Map record = null; // do this in an excpetion handler so that we can depend on the // finally clause to close the connection try { stmt = conn.createStatement(); rs = stmt.executeQuery(sqlString); metaData = rs.getMetaData(); final int fields=metaData.getColumnCount(); while( rs.next() ) { record = new HashMap(); for( int i=1; i <= fields; i++ ) { try { record.put( metaData.getColumnName(i), rs.getObject(i) ); } catch(NullPointerException npe) { // no need to do anything... if it fails, just ignore it and continue } } // end for list.add(record); } // end while } catch (SQLException sqle) { throw sqle; } catch (Exception e) { throw e; } finally { try { stmt.close(); if(closeConnection) conn.close(); } catch(SQLException e) { throw e; } // end try } // end finally return list; // will be null if none found }
7
public static void main(String args[]) { //MagicPower.setMP(999); GraphicDisplay gd = new GraphicDisplay(); Game game = new Game(gd); game.init(); gd.setGame(game); gd.menu(); //gd.setup(); // game.getMap().addTower(2, 2); // game.getMap().addTower(6, 1); // game.getMap().addTower(8, 1); // game.getMap().addTower(8, 3); // game.getMap().addTower(8, 6); // game.getMap().addTower(8, 18); // game.getMap().setGem(new DmgGem()); // game.getMap().upgradeTower(2, 2); // game.start(); Parser p = new Parser(game); while(true) { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); try { p.parse(r.readLine()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
2
public void startTeleport2(int x, int y, int height) { if(c.duelStatus == 5) { c.sendMessage("You can't teleport during a duel!"); return; } if(c.duelStatus >= 1 && c.duelStatus <= 4) { Client o = (Client) Server.playerHandler.players[c.duelingWith]; c.duelStatus = 0; o.duelStatus = 0; //c.sendMessage("@red@The challange has been declined."); //o.sendMessage("@red@Other player has declined the challange."); //Misc.println("trade reset"); o.getTradeAndDuel().declineDuel(); c.getTradeAndDuel().declineDuel(); //return; } if(System.currentTimeMillis() - c.teleBlockDelay < c.teleBlockLength) { c.sendMessage("You are teleblocked and can't teleport."); return; } if(!c.isDead && c.teleTimer == 0) { c.stopMovement(); removeAllWindows(); c.teleX = x; c.teleY = y; c.npcIndex = 0; c.playerIndex = 0; c.faceUpdate(0); c.teleHeight = height; c.startAnimation(714); c.teleTimer = 11; c.teleGfx = 308; c.teleEndAnimation = 715; } }
6
public static Sha1Hash forValue (Value<?> value) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA1"); } catch (NoSuchAlgorithmException e) { // If the SHA1 algorithm doesn't exist, returns null return null; } BencodeOutputStream bout = new BencodeOutputStream(new DigestOutputStream(new VoidOutputStream(), md)); try { bout.writeValue(value); } catch (IOException e) { // This should never happen // In case it does, this method returns null return null; } finally { bout.close(); } return new Sha1Hash(md.digest()); }
3
public Car issueCar(DrivingLicense drivingLicense, String typeOfCar){ Date now = new Date(); Car c = AbstractCar.getInstance(typeOfCar, RegistrationNumber.getInstance(extracted(registrationNumber).getLetterIdentifier(), extracted(registrationNumber).getNumberIdentifier()), fuelCapacity, fuelInCar, carRented); long driverAge = now.getTime() - drivingLicense.getDateOfBirth().getTime(); long licenseAge = now.getTime() - drivingLicense.getDateOfIssue().getTime(); if (typeOfCar.equalsIgnoreCase("small car")){ if(driverAge > 20*365*24*60*60*1000 && licenseAge > 1*365*24*60*60*1000 && drivingLicense.getIsFullLicense()==true){ c = AbstractCar.getInstance("small car", RegistrationNumber.getInstance(extracted(registrationNumber).getLetterIdentifier(), extracted(registrationNumber).getNumberIdentifier()), fuelCapacity, fuelInCar, carRented); fuelInCar = 49; carRented = true; CARS.remove(c); } else { throw new IllegalArgumentException("A car cannot be allocated"); } } else if (typeOfCar.equalsIgnoreCase("large car")){ if(driverAge > 25*365*24*60*60*1000 && licenseAge > 5*365*24*60*60*1000 && drivingLicense.getIsFullLicense()== true){ c = AbstractCar.getInstance("small car", RegistrationNumber.getInstance(extracted(registrationNumber).getLetterIdentifier(), extracted(registrationNumber).getNumberIdentifier()), fuelCapacity, fuelInCar, carRented); fuelInCar = 60; carRented = true; CARS.remove(c); } else { throw new IllegalArgumentException("A car cannot be allocated"); } } else{ throw new IllegalArgumentException("That is not a suitable type of car"); } RENTEDCARS.put(drivingLicense, c); return c; }
8
private void readNormalPatchContent(SinglePatch patch) throws IOException, PatchException { List<Hunk> hunks = new ArrayList<Hunk>(); Hunk hunk = null; Matcher m; for (;;) { String line = readPatchLine(); if (line == null || line.startsWith("Index:")) { unreadPatchLine(); break; } if ((m = normalAddRangePattern.matcher(line)).matches()) { hunk = new Hunk(); hunks.add(hunk); parseNormalRange(hunk, m); } else if ((m = normalChangeRangePattern.matcher(line)).matches()) { hunk = new Hunk(); hunks.add(hunk); parseNormalRange(hunk, m); } else if ((m = normalDeleteRangePattern.matcher(line)).matches()) { hunk = new Hunk(); hunks.add(hunk); parseNormalRange(hunk, m); } else { if (line.startsWith("> ")) { hunk.lines.add("+" + line.substring(2)); } else if (line.startsWith("< ")) { hunk.lines.add("-" + line.substring(2)); } else if (line.startsWith("---")) { // ignore } else { throw new PatchException("Invalid hunk line: " + line); } } } patch.hunks = hunks.toArray(new Hunk[hunks.size()]); }
9
@Override public Attributes clone() { if (attributes == null) return new Attributes(); Attributes clone; try { clone = (Attributes) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } clone.attributes = new LinkedHashMap<String, Attribute>(attributes.size()); for (Attribute attribute: this) clone.attributes.put(attribute.getKey(), attribute.clone()); return clone; }
3
public static void main(String[] args) { Flower x = new Flower(); x.printPetalCount(); }
0
public boolean readBuffersFromNextSoundInSequence() { if( !toStream ) { errorMessage( "Method 'readBuffersFromNextSoundInSequence' may " + "only be used for streaming sources." ); return false; } synchronized( soundSequenceLock ) { if( soundSequenceQueue != null && soundSequenceQueue.size() > 0 ) { if( nextCodec != null ) nextCodec.cleanup(); nextCodec = SoundSystemConfig.getCodec( soundSequenceQueue.get( 0 ).getFilename() ); nextCodec.initialize( soundSequenceQueue.get( 0 ).getURL() ); SoundBuffer buffer = null; for( int i = 0; i < SoundSystemConfig.getNumberStreamingBuffers() && !nextCodec.endOfStream(); i++ ) { buffer = nextCodec.read(); if( buffer != null ) { if( nextBuffers == null ) nextBuffers = new LinkedList<SoundBuffer>(); nextBuffers.add( buffer ); } } return true; } } return false; }
8
public boolean checkDraw() { if (drawCounter == 42 && !(checkVertical() && checkMainDiagonal() && checkAntiDiagonal() && checkHorizontal())) { game.setGameIsOver(true); return true; } return false; }
5
public Vector getAcceleration(){ Vector accel = new Vector(0,-12); if( isOnGround ){ accel.x = controller.getX()*3; } else if ( controller.getButtonJump() && jetpackFuel > 0 ){ accel.x = controller.getX()*12; } else { accel.x = controller.getX()*1; } if( controller.getButtonJump() && jetpackFuel > 0 ){ accel.y = 10; } return accel; }
5
public int getStudentCategoryId() { return studentCategoryId; }
0
public String getDerivation() { return derivation; }
0
void setElement(String name, int contentType, String contentModel, Hashtable attributes) throws java.lang.Exception { Object element[]; // Try looking up the element element = (Object[]) elementInfo.get(name); // Make a new one if necessary. if (element == null) { element = new Object[3]; element[0] = new Integer(CONTENT_UNDECLARED); element[1] = null; element[2] = null; } else if (contentType != CONTENT_UNDECLARED && ((Integer) element[0]).intValue() != CONTENT_UNDECLARED) { error("multiple declarations for element type", name, null); return; } // Insert the content type, if any. if (contentType != CONTENT_UNDECLARED) { element[0] = new Integer(contentType); } // Insert the content model, if any. if (contentModel != null) { element[1] = contentModel; } // Insert the attributes, if any. if (attributes != null) { element[2] = attributes; } // Save the element info. elementInfo.put(name, element); }
6
private void moveCamera(MouseEvent e) { //System.out.println("============= Move camera ============"); try { dragEndScreen = e.getPoint(); Point2D.Float dragStart = transformPoint(dragStartScreen); Point2D.Float dragEnd = transformPoint(dragEndScreen); double dx = dragEnd.getX() - dragStart.getX(); double dy = dragEnd.getY() - dragStart.getY(); coordTransform.translate(dx, dy); dragStartScreen = dragEndScreen; dragEndScreen = null; targetComponent.repaint(); } catch (NoninvertibleTransformException ex) { ex.printStackTrace(); } }
1
public void run() { Socket sckOut = null; InetSocketAddress isaTmp = null; try { sckOut = new Socket(); sckOut.bind ( new InetSocketAddress ( EzimNetwork.localAddress , 0 ) ); isaTmp = new InetSocketAddress ( this.addr , this.port ); sckOut.connect(isaTmp, EzimNetwork.dtxTimeout); EzimDtxFileSemantics.sendFile ( sckOut , this.efo.getId() , this.efo ); } catch(Exception e) { EzimLogger.getInstance().warning(e.getMessage(), e); this.efo.unregDispose(); } finally { try { if (sckOut != null && ! sckOut.isClosed()) sckOut.close(); } catch(Exception e) { EzimLogger.getInstance().severe(e.getMessage(), e); } } }
4
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); HttpSession session=request.getSession(true); Connection con=(Connection)Konekcija.konekcija(); String []g = request.getParameterValues("check"); String dugme=request.getParameter("dodaj"); if(dugme.equalsIgnoreCase("odobri")){ if (g != null) { for (int i = 0; i < g.length; i++) { String naziv=g[i]; Statement st=null; Statement st1=null; ResultSet rs1=null; try{ session.setAttribute("naziv", naziv); st1=con.createStatement(); st1.executeUpdate("Delete from trebovanje where Naziv='"+naziv+"'");; RequestDispatcher dis1=request.getRequestDispatcher("formaZaDodavanjeArtikla.jsp"); dis1.forward(request, response); }catch(SQLException e){ } } } }else if(dugme.equalsIgnoreCase("odbij")){ if (g != null) { for (int i = 0; i < g.length; i++) { String naziv=g[i]; Statement st3=null; try{ st3=con.createStatement(); st3.executeUpdate("Delete from trebovanje where Naziv='"+naziv+"'"); RequestDispatcher dis=request.getRequestDispatcher("logovanjeSefaMagacina.jsp"); dis.forward(request, response); }catch(SQLException e){} } } } }
8
public EventInfo(String name, String loc, String id, String note) { final JFrame eventInfo = new JFrame(); eventInfo.setVisible(true); eventInfo.setTitle("Event Info"); eventInfo.setLocationRelativeTo(CalendarPanel.bullseye); eventInfo.setSize(400, 300); JPanel infoPanel = new JPanel(); eventInfo.getContentPane().add(infoPanel); infoPanel.setSize(400, 300); infoPanel.setVisible(true); infoPanel.setLayout(null); JButton btnCancel = new JButton("Cancel"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { eventInfo.dispose(); } }); btnCancel.setBounds(134, 231, 107, 29); infoPanel.add(btnCancel); JLabel lblEventName = new JLabel("Event Name: "); lblEventName.setBounds(17, 20, 117, 16); infoPanel.add(lblEventName); JLabel lblEventDescription = new JLabel("Event Location: "); lblEventDescription.setBounds(17, 48, 117, 16); infoPanel.add(lblEventDescription); JLabel lblEventNote = new JLabel("Event Note:"); lblEventNote.setBounds(17, 108, 117, 16); infoPanel.add(lblEventNote); eventName = new JTextField(); eventName.setEditable(false); eventName.setBounds(146, 14, 215, 28); infoPanel.add(eventName); eventName.setText(name); eventName.setColumns(10); location = new JTextField(); location.setEditable(false); location.setBounds(146, 42, 215, 28); infoPanel.add(location); location.setText(loc); location.setColumns(10); txtpnNote = new JTextPane(); txtpnNote.setBorder(new LineBorder(Color.LIGHT_GRAY)); txtpnNote.setText(note); txtpnNote.setBounds(146, 108, 215, 83); infoPanel.add(txtpnNote); JLabel lblEventID = new JLabel("Event ID: "); lblEventID.setBounds(17, 76, 117, 16); infoPanel.add(lblEventID); eventId = new JTextField(); eventId.setBounds(146, 72, 215, 28); eventId.setText(id); infoPanel.add(eventId); eventId.setColumns(10); lblMsg = new JLabel(""); lblMsg.setBounds(146, 204, 215, 16); infoPanel.add(lblMsg); JButton btnSave = new JButton("Save"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String eventid = eventId.getText(); String note = txtpnNote.getText(); if (eventid.length() > 11) { lblMsg.setText("Can't set notes for CBS Events."); } else { try { String answer = Switch.switchMethod("saveNote", eventid, note); System.out.println(answer); if (answer.equals("0")) { lblMsg.setText("Note updated!"); Thread.sleep(1000); eventInfo.dispose(); } else if (answer.equals("1")) { lblMsg.setText("Note added!"); Thread.sleep(1000); eventInfo.dispose(); } } catch (Exception e1) { e1.printStackTrace(); } } } }); btnSave.setBounds(267, 231, 107, 29); infoPanel.add(btnSave); JButton delEvent = new JButton("Delete event"); delEvent.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String eventid = eventId.getText(); try { String answer = Switch.switchMethod("deleteEvent", eventid, ""); if (answer.equals("0")) { @SuppressWarnings("unused") CBSTEST change = new CBSTEST(CalendarLogin.currentUser .getUsername()); eventInfo.dispose(); } else if (answer.equals("1")) { lblMsg.setText("Couldn't delete event."); } } catch (Exception e1) { e1.printStackTrace(); } } }); delEvent.setBounds(17, 231, 107, 29); infoPanel.add(delEvent); }
7
private void maxHeapify(int pos){ if(!isLeaf(pos)){ if(myHeap[pos].compare(myHeap[this.leftChild(pos)]) == -1 || myHeap[pos].compare( myHeap[this.rightChild(pos)]) == -1){ if(myHeap[this.leftChild(pos)].compare(myHeap[this.rightChild(pos)]) == 1){ swap(pos, this.leftChild(pos)); maxHeapify(this.leftChild(pos)); }else{ swap(pos,this.rightChild(pos)); maxHeapify(this.rightChild(pos)); } } } }
4
public void keyPressed(KeyEvent e) { if(count>=3 && count<5) picnum=6; if(count>4) picnum=7; if(count<3) picnum=5; int key = e.getKeyCode(); if(key == 37) direction = LEFT; else if(key == 38) direction = UP; else if(key == 39) direction = RIGHT; else if (key == 40) direction = DOWN; else if(key==32) space=true; }
9
private static List<String> tokenise(String string, Map<Character, Match> matches, char escapeChar, boolean includeSplitCharAsToken) { List<String> tokenised = new LinkedList<>(); StringBuffer sb = new StringBuffer(); boolean escape = false; for (char c : string.toCharArray()) { if (!escape && matches.containsKey(c)) { // split here if (sb.length() > 0) { tokenised.add(sb.toString()); sb = new StringBuffer(); } if (includeSplitCharAsToken) { tokenised.add(String.valueOf(c)); } escape = false; } else if (c == escapeChar) { if (escape) { // we've escaped the escape char so this should be added to the string buffer sb.append(c); escape = false; } else { escape = true; } } else { sb.append(c); escape = false; } } if (sb.length() > 0) { tokenised.add(sb.toString()); } return tokenised; }
8
@Override public void caseAParaPassoComando(AParaPassoComando node) { inAParaPassoComando(node); if(node.getVar() != null) { node.getVar().apply(this); } if(node.getADe() != null) { node.getADe().apply(this); } if(node.getAPasso() != null) { node.getAPasso().apply(this); } if(node.getAAte() != null) { node.getAAte().apply(this); } { List<PComando> copy = new ArrayList<PComando>(node.getComando()); for(PComando e : copy) { e.apply(this); } } outAParaPassoComando(node); }
5
@SuppressWarnings("unchecked") @Override public <T extends Serializable> DiagnosisChannel<T> channel(Class<? extends DiagnosisChannelID<T>> channel, ChannelOption... options) { // In case we are disabled, return a dummy if (this.isDisabled) { final DiagnosisChannel<?> impl = new DiagnosisChannelDummyImpl(this, channel); return (DiagnosisChannel<T>) impl; } // In case this was the first call, create a serializer synchronized (this) { try { if (this.serializer == null) { this.serializer = new LogFileWriter(this.recordingFile, this.compressOutput); } } catch (Exception e) { // In case something goes wrong, return a dummy e.printStackTrace(); final DiagnosisChannel<?> impl = new DiagnosisChannelDummyImpl(this, channel); return (DiagnosisChannel<T>) impl; } } final DiagnosisChannel<?> impl = new DiagnosisChannelImpl(this, channel); return (DiagnosisChannel<T>) impl; }
7
private boolean isBlocked(float x, float y) { boolean blocked = false; float tweakedX = x + 4; float tweakedY = y + 8 + mapY; int rowCount = genX / blockSize; int startY = (Math.round(mapY / blockSize))* rowCount + 1; int endY = (Math.round((mapY + screenHeight) / blockSize) - 1)* rowCount; if(startY < 0) startY = 0; if(endY > map.length) endY = map.length; if(tweakedX > screenWidth || tweakedX < 0) blocked = true; playerBoundingRect.setLocation(tweakedX,tweakedY); for(int i = startY; i < endY; i++){ if(playerBoundingRect.intersects(map[i])){ if(map[i].type != 0){ blocked = true; } } } return blocked; }
7
public void run() { while (true) { try { String msg = (String) sInput.readObject(); // if console mode print the message and add back the prompt if (cg == null) { System.out.println(msg); System.out.print("> "); } else { cg.append(msg); } } catch (IOException e) { display("Server has close the connection: " + e); if (cg != null) cg.connectionFailed(); break; } // can't happen with a String object but need the catch anyhow catch (ClassNotFoundException e2) { } } }
5
public void updateForecast() { Date date = new Date(); long maxTimeNoUpdate = Long.parseLong(config.getWeather_expiration_time()); long timeNow = date.getTime()/1000L; long timeLastForecast = 0; try { crs = qb.selectFrom("forecast").all().executeQuery(); if(crs.next()){ timeLastForecast = crs.getDate("date").getTime()/1000L; } } catch(SQLException e) { e.printStackTrace(); } finally { try { crs.close(); } catch (SQLException e) { e.printStackTrace(); } } if(timeNow-timeLastForecast > maxTimeNoUpdate){ System.out.println("UPDATING FORECAST"); saveForecast(); } else { System.out.println("FORECAST IS UP TO DATE"); } }
4
public HGSearchResult<T> execute() { switch (scanType) { case keys: return ((HGIndex<T, ?>)index).scanKeys(); case values: ((HGIndex<?, T>)index).scanValues(); default: switch (operator) { case EQ: return ((HGIndex<Object, T>)index).find(key.get()); case LT: return ((HGSortIndex<Object, T>)index).findLT(key.get()); case GT: return ((HGSortIndex<Object, T>)index).findGT(key.get()); case LTE: return ((HGSortIndex<Object, T>)index).findLTE(key.get()); case GTE: return ((HGSortIndex<Object, T>)index).findGTE(key.get()); default: throw new HGException("Wrong operator code [" + operator + "] passed to IndexBasedQuery."); } } }
9
public void NextQuestion() { if(i == QuestionCount -1 ) { i = 0; } else { // Current Question Id incremented by 1 i++; } // Display question in form this.SetUp(); }
1
private void trickleDown(int index) { int largerChild; BTPosition<T> top = heap.get(index); while (index < size / 2) { int leftChild = 2 * index + 1; int rightChild = leftChild + 1; if (rightChild < size && comp.compare(heap.get(leftChild).element(), heap.get(rightChild).element()) < 0) largerChild = rightChild; else largerChild = leftChild; // if top >= largerChild, no more tickle, break if (comp.compare(top.element(), heap.get(largerChild).element()) >= 0) break; heap.set(index, heap.get(largerChild)); index = largerChild; } heap.set(index, top); // put old root to index }
4
@Override public String getOutputStatement(String toDisplay) { int l = toDisplay.length(); int dl = l * 2 + 11; if (dl < 0) dl = l; StringBuilder sb = new StringBuilder(dl); sb.append("println(\""); for (int i = 0; i < l; i++) { char c = toDisplay.charAt(i); switch (c) { case '\\': sb.append('\\'); sb.append('\\'); break; case '\n': sb.append('\\'); sb.append('n'); break; case '\r': sb.append('\\'); sb.append('r'); break; case '\t': sb.append('\\'); sb.append('t'); break; case '\'': sb.append('\\'); sb.append('\''); break; case '"': sb.append('\\'); sb.append('"'); break; default: sb.append(c); break; } } sb.append("\")"); return sb.toString(); }
8
public int minCut(String s) { int min=0; if(s==null||s.length()==0){ return min; } int len=s.length(); int[] cuts=new int[len+1]; boolean[][] matrix=new boolean[len][len]; //initiate the cuts to the worst condition for(int i=0;i<len;i++){ cuts[i]=len-i; } //Dynamic Programming for(int i=len-1;i>=0;i--){ for(int j=i;j<len;j++){ if((s.charAt(i)==s.charAt(j)&&(j-i<2))||(s.charAt(i)==s.charAt(j) && matrix[i+1][j-1])){ matrix[i][j]=true; cuts[i]=Math.min(cuts[i], cuts[j+1]+1); } } } min=cuts[0]-1; return min; }
9
private static void loadOptions() { File inputFile = new File("haven.conf"); if (!inputFile.exists()) { return; } try { options.load(new FileInputStream("haven.conf")); } catch (IOException e) { System.out.println(e); } String hideObjects = options.getProperty("hideObjects", ""); String hideHighlight = options.getProperty("hcolor", "255,0,0,128"); // System.out.println(hideHighlight); String clist[] = hideHighlight.split(","); if(clist.length != 4) { clist[0] = "255"; clist[1] = "0"; clist[2] = "0"; clist[0] = "128"; } // String salpha = hideHighlight.substring(8); // hideAlpha = Integer.parseInt(salpha, 16); // hideHighlight = hideHighlight.substring(0, 8); // hideColor = Color.decode(hideHighlight); hideColor = new Color(Integer.valueOf(clist[0]), Integer.valueOf(clist[1]), Integer.valueOf(clist[2]), Integer.valueOf(clist[3])); GoogleTranslator.apikey = options.getProperty("GoogleAPIKey", "AIzaSyCuo-ukzI_J5n-inniu2U7729ZfadP16_0"); zoom = options.getProperty("zoom", "false").equals("true"); noborders = options.getProperty("noborders", "false").equals("true"); new_minimap = options.getProperty("new_minimap", "true").equals("true"); new_chat = options.getProperty("new_chat", "true").equals("true"); use_smileys = options.getProperty("use_smileys", "true").equals("true"); isMusicOn = options.getProperty("music_on", "true").equals("true"); isSoundOn = options.getProperty("sound_on", "true").equals("true"); showDirection = options.getProperty("show_direction", "true").equals( "true"); showNames = options.getProperty("showNames", "true").equals("true"); showOtherNames = options.getProperty("showOtherNames", "false").equals( "true"); showBeast = options.getProperty("showBeast", "false").equals("true"); showRadius = options.getProperty("showRadius", "false").equals("true"); showHidden = options.getProperty("showHidden", "false").equals("true"); simple_plants = options.getProperty("simple_plants", "false").equals( "true"); objectHighlighting = options.getProperty("objMouseHLight", "false") .equals("true"); // Kerri onlineNotifier = options.getProperty("onlineNotifier", "false").equals( "true"); // Kerri showDayTime = options.getProperty("showDayTime", "false") .equals("true"); // Kerri objectBlink = options.getProperty("objectBlink", "false") .equals("true"); // Kerri autoSaveMinimaps = options.getProperty("autoSaveMinimaps", "false").equals("true"); // Kerri sshot_compress = options.getProperty("sshot_compress", "false").equals( "true"); sshot_noui = options.getProperty("sshot_noui", "false").equals("true"); sshot_nonames = options.getProperty("sshot_nonames", "false").equals( "true"); newclaim = options.getProperty("newclaim", "true").equals("true"); showq = options.getProperty("showq", "true").equals("true"); showpath = options.getProperty("showpath", "false").equals("true"); showFlavors = options.getProperty("showFlavors", "false").equals("true"); showpathAll = options.getProperty("showpathAll", "false").equals("true"); tileAA = options.getProperty("tileAA", "false").equals("true"); // Kerri drawIcons = options.getProperty("drawIcons", "false").equals("true"); // Kerri // Kerri hideTressp = options.getProperty("hideTressp", "false").equals("true"); hideTheft = options.getProperty("hideTheft", "false").equals("true"); hideAsslt = options.getProperty("hideAsslt", "false").equals("true"); hideBatt = options.getProperty("hideBatt", "false").equals("true"); hideVand = options.getProperty("hideVand", "false").equals("true"); hideMurd = options.getProperty("hideMurd", "false").equals("true"); // show_minimap_profits = options.getProperty("show_minimap_profits", "false").equals("true"); toggleCA = options.getProperty("toggleCA", "false").equals("true"); toggleTR = options.getProperty("toggleTR", "false").equals("true"); toggleCL = options.getProperty("toggleCL", "false").equals("true"); show_gob_health = options.getProperty("show_gob_health", "false") .equals("true"); show_minimap_players = options.getProperty("show_minimap_players", "false").equals("true"); show_minimap_radius = options.getProperty("show_minimap_radius", "false").equals("true"); sfxVol = Integer.parseInt(options.getProperty("sfx_vol", "100")); musicVol = Integer.parseInt(options.getProperty("music_vol", "100")); hideObjectList.clear(); if (!hideObjects.isEmpty()) { for (String objectName : hideObjects.split(",")) { if (!objectName.isEmpty()) { hideObjectList.add(objectName); } } } Resource.checkhide(); timestamp = options.getProperty("timestamp", "false").equals("true"); try { INIFile ifile = new INIFile("haven.ini"); minimap_highlights = ifile.getSectionColors("HIGHLIGHT", ""); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
7