text
stringlengths
14
410k
label
int32
0
9
public static void main(String[] args) { Scanner inputScanner = null; try { inputScanner = new Scanner(new File(args[0])); } catch (Exception e) { System.err.println("Invalid file input"); } int input; int count; int count2; int count3; while (inputScanner.hasNextLine()) { count = 1; cou...
4
String[] getMOTD() { try { File file = new File("MOTD.txt"); if(!file.exists()){ file.createNewFile(); } BufferedReader r = new BufferedReader(new FileReader(file)); ArrayList < String > temparray = new ArrayList < String > (); String s = ...
3
public boolean matchesSub(Identifier ident, String subident) { String prefix = ident.getFullName(); if (prefix.length() > 0) prefix += "."; if (subident != null) prefix += subident; if (firstStar == -1 || firstStar >= prefix.length()) return wildcard.startsWith(prefix); return prefix.startsWith(wildc...
4
public void updateProcess(int NEW_STATE) { long timePassed = SystemClock.getTime()-this.timeOfLastEvent; if (NEW_STATE == CPU_QUEUE) { Statistics.processesPlacedInCpuQueue(); } else if (NEW_STATE == IO_QUEUE) { Statistics.processesPlacedInIOQueue(); } else if (NEW_STATE == FINISHED) { Statistics.pro...
9
private String determineChomp (String text) { String tail = text.substring(text.length() - 2, text.length() - 1); while (tail.length() < 2) tail = " " + tail; char ceh = tail.charAt(tail.length() - 1); char ceh2 = tail.charAt(tail.length() - 2); return ceh == '\n' || ceh == '\u0085' ? ceh2 == '\n' || ceh2 ...
5
public boolean checkEndConditions(){ //the return value boolean retVal = false; try{ //the number of each piece left int whitesGone = 0 , bluesGone = 0; //the board to work with Board temp = theFacade.stateOfBoard(); //go through all the spots on the board for(...
7
public double perimeter() throws TypeOverflowException { double p = 0; try { for (Iterator<Line> it = lineIterator(); it.hasNext(); ) { p += it.next().distance(); if (Double.isInfinite(p) || Double.isNaN(p)) throw new TypeOverflowException(); } } catch(OverflowException e) { throw new Type...
4
private void affichageErreursDiffuseur(List<Error> erreursDiffuseur) { for (Error e : erreursDiffuseur) { switch (e) { case raisonSocialeVide: this.labelErreurRaisonSocialeDiffuseur.setText("Veuillez saisir une raison sociale"); break; ...
9
public void init(File param){ isInialize=true; try { configFile = FileConfig.deserializeXMLToObject(param); } catch (FileNotFoundException e1) {e1.printStackTrace();} /* * Download SVM */ try { File f = new File(configFile.getBinSVM()); if(f.exists()){ FileInputStream fis = new File...
9
public boolean connect() { try { connectionSocket = new DatagramSocket(); inetAddress = InetAddress.getByName(ip); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
1
* @throws UnknownHostException if cyc server host not found on the network * @throws IOException if a data communication error occurs * @throws CycApiException if the api request results in a cyc server error */ public void converseVoid(final Object command) throws UnknownHostException, IOException...
1
public int lastLineNumber(){ int lineNum = parse.getLastLineNumber(); if (lineNum <= -1) return -1; // Nothing has been read yet if (lineNum == 1) return -1; // only labels have been read return lineNum - 1; // adjust line number to account for the label line }
2
@Override public void paintComponent(Graphics graphics) { // Controls when canvas needs to be drawn onto. if (this.startDraw) { // Get the reference of graphics ovject and pass it to screengc. Graphics screengc = graphics; // Get the graphics instead from the buf...
2
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("<td valign='top'>"); sb.append("Event created by: ").append(getCreator()+"<br />"); sb.append("Date: ").append(new Date(getDatetimemillis())+"<br />"); sb.append("Position: ").append(getLatitud...
6
@Override public void checkForMutations() { // Convenience variables. AbstractAction replicateAction = ((AbstractAction)replicationResult.getReplicate()); Collection<ICondition> original = action.getConditions(); Collection<ICondition> replicate = replicateAction.getConditions(); // Look for addition and...
9
public Image attackImage(int i) { Image temp = null; switch(i) { case 1: temp = new ImageIcon("src/images/north_attack.png").getImage(); break; case 2: temp = new ImageIcon("src/images/north_east_attack.png").getImage(); break; cas...
8
public void FixCSV(String filePath, boolean isFixHeader) throws FileNotFoundException, IOException{ FileManager fm = new FileManager(); fm.copy(filePath, "c:/temp",true); File theFile = new File("c:/temp"); FileReader readerFile = new FileReader(theFile); BufferedReader ...
6
public SchemeObject readSymbol(){ StringBuilder buffer = new StringBuilder(); int c = getc(); while(isInitial(c) || Character.isDigit(c) || c == '+' || c == '-' || c == '.' || c == '/' || c == '_' || c == '&'){ buffer.append((char)c); c = getc(); } if(isDelimiter(c)){ ...
9
public int compareTo( Object obj ) { if( obj == null ) { return( 1 ); } else if( obj instanceof GenKbSecFormByUJEEServletIdxKey ) { GenKbSecFormByUJEEServletIdxKey rhs = (GenKbSecFormByUJEEServletIdxKey)obj; if( getRequiredSecAppId() < rhs.getRequiredSecAppId() ) { return( -1 ); } else if( getR...
9
public MediaUrlDao() { // create a database connection try { con = DriverManager. getConnection("jdbc:h2:./database/twitterKeyWordSearch.h2"); tableCheckAndCreate(); } catch (SQLException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } }
1
public static byte pedir_q_cuenta(){ byte aux=0; do{ try{ System.out.println("1. Ingreso en Cuenta Corriente"); System.out.println("2. Ingreso en Cuenta Ahorro"); System.out.print("OP => "); BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); aux=Byte.parseByte(stdin.r...
4
@Override public boolean execute(Player player) { if (!player.getInventory().hasItem("beamer")) { GameEngine.gui.println("You can not teleport without the beamer."); return false; } Beamer beamer = (Beamer) player.getInventory().getItem("beamer"); if (beamer.isCharged()) { Room vRoom = beamer.g...
4
public boolean equals(Object aObject) { if (this == aObject) { return true; } else if (aObject instanceof DAOCompeticao) { DAOCompeticao lDAOCompeticaoObject = (DAOCompeticao) aObject; boolean lEquals = true; return lEquals; } return false;...
2
public void eseguiSimulazioneConvalida() { /* Inizializzazione vettore. */ ArrayList<Double> tempiUscitaMedi = new ArrayList<Double>(); /* Cicla sui job. */ for (int i = passo ; i <= jobTotali ; i += passo) { seed_arrivi = 229; seed_routing = 227; s...
4
public static int discrete(double[] a) { double EPSILON = 1E-14; double sum = 0.0; for (int i = 0; i < a.length; i++) { if (a[i] < 0.0) throw new IllegalArgumentException("array entry " + i + " is negative: " + a[i]); sum = sum + a[i]; } if (sum > 1.0 + EP...
7
protected void fillSpectrum() { for (int i = 0; i < spectrum.length; i++) { spectrum[i] = (float) Math.sqrt(real[i] * real[i] + imag[i] * imag[i]); } if (whichAverage == LINAVG) { int avgWidth = (int) spectrum.length / averages.length; for (int i = 0; i < averages.length; i++) ...
9
public void fadeOutIn( FilenameURL filenameURL, long milisOut, long milisIn ) { if( !toStream ) { errorMessage( "Method 'fadeOutIn' may only be used for " + "streaming and MIDI sources." ); return; } if( filenameURL == null ) ...
5
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { // hack TreePath path = tree.getPathForRow(row); if (path != null) { TreeNode tn = (TreeNode)path.getLastPathCom...
4
@Override public void onCollideWithEntity(Entity entity) { if(timeAlive >= lifeTime && !this.hasCollided && !(entity instanceof EntityPlayer)) { this.hasCollided = true; world.attemptAttack(this, this.getBB(this.getCoords()), this.getFacing().copy().normalise(), this.damage, this.knockback); } }
3
private void copyHashMap(HashMap from, HashMap to) { to.clear(); Iterator it = from.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String value = (String) from.get(key); to.put(key,value); } }
1
private void updatePicture() { BufferedImage bufferedImage = null; try { Iterator<ImageReader> readers = ImageIO .getImageReadersByMIMEType(mimeType); ImageInputStream iis = ImageIO .createImageInputStream(new ByteArrayInputStream(image)); if (readers.hasNext()) { ImageReader reader = reader...
5
public void untimed() { boolean captured = lock.tryLock(); try { System.out.println("tryLock(): " + captured); } finally { if (captured) lock.unlock(); } }
1
public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int cases = Integer.parseInt(in.readLine()); StringBuilder sb = new StringBuilder( ); for (int i = 0; i < cases; i++) { String line = in.readLine(); int M = 0; int F = 0; ...
7
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...
6
@Override public void setNewPosition(int x, int y) { boolean bottleIsThrowable = mMovementStr == MovementStrategy.ALIVE && bottle != null; if (bottleIsThrowable && rnd.nextInt(30) == 0) { bottle.setNewPosition(getX(), getY()); Field.getInstance().addStationar...
3
Object getParameter(int position) { if (position >= 0 && position < values.length) { if (values[position] == null) { try { values[position] = types[position].newInstance(); } catch (Exception ex) { throw new RuntimeException(ex)...
4
public int getTextureForDownloadableImage(String par1Str, String par2Str) { ThreadDownloadImageData var3 = (ThreadDownloadImageData)this.urlToImageDataMap.get(par1Str); if (var3 != null && var3.image != null && !var3.textureSetupComplete) { if (var3.textureName < 0) ...
7
@Override public String getAnswer() throws Exception { //Reworked this to use a boolean cache instead of a Set for a major jump in performance. //Max value is x^2 + 2^3 + 2^4 int max = (int) sqrt(TARGET - 8 - 16); Iterable<Long> primes = getPrimes(max); boolean[] cache = new...
7
Hashtable getHiddenMethods() { if (hiddenMethods == null) hiddenMethods = new Hashtable(); return hiddenMethods; }
1
public boolean solve() { Scanner sc = new Scanner(System.in); pattern = sc.next(); while (sc.hasNext()) { int openCost = sc.nextInt(); int closeCost = sc.nextInt(); bracketCosts.add(new Cost(openCost, closeCost)); } int currI...
9
private void paintBoard(Graphics graphics) { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { graphics.setColor(BOARD_COLOR); graphics.drawRect(STARTING_X_INDEX + (j * SIZE_OF_SQUARE), STARTING_Y_INDEX + (i * SIZE_OF_SQUARE), SIZE_OF_SQUARE, SIZE_OF_SQUARE); } } }
2
public Object nextValue() throws JSONException { char c = nextClean(); String s; switch (c) { case '"': case '\'': return nextString(c); case '{': back(); return new JSONObject(this); case '[': ...
8
public void showStorage(){ System.out.println("Total Balance : " + access(Accesscreate())); if(characterList.size() != 0){ System.out.println("List character : "); for(Character character : characterList){ System.out.println("character :" + character.toString()); } }else{ System.out.print...
2
public int getUserAccess() { return userAccess; }
0
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...
6
protected void renderHealthbars(Rendering rendering, Base base) { if (! structure.intact()) return ; if (healthbar == null) healthbar = new Healthbar() ; healthbar.level = structure.repairLevel() ; final BaseUI UI = (BaseUI) PlayLoop.currentUI() ; if ( UI.selection.selected() != this && ...
7
private void addStringFromDir(File dir) { System.out.println("addString"); File file = dir; BufferedReader fin = null; try { fin = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException e1) { e1.printStackTrace(); } String str = null; try { str = fin.r...
4
public String getParknameByPID(Statement statement,String PID)//根据PID获取停车场名 { String result = null; sql = "select parkname from Park where PID = '" + PID +"'"; try { ResultSet rs = statement.executeQuery(sql); while (rs.next()) { result = rs.getString("parkname"); } } catch (SQLException e) ...
2
@Override public void actionPerformed(ActionEvent evt) { if (evt.getSource().equals(editButton)) { setEditFieldsEditable(true); riverList.setEnabled(false); setButtonMode(1); } if (evt.getSource().equals(newButton)) { riverListModel.insertElementAt(MainWindow.riverDB.newRiver (), riverLis...
7
public void setUsed(Boolean used) { this.used = used; }
0
public int[] bothUtility(){ int blueUtil = 0; int greenUtil = 0; for(int i = 0; i < boardSize; i++) { for(int j = 0; j <boardSize; j++) { COLOR myColor=this.board.get(i).get(j).color; if( myColor== COLOR.BLUE) { blueUtil += this.board.get(i).get(j).weight; }else if(myColor == COLOR.GR...
4
public void clearCurrent() { int position; ItemPanel itemPanel; for ( position = 0; position < Data.INVEN_SLOTS; position++ ) { itemPanel = (ItemPanel) panelInven.getComponent( position ); setItemPanel( itemPanel, null ); } // for for ( position = 0; position < Data.COIN_SLOTS; ...
4
public boolean isHorizontal() { return horizontal; }
0
public String toString() { int level = level(); char[] tab = new char[level]; for(int i = 0; i < level; i++) { tab[i] = '\t'; } String tabs = new String(tab); StringBuilder toReturn = new StringBuilder(); int longestKey = 0, extraWidth = 4;...
8
public ArrayList<Integer> postorderTraversal(TreeNode root) { if (root == null) return new ArrayList<Integer>(); ArrayList<Integer> result = new ArrayList<Integer>(); Stack<TreeNode> stack = new Stack<TreeNode>(); TreeNode p = root; boolean inLeft = true; ...
9
public static Test suite() { try { endpointURL = new URL(endpointURLString); } catch (MalformedURLException e) { } TestSuite testSuite = new TestSuite(); testSuite.addTest(new UnitTest("testMakeValidConstantName")); testSuite.addTest(new UnitTest("testCycAccessInitialization")); testS...
1
@Override public byte[] drawInvoice() throws IOException, COSVisitorException { PDDocument doc = null; try { doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(doc, page); ...
6
public static ListNode mergeSortedList(ListNode l1, ListNode l2){ if(l1 == null) return l2; if(l2 == null) return l1; ListNode newHead; ListNode curNode; if(l1.val < l2.val){ newHead = l1; l1 = l1.next; }else { newHead = l2; ...
9
public void choisirParametres() { // Initialisation des tailles de grille this.jComboBoxTailleGrilles.removeAllItems(); for(TailleGrille tg : this.TailleGrilles){ this.jComboBoxTailleGrilles.addItem(tg.getX()+"x"+tg.getY()); } // Initialisation des e...
3
protected void readAttribute(String name, int length, ConstantPool constantPool, DataInputStream input, int howMuch) throws IOException { byte[] data = new byte[length]; input.readFully(data); if ((howMuch & UNKNOWNATTRIBS) != 0) { if (unknownAttributes == null) unknownAttributes = new SimpleMap(); ...
2
private int[] findCloesetPoints(int point, List<Integer> knownPoints, boolean downwards) throws InterpException { int positionLast = -1; int position = -1; for (Integer curPoint : knownPoints) { position = knownPoints.indexOf(curPoint)...
7
@Override public void run() { // get folders int number_of_folders = 0; if (main.arguments.length >= 1 && lib.Console.isNumeric(main.arguments[0])) { number_of_folders = new Integer(main.arguments[0]); } else { number_of_folders = lib.Console.inputInteger("How...
6
private void isLessThanEqualsToDate(Date param, Object value) { if (value instanceof Date) { if (!(param.before((Date) value) || param.equals((Date) value))) { throw new IllegalStateException("Given Date does not lie after the supplied date."); } } else { throw new IllegalArgumentException(); } }
3
public String execute(HttpServletRequest request, HttpServletResponse arg1) throws Exception { ResourceBundle bundle = Resource.getInstance().getRequestToObjectMap(); this.salesItemId = generalTools.NullToEmpty((String)request.getParameter("salesItemId")); this.txtCountryId = generalTools.NullToEmpty((Strin...
9
public static void exec(String s) { try { String cmd = s + "\n"; try { JFrameMain.proc.getOutputStream().write(cmd.getBytes()); JFrameMain.proc.getOutputStream().flush(); } catch (IOException e) { System.out.println(e.getMessage()); } if (s.equalsIgnoreCase("stop")) { BukkitServer.stop(...
4
@Override public void moveCursor(int down, int right) { for (int i = 0; i < right; i++) { this.getCursor().movePositionRight(); } for (int i = 0; i > right; i--) { this.getCursor().movePositionLeft(); } for (int i = 0; i < down; i++) { this.getCursor().selectLineDown(); } for (int i = 0; i > dow...
4
@Test(expected = DuplicateInstanceException.class) public void addDuplicateActivityTest() throws DuplicateInstanceException { Activity activity = null; try { activity = activityService.find(0); } catch (InstanceNotFoundException e) { fail("Activity not exist"); } activityService.create(activity); }
1
public static String camelCaseToUnderline(String name) { final int length = name.length(); boolean inupper = false; StringBuilder stb = new StringBuilder(length); int i = 0; while (i < length) { char c = name.charAt(i); i = i + 1; if(inupper) {...
7
@Override public void ParseIn(Connection Main, Server Environment) { Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom); if (Room == null || !Room.CheckRights(Main.Data, true) || Room.MoodlightData == null) { return; } Environment.InitPacket(...
5
public boolean contains(World world, Vector pt) { if (!this.world.getName().equals(world.getName())) { return false; } final double x = pt.getX(); final double y = pt.getY(); final double z = pt.getZ(); return x >= min.getBlockX() && x < max.getBlockX() + 1 && y >= min.getBlockY() && y < max.getBloc...
6
private static int[] merge(int[] left, int[] right) { int[] merged = new int[left.length + right.length]; int mergedTail = left.length + right.length -1; int leftTail = left.length -1; int rightTail = right.length -1; while(leftTail>=0 && rightTail>=0) { if(left[leftTail] >= right[rightTail]) { me...
7
public Instances pruneToK(Instances neighbours, double[] distances, int k) { if(neighbours==null || distances==null || neighbours.numInstances()==0) { return null; } if (k < 1) { k = 1; } int currentK = 0; double currentDist; for(int i=0; i < neighbours.numInstances(); ...
7
private String digitConver(char digit) { String returnVal; switch(digit) { case '1': returnVal = "壹";break; case '2': returnVal = "贰";break; case '3': returnVal = "叁";break; case '4': returnVal = "肆";break; case '5': returnVal = "伍";break; case '6': ...
9
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player player = (Player)sender; if(commandLabel.equalsIgnoreCase("ignite")) { if(sender.hasPermission("basics.command.ignite.self")) { if(args.length == 1) { sender.sendMessage(ChatColor.GREEN + "You have b...
5
public void TheifStall(String stallName, String message, int lvlReq, int XPamount, int item, int itemAmount, int delay, int emote) { if(theifTimer == 0) { if(playerLevel[17] >= lvlReq) { setAnimation(emote); sendMessage("You steal from the "+stallName); sendMessage(message); addItem(item, itemAmount); ...
3
public Object mapValue(Object value) { return value instanceof Type ? mapType((Type) value) : value; }
1
public void printBrake(){ DecimalFormat df = new DecimalFormat("#.000"); IO.println("> Brake Calculation for " + speed + "m/s braking at " + brakerate + " m/s"); IO.print("Cofirm Operation... (y/n) "); Scanner s = new Scanner(System.in); String confirm = s.nextLine(); IO.logln("<IN> " + confirm); ...
6
public CodeMap3y set(final int index, final int value) { final int i0 = index >>> 26; int[][] map1; if (i0 != 0) { if (map == null) map = new int[MAX_INDEX_ZERO][][]; map1 = map[i0]; if (map1 == null) map[i0] = map1 = new int[MAX_INDEX_ONE][]; } else map1 = map10; final int i1 = (index >...
5
public final int getRowCount() { return data.size(); }
0
private void readValues(Stream buffer) { do { int configId = buffer.getUnsignedByte(); if (configId == 0) { return; } else if (configId == 1) { anInt390 = buffer.get24BitInt(); method262(anInt390); } else if (configId == 2) { anInt391 = buffer.getUnsignedByte(); } else if (configId == 3...
8
@Override public TrackerResponse sendRequest (TrackerRequest request, long time, TimeUnit unit) { String host = uri.getHost(); int port = uri.getPort(); try (DatagramSocket socket = new DatagramSocket()) { InetAddress addr = InetAddress.getByName(host); // UDP Socke...
7
public Value measure(Env env) throws SimPLException { Value v1 = e.measure(env); switch(this.op){ case negative: if(v1.type.typeid == Type.TypeEnum.t_int) { IntValue res = new IntValue(); res.type.typeid = Type.TypeEnum.t_int; res.value = -((IntValue)v1).value; return res; } else ...
4
public static Object createObjectViaDefaultConstructor(String className) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if(className != null) { // Fetch class object ... Class<?> cla...
3
public AbilityType getAbilityFromHotkey(int x) { if (x < 10) { return player.characterSheet.hotkeys[x - 1]; } return null; }
1
private TreeNodeObject makeRootNode(ResultData result) { // erste Knoten ist Wurzelknoten String rootPid = ""; // alle erzeugten TreeNodeObjekte werden in einer HashMap gespeichert Map<String, TreeNodeObject> hashMap = new HashMap<String, TreeNodeObject>(); // erst werden alle TreeNodeObjekte ohne Unterm...
9
public static void initPermissions() { createFiles(); // make sure the files exist, if not, create them try { Server.display("Loading permissions from file..."); BufferedReader inputFile = null; try { // Clear arrays lstAdmin.clear(); ...
8
private List<Integer> findSharedMovies(int user1, int user2) { List<Integer> sharedMovies = new ArrayList<Integer>(); HashSet<Integer> user1Movies = userRatedMovies.get(user1); HashSet<Integer> user2Movies = userRatedMovies.get(user2); if (user1Movies == null || user2Movies == null) { return sharedMovies; ...
4
public static boolean overlaps(Rectangle r1, Rectangle r2){ //check if r2's verticies are contained in r1 if (r1.contains(r2.getLocation())){ return true; } else if(r1.contains(new Point(r2.x + r2.width, r2.y))){ return true; } else if(r1.contains(new Point(r2.x, r2.y + r2.height))){ return true; ...
8
@Override public void execute(CommandSender sender, String[] arg1) { if (!CommandUtil.hasPermission(sender, PERMISSION_NODES)) { sender.sendMessage(plugin.NO_PERMISSION); return; } if (arg1.length != 1) { sender.sendMessage(ChatColor.RED + "/" + plugin.accept + " (channel)"); return; } String...
6
public static String readFile(String filename) { //read content from file BufferedReader br = null; String data = ""; try { String sCurrentLine = ""; br = new BufferedReader(new FileReader("" + filename)); while ((sCurrentLine = br.readLine()) != n...
4
public static String getMediaDirectory() { String directory = null; boolean done = false; // check if the application properties are null if (appProperties == null) { appProperties = new Properties(); // load the properties from a file try { // get the URL for where we l...
8
public static void setWordWrapInWindow(IWorkbenchWindow window, boolean state) { if (window == null) { return; } IWorkbenchPage page = window.getActivePage(); // iterate all open editors IEditorReference[] editors = page.getEditorReferences(); for (IEditorR...
2
protected void doStart() { if ("".equals(fetchFrequencyTf.getText()) || "".equals(repostFrequencyTf.getText()) || "".equals(repostCountTf.getText()) || "".equals(commentCountTf.getText())) { JOptionPane.showMessageDialog(null, "请输入信息!", "设置", JOptionPane.ERROR_MESSAGE); return; } // 保存设置 try...
9
public static String getInitials(String s, boolean withFirstLetter) { if (s == null) { return null; } StringBuilder sb = new StringBuilder(s.length()); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ...
7
public int reverse(int x) { if (x == 0) { return x; } int val = Math.abs(x); int retVal = 0; while (val > 0) { retVal = retVal * 10 + (val % 10); val = val / 10; } // Checking whether there should be leading zero's? //Print number with leading zero's int zeroval = Math.abs(x); int zeros...
8
Context(Object... parameters){ int length = parameters.length/2; Reference[] reference_array = new Reference[length]; for(int i = 0; i < length; i++){ reference_array[i] = new Reference((String)parameters[2*i], (parameters[2*i+1] instanceof Representation)?(Representation)parameters[2*i+1]:new Representation(p...
2
@Test public void testAddRedMarker() { System.out.println("addRedMarker"); Cell instance = new Cell(0,0); instance.addRedMarker(0); instance.addRedMarker(1); instance.addRedMarker(2); instance.addRedMarker(3); instance.addRedMarker(4); instance.addRedM...
0
private static int task2() { int sum = 0; int temp = 1; int temp2 = 1; int tempTotal = 0; for (int i = tempTotal; tempTotal < 4000000; i += tempTotal) { tempTotal = temp + temp2; if ((tempTotal % 2) == 0) { sum += tem...
2
private void c_OHPage(){ c_OHPane = new JPanel(); c_OHPane.setBackground(SystemColor.activeCaption); c_OHPane.setLayout(null); JLabel lbl_OpeningHour = new JLabel("Opening Hour"); lbl_OpeningHour.setHorizontalAlignment(SwingConstants.CENTER); lbl_OpeningHour.setFont(new Font("Arial", Font.BOLD, 30)); l...
0
public void action(Echeancier e, Etage etage, int date) { System.out.println("Début action"); //La cabine change d'étage this.setEtage(etage); this.setDistanceParcourue(this.getDistanceParcourue() + 1); if (this.etage.getNumero() == ascenseur.getNumEtageLePlusHaut() || this.e...
7