text
stringlengths
14
410k
label
int32
0
9
private boolean objectsAreEqual(SMPLContainer e1, SMPLContainer e2) { if (!e1.getType().equals(e2.getType())) { return false; } else { if ("Vector".equals(e1.getType())) { SMPLVector v1 = (SMPLVector) e1.getValue(); SMPLVector v2 = (SMPLVector) e2...
9
* @param p * the type of particle to be inserted. If null, then use the parameters specified by <code>GayBerneConfigure</code> * @return 'true' if the action is done, 'false' if not */ public boolean insertAnGB(int x, int y, GayBerneParticle p) { if (nParticle >= gb.length) return false; if (p ...
8
public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { // print implicit argument System.out.print(target); // print method name System.out.print("." + m.getName() + "("); // print explicit arguments if (args != null) { for (int i = 0; i < ar...
3
public boolean serializeSessionKey(String keyFilename, SessionKey sessionKey) { try { File f = new File(keyFilename); f.createNewFile(); OutputStream file = new FileOutputStream(keyFilename); OutputStream buffer = new BufferedOutputStream(file); ObjectOutput output = new ObjectOutputStream(buffer); ...
2
private Class getNFontClass(int fontType) throws ClassNotFoundException { Class fontClass = null; if (FONT_OPEN_TYPE == fontType) { fontClass = Class.forName(NFONT_OPEN_TYPE); } else if (FONT_TRUE_TYPE == fontType) { fontClass = Class.forName(NFONT_TRUE_TYPE); } e...
5
@Override public boolean addItem(Item item) { //TODO: koordinovane ulozenie rozlozeneho itemu. int shelfCap = Shelf.DEFAULT_CAPACITY; int itemAmount = item.getAmount(); List<IShelf> shelfs = new ArrayList(); //rozlozenie itemu. int numofShelfs = itemAmount / shelfCap ...
6
public byte[][] getBoard() { int width = gameBoard.getWidth(); int height = gameBoard.getHeight(); byte[][] ret = new byte[height][width]; if (opponentAttack.getType() == Attack.INVISIBLE_GAME && opponentAttack.isActive()) { for (int r = 0; r < height; r++) { for (int c = 0; c < width; c++) { re...
8
public Icon setDescription(String description) { this.description = description; this.appendlessDescription = description; ItemMeta im = item.getItemMeta(); //Create an ArrayList to hold the lore that will be added to the item ArrayList<String> lore = new ArrayList<String>(); //Split the descripti...
3
public static void compter(final int lastSecond,final int lastMinute){ secondes=lastSecond; minutes=lastMinute; ActionListener compterTemps=new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean rep=verifier(); if(rep){ pauseTime(); return; } if(sec...
9
public InnerClassInfo getOuterClassInfo(ClassInfo ci) { if (ci != null) { InnerClassInfo[] outers = ci.getOuterClasses(); if (outers != null) return outers[0]; } return null; }
2
public Boolean loadElGamalKey() { Console console = System.console(); String message = "Enter the location of the Authority ElGamal public key"; String input; ElGamalPublicKeyParameters pubKey = null; while (true) { try { System.out.println(message); input = console.readLine(); pubKey = Importe...
6
@SuppressWarnings("serial") public SchemaEditorMenuBar(final BasicGraphEditor editor) { final mxGraphComponent graphComponent = editor.getGraphComponent(); final mxGraph graph = graphComponent.getGraph(); JMenu menu = null; JMenu submenu = null; // Creates the file menu menu = add(new JMenu(mxResources.g...
9
public boolean readBoolean(String pSection, String pKey, boolean pDefault) { //if the ini file was never loaded from memory, return the default if (buffer == null) {return pDefault;} Parameters params = new Parameters(); //get the value associated with pSection and PKey String valueText = getValu...
4
public ConfigurationSection getDefaultSection() { Configuration root = getRoot(); Configuration defaults = root == null ? null : root.getDefaults(); if (defaults != null) { if (defaults.isConfigurationSection(getCurrentPath())) { return defaults.getConfigurationSecti...
3
private void processNodeTag(Attributes attributes) { byte[] node = null; long lastTS = 0; short lastClockSeq = 0; for (int i = 0; i < attributes.getLength(); i++) { String attributeName = attributes.getLocalName(i); if ("".equals(attributeN...
9
private void handle_kick(String[] cmd) { boolean exists = false; if (!is_admin()) // Only Admin can kick return; if (cmd.length != 2) { cliprint("Wrong parameter count. See \\help for details." + VT100.crlf); return; } for (Enumeration e = cliinfo.elements(); e.hasMoreElements();) { cli_info nn ...
6
public String getUser() { return user; }
0
@Override public final Component getTableCellRendererComponent( final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { if (value instanceof Program) { final Program program =...
2
public void removeUndoQueueListener(UndoQueueListener l) { undoQueueListeners.remove(l); }
0
public void renderTileWithAlpha(int xp, int yp, Tile tile, int alphaPercentage) { xp -= xOffset; yp -= yOffset; Sprite sprite = tile.getSprite(); for (int y = 0; y < sprite.SIZE; y++) { int ya = y + yp; for (int x = 0; x < sprite.SIZE; x++) { int xa = x + xp; if (xa < -sprite.SIZE || xa >= width |...
8
ComponentAccess lookup(Object cmd) { if (cmd == null) { throw new ComponentException("null component."); } if (cmd == ca.getComponent()) { throw new ComponentException("Cannot add the compound to itself " + cmd.toString()); } ComponentAccess w = oMap.get(cmd); if (w == null) { oMap.put(cmd, w ...
3
@Override public Node beforeDecode(mxCodec dec, Node node, Object into) { if (into instanceof mxRootChange) { mxRootChange change = (mxRootChange) into; if (node.getFirstChild() != null && node.getFirstChild().getNodeType() == Node.ELEMENT_NODE) { // Makes sure the original node isn't modified ...
5
private void updateGameQueue(GameTime gameTime) { // Iterate and call the start ups of any hudItems which are // waited to be added to the HUDSystem explicitly for (IHudItem hudItem : hudItemQueue.getAllWaiting()) { hudItem.startUp(gameTime); } // Get the list of HUDItems which wanted to be removed from t...
2
public Tilemap(String path, int dimension, boolean setCurrent) { // TODO - Save all tile textures on one texture block = Texture.getTexture("block"); block.setSize(dimension, dimension); this.dimension = dimension; // TODO - Load a tile map from file glBindBuffer(GL_ARRAY_BUFFER, Game.VBO.get(0)); vtBu...
7
@Override public Anomaly.AnomalyLevel checkPoint(Point point) { if (globalOverview.isEmpty()) { lastTimeStamp = point.getTime(); } long currentTimeStamp = point.getTime(); while (currentTimeStamp - lastTimeStamp > globalOverviewInterval) { globalOverview.rem...
6
public String getMacro() { String macro = null; // Have a shape with an embed? OOXMLElement oe = getObject( SP ); if( oe != null ) { macro = ((Sp) oe).getMacro(); } // how's about a picture? if( macro == null ) { oe = getObject( PIC ); } if( (oe != null) && (macro == null) ) { macro = ...
7
private boolean isValidNumber(String text) { if (text.endsWith("1") || text.endsWith("2") || text.endsWith("3") || text.endsWith("4") || text.endsWith("5") || text.endsWith("6") || text.endsWith("7") || text.endsWith("8")) { return true; } else { return false; ...
8
public void closeConsole() { this.open = false; }
0
public List<String> getMessages() { return messages; }
0
public boolean isEmpty() { return size() == 0; }
0
public static synchronized IMySQLConnection getConnection(String databaseName) throws MySQLException, SQLException { if(sPools == null) { throw new MySQLException("No pool for database: " + databaseName); } MySQLConnectionPool pool = sPools.get(databaseName); if(pool == null) { throw new MySQLException("No po...
3
public static String getCoastlineCoding(Game game, Position center) { char[] coding = {'0','0','0','0' }; int row = center.getRow(), col = center.getColumn(); Position p; int offsetRow[] = { -1,0,+1,0 }; int offsetCol[] = { 0,+1,0,-1 }; // iterate over the four compas directions // for...
6
public String execute(JavaService js) { if (args.length < 2) { return invalidArguments; } switch (args[1]) { case "options": return loadElectionOptions(); case "rsa": return loadRSAKeys(); case "elgamal": return loadElGamalKeys(); case "all": StringBuilder sb = new StringBuilder(); sb.a...
5
public void showBankAccount(CommandSender player, String bank, String name) { Bank Bank = null; BankAccount account = null; Holdings holdings = null; boolean self = Misc.isSelf(player, name); if (!iConomy.Banks.exists(bank)) { Messaging.send(player, this.Template.parse("error.bank.d...
5
public static int getLevenshteinDistance(String s, String t) { if (s == null || t == null) { throw new IllegalArgumentException("Strings must not be null"); } /* * The difference between this impl. and the previous is that, rather * than creating and retaining a matrix of size s.length()+1 by * t.len...
8
@Override public void mouseExited(MouseEvent e) { }
0
@Override @SuppressWarnings("unchecked") public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { CommandContext cc = new CommandContext(sender, cmd, alias, args, annot); try { if (mcomplete != null) { return (List<String>)mcomplete.invoke(cmdinstance, cc); ...
2
private void createSupplyProductList() { productList = new ArrayList<ArrayList<Product>>(); ArrayList<Product> list; for (Person supplier : getPersonDB().getSupplierList()) { list = new ArrayList<Product>(); for (StockItem stockItem : getStockDB().getStockList()) { Product product = stockItem.getProduct...
3
public void BusJourneyComplete() { /* * robert add your journey completion code here */ /* * This is clean up code for the bus in preperation for the next trip */ //clear the passangers on board this.passengersOnBoard = 0; }
0
public void setTile(int x, int y, Image tile) { tiles[x][y] = tile; }
0
private boolean checkForKey() throws Exception { String query = m_query; query = query.replaceAll(" +"," "); //query has to use all columns if(!query.startsWith("SELECT *")) return false; m_orderBy.clear(); if(!m_DataBaseConnection.isConnected()) m_Dat...
7
private void setClass( Token token ) { Table existingTable = null; String value = token.getValue(); table.setDomName( value ); table.setTableName( camelToCaps( value ) ); // if table already exists, stop parsing. existingTable = tableMap.get( value ); if ( exist...
1
private int jjMoveStringLiteralDfa12_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(10, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(11, active0); return 12; } switch(curChar) { case 3...
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
6
@Override public void documentRemoved(DocumentRepositoryEvent e) {}
0
public void newarray(final Type type) { int typ; switch (type.getSort()) { case Type.BOOLEAN: typ = Opcodes.T_BOOLEAN; break; case Type.CHAR: typ = Opcodes.T_CHAR; break; case Type.BYTE: typ = Opcodes.T_BYTE; break; case Type.SHORT: typ = Opcodes.T_SHORT; break; case Type.INT: t...
8
public static String readData(InputStream in) { StringBuffer sb = new StringBuffer(); try { BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } } cat...
2
public double getPosX() { return posX; }
0
public EnemyCar() { //load resources Initialize(); LoadContent(); // Now that we have carImgWidth we set starting x coordinate. x = (int) (Framework.frameWidth * 0.60); }
0
public Deck deckReader(String xmlFile) throws ParserConfigurationException, SAXException, IOException { Deck deck = new Deck(); File deckXML = new File(xmlFile); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuil...
7
private ArrayList<ExtendedModInfo> examineModPath() { ArrayList<ExtendedModInfo> list = new ArrayList<>(); String[] entries = modDir.getEntries(); log.info("Examine directory \"" + modDir.getPath() + "\""); log.info("Found " + entries.length + " entities"); for(String entry : entries) { IDirec...
6
public URL downloadUrl(String genomeVer) { try { String version = SnpEff.VERSION_MAJOR; // Replace '.' by '_' version = version.replace('.', '_'); String urlRoot = getDatabaseRepository(); StringBuilder urlsb = new StringBuilder(); urlsb.append(urlRoot); if (urlsb.charAt(urlRoot.length() - 1)...
2
@Override public void actionPerformed(ActionEvent e) { Outliner.documentAttributes.configureAndShow(Outliner.documents.getMostRecentDocumentTouched().getTree()); }
0
private void writeInformation(String key,dir_type type) { recourcePanel.removeAll(); HashMap<String, String> information = null; JLabel lable = new JLabel(); lable.setFont(new Font("Information",0, 30)); if(ref_key_pat.containsKey(key) || ref_key_stu.containsKey(key) || ref_key_ser.containsKey(key)){ swit...
8
public LayeredPanelList openProject(){ LayeredPanelList lstOut = null; fc = new JFileChooser(strProjectsDir); fc.showOpenDialog(compParent); //System.out.println(fc.getSelectedFile()); try{ if(fc.getSelectedFile() != null){ this.strCurrentProject = fc...
3
public static void saveGameData() { String output ="savedata/"+idString+".jokes"; try { PrintWriter fout=new PrintWriter(new FileWriter(output)); if(VERSION.equals("Peaches")) fout.println("PDAE"+idString); else fout.println("CDAE"+idString); //Game Vars fout.println(name); fout.prin...
2
private boolean bajaUsuarios(HttpServletRequest request, HttpServletResponse response) throws IOException { ConexionBD con = new ConexionBD(); String[] seleccion = request.getParameterValues("usuarios"); if (seleccion != null && seleccion.length > 0) { for (int cont = 0; cont < sel...
3
public static synchronized NetworkSharedUser getUserById(int id) { for(NetworkSharedUser u : usersOnline) { if(u.getId() == id) { return u; } } return null; }
2
private int paintStr(int i, int sides) { // Try to find an empty space of the string Point position = null; Rectangle bounds = null; Shape draw_word = null; AffineTransform tx = null; boolean found = false; Point[] str_vertex = new Point[4]; while (!found) { // Set the font try { f...
9
public static String getFileName(String filepath) { File file = new File(filepath); return file.getName(); }
0
public void setTaskId(Integer taskId) { this.taskId = taskId; }
0
public int getX() { return x; }
0
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (args.length > 0) { switch (args[0]) { case "craft": ...
5
public char[] getSaleParams() throws Exception { char[] params = new char[55]; // Массивы параметров char[] count_array = Convert.toCharArray(new Double(this.count * 1000).intValue()); char[] price_array = Convert.toCharArray(new Double(this.price * 100).intValue...
4
private boolean isNear(int i1, int j1, int i2, int j2){ int idif = Math.abs(i1-i2); int jdif = Math.abs(j1-j2); if(idif > -1 && idif < 2 && jdif > -1 && jdif < 2) return true; return false; }
4
@Override public boolean equals(Object loan){ if (loan == null) return false; Loan l = (Loan)loan; //first of all, if the two loans are void, they are equal if(l.isVoidLoan() && voidLoan) return true; if((l.isVoidLoan() && !voidLoan) || (!l.isVoidLoan() && voidLoan)) return false; //System.o...
9
public void removePersons(int persons) { int i = 0; try { int loops = 0; while (i < persons) { loops++; if (items.get(loops) instanceof Person) { if (!((MovingMapItem) items.get(loops)).dying()) { ((MovingMapItem) items.get(loops)).kill(); i++; ...
4
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
7
private IResult handle(String url, String queryString, String mode) { IResult result = new ResultPojo(); BufferedReader rd = null; HttpURLConnection con = null; try { URL urx = new URL(url+queryString); con = (HttpURLConnection)urx.openConnection(); con.setReadTimeout(1000); con.setRequestMethod(mod...
5
public String getPath(String path) { String split[] = path.split("\\."); if (split.length <= 0) return path; String newPath = ""; boolean set = true; ConfigurationSection section = file.getRoot(); for (int i = 0; i < split.length; i++) { if (!set) { newPath += "." + split[i]; continue; }...
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Customer other = (Customer) obj; if (age != other.age) return false; ...
8
public int[] lectura(){ try { // Apertura del fichero y creacion de BufferedReader para poder // hacer una lectura comoda (disponer del metodo readLine()). archivo = new File ("C:\\Users\\Temp\\Desktop\\Cuarto Semestre\\Algoritmos y estructura de datos\\Hoja de trabajo/archivo.txt");...
4
@Override public boolean tick(Tickable ticking, int tickID) { if(!(affected instanceof MOB)) return super.tick(ticking,tickID); if(!super.tick(ticking,tickID)) return false; final Room R=((MOB)affected).location(); for(int i=0;i<R.numInhabitants();i++) { final MOB M=R.fetchInhabitant(i); if((M...
9
public static ArrayList<Question> getQuestions() { synchronized (MainInfo.class) { ArrayList<Question> aryQuestions = new ArrayList<Question>(); try { for (int i = 0; true; i++) { { Class<?> clsQuestion = Class.forName("questions.QuestionW" + i + "_" + 0); aryQu...
8
public static void main(String[]args){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int e = in.nextInt(); TreeSet<Integer> m = new TreeSet<>(); TreeSet<Integer> p = new TreeSet<>(); for (int i = 0 ; i < ...
9
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((cachedPath == null) ? 0 : cachedPath.hashCode()); result = prime * result + ((lastChecked == null) ? 0 : lastChecked.hashCode()); result = prime * result + ((linkStatus == null...
5
private double getAverage(String dsName, String rpnExpression) throws RrdException { RpnCalculator rpnCalculator = null; if(rpnExpression != null) { rpnCalculator = new RpnCalculator(rpnExpression); } double vals[] = getValues(dsName); double totalVal = 0; long totalSecs = 0; for(int i = 0; i < vals.le...
5
private static List<String> reproduceSentence(final Map<Integer, Set<String>> words, final int[] indexes, int phoneLength) { List<String> sentence = new LinkedList<String>(); for (int i = 0; i < indexes.length && indexes[i] != -1; i++) { int startIndex = indexes[i]; int endIndex ...
4
public void setProtected(final boolean flag) { if (this.isDeleted) { final String s = "Cannot change a field once it has been marked " + "for deletion"; throw new IllegalStateException(s); } int mod = methodInfo.modifiers(); if (flag) { mod |= Modifiers.PROTECTED; } else { mod &= ~Modifiers...
2
private static boolean containsOpCode(int[] opCodeClass) { assert(_opCode != 1 && _opCode != 0 && _opCode != 28); for (int i = 0; i < opCodeClass.length; i++) { if (_opCode == opCodeClass[i]) { return true; } } return false; }
4
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; User user = (User) o; return id == user.id && this.hashCode() == user.hashCode(); }
4
private void buildFieldRef() { // if (editableElements.size() == 0 || editableTextFields.size() == 0) { // Build up a reference to the screens to make the status, reset and addProcessStatus easier Field[] fields = this.getClass().getDeclaredFields(); for (Field field : fields) { // As long as I ...
9
public static void main(String[] args) { int port = 9090; String ip = "localhost"; if (args.length == 2) { port = Integer.parseInt(args[0]); ip = args[1]; } try { Test test = new Test(); ChatClient tester = new C...
3
public DeviceInfoType getDeviceInfo() { return deviceInfo; }
0
private void loadRandomSplashes() { try { // Total number of screens to display int totalScreens = 1; // Used in display screens randomly // All of this is mostly unused List<Integer> usedInts = new LinkedList<Integer>(); // Text file containing names of images for splash screens BufferedReader r...
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Cliente)) { return false; } Cliente other = (Cliente) object; if ((this.id == null && other.id != null) || (thi...
5
public IUserDao getUserDao() { return userDao; }
0
public static void menuRemove(HousePetList hpArray) { HousePet housepet = new HousePet(); HousePet removedHP = new HousePet(); @SuppressWarnings("resource") Scanner console = new Scanner(System.in); int aChipID = -1; String outputStatement = ""; /* di...
5
private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset, int options ) { // Lots of error checking and exception throwing if( source == null ){ throw new NullPointerException( "Source array was null." ); } // end if ...
8
public void run() { decompiler.setOption("verbose", verboseCheck.getState() ? "1" : "0"); decompiler.setOption("pretty", prettyCheck.getState() ? "1" : "0"); errorArea.setText(""); // /#ifdef AWT10 // / saveButton.disable(); // /#else saveButton.setEnabled(false); // /#endif lastClassName = classFiel...
5
public boolean executeMouvement() { int tabXY[ ] = new int[2]; boolean positionOK=true; Carte carte = null; int compteur=0; if (Carte.isCreated()){ carte = Carte.getInstance(0, 0, 0, null); } if (carte!=null){ carte.getCartePanel().getTabLignes().get(chevalier.getPositionX()).get(chevalier.getPos...
8
public SpaceShipDelegation(String name) { this.name = name; }
0
private XMLReader createNewXmlReader() { try { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); // Disable // DTD // validation parserFact...
2
public static String resultString(int width,List<Board> boards) { String ret=""; String[] lines=new String[8]; for (int i=0;i<8;i++) lines[i]=""; for (int bdi=0;bdi<boards.size();) { for (int j=0;(j<width)&&(bdi<boards.size());j++,bdi++) { String[] bdLines=boards.get(bdi).toString().split("\n"); for ...
7
private void parse_require( String line, String keyword, String[] split, int lineNumber, boolean strictMode ) throws ParseException { // Line has the format: // "Require" {"Group"|"User"} [UserList|GroupList] if( split.length < 2 ) { throw new ParseException( "Invalid '"+keyword+"' declarati...
4
public Resolution newOrderForm() { HttpSession session = context.getRequest().getSession(); AccountActionBean accountBean = (AccountActionBean) session.getAttribute("/actions/Account.action"); CartActionBean cartBean = (CartActionBean) session.getAttribute("/actions/Cart.action"); clear(); if (acco...
3
* @param yPos y coordinate * @param ySp 1 for down, -1 for up * @param xSp 1 right, -1 for left * @return */ private boolean checkDir(int xPos, int yPos, int ySp, int xSp){ StringBuilder sb = new StringBuilder(xPos + "," + yPos); int p = board[yPos][xPos]; int totalCount = 1; short doItTwice = 2; ...
8
public void unknownInstruction(int pc, int op) { switch (op) { case SLEEP: cycles += 100; break; case LOAD_FILE: if (acc == 0) monitor.info("**** LOAD FILE! ***** PC = " + Integer.toString(pc, 16) + " => " + Integer.toString(rindex, 16)); else ...
7
public static boolean isObstacle(byte a_data) { return a_data != MAP_NOTHING && //nothing a_data != MAP_SOFT_OBSTACLE && //border hill, jumpable from the bottom. a_data != MAP_SIMPLE_BRICK && //Breakable brick a_data != MAP_QUESTION_BRICK && //Unbreakable bri...
8
public void gameInit() { //creates stuff ball = new Ball(); //creates the ball paddle = new Paddle(); //creates the paddle bg = new Background(0,0); bullet = new Bullet(); int k = 0; //this whole things creates the bricks from the array (30 bricks in total) for (int i ...
2