text
stringlengths
14
410k
label
int32
0
9
public boolean didHouseWin() { return !theHouse.hasBust() && theHouse.getScore() > player.getScore() || theHouse.getScore() <= 21 && player.hasBust(); }
3
String longestPalindrome (String s){ String longest; int l = s.length(); if (l==0) return ""; longest = s.substring(0,1); // a single char itself is a palindrome for (int i = 0; i < l-1; i++) { String s1 = expandCenter(s,i,i); if (s1.length() > longest.length()) longest = s1; String s2 = expandCenter(s,i,i+1); if (s2.length() > longest.length()) longest = s2; } return longest; }
5
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); EntradaParam oEntradaParam = new EntradaParam(request); EntradaBean oEntradaBean = new EntradaBean(); HiloDao oHiloDao = new HiloDao(oContexto.getEnumTipoConexion()); UsuarioDao oUsuarioDao = new UsuarioDao(oContexto.getEnumTipoConexion()); try { oEntradaBean = oEntradaParam.load(oEntradaBean); oEntradaBean.setHilo(oHiloDao.get(oEntradaBean.getHilo())); oEntradaBean = oEntradaParam.load(oEntradaBean); oEntradaBean.setUsuario(oUsuarioDao.get(oEntradaBean.getUsuario())); } catch (NumberFormatException e) { oContexto.setVista("jsp/mensaje.jsp"); return "Tipo de dato incorrecto en uno de los campos del formulario"; } oContexto.setVista("jsp/entrada/form.jsp"); return oEntradaBean; }
1
public void setFormat(String s) { if ("xmi".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.XMI_STANDARD); } if ("xmi:argo".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.XMI_ARGO); } if ("xmi:start".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.XMI_STAR); } if ("eps".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.EPS); } if ("pdf".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.PDF); } if ("eps:text".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.EPS_TEXT); } if ("svg".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.SVG); } if ("txt".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.ATXT); } if ("utxt".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.UTXT); } }
9
public synchronized void loadConfigData(String propFile, boolean overwriteProperty) { Configuration propData = getConfigFileData(propFile); if (propData != null) { Iterator<String> itr = propData.getKeys(); while (itr.hasNext()) { String key = itr.next(); if (overwriteProperty || !configData.containsKey(key)) { configData.setProperty(key, propData.getProperty(key)); } } } }
4
private void readmagicItemsFromFileToList(String fileName, ListMan lm) { File myFile = new File(fileName); try { Scanner input = new Scanner(myFile); while (input.hasNext()) { // Read a line from the file. String itemName = input.nextLine(); // Construct a new list item and set its attributes. ListItem fileItem = new ListItem(); fileItem.setName(itemName); fileItem.setCost(Math.random() * 100); // random pricing. fileItem.setNext(null); // Add the newly constructed item to the list. lm.add(fileItem); } // Closing the magicItems file input.close(); } catch (FileNotFoundException ex) { System.out.println("File not found. " + ex.toString()); } }
2
public static void addNew() { for (Organism org: a) { switch (org.species) { case Organism.BLUE: bOrgs.add(org); break; case Organism.RED: rOrgs.add(org); break; case Organism.YELLOW: yOrgs.add(org); break; case Organism.ORANGE: oOrgs.add(org); break; default: System.out.println(org.species + "??"); } } a.clear(); }
5
public static AbstractModel getRegularGrid(int min, int max, int distance,AbstractModel result) { // AbstractModel result = new ModelParallel(); for (int i = min; i < max; i += distance) { for (int j = min; j < max; j += distance) { result.p.add(new Particle(0.5, 0, 0, i, j)); } } return result; }
2
GridData getData(Control[][] grid, int row, int column, int rowCount, int columnCount, boolean first) { Control control = grid[row][column]; if (control != null) { GridData data = (GridData) control.getLayoutData(); int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); int i = first ? row + vSpan - 1 : row - vSpan + 1; int j = first ? column + hSpan - 1 : column - hSpan + 1; if (0 <= i && i < rowCount) { if (0 <= j && j < columnCount) { if (control == grid[i][j]) return data; } } } return null; }
8
public String escapeObfuscation() { String escapeObfuscatedCode = null; /* * エスケープ処理は文字ごとに行う必要があるため、1文字ずつに分ける。 * 後に正規表現により比較作業を行うため、String型の配列に格納する。 */ char ch[] = targetCode.toCharArray(); String[] choppedCode = new String[ch.length]; for (int i = 0; i < choppedCode.length; i++) { choppedCode[i] = String.valueOf(ch[i]); } /* * エスケープ処理の文字が%以外の時は最後にReplace処理を行う必要があるため * %以外のときはReplaceメソッドの準備をする。 */ StringBuilder stringBuilder = new StringBuilder(); if (escapeKeyCharacter.matches("%")) { stringBuilder.append("eval(unscape('"); } else { stringBuilder.append("eval(unscape(('"); } /* * エスケープコードへの変換を行う。 * 一部文字はうまく変換できない(09→9)ため、別途処理が必要となる。 * 具体的には、変換後の文字数が2文字以下の場合は、頭に0をつける。 */ String s = null; for (int i = 1; i < ch.length; i++) { s = Integer.toHexString(ch[i]); if (s.length() < 2) { stringBuilder.append(escapeKeyCharacter + "0" + Integer.toHexString(ch[i])); } else { stringBuilder.append(escapeKeyCharacter + Integer.toHexString(ch[i])); } /* * コードの終端を整える。 * エスケープ文字が%以外の場合は、Replaceメソッドを挿入する。 * また、エスケープ文字にエスケープ処理が必要な場合は、処理を行う。 */ if (i == (targetCode.length() - 1)) { if (escapeKeyCharacter.matches("%")) { stringBuilder.append("'));"); } else { if (isNeedsEscape(escapeKeyCharacter)) { stringBuilder.append("').replace(/\\" + escapeKeyCharacter + "/g, '%')));"); } else { stringBuilder.append("').replace(/" + escapeKeyCharacter + "/g, '%')));"); } } } } escapeObfuscatedCode = stringBuilder.toString(); return escapeObfuscatedCode; }
7
@Override public V put(K key, V value) { V candidateValue = straight.get(key); K candidateKey = reverse.get(value); if (candidateKey==null && candidateValue==null) { straight.put(key, value); reverse.put(value, key); return null; } else if (candidateKey==null && candidateValue!=null) { V curV = straight.put(key, value); reverse.remove(curV); reverse.put(value, key); return curV; } else if (candidateKey!=null && candidateValue==null) { K curK = reverse.put(value, key); straight.remove(curK); straight.put(key, value); return null; } else if (!(value.equals(candidateValue) && key.equals(candidateKey))) { throw new IllegalArgumentException("Key and value are both present, but not in the same pair. Impossible to but that pair in the map"); } else { return value; } }
8
private ChannelEventsListener getChannelEventsListener(String name) { for (ChannelEventsListener listener : channelEventsListeners) { if ( listener.getChannelName().equalsIgnoreCase(name) ) return listener; } return null; }
2
@Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.MAGENTA); g.fillRect(0, 0, tileSize * tileLineWidth, this.getHeight()); // System.out.println(imgs.size()); // for(int i = 0; i < imgs.length; i++){ ImageIcon img = imgs[i]; int tempHeight = 0; int tempWidth = i; while(tempWidth >= tileLineWidth){ tempWidth -= tileLineWidth; tempHeight++; } if(img != null){ img.paintIcon(this, g, tempWidth * tileSize, tempHeight * tileSize); if(infoMode){ g.setColor(Color.WHITE); g.drawString("t: " + tileInfo[i], tempWidth * tileSize, tempHeight * tileSize + 10); } } } if(mouseTileX <= 9) cursor[tileSizeToCursor[tileSize]].paintIcon(this, g, mouseTileX * tileSize, mouseTileY * tileSize); // g.setColor(Color.BLACK); // g.drawString("choice: " + tileChoice, 10, 200); }
5
public TreeNode nodeAtPoint(Point2D point) { return treeDrawer.nodeAtPoint(point, getSize()); }
0
@Test public void addParameterTest() { TeleSignRequest tr; if(!timeouts && !isHttpsProtocolSet) tr = new TeleSignRequest("https://rest.telesign.com", "/v1/phoneid/standard/15551234567", "GET", "customer_id", "secret_key"); else if(timeouts && !isHttpsProtocolSet) tr = new TeleSignRequest("https://rest.telesign.com", "/v1/phoneid/standard/15551234567", "GET", "customer_id", "secret_key", connectTimeout, readTimeout); else if(!timeouts && isHttpsProtocolSet) tr = new TeleSignRequest("https://rest.telesign.com", "/v1/phoneid/standard/15551234567", "GET", "customer_id", "secret_key", HTTPS_PROTOCOL); else tr = new TeleSignRequest("https://rest.telesign.com", "/v1/phoneid/standard/15551234567", "GET", "customer_id", "secret_key", connectTimeout, readTimeout, HTTPS_PROTOCOL); assertNull(tr.getAllParams().get("code")); tr.addParam("code", "001"); assertTrue(tr.getAllParams().get("code").equals("001")); }
6
public boolean isSCC() { Set<V> visited = new HashSet<>(); //Step 1 : clone and obtain a reversed graph MyGraph<V,E> reversed = cloneAndReverse(); //Step 2: Calculate finishing times.. pass the vertex one by one Set<Vertex<V>> vertices = reversed.getAllVertex(); //stack will have elements in order of their finishing times LinkedList<Vertex<V>> stack = new LinkedList<>(); for(Vertex<V> vertex : vertices){ if(!visited.contains(vertex.data)){ dfsFinishingTime(reversed, stack, visited, vertex); } } if(stack.size()!=vertices.size()){ return false; } //step 3 : on unreversed graph now go through stack one by one and do a dfs.. collect the DFS elements in scc set visited.clear(); List<Set<Vertex<V>>> scc = new ArrayList<>(); while(!stack.isEmpty()){ Vertex<V> vertex = stack.pop(); Set<Vertex<V>> component = new HashSet<Vertex<V>>(); if(!visited.contains(vertex.data)){ dfsSCC((MyGraph) this, component, visited,vertex); scc.add(component); } } return scc.size()==1 && scc.get(0).size() == vertices.size(); }
6
public ArrayList<Integer> decodage(ArrayList<Integer> codeADecoder) { ArrayList<Integer> codeSort = new ArrayList<Integer>(); ArrayList<Integer> chaineDecodee = new ArrayList<Integer>(); //Trie du code codeSort = new ArrayList<>(codeADecoder); Collections.sort(codeSort); /*System.out.println("Code trié : " + codeSort); System.out.println("Position : 0 1 2 3 4 "); System.out.println("Code : " + code); System.out.println("CodeSort : " + codeSort);*/ int posi = positionChaine, nbOccu = 1, c = 0; for(int i=0 ; i<tailleMot ; i++) { //On regarde la lettre à la position posi dans codeSort c = codeSort.get(posi); //On ajoute cette lettre au début de la chaine décodé chaineDecodee.add(c); //On regarde l'occurence de cette lettre dans codeSort jusqu'à posSort mais pas au delà --> nbOccu nbOccu = Collections.frequency(codeSort.subList(0, posi+1), c);//System.out.println("Occu de " + c +" " + nbOccu); //On récupère la position dans code de cette lettre à la nbOccu ieme fois ( nbOccu = 2 --> donc la 2nde occurence) int debut = 0; for(int j=0 ; j < nbOccu ; j++) { posi = codeADecoder.subList(debut, tailleMot).indexOf(c) + debut; debut = posi + 1; } } return chaineDecodee; }
2
@Override public Customer findCustomerByEmail(String email) { String sql = "SELECT * FROM customer WHERE email='" + email + "';"; Connection con = null; Customer customer = null; try { con = getConnection(); PreparedStatement statement = con.prepareStatement(sql); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) customer = buildCustomer(resultSet); } catch (SQLException e) { e.printStackTrace(); } finally { if (con != null) closeConnection(con); } return customer; }
3
public waitGUI() throws ImageLoadFailException { addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { //listens for Spacebar to skip to next GUI if(' ' == e.getKeyChar()) waiter.startNext(); } }); setResizable(false); ImageIcon loadIcon = null; JOptionPane .showMessageDialog( null, "Find the loading image.\nIf you can't find it, one will be fetched from the internet.", "Image File not Found", JOptionPane.WARNING_MESSAGE); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); fc.setFileFilter(new FileNameExtensionFilter("Image Files", "jpg", "png", "gif", "bmp")); int returnVal = fc.showOpenDialog(null); if(returnVal == JFileChooser.CANCEL_OPTION) { //if user hits cancel, tries to obtain image from internet try { URL loadURL = new URL("http://i.imgur.com/dZgTHsw.gif"); loadIcon = new ImageIcon(loadURL); setBounds(0, 0, loadIcon.getIconWidth() + 6, loadIcon.getIconHeight() + 25); } catch(MalformedURLException e) {} } if(returnVal == JFileChooser.APPROVE_OPTION) { loadIcon = new ImageIcon(fc.getSelectedFile().getPath()); } layeredPane = new JLayeredPane(); layeredPane.setBorder(null); layeredPane.setBounds(0, 0, loadIcon.getIconWidth(), loadIcon.getIconHeight()); setTitle("20 Questions"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if(loadIcon.getIconHeight() == -1 || loadIcon.getIconWidth() == -1) throw new ImageLoadFailException(); //if Icon is -1 by -1, throw setBounds(0, 0, loadIcon.getIconWidth() + 6, loadIcon.getIconHeight() + 25); setLocationRelativeTo(null); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); loadingObj = new JLabel(); loadingObj.setHorizontalAlignment(SwingConstants.CENTER); loadingObj.setVerticalAlignment(SwingConstants.CENTER); loadingObj.setFont(new Font("Tahoma", Font.PLAIN, 18)); loadingObj.setForeground(Color.BLACK); loadingObj.setBounds(0, 28, getWidth(), getHeight() - 28); object = new JLabel("Loading objects..."); object.setHorizontalAlignment(SwingConstants.CENTER); object.setVerticalAlignment(SwingConstants.CENTER); object.setFont(new Font("Tahoma", Font.PLAIN, 18)); object.setForeground(Color.BLACK); object.setBounds(0, 0, getWidth(), getHeight() - 28); if(loadIcon.getIconHeight() != -1) { //setBounds of label if image exists JLabel label = new JLabel(loadIcon); label.setBounds(0, 0, loadIcon.getIconWidth(), loadIcon.getIconHeight()); layeredPane.add(label, 2); } layeredPane.add(object, 0); layeredPane.add(loadingObj, 0); contentPane.add(layeredPane); }
7
private void run() { Scanner scn = new Scanner(System.in); String line = scn.nextLine(); while (!line.trim().equals("0 0 0")) { String input[] = line.trim().split(" "); stickers = 0; lr = -1; cr = -1; lin = Integer.parseInt(input[0]); col = Integer.parseInt(input[1]); grid = new char[lin][]; for (int l = 0; l < lin; l++) { grid[l] = scn.nextLine().toCharArray(); if (lr == -1) { for (int c = 0; c < col; c++) { if (grid[l][c] == 'N' || grid[l][c] == 'S' || grid[l][c] == 'L' || grid[l][c] == 'O') { lr = l; cr = c; or = grid[l][c]; } } } } // Começa a simulação... String commands = scn.nextLine(); for (char comm : commands.toCharArray()) { apply(comm); } System.out.println(stickers); line = scn.nextLine(); } }
9
protected static int matchColour(Color colour, Color[] palette, int paletteStart, int paletteEnd, double chromaWeight) { if (chromaWeight < 0.0) { int bestI = paletteStart; int bestD = 4 * 256 * 256; for (int i = paletteStart; i < paletteEnd; i++) { int ðr = colour.getRed() - palette[i].getRed(); int ðg = colour.getGreen() - palette[i].getGreen(); int ðb = colour.getBlue() - palette[i].getBlue(); int ð = ðr*ðr + ðg*ðg + ðb*ðb; if (bestD > ð) { bestD = ð; bestI = i; } } return bestI; } Double _chroma = labMapWeight.get(); HashMap<Color, double[]> _labMap = ((_chroma == null) || (_chroma.doubleValue() != chromaWeight)) ? null : labMap.get(); if (_labMap == null) { labMap.set(_labMap = new HashMap<Color, double[]>()); labMapWeight.set(new Double(chromaWeight)); } double[] lab = _labMap.get(colour); /* if (lab == null) */ // FIXME Why does this not work!? _labMap.put(colour, lab = Colour.toLab(colour.getRed(), colour.getGreen(), colour.getBlue(), chromaWeight)); double L = lab[0], a = lab[1], b = lab[2]; int bestI = -1; double bestD = 0.0; Color p; for (int i = paletteStart; i < paletteEnd; i++) { double[] tLab = _labMap.get(p = palette[i]); /* if (tLab == null) */ // FIXME Why does this not work!? _labMap.put(colour, tLab = Colour.toLab(p.getRed(), p.getGreen(), p.getBlue(), chromaWeight)); double ðL = L - tLab[0]; double ða = a - tLab[1]; double ðb = b - tLab[2]; double ð = ðL*ðL + ða*ða + ðb*ðb; if ((bestD > ð) || (bestI < 0)) { bestD = ð; bestI = i; } } return bestI; }
9
public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
6
public void trackTarget(){ Target targetFromDashboard = null; String visionData = SmartDashboard.getString("VisionData", null); if (visionData == null) { // Only report error once if (!m_visionWidgetMissingReported) { System.out.println("VisionData is empty, does the SmartDashboard have the vision widget?"); m_visionWidgetMissingReported = true; } Robot._gyroTarget = 0; } else if (visionData.length() != 0) { //System.out.println("Vision Data : " + visionData); m_noTargetDetectedReported = false; targetFromDashboard = Target.loadFromString(visionData); double newAngleOffset = targetFromDashboard.getCenterAngleOffset() + m_ratio*(targetFromDashboard.getRightAngleOffset() - targetFromDashboard.getCenterAngleOffset()); //System.out.println("Vision::" + targetFromDashboard.getBoundingRectBottom()); // Only report angle offset when it changes if (((int)m_lastAngleOffset) != ((int)newAngleOffset)) { System.out.println("Target Angle Offset (From Dashboard) : " + targetFromDashboard.getCenterAngleOffset()); m_lastAngleOffset = newAngleOffset; } Robot._gyroTarget = newAngleOffset; Robot._bottomPixel = targetFromDashboard.getBoundingRectBottom(); Robot._topPixel = targetFromDashboard.getBoundingRectTop(); } else { // No targets are being tracked if (!m_noTargetDetectedReported) { System.out.println("No target is detected."); m_noTargetDetectedReported = true; } Robot._gyroTarget = 0; } }
5
private String getscoreMineralDifference(HashMap<String, int[]> otherScoreMinerals){ String a = ""; int scoreDiff = 0; int mineralDiff = 0; if(!otherScoreMinerals.keySet().equals(playerScoreMinerals.keySet())){ for(String s: otherScoreMinerals.keySet()){System.out.println(s);} System.out.println("different from"); for(String s: playerScoreMinerals.keySet()){System.out.println(s);} //// throw new Exception("Invalid Comparison!"); } for(String k : otherScoreMinerals.keySet()){ if(!otherScoreMinerals.get(k).equals(playerScoreMinerals.get(k))){ scoreDiff = (playerScoreMinerals.get(k)[0] - otherScoreMinerals.get(k)[0]); mineralDiff = (playerScoreMinerals.get(k)[0] - otherScoreMinerals.get(k)[0]); if(scoreDiff != 0) a = a.concat(k + "+score:" + scoreDiff+"\n"); if(mineralDiff != 0) a = a.concat(k + "+mineral:" + mineralDiff+"\n"); } } return a; }
7
public void namiLogin() throws IOException, NamiLoginException { // skip if already logged in if (isAuthenticated) { return; } HttpPost httpPost = new HttpPost(NamiURIBuilder.getLoginURIBuilder( server).build()); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("username", credentials.getApiUser())); nvps.add(new BasicNameValuePair("password", credentials.getApiPass())); if (server.useApiAccess()) { nvps.add(new BasicNameValuePair("Login", "API")); nvps.add(new BasicNameValuePair("redirectTo", "./pages/loggedin.jsp")); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); HttpResponse response = execute(httpPost, true); HttpEntity responseEntity = response.getEntity(); Type type = NamiApiResponse.getType(Object.class); NamiApiResponse<Object> resp = gson.fromJson(new InputStreamReader( responseEntity.getContent()), type); if (resp.getStatusCode() == 0) { isAuthenticated = true; log.info("Authenticated to NaMi-Server using API."); // SessionToken wird automatisch als Cookie im HttpClient // gespeichert } else { // Fehler beim Verbinden (3000 z.B. bei falschem Passwort) isAuthenticated = false; throw new NamiLoginException(resp); } } else { nvps.add(new BasicNameValuePair("redirectTo", "app.jsp")); nvps.add(new BasicNameValuePair("Login", "Anmelden")); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); HttpResponse response = execute(httpPost, false); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { // need to follow one redirect Header locationHeader = response.getFirstHeader("Location"); EntityUtils.consume(response.getEntity()); if (locationHeader != null) { String redirectUrl = locationHeader.getValue(); HttpGet httpGet = new HttpGet(redirectUrl); response = execute(httpGet, false); statusCode = response.getStatusLine().getStatusCode(); log.info("Got redirect to: " + redirectUrl); if (statusCode == HttpStatus.SC_MOVED_TEMPORARILY) { // login successful EntityUtils.consume(response.getEntity()); isAuthenticated = true; log.info("Authenticated to NaMi-Server without API."); } } } else { // login not successful isAuthenticated = false; String error = ""; try { Document doc = getCleanedDom(response.getEntity() .getContent()); XPathFactory xpathFac = XPathFactory.instance(); // XPath describes content of description field String xpathStr = "/html/body//p[1]/text()"; XPathExpression<Text> xpath = xpathFac.compile(xpathStr, Filters.textOnly()); Text xpathResult = xpath.evaluateFirst(doc); if (xpathResult != null) { error = StringEscapeUtils.unescapeHtml4(xpathResult .getText()); } } catch (Exception e) { throw new NamiLoginException(e); } throw new NamiLoginException(error); } } }
8
public void setId(Long id) { this.id = id; }
0
public static void main(String args[]) { for (;;) { break; } System.out.println("Value:" + new TestFor().test); }
1
public long node() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } if (node < 0) { node = leastSigBits & 0x0000FFFFFFFFFFFFL; } return node; }
2
public void EliminaFinal () { if ( VaciaLista()) System.out.println ("No hay elementos"); else { if (PrimerNodo == PrimerNodo.siguiente) PrimerNodo = null; else { NodosProcesos Actual =PrimerNodo; while (Actual.siguiente.siguiente != PrimerNodo) Actual = Actual.siguiente; Actual.siguiente = PrimerNodo; } } }
3
@SuppressWarnings("unchecked") public <T> T[] getArray(Class<T> type, ReadCallback<T> callback) { if (getBoolean()) { T[] array = (T[])Array.newInstance(type, getUshort()); if (!valid) { return null; } for (int i = 0; i < array.length && valid; i++) { if (getBoolean()) { array[i] = callback.read(this); } } if (valid) { return array; } } return null; }
6
public void makeExcitatoryVBHConnections3(CABot3Net linesNet, CABot3Net gratingsNet, String lineType, String grateType){ int netSize =linesNet.getInputSize(); int column; int cols = linesNet.getCols(); double weight; if (grateType.compareToIgnoreCase("vgrate3")==0){ weight = 1.5; } else{ weight =1.2; } int v3OnOffset = netSize*getLineOffset(lineType, "3on"); ///int v3OffOffset = netSize*getLineOffset(lineType, "3off"); int gratingOffset = netSize*getGrateOffset(grateType+"3"); for(int i=0; i<netSize; i++){ //add central connection 3X3 and 6X6 linesNet.neurons[v3OnOffset+i].addConnection(gratingsNet.neurons[gratingOffset+i], weight); //if we're not "falling off" the edge, add connections -2 and +2 columns away column = i%cols; if(column > 1){ linesNet.neurons[v3OnOffset+i-2].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } if(column<cols-2){ linesNet.neurons[v3OnOffset+i+2].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } //if we're not "falling off" the edge, add connections -4 and +4 columns away column = i%cols; if(column > 3){ linesNet.neurons[v3OnOffset+i-4].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } if(column<cols-4){ linesNet.neurons[v3OnOffset+i+4].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } //if we're not "falling off" the edge, add connections -6 and +6 columns away if(column > 5){ linesNet.neurons[v3OnOffset+i-5].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } if(column<cols-6){ linesNet.neurons[v3OnOffset+i+5].addConnection(gratingsNet.neurons[gratingOffset+i], weight); } } }
8
public static Map<String, Ban> load(String path) { Map<String, Ban> result = Collections.emptyMap(); File f = new File(path); if (f.exists() == false) { touchBanList(path); } else { try { FileInputStream fileStream = new FileInputStream(f); ObjectInputStream input = new ObjectInputStream(fileStream); result = (Map<String, Ban>) input.readObject(); input.close(); } catch (IOException e) { log.warning("[TimeBan] Error while reading from stream! Try a server reload..."); log.info(e.getMessage()); } catch (ClassNotFoundException e) { log.log(Level.SEVERE, e.getMessage()); } } return result; }
3
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if((commands.size()<1)&&(givenTarget==null)) { mob.tell(L("What would you like to open?")); return false; } final Environmental item=super.getAnyTarget(mob,commands,givenTarget,Wearable.FILTER_UNWORNONLY); if(item==null) return false; if((item instanceof MOB) ||(item instanceof Area) ||(item instanceof Room)) { mob.tell(L("You can't open that!")); return false; } if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=proficiencyCheck(mob,0,auto); if(success) { final CMMsg msg=CMClass.getMsg(mob,item,this,CMMsg.MSG_THIEF_ACT,L("<S-NAME> open(s) <T-NAME>."),CMMsg.NO_EFFECT,null,CMMsg.NO_EFFECT,null); if(mob.location().okMessage(mob,msg)) { mob.location().send(mob,msg); CMLib.commands().postOpen(mob,item,true); } } else { beneficialVisualFizzle(mob,item,L("<S-NAME> attempt(s) to open <T-NAME> quietly, but fail(s).")); CMLib.commands().postOpen(mob,item,false); } return success; }
9
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { DatabaseManager manager=DatabaseManager.getManager(); try { Equipment equipment = manager.getEquipmentDao().queryForId( Integer.parseInt(request.getParameter(ID))); if(equipment==null){ ServletResult.sendResult(response, ServletResult.NOT_FOUND); return; } String title=request.getParameter(Equipment.TITLE); String masterRoom=request.getParameter(Equipment.MULTIPURPOSE_ROOM); String description=request.getParameter(Equipment.DESCRIPTION); String available=request.getParameter(Equipment.AVAILABLE); if(!MyServlet.isEmpty(title)){ equipment.setTitle(title); } if(!MyServlet.isEmpty(masterRoom)){ MultipurposeRoom room=manager.getMultipurposeRoomDao().queryForId( Integer.parseInt(masterRoom)); if(room==null){ ServletResult.sendResult(response, ServletResult.NOT_FOUND); return; } equipment.setRoom(room); } if(!MyServlet.isEmpty(description)){ equipment.setDescription(description); } if(!MyServlet.isEmpty(available)){ equipment.setAvailable(Boolean.parseBoolean(available)); } ServletResult.sendResult(response, manager.getEquipmentDao().update(equipment)==1 ? ServletResult.SUCCESS : ServletResult.ERROR); } catch (NumberFormatException e) { e.printStackTrace(); ServletResult.sendResult(response, ServletResult.BAD_NUMBER_FORMAT); } catch (SQLException e) { e.printStackTrace(); ServletResult.sendResult(response, ServletResult.ERROR); } }
9
@Override public String toString() { StringBuilder hex = new StringBuilder(); for(byte b : value) { String hexDigits = Integer.toHexString(b).toUpperCase(); if(hexDigits.length() == 1) { hex.append("0"); } hex.append(hexDigits).append(" "); } String name = getName(); String append = ""; if(name != null && !name.equals("")) { append = "(\"" + this.getName() + "\")"; } return "TAG_Byte_Array" + append + ": " + hex.toString(); }
4
public static void main(String args[]) { //<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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(CadastroPremiacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(CadastroPremiacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(CadastroPremiacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(CadastroPremiacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> java.awt.EventQueue.invokeLater(new Runnable() { public void run() { CadastroPremiacao dialog = new CadastroPremiacao(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); }
6
public void start(BundleContext context) throws Exception { m_context = context; synchronized (m_refList) { // Listen for events pertaining to dictionary services. m_context.addServiceListener(this, "(&(objectClass=" + DictionaryService.class.getName() + ")" + "(Language=*))"); // Query for all dictionary services. ServiceReference[] refs = m_context.getServiceReferences(DictionaryService.class.getName(), "(Language=*)"); // Add any dictionaries to the service reference list. if (refs != null) { for (int i = 0; i < refs.length; i++) { // Get the service object. Object service = m_context.getService(refs[i]); // Make that the service is not being duplicated. if ((service != null) && (m_refToObjMap.get(refs[i]) == null)) { // Add to the reference list. m_refList.add(refs[i]); // Map reference to service object for easy look up. m_refToObjMap.put(refs[i], service); } } // Register spell checker service if there are any // dictionary services. if (m_refList.size() > 0) { m_reg = m_context.registerService(SpellChecker.class.getName(), new SpellCheckerImpl(), null); } } } }
5
public void moveDown(Tetromino piece, int x, int y, int orientation) { boolean[][] tiles = piece.getTiles(); int count = 0; // clear the current piece out int width = piece.getTiles()[0].length == 9 ? 3 : 4; // get width (3 or 4) of piece width = piece.getTiles()[0].length == 4 ? 2 : width; for(int row = 0; row < width; ++row) { for(int col = 0; col < width; ++col){ if(tiles[orientation][count++] && !screen[row+y][col+x].isEmpty()){ screen[row+y][col+x] = new Square(); } } } addPiece(piece, x, ++y, orientation); }
6
private void inorder(Node node, Queue<Key> q) { if (node == null) return; inorder(node.left, q); q.add(node.key); inorder(node.right, q); }
1
public void draw(MinuetoWindow window, MinuetoImage[] imageMapImages, int x, int y) { int sizeScreenX = window.getWidth(); int sizeScreenY = window.getHeight(); int tileIndexX = x / this.tileSize; int tileRemainderX = x % this.tileSize; int tileIndexY = y / this.tileSize; int tileRemainderY = y % this.tileSize; int drawingX = -tileRemainderX; int drawingY = -tileRemainderY; int indexX = tileIndexX; int indexY = tileIndexY; while (drawingX < sizeScreenX) { while (drawingY < sizeScreenY) { if ( (indexX < this.sizeX) && (indexY < this.sizeY) ) { window.draw(imageMapImages[this.mapData[indexX][indexY]], drawingX, drawingY); } drawingY = drawingY + this.tileSize; indexY++; } drawingY = -tileRemainderY; drawingX = drawingX + this.tileSize; indexY = tileIndexY; indexX++; } }
4
private boolean isOperator( String op ) { return op.equals("+") || op.equals("-") || op.equals("/") || op.equals("*"); }
3
public void playerTurn(int id) { boolean myTurn = false; if (id == myID) { myTurn = true; } //Enable all the buttons if its your turn, otherwise disable them for (int i=0;i<digitButton.length; i++) { digitButton[i].setEnabled(myTurn); } }
2
public static synchronized void writeLogFile(final String message) { new Thread(new Runnable() { @Override public void run() { try { if (Logger.log == null) { Logger.log = new Logger(); } Logger.log.writeLog(message); } catch (Exception ex) { java.util.logging.Logger.getLogger(Logger.class.getName()).log(Level.SEVERE, null, ex); } } }).run(); }
2
public GetDataBySubjectResponse(Request request, String response) throws XPathExpressionException, IOException { super(request, response, false); this.subjects = new HashMap<SubjectID, Subject>(); try { Document doc = this.getDocument(); if(response != null) { NodeList nodes = Utilities.selectNodes(doc, "/m:Members/m:Member", XMLLabels.STANDARD_NAMESPACES); if(nodes != null) { for(int i = 0; i < nodes.getLength(); ++i) { Node member = nodes.item(i); String value = Utilities.selectSingleText(member, "./m:UniqueID", XMLLabels.STANDARD_NAMESPACES); String domain = Utilities.selectSingleText(member, "./m:UniqueID/@domain", XMLLabels.STANDARD_NAMESPACES); if(!Utilities.isNullOrWhitespace(value) && !Utilities.isNullOrWhitespace(domain)) { SubjectID id = new SubjectID(domain, value); this.subjects.put(id, new Subject(id, member)); } } } } } catch(Exception e) { // TODO. } }
6
public void checkdoors() { System.out.println(); String convertstring; // Check of er een deur is aan de oostzijde if (getEast() == 0) { } else {// als er een deur is doe dit: System.out.println("There is a door on the east side of the room"); convertstring = "" + getEast(); // Als de string getvisited het kamernummer in zich heeft, dan heb // je de kamer bezocht en krijg je het nummer te zien. if (getVisited().contains(convertstring)) { System.out.println("The door leads to room: " + getEast()); } else {// Als de kamer nog niet bezocht is System.out.println("We haven't been through this door yet."); } } // Check of er een deur is aan de zuiderlijke zijde if (getSouth() == 0) { } else {// als er een deur is doe dit: System.out.println("There is a door on the south side of the room"); convertstring = "" + getSouth(); // Als de string getvisited het kamernummer in zich heeft, dan heb // je de kamer bezocht en krijg je het nummer te zien. if (getVisited().contains(convertstring)) { System.out.println("The door leads to room: " + getSouth()); } else {// Als de kamer nog niet bezocht is System.out.println("We haven't been through this door yet."); } } // Check of er een deur is aan de westzijde if (getWest() == 0) { } else {// als er een deur is doe dit: System.out.println("There is a door on the west side of the room"); convertstring = "" + getWest(); // Als de string getvisited het kamernummer in zich heeft, dan heb // je de kamer bezocht en krijg je het nummer te zien. if (getVisited().contains(convertstring)) { System.out.println("The door leads to room: " + getWest()); } else {// Als de kamer nog niet bezocht is System.out.println("We haven't been through this door yet."); } } // Check of er een deur is aan de noordzijde if (getNorth() == 0) { } else {// als er een deur is doe dit: System.out.println("There is a door on the north side of the room"); convertstring = "" + getNorth(); // Als de string getvisited het kamernummer in zich heeft, dan heb // je de kamer bezocht en krijg je het nummer te zien. if (getVisited().contains(convertstring)) { System.out.println("The door leads to room: " + getNorth()); } else {// Als de kamer nog niet bezocht is System.out.println("We haven't been through this door yet."); } } }
8
public static void process_queue(Queue<FileMessage> q[]){ //to be completed........................ based on readwrite class.......... while(true ){ int exit_flag=1; for(int i=0; i<q.length;i++){ if(!q[i].isEmpty()){ //System.out.println("Index--"+i+"::Queue size---"+q[i].size()); exit_flag=0; FileMessage message=q[i].peek(); //System.out.println("MY Node"+DFSMain.currentNode.getNodeID()+":: Message Node"+message.node_id); synchronized(FileSystem.map_filestatus){ if(!FileSystem.map_filestatus.containsKey(message.file)) { // rw.proceess_input(message); System.out.println("**********8trying againg"); FileSystem.map_filestatus.put(message.file, "Pending"); Thread readWrite=new Thread(new ReadWrite(message),"RWThread"+i); readWrite.start(); } if(FileSystem.map_filestatus.get(message.file)!=null){ if(FileSystem.map_filestatus.get(message.file).equals("complete")){ q[i].poll(); //message=q[i].peek(); FileSystem.map_filestatus.remove(message.file); // rw.proceess_input(message); } } } } } if(exit_flag==1){ System.out.println("-----------------------------------------------"); System.out.println("--------D O N E ------------------------"); break; } } System.out.println("-----------------------------------------------"); System.out.println("--------sending exit ------------------------"); DFSCommunicator.broadcastTerminate(); }
7
@Override public void checkMail() { super.checkMail(); List<Literal> percepts = convertMessageQueueToLiteralList(getTS().getC().getMailBox()); model.update(percepts); Iterator<Message> im = getTS().getC().getMailBox().iterator(); while (im.hasNext()) { Message message = im.next(); Literal percept = Literal.parseLiteral(message.getPropCont().toString()); String p = percept.getFunctor(); // String ms = message.getPropCont().toString(); // logger.info("[" + getAgName() + "] receved mail: " + ms); if (p.equals(Percept.visibleEdge) || p.equals(Percept.visibleEntity) || p.equals(Percept.visibleVertex) || p.equals(Percept.probedVertex) || p.equals(Percept.surveyedEdge) || p.equals(Percept.saboteur) || p.equals(Percept.inspectedEntity) || p.startsWith(Percept.coworker)) { im.remove(); // removes the percept from the mailbox } } }
9
public static void crop(Rectangle rect) { if (lastScreenshot == null) return; BufferedImage image = lastScreenshot.getImage(); int x = (int) rect.getX(); int y = (int) rect.getY(); int width = (int) rect.getWidth(); int height = (int) rect.getHeight(); // Crop the image to the secified dimensions and re-create the screenshot object. BufferedImage newImage = image.getSubimage(x, y, width, height); lastScreenshot = new ScreenshotImage(newImage, newImage.getWidth(), newImage.getHeight()); }
1
MainFrame() { final ClassLoader cLoader = getClass().getClassLoader(); ImageIcon collapseIcon = new ImageIcon(/*cLoader.getResource("images/Toggle_03_Hide.png"*/); final JLabel collapseBtn = new JLabel(collapseIcon); ImageIcon windowIcon = new ImageIcon(/*cLoader.getResource("images/WindowIcon02-50x50.png")*/); setIconImage(windowIcon.getImage()); setJMenuBar(menuBar); jtaOutput.setLineWrap(true); jtaOutput.setWrapStyleWord(true); jtaOutput.setEditable(false); upperPanel.rightPanel.add(containerForChooser); containerForChooser.add(leftInnerPanel); containerForChooser.add(rightInnerPanel); leftInnerPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); rightInnerPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); jcboCalcChooser = new JComboBox<String>(calcName); jcboCalcChooser.setSelectedIndex(panelIndex); leftInnerPanel.add(jcboCalcChooser); rightInnerPanel.add(collapseBtn); jtaOutput.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { ctrlPressed = true; } } @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { ctrlPressed = false; } } }); jtaOutput.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (ctrlPressed == true) { if (outputFocused == true) { int wheel = e.getWheelRotation(); if (wheel < 0) { if (fontSize < maxFontSize) { fontSize++; } } else { if (fontSize > minFontSize) { fontSize--; } } Font font = new Font(jtaOutput.getFont().getName(), Font.PLAIN, fontSize); jtaOutput.setFont(font); } } } }); jtaOutput.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { outputFocused = true; } @Override public void focusLost(FocusEvent e) { outputFocused = false; } }); jcboCalcChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { collapseBtn.setIcon(new ImageIcon(/*cLoader.getResource("images/Toggle_03_Hide.png")*/)); hiddenPanel = false; setPanel(jcboCalcChooser.getSelectedIndex()); } }); collapseBtn.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (hiddenPanel == false) { collapseBtn.setIcon(new ImageIcon(cLoader.getResource("images/Toggle_03_Show.png"))); upperPanel.leftPanel.removeAll(); upperPanel.leftPanel.revalidate(); hiddenPanel = true; } else if (hiddenPanel == true) { collapseBtn.setIcon(new ImageIcon(cLoader.getResource("images/Toggle_03_Hide.png"))); showPanel(); upperPanel.leftPanel.revalidate(); hiddenPanel = false; } } }); upperPanel.rightPanel.add(scrollerForOutput); panelForCollapseBtn.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelForCollapseBtn.add(new JLabel("Hello World")); borderForOutput = BorderFactory.createCompoundBorder(new TitledBorder( "Output"), new BevelBorder(BevelBorder.LOWERED)); scrollerForOutput.setBorder(borderForOutput); setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); add(upperPanel, BorderLayout.NORTH); add(lowerPanel, BorderLayout.SOUTH); }
9
public int getPostIndex(byte[] bytes, Charset charset) { String firstBytes = new String(bytes, charset); String separator = CRLFx2; int index = firstBytes.indexOf(CRLFx2); int indexCR = firstBytes.indexOf(CRx2); int indexLF = firstBytes.indexOf(LFx2); if (indexCR != -1 && indexCR < index) { separator = CRx2; index = indexCR; } if (indexLF != -1 && indexLF < index) separator = LFx2; return getByteIndexIncludingSeparator(firstBytes, separator); }
4
private void add(File source, JarOutputStream target) throws IOException { BufferedInputStream in = null; try { // If the file provided is a directory if (source.isDirectory()) { // Replace \ with File.separator String name = source.getPath().replace("\\", File.separator); // If name is not empty if (!name.isEmpty()) { // Remove the first for characters (tmp+File.separator) name = name.substring(4); // If name doesn't end with File.separator if (!name.endsWith(File.separator)) // Append File.separator to name name += File.separator; // Create a new entry with the name stored int the name variable JarEntry entry = new JarEntry(name); // Set the last modified time entry.setTime(source.lastModified()); // Add the entry to the JarOutputStream target.putNextEntry(entry); // This bit of code is not actually necessary because putNextEntry() actually calls closeEntry() //target.closeEntry(); } // Iterate through the files for (File nestedFile: source.listFiles()) // Call add function on new file (we operate recursively on directories) add(nestedFile, target); } // (The file is not a folder) Create a new entry with the name JarEntry entry = new JarEntry(source.getPath().replace("\\", "/").substring(4)); // Set the last modified time entry.setTime(source.lastModified()); // Add the entry to the JarOutputStream target.putNextEntry(entry); // Create a new BufferedInputStream using the JarOutputStream in = new BufferedInputStream(new FileInputStream(source)); // Create a byte array to store data byte[] buffer = new byte[1024]; // Loop forever while (true) { // Count is the bytes read int count = in.read(buffer); // If count is -1 we're done reading if (count == -1) // Break the loop break; // Write th buffer to the JarOutputStream target.write(buffer, 0, count); } // Close the entry target.closeEntry(); } finally { // If the BufferedInputStream is not null, close it if (in != null) in.close(); } }
7
public boolean isLive() { return isLive; }
0
@Override public boolean equals(Object object) { if (object == null) { return false; } if (getClass() != object.getClass()) { return false; } Person person = (Person) object; if (this.gender == null || !this.gender.equals(person.getGender())) { return false; } if (this.firstName == null || !this.firstName.equals(person.getFirstName())) { return false; } if (this.surname == null || !this.surname.equals(person.getSurname())) { return false; } if (this.age != person.getAge()) { return false; } return true; }
9
private int addToShow(int rowIndex, int colIndex, Integer index, int[][] array){ field[rowIndex][colIndex].show(); for (int i = rowIndex - 1; i <= rowIndex + 1; i++) { for (int j = colIndex - 1; j <= colIndex + 1; j++) { if (checkIndex(i, j)) { if (field[i][j].getCellType() == CellType.Index) field[i][j].show(); else if (field[i][j].getCellType() == CellType.Empty && !field[i][j].isVisible()) { field[i][j].show(); array[index][0] = i; array[index][1] = j; index++; } } } } return index; }
6
public static boolean getDontQuit() { return dontQuit; }
0
@FXML private void handleTxtBarCodeAction(ActionEvent event) { clearIndicator(); if (txtBarCode.getText().isEmpty()) { return; } txtItemName.setDisable(false); txtItemName.requestFocus(); Item item = select(txtBarCode.getText()); if (item != null) { txtItemName.setText(item.getName()); txtPrice.setText(item.getPrice()); if (item.getSupplierCode() == 0) { cobSuppliers.setValue(null); } else { Suppliers suppliers = new Suppliers(item.getSupplierCode()); cobSuppliers.setValue(suppliers); } if (item.getBumonCode() == 0) { cobBumon.setValue(null); } else { Bumon bumon = new Bumon(item.getBumonCode()); cobBumon.setValue(bumon); } } else { txtItemName.clear(); txtPrice.clear(); cobSuppliers.setValue(null); cobBumon.setValue(null); } if (item != null) { showIndicator(indicator); } }
5
public LauncherView(Fighter[] m) { p2ReadyBool = p1ReadyBool = false; model = m; selection = new int[model.length]; // general layout stuff GridBagLayout generalLayout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); // default spacing setLayout(generalLayout); // Panels // player one playerOnePanel = new JPanel(); playerOnePanel .setBorder(BorderFactory.createTitledBorder("Player One")); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; generalLayout.setConstraints(playerOnePanel, constraints); add(playerOnePanel); // player two playerTwoPanel = new JPanel(); playerTwoPanel .setBorder(BorderFactory.createTitledBorder("Player Two")); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; generalLayout.setConstraints(playerTwoPanel, constraints); add(playerTwoPanel); // buttons startGame = new JButton("START!"); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.fill = GridBagConstraints.NONE; constraints.weightx = 0; constraints.weighty = 0; generalLayout.setConstraints(startGame, constraints); add(startGame); // p1 panel // p1 layout GridBagLayout player1Layout = new GridBagLayout(); GridBagConstraints p1Const = new GridBagConstraints(); p1Const.insets = new Insets(5, 5, 5, 5); // default spacing playerOnePanel.setLayout(player1Layout); // buttons p1Character = new JButton[model.length]; for (int i = 0; i < p1Character.length; i++) { p1Character[i] = new JButton(model[i].getName()); p1Const.gridx = i % 4; //will reset the position to 0 every 5 p1Const.gridy = 1 * (i / 4); //will make a new line for buttons after each set of 5 p1Const.gridwidth = 1; p1Const.gridheight = 1; p1Const.fill = GridBagConstraints.NONE; p1Const.weightx = 1; p1Const.weighty = 0; player1Layout.setConstraints(p1Character[i], p1Const); playerOnePanel.add(p1Character[i]); } p1Ready = new JButton("Ready!"); p1Const.gridx = 0; p1Const.gridy = 20; p1Const.gridwidth = 5; p1Const.gridheight = 1; p1Const.fill = GridBagConstraints.NONE; p1Const.weightx = 0; p1Const.weighty = 0; player1Layout.setConstraints(p1Ready, p1Const); playerOnePanel.add(p1Ready); // text area p1Desc = new JTextArea(); p1Const.gridx = 0; p1Const.gridy = 19; p1Const.gridwidth = 5; p1Const.gridheight = 1; p1Const.fill = GridBagConstraints.BOTH; p1Const.weightx = 1; p1Const.weighty = 1; player1Layout.setConstraints(p1Desc, p1Const); playerOnePanel.add(p1Desc); p1Desc.setEditable(false); p1Stats = new JTextArea(); p1Const.gridx = 3; p1Const.gridy = 18; p1Const.gridwidth = 2; p1Const.gridheight = 1; p1Const.fill = GridBagConstraints.BOTH; p1Const.weightx = 0; p1Const.weighty = 0; player1Layout.setConstraints(p1Stats, p1Const); playerOnePanel.add(p1Stats); p1Stats.setEditable(false); // Label p1Image = new JLabel(new ImageIcon("res/portraits/unknown.png")); p1Const.gridx = 0; p1Const.gridy = 18; p1Const.gridwidth = 3; p1Const.gridheight = 1; p1Const.fill = GridBagConstraints.NONE; p1Const.weightx = 0; p1Const.weighty = 0; player1Layout.setConstraints(p1Image, p1Const); playerOnePanel.add(p1Image); // p2 panel // p2 layout GridBagLayout player2Layout = new GridBagLayout(); GridBagConstraints p2Const = new GridBagConstraints(); p2Const.insets = new Insets(5, 5, 5, 5); // default spacing playerTwoPanel.setLayout(player2Layout); // buttons p2Character = new JButton[model.length]; for (int i = 0; i < p2Character.length; i++) { p2Character[i] = new JButton(model[i].getName()); p2Const.gridx = i % 4; //will reset the position to 0 every 5 p2Const.gridy = 1 * (i / 4); //will make a new line for buttons after each set of 5 p2Const.gridwidth = 1; p2Const.gridheight = 1; p2Const.fill = GridBagConstraints.NONE; p2Const.weightx = 1; p2Const.weighty = 0; player2Layout.setConstraints(p2Character[i], p2Const); playerTwoPanel.add(p2Character[i]); } p2Ready = new JButton("Ready!"); p2Const.gridx = 0; p2Const.gridy = 20; p2Const.gridwidth = 5; p2Const.gridheight = 1; p2Const.fill = GridBagConstraints.NONE; p2Const.weightx = 0; p2Const.weighty = 0; player2Layout.setConstraints(p2Ready, p2Const); playerTwoPanel.add(p2Ready); // text area p2Desc = new JTextArea(); p2Const.gridx = 0; p2Const.gridy = 19; p2Const.gridwidth = 5; p2Const.gridheight = 1; p2Const.fill = GridBagConstraints.BOTH; p2Const.weightx = 1; p2Const.weighty = 1; player2Layout.setConstraints(p2Desc, p2Const); playerTwoPanel.add(p2Desc); p2Desc.setEditable(false); p2Stats = new JTextArea(); p2Const.gridx = 3; p2Const.gridy = 18; p2Const.gridwidth = 2; p2Const.gridheight = 1; p2Const.fill = GridBagConstraints.BOTH; p2Const.weightx = 0; p2Const.weighty = 0; player2Layout.setConstraints(p2Stats, p2Const); playerTwoPanel.add(p2Stats); p2Stats.setEditable(false); // Label p2Image = new JLabel(new ImageIcon("res/portraits/unknown.png")); p2Const.gridx = 0; p2Const.gridy = 18; p2Const.gridwidth = 3; p2Const.gridheight = 1; p2Const.fill = GridBagConstraints.NONE; p2Const.weightx = 0; p2Const.weighty = 0; player2Layout.setConstraints(p2Image, p2Const); playerTwoPanel.add(p2Image); update(); }
2
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { URL url = e.getURL(); try { viewer.setPage(url); addURL(url); } catch (IOException ex) { System.out.println("IOException: " + ex.getMessage()); } } }
2
@Override public void render(Document html, Element node) { Element sectionNode = html.createElement("section"); sectionNode.setAttribute("data-section-name", name); // set coded content in ID if (getCodedContentCollection() != null) { sectionNode.setAttribute("id", getCodedContentCollection().getId()); } node.appendChild(sectionNode); Element headerNode = html.createElement("header"); if (depth < 3) { headerNode.setAttribute("class", "level" + Integer.toString(depth)); } else { headerNode.setAttribute("class", "level3"); } headerNode.setTextContent(fixHeaderName(name)); sectionNode.appendChild(headerNode); // if no children, no paragraph tag if (getChildren().size() > 0) { Element pNode = html.createElement("p"); sectionNode.appendChild(pNode); childrenRender(html, pNode); } }
3
public static void highlight(String position, int r, int g, int b){ if(false){ GraphicsConnection.debugConnection.sendHighlight(position, r, g, b); } }
1
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(ID())!=null) { mob.tell(target,null,null,L("<S-NAME> already <S-HAS-HAVE> the blindsight.")); return false; } if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=proficiencyCheck(mob,0,auto); if(success) { final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?L("<T-NAME> attain(s) blindsight."):L("^S<S-NAME> @x1 for the blindsight.^?",prayWord(mob))); if(mob.location().okMessage(mob,msg)) { mob.location().send(mob,msg); beneficialAffect(mob,target,asLevel,0); final Ability A=target.fetchEffect(ID()); if(A!=null) { target.delEffect(A); target.addPriorityEffect(A); } } } else return beneficialWordsFizzle(mob,target,L("<S-NAME> @x1 for blindsight, but go(es) unanswered.",prayWord(mob))); // return whether it worked return success; }
9
public String extractSection (int start,int end) { StringBuilder out=new StringBuilder(); int a; int tc=counter+start; if (tc>=totalLength) tc=tc-totalLength; for (a=start;a<end;a++) { if (this.get(tc)==true) out.append("1"); else out.append("0"); tc++; if (tc==totalLength) tc=0; } return out.toString(); }
4
private Batch <Actor> talksTo() { final Batch <Actor> batch = new Batch <Actor> () ; if (subject instanceof Actor) { final Actor a = (Actor) subject ; batch.add(a) ; } else if (subject instanceof Venue) { final Venue v = (Venue) subject ; for (Actor a : v.personnel.residents()) batch.include(a) ; for (Actor a : v.personnel.workers() ) batch.include(a) ; } return batch ; }
4
public boolean find(long searchKey) { // find specified value int j; for (j = 0; j < nElems; j++) // for each element, if (a[j] == searchKey) // found item? break; // exit loop before end if (j == nElems) // gone to end? return false; // yes, can’t find it else return true; // no, found it } // end find()
3
public static void writeSearchResponse(SearchResponse response, BufferedWriter out, boolean writeQuery, boolean writeLink, boolean writeTitle, boolean writeSnippet) throws Exception { List<SearchResponse.Result> results = response.getResults(); System.out.println(">>>> WRITE " + results.size() + " RESULTS FOR \"" + response.getRequestedQuery() + "\" TO FILE"); for (SearchResponse.Result result : results) { List<String> fields = new ArrayList<String>(); if (writeQuery) fields.add("\"" + response.getRequestedQuery() + "\""); if (writeLink) fields.add(result.getLink()); if (writeTitle) fields.add("\"" + result.getTitle() + "\""); if (writeSnippet) fields.add("\"" + result.getSnippet() + "\""); WebSearchLauncher.writeCSVLine(fields, out); } }
5
public String getNextUntitledDockableName(String baseTitle, Dockable exclude) { List<Dockable> dockables = getDockables(); int value = 0; String title; boolean again; do { again = false; title = baseTitle; if (++value > 1) { title += " " + value; //$NON-NLS-1$ } for (Dockable dockable : dockables) { if (dockable != exclude && title.equals(dockable.getTitle())) { again = true; break; } } } while (again); return title; }
5
public void set(int key, int value) { int hk = hash(key); boolean isSet = false; int index = -1; if (full==false) { for (int i=0;i<cache.length;i++) { if (cache[(hk+i)%cache.length]==null) { index = i; isSet = true; break; } if (cache[(hk+i)%cache.length].key==key) { index = i; isSet = true; break; } } if (isSet==false) full = true; } if (isSet==false) { for (int i=0;i<cache.length;i++) { if (cache[(hk+i)%cache.length].key==key) { index = i; isSet = true; break; } // if (cache[(hk+i)%cache.length].time>0) { // index = i; // isSet = true; // break; // } } } if (isSet) cache[(hk+index)%cache.length] = new Item(key, value); else cache[hk] = new Item(key,value); System.out.println("set("+String.valueOf(key)+","+String.valueOf(value)+")->\n"+this); }
9
public byte[] toByteArray(){ byte [] out = null; try { ByteArrayOutputStream bo = new ByteArrayOutputStream(); OutputStream baos = bo; if(this.type==Type.Dictionary){ baos.write('d'); for(Entry<String, Bencoding> s:dictionary.entrySet()){ byte [] bytes = s.getKey().getBytes("UTF-8"); String l = Long.toString(bytes.length); baos.write(l.getBytes("UTF-8")); baos.write(':'); baos.write(bytes); baos.write(s.getValue().toByteArray()); } baos.write('e'); }else if(this.type==Type.Integer){ baos.write('i'); String s = integer.toString(); baos.write(s.getBytes("UTF-8")); baos.write('e'); }else if(this.type==Type.List){ baos.write('l'); for(Bencoding b: list){ baos.write(b.toByteArray()); } baos.write('e'); }else{ byte [] bytes = byteString; String l = Long.toString(bytes.length); baos.write(l.getBytes("UTF-8")); baos.write(':'); baos.write(bytes); } baos.close(); baos.flush(); out = bo.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return out; }
6
public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton)e.getSource(); String s = sourceButton.getName(); //Use the dummy game to make a guess MasterMindGame m = gui.getGameP2(); if (s.contains("send")) { //Assuming user sets enough colours sol will be the solution to send ArrayList<Integer> sol = m.getFullGuess(); //System.out.println("size of sol is " + sol.size()); if (sol.size() != 4) { this.gui.notEnoughError(); } else { try { //Send opponents answer to them this.gui.getClient().sendInitial(sol); // if we went first, we need to receive our answer now if (this.gui.getTurnOrder() == 0) { MasterMindGame game = new MasterMindGame(Client.receiveInitial(), 8, true); this.gui.setGame(game); } } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //We make a new game for second screen MasterMindGame p2Game = new MasterMindGame(sol, 8, true); this.gui.setGameP2(p2Game); //Hide start screen this.gui.hideStart(); this.gui.hideMultScreen(); //Create GUI this.gui.createGUI(); //if we're going second, we need to get the first move from opponent before we make ours if (this.gui.getTurnOrder() != 0) { this.gui.setTurnLabel("waiting for opponent to send our answer"); try { ArrayList<Integer> opponentMove = this.gui.getClient().receiveMove(); System.out.println("got guess from opponent: " + opponentMove); //update our opponent's screen (on our end) accordingly boolean opponentWon = this.gui.colourScreenMult(opponentMove); //TODO : get the hint } catch (Exception exc) { // TODO Auto-generated catch block exc.printStackTrace(); } } } } else if (s.contains("clear")) { if (m.getFullGuess().size() == 0) { gui.showEmptyError(); } else { gui.clearRowMult(); } } }
8
@Override public JSite load() { if (loaded) return this; String body = null; try { body = JHttpClientUtil.postText( context.getUrl() + JHttpClientUtil.Sites.URL, JHttpClientUtil.Sites.GetSite.replace("{SiteUrl}", context.getUrl()), JHttpClientClient.getWebserviceSopa() ); } catch (Exception ex) { throw new RuntimeException(ex); } Node listElement; Document document; try { document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new ByteArrayInputStream(body.getBytes())); } catch (Exception ex) { throw new RuntimeException(ex); } NodeList nodes = document.getElementsByTagName("GetSiteResult"); if (nodes.getLength() > 0) listElement = nodes.item(0).getFirstChild(); else return null; Pattern pattern = Pattern.compile("(\\w+)=\\\"([^\\\"]+)\\\""); Matcher matcher = pattern.matcher(listElement.getNodeValue()); int start = 0; while (matcher.find(start)) { attributes.put(matcher.group(1), new JContentValue(matcher.group(2))); start = matcher.end(); } loaded = true; return this; }
5
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String p; if ((p = request.getParameter("delete_id")) != null) { // del Advertisement advertToDelete = this.advertRepo.getById(Integer .parseInt(p)); if (advertToDelete.getAdvertiser().getUsername() .equals(request.getUserPrincipal().getName())) { response.getWriter().write( "Advert with title " + advertToDelete.getTitle() + " is going to be deleted"); advertRepo.deleteAdvertisement(advertToDelete); } } else if ((p = request.getParameter("sold_id")) != null) { int id = Integer.parseInt(p); Advertisement soldAdvert = this.advertRepo.getById(id); if (soldAdvert != null) { soldAdvert.setStatus(1); // 0 = unsold, 1 = sold this.advertRepo.updateAdvertisement(soldAdvert); } this.getServletContext().getRequestDispatcher("/advertisements") .forward(request, response); } else if ((p = request.getParameter("save_id")) != null) { Advertisement advertToUpdate = this.advertRepo.getById(Integer .parseInt(p)); if (advertToUpdate.getAdvertiser().getUsername() .equals(request.getUserPrincipal().getName())) { String title = request.getParameter("Title"); String description = request.getParameter("Description"); String price = request.getParameter("Price"); if (advertToUpdate != null) { advertToUpdate.setTitle(title); advertToUpdate.setDescription(description); advertToUpdate.setPrice(price); this.advertRepo.updateAdvertisement(advertToUpdate); } } this.getServletContext().getRequestDispatcher("/advertisements") .forward(request, response); } else { String title = request.getParameter("Title"); String description = request.getParameter("Description"); String price = request.getParameter("Price"); // add new Advert Advertisement advertToSave = new Advertisement(); advertToSave.setTitle(title); User advertiser = this.userRepo.getByUsername(request .getUserPrincipal().getName()); advertToSave.setAdvertiser(advertiser); advertToSave.setPrice(price); advertToSave.setDate(new Date().toString().substring(0, 10)); advertToSave.setDescription(description); this.advertRepo.addAdvertisement(advertToSave); request.setAttribute("Advertisement", advertToSave); getServletContext() .getRequestDispatcher("/SingleAdvertisement.jsp").forward( request, response); } }
7
protected Query getWildcardQuery(String field, String termStr) throws ParseException { if ("*".equals(field)) { if ("*".equals(termStr)) return newMatchAllDocsQuery(); } if (!allowLeadingWildcard && (termStr.startsWith("*") || termStr.startsWith("?"))) throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery"); if (lowercaseExpandedTerms) { termStr = termStr.toLowerCase(); } Term t = new Term(field, termStr); return newWildcardQuery(t); }
6
public Player(Level level, int x, int y) { super(level, x, y); hWidth = 8; hHeight = 15; hXOffs = 4; hYOffs = 7; movementSpeed = 0.2; maxMovementSpeed = 4.0; maxFallingSpeed = 6; stopMovementSpeed = 0.3; jumpMomentum = -6; gravity = 0.3; animation = new Animation(); animation.setFrames(Assets.PLAYER_IDLE); animation.setFPS(-1); }
0
public static boolean manuallySetGuildLevel(String[] args, CommandSender s) { //Various checks if(Util.isBannedFromGuilds(s) == true){ //Checking if they are banned from the guilds system s.sendMessage(ChatColor.RED + "You are currently banned from interacting with the Guilds system. Talk to your server admin if you believe this is in error."); return false; } if(!s.hasPermission("zguilds.admin.setlevel")){ //Checking if they have the permission node to proceed s.sendMessage(ChatColor.RED + "You lack sufficient permissions to set a guilds level. Talk to your server admin if you believe this is in error."); return false; } if(args.length > 4){ //Checking if the create command has proper args s.sendMessage(ChatColor.RED + "Incorrectly formatted guild set level command! Proper syntax is: \"/guild setlevel <Guild name> <# (1-25)>\""); return false; } targetGuild = args[2].toLowerCase(); if(Main.guilds.getConfigurationSection("Guilds." + targetGuild) == null){ //Checking if that guild already exists s.sendMessage(ChatColor.RED + "That guild doesn't exist. Unable to change level."); return false; } if(!args[3].matches("^[0-9]+$")){ //Checking if the type is valid s.sendMessage(ChatColor.RED + "The new level can only contain numbers."); return false; } if(args[3].startsWith("0")){ s.sendMessage(ChatColor.RED + "The level you're attempting to set can't begin with '0'."); return false; } targetGuildsNewLevel = Integer.parseInt(args[3]); if(targetGuildsNewLevel > 25 || targetGuildsNewLevel < 1){ s.sendMessage(ChatColor.RED + "You can't set a guild higher than level 25, or lower than 1."); return false; } Main.guilds.set("Guilds." + targetGuild + ".Level", targetGuildsNewLevel); s.sendMessage(ChatColor.DARK_GREEN + "You set the level of \"" + targetGuild + "\" to " + targetGuildsNewLevel + "."); Main.saveYamls(); return true; }
8
public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException { ArrayList var1 = null; for (byte var2 = par0DataInputStream.readByte(); var2 != 127; var2 = par0DataInputStream.readByte()) { if (var1 == null) { var1 = new ArrayList(); } int var3 = (var2 & 224) >> 5; int var4 = var2 & 31; WatchableObject var5 = null; switch (var3) { case 0: var5 = new WatchableObject(var3, var4, Byte.valueOf(par0DataInputStream.readByte())); break; case 1: var5 = new WatchableObject(var3, var4, Short.valueOf(par0DataInputStream.readShort())); break; case 2: var5 = new WatchableObject(var3, var4, Integer.valueOf(par0DataInputStream.readInt())); break; case 3: var5 = new WatchableObject(var3, var4, Float.valueOf(par0DataInputStream.readFloat())); break; case 4: var5 = new WatchableObject(var3, var4, Packet.readString(par0DataInputStream, 64)); break; case 5: var5 = new WatchableObject(var3, var4, Packet.readItemStack(par0DataInputStream)); break; case 6: int var6 = par0DataInputStream.readInt(); int var7 = par0DataInputStream.readInt(); int var8 = par0DataInputStream.readInt(); var5 = new WatchableObject(var3, var4, new ChunkCoordinates(var6, var7, var8)); } var1.add(var5); } return var1; }
9
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { List<BankDeposit> deposits = ReaderFactory.getInstance().getDOMReader() .readXML(DataPath.XML_FILE); request.setAttribute("deposits", deposits); request.setAttribute("type", ParserType.DOM); return PageName.DEPOSITS_PAGE; } catch (XMLReaderDOMException ex) { log.error(ex.getHiddenException()); } return PageName.ERROR_PAGE; }
1
public Configuration(String path, int splitSize) { List<String> lines = new ArrayList<>(); try(BufferedReader br = new BufferedReader(new InputStreamReader( new BufferedInputStream(new FileInputStream(new File(path)))))) { while(true) { String line = br.readLine(); if(line == null) { break; } line = line.trim(); if(line.isEmpty() || line.startsWith("Konfiguracija")) { continue; } lines.add(line); } } catch(IOException e) { e.printStackTrace(); } this.configurations = new ArrayList<>(); DataSample[] conf = new DataSample[splitSize]; for(int i = 0; i < lines.size(); i++) { String[] parts = lines.get(i).split("\\s+"); double[] data = new double[parts.length - 1]; for(int j = 0; j < data.length; j++) { data[j] = Double.parseDouble(parts[j]); } conf[i % splitSize] = new DataSample(new Vector(data), parts[parts.length - 1]); if((i + 1) % splitSize == 0) { this.configurations.add(conf); conf = new DataSample[splitSize]; } } }
8
public static void otherMethod(int[] src,int k){ if( k > src.length){ return; } TreeSet<Integer> s = new TreeSet<Integer>(); for(int i=0;i<k;i++){ s.add(src[i]); } for(int i=k;i<src.length;i++){ int last = s.last(); if(last > src[i] ){ s.remove(last); s.add(src[i]); } } Iterator t = s.iterator(); while(t.hasNext()){ System.out.println(t.next()); } }
5
protected int checkForDraw() { //db.a(includeImages,"Rules checkForDraw: with no images included"); //db.a(boardImagesStored > 0, "Rules checkForDraw: no board images stored"); // db.pr("Rules: stag count is "+stagnateCount); // Check for stagnation. if (stagnateCount == maxStagnationMoves * 2 - 1) { return STATE_DRAWNSTAG; } int currBoard = (boardImagesStored - 1) * boardImageLength; // Compare this board image with those that came before to see if it // repeats. int repCount = 0; int compBoard = currBoard; while (true) { // examine only those positions for the current player. compBoard -= boardImageLength * 2; if (compBoard < 0) { break; } // Compare last int first, since it contains the checksum. int i; for (i = boardImageLength - 1; i >= 0; i--) { if (boardImages[compBoard + i] != boardImages[currBoard + i]) { break; } } if (i >= 0) { continue; } repCount++; if (repCount == repeatCountForDraw) { return STATE_DRAWNREP; } } // boardRepCount = repCount; if ( maxMovesPerGame != 0 && moveNumber == maxMovesPerGame ) { return STATE_DRAWNMAXMOVES; } return STATE_PLAYING; }
9
protected String encodeTerm(List<Term> sentence, int idx, Response prediction, boolean isTrainingSet, String predictionType) { Term term = sentence.get(idx); String text = term.getText().trim(); StringBuilder builder = new StringBuilder(); builder.append("curToken=").append(text); builder.append(" entityTag=").append(term.getNETag()); builder.append(" isPerson=").append(EntityUtils.isPerson(term)); if (idx > 0) { Term prev = sentence.get(idx-1); builder.append(" prevToken=").append(prev.getText().trim()); } if (idx > 1) { Term prev = sentence.get(idx-2); builder.append(" prevprevToken=").append(prev.getText().trim()); } if (idx < sentence.size()-1) { Term next = sentence.get(idx+1); builder.append(" nextToken=").append(next.getText().trim()); } if (idx < sentence.size()-2) { Term next = sentence.get(idx+2); builder.append(" nextnextToken=").append(next.getText().trim()); } predictionType = predictionType.toLowerCase(); if (isTrainingSet && prediction != null) {// training set builder.append(" is"+predictionType+"="); String entity = term.getText().replaceAll("_", " "); if ("PARENT".equalsIgnoreCase(predictionType)) { builder.append(prediction.getParents().contains(entity)); } else if ("SPOUSE".equalsIgnoreCase(predictionType)) { builder.append(prediction.getSpouses().contains(entity)); } else if ("CHILD".equalsIgnoreCase(predictionType)) { builder.append(prediction.getChildren().contains(entity)); } } else builder.append(" is"+predictionType+"="); return builder.toString(); }
9
public static Vector<Assignment> assignNextChance() { if(DEBUG) System.out.println("Making sure we have assigned all chance variables"); //get the next chance variable to assign Variable nextChance = null; for(int i = 1; i < variables.size(); i++) { Variable v = variables.get(i); if(v.isChance() && v.getAssignment() == Variable.UNASSIGNED) { nextChance = v; break; } } //if we cannot find a chance variable to assign, so they have all been assign. //return the current assignment if(nextChance == null) { if(Clause.isFormulaSAT(clauses)) { //make an Assignment, and return it with a probably 1, since we are SAT Vector<Assignment> SATAssignment = new Vector<Assignment>(); SATAssignment.add(new Assignment(variables, 1.0)); return SATAssignment; } else if(Clause.isFormulaUnSAT(clauses)) { //make an assignment with probability 0.0 (since we are UNSAT) //and return it. Vector<Assignment> UNSATAssignment = new Vector<Assignment>(); UNSATAssignment.add(new Assignment(variables, 0.0)); return UNSATAssignment; } else { //we are neither SAT or UNSAT, yet there are no more chance variables to assign - this shouldn't happen //FREAK OUT!!!! System.out.println("Tried to assign all the chance variables after finding out we were SAT/UNSAT, but now we are not SAT or UNSAT!!!!"); printFormulaInfo(); System.exit(5); } } //we have found a chance variable to assign //assign it to true and false, adjust the resulting probabilities based on the variable's //chance that it is true or false //and return all the resulting assignments Vector<Assignment> trueAssignments = tryAssign(nextChance, Variable.TRUE); for(Assignment a : trueAssignments) a.adjustProbability(nextChance.getChanceTrue()); Vector<Assignment> falseAssignmetns = tryAssign(nextChance, Variable.FALSE); for(Assignment a : falseAssignmetns) a.adjustProbability(nextChance.getChanceFalse()); //return all of the assignments if it is true and false. Vector<Assignment> allAssignments = new Vector<Assignment>(); allAssignments.addAll(trueAssignments); allAssignments.addAll(falseAssignmetns); return allAssignments; }
9
private BinaryStdOut() { }
0
public int getArrayIndex(int... ind) { if(ind.length == indexDim) { if(ind.length == 1) { return ind[0]; } if(ind.length == 2) { if(this.checkIndex(0, ind[0]) == false || this.checkIndex(1, ind[1]) == false) { return -1; } return ind[0] + ind[1]*dimSizes[0]; } if(ind.length == 3) { if(this.checkIndex(0, ind[0])==false|| this.checkIndex(1, ind[1])==false|| this.checkIndex(2, ind[2])==false) { return -1; } return (ind[2]*dimSizes[1]*dimSizes[0])+(ind[1]*dimSizes[0]) + ind[0]; } } return -1; }
9
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (sender.hasPermission("peacekeeper.addbadword")) { if (args[0] == "-d") { for (String arg : args) { config.FilterList.remove(arg); } } else { for (String arg : args) { config.FilterList.add(arg); } } main.getConfig().set("Word Filter.Filtered Words", config.FilterList); main.saveConfig(); return true; } else return false; }
4
private List<String> getPhoneNumbersDisplay() { List<String> displayList = Lists.newArrayList(); for (PhoneNumber phoneNumber : phoneNumbers) { displayList.add(phoneNumber.toDisplayString()); } return displayList; }
1
public boolean startsWith(String word) { if (word == null || word.length() == 0) return false; int len = 0; TrieNode node = root; while (len < word.length()) { boolean found = false; for (int i = 0; i < node.nodes.size(); i++) { if (node.nodes.get(i).val.equals(String.valueOf( word.charAt(len)))) { node = node.nodes.get(i); found = true; break; } } if (!found) return false; len = len + 1; } return true; }
6
@Override public byte[] getHTTPMessageBody() { try { writeToPatchContent(); } catch (Exception e) { e.printStackTrace(); } return "Request Invalid".getBytes(); }
1
public void bytesWrite(int bytes, int clientId) { if (this.clientId == clientId) { for (Iterator i = observers.iterator(); i.hasNext();) { ObservableStreamListener listener = (ObservableStreamListener) i .next(); listener.bytesWrite(bytes, clientId); } } }
2
@Override public int[][] getCost() { final int PAS_DE_TRONCON = this.getMaxArcCost() + 1; int size = this.getNbVertices(); int[][] costs = new int[size][size]; for (int i = 0; i < size; ++i) { for(int j=0; j<size; j++) { costs[i][j] = PAS_DE_TRONCON; } int[] successors = this.getSucc(i); int[] succCosts = this.getSuccCost(i); for (int j = 0; j < successors.length; ++j) { costs[i][successors[j]] = succCosts[j]; } } return costs; }
3
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/backlog/form.jsp"); BacklogBean oBacklogBean; BacklogDao oBacklogDao; oBacklogBean = new BacklogBean(); BacklogParam oBacklogParam = new BacklogParam(request); oBacklogBean = oBacklogParam.loadId(oBacklogBean); oBacklogDao = new BacklogDao(oContexto.getEnumTipoConexion()); UsuarioDao oUsuarioDao = new UsuarioDao(oContexto.getEnumTipoConexion()); try { oBacklogBean = oBacklogDao.get(oBacklogBean); oBacklogBean.setUsuario(oUsuarioDao.get(oBacklogBean.getUsuario())); } catch (Exception e) { throw new ServletException("EntradaController: View Error: Phase 1: " + e.getMessage()); } return oBacklogBean; }
1
@Override public void keyPressed(KeyEvent e) { int keycode = e.getKeyCode(); try { good2.hero.getX(); good2.keyPressed(e); } catch (Exception E) { //pass } //Key commands if (keycode == KeyEvent.VK_Q) { WindowFrame.exit(); } if (keycode == KeyEvent.VK_R) { WindowFrame.replay(frame.doExit); } if (keycode == KeyEvent.VK_O) { WindowFrame.play(); } if (keycode == KeyEvent.VK_ENTER) { if (gm == 1) { gm2(); } } //fast forward if (keycode == KeyEvent.VK_F) { rate ++; for (int i = 0; i < 10; i++) { //Update things a lot faster if the F key is pressed WindowFrame.window.paint(g); } } else { rate = 0; //Set the rate back to 0 if it is not pressed } }
8
@Override public void handleDFSInit() { // rst $28 dfs.addJumpTable(0x6e, 5); dfs.addJumpTable(0x2fb, 55, "GameStateTable"); dfs.addJumpTable(0x6480, 8); dfs.addJumpTable(0x6490, 8); dfs.addJumpTable(0x64a0, 4); dfs.addJumpTable(0x64a8, 4); dfs.addFunction(0x0, "Unused_rst00"); dfs.addRawBytes(0x3, 5); dfs.addFunction(0x8, "Unused_rst08"); dfs.addRawBytes(0xb, 29); dfs.addRawBytes(0x34, 12); dfs.addRawBytes(0x43, 5); dfs.addRawBytes(0x4b, 5); dfs.addRawBytes(0x53, 5); dfs.addFunction(0xd0, ".unused_00d0"); dfs.addRawBytes(0xda, 38); dfs.addIgnore(0x104, 0x4c); dfs.addSection(0x150, "Start"); dfs.addFunction(0x153, ".unused_0153"); dfs.addFunction(0x474, ".unused_0474"); dfs.addFunction(0x57d, ".unused_057d"); dfs.addFunction(0x582, null); dfs.addByteArray(0x705, 8, ".unknown_2P_0705", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x7f6, 6, "HighCursorPosP1_2P", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x802, 6, "HighCursorPosP2_2P", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x8c4, 4, ".unknown_2P_08c4", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x8d4, 4, ".unknown_2P_08d4", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0xf3c, 9, ".unknown_2P_0f3c", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addFunction(0x10a8, ".unused_10a8"); dfs.addByteArray(0x10ed, 6, "Unknown_2P_10ed", ROM.FORMAT_HEX); dfs.addByteArray(0x10f3, 11, "Unknown_2P_10f3", ROM.FORMAT_HEX); dfs.addByteArray(0x10fe, 11, "Unknown_2P_10fe", ROM.FORMAT_HEX); dfs.addByteArray(0x1109, 9, "Unknown_2P_1109", ROM.FORMAT_HEX); dfs.addByteArray(0x12f5, 16, "Unknown_2c_12f5", ROM.FORMAT_HEX); dfs.addByteArray(0x14a8, 4, "Unknown_2b_14a8", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x141b, 1, "Unknown_26_141b", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1422, 1, "Unknown_26_1422", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1429, 1, "Unknown_26_1429", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1430, 1, "Unknown_26_1430", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1615, 10, "TypeALevelCursorPos", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x16d2, 10, "TypeBLevelCursorPos", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1741, 6, "TypeBHighCursorPos", ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addRawBytes(0x174d, 1); dfs.addByteArray(0x1b06, 21, "LevelFrameDelayList", ROM.FORMAT_DEC); dfs.addByteArray(0x1b40, 4, "DemoHighLineData", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1cdd, 1, "PauseText", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x1e31, 10, ".unknown_22_1e31", ROM.FORMAT_HEX); dfs.addFunction(0x2665, ".unused_2665"); dfs.addByteArray(0x26bf, 1, "Unknown_list_26bf", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26c7, 1, "Unknown_list_26c7", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26cf, 2, "Unknown_2a_26cf", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26db, 1, "Unknown_10_26db", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26e1, 2, "Unknown_12_26e1", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26ed, 2, "Unknown_16_26ed", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x26f9, 3, "Unknown_1d_26f9", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x270b, 3, "Unknown_1d_270b", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x271d, 2, "Unknown_1e_271d", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2729, 2, "Unknown_1e_2729", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2735, 10, "Unknown_22_2735", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2771, 3, "Unknown_26_2771", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2783, 3, "Unknown_2e_2783", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addFunction(0x27e1, ".unused_27e1"); dfs.addByteArray(0x2839, 10, "HitStartToContinueOverlay", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2889, 18, "ScoreCountScreen", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x293d, 1, null, ROM.FORMAT_HEX); dfs.addByteArray(0x293e, 7, "GameOverOverlay", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x2976, 6, "PleaseTryAgainOverlay", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addFunction(0x2a10, ".unused_2a10"); dfs.addFunction(0x2a18, ".unused_2a18"); dfs.addPointerTable(0x2b64, 94, "PieceDataTable"); String[] knownPieces = { "LRot0", "LRot1", "LRot2", "LRot3", "JRot0", "JRot1", "JRot2", "JRot3", "IRot0", "IRot1", "IRot2", "IRot3", "ORot0", "ORot1", "ORot2", "ORot3", "ZRot0", "ZRot1", "ZRot2", "ZRot3", "SRot0", "SRot1", "SRot2", "SRot3", "TRot0", "TRot1", "TRot2", "TRot3", "AType", "BType", "CType", "OffType", "Num0", "Num1", "Num2", "Num3", "Num4", "Num5", "Num6", "Num7", "Num8", "Num9", }; for (int i=0;i<94; i++) { String name = i<knownPieces.length ? knownPieces[i] : "Unknown"; int add = dfs.rom.payloadAsAddress[0x2b64+2*i]; dfs.addPointerTable(add, 1, name+"D1_"+Integer.toHexString(add)); dfs.addRawBytes(add+2, 2); int addadd = dfs.rom.payloadAsAddress[add]; dfs.addPointerTable(addadd, 1, name+"D2_"+Integer.toHexString(addadd)); int cadd = addadd+2; while ((cadd - addadd < 0x100) && dfs.rom.data[cadd] != (byte)0xff) cadd++; dfs.addRawBytes(addadd + 2, cadd - addadd - 1); int addaddadd = dfs.rom.payloadAsAddress[addadd]; dfs.addByteArray(addaddadd, 1, null, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); } dfs.addRawBytes(0x31a9, 0x20, "Shape4x4"); dfs.addRawBytes(0x31c9, 0x10, "Shape8x1"); dfs.addRawBytes(0x31d9, 0x1c, "Shape2x7"); dfs.addRawBytes(0x31f5, 0x38, "ShapeRocket4x8"); dfs.addRawBytes(0x322d, 0x12, "Shape3x3"); dfs.addRawBytes(0x323f, 0xc50, "UnknownTileset2bpp_323f"); dfs.addByteArray(0x3e8f, 0x12, "IngameTypeAScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x3ff7, 1, "IngameTypeBScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x4000, 1, null, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x400b, 0x11, null, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x415f, 0x138, "AlphabetTileset1bpp", ROM.FORMAT_BIN); dfs.addRawBytes(0x4297, 0xa0, "UnknownTileset2bpp_4297"); dfs.addRawBytes(0x4337, 0x6d0, "UnknownTileset2bpp_4337"); dfs.addByteArray(0x4a07, 0x12, "LegalScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x4b6f, 0x12, "TitleScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x4cd7, 0x12, "TypeSelectScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x4e3f, 0x12, "TypeALevelSelectScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x4fa7, 0x12, "TypeBLevelSelectScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x510f, 18, "WonDancingScreen", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x51c3, 1, null, ROM.FORMAT_HEX); dfs.addByteArray(0x51c4, 4, "RocketPlatformScreenLines", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x5214, 0x12, "HighSelect2PScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x537c, 0x12, "Unknown_2P_537c_ScreenTiles", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x54e4, 4, "WinsLosses2PHeaderScreenLines", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addByteArray(0x5534, 6, "WinsLosses2PFooterScreenLines", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addRawBytes(0x55ac, 0xd04, "MarioLuigiRocketTileset2bpp"); dfs.addByteArray(0x62b0, 0x80, "Demo1Controls", ROM.FORMAT_BUTTONS, ROM.FORMAT_DEC); dfs.addByteArray(0x63b0, 0x50, "Demo2Controls", ROM.FORMAT_BUTTONS, ROM.FORMAT_DEC); dfs.addRawBytes(0x6450, 0x30, "Unknown_24_6450"); dfs.addPointerTable(0x64b0, 0x11, "Unknown_Sound_64b0"); for (int i=0;i<0x11; i++) { int add = dfs.rom.payloadAsAddress[0x64b0+2*i]; dfs.addRawBytes(add, 1, "UnknownD1_Sound_"+Integer.toHexString(add)); dfs.addPointerTable(add+1, 5); for (int j=0;j<5;j++) if (dfs.rom.payloadAsAddress[add+1+2*j] == 0) dfs.rom.payloadAsAddress[add+1+2*j] = -1; dfs.addRawBytes(0x6ef9, 0xc, "UnknownD2_Sound_6ef9"); dfs.addRawBytes(0x6f05, 0x9, "UnknownD2_Sound_6f05"); dfs.addRawBytes(0x6f0e, 0x1d, "UnknownD2_Sound_6f0e"); dfs.addRawBytes(0x6f2b, 0x14, "UnknownD2_Sound_6f2b"); dfs.addRawBytes(0x6ffa, 0xe, "UnknownD2_Sound_6ffa"); dfs.addRawBytes(0x7008, 0x13a, "UnknownD2_Sound_7008"); dfs.addRawBytes(0x7142, 0xa, "UnknownD2_Sound_7142"); dfs.addRawBytes(0x714c, 0xa, "UnknownD2_Sound_714c"); dfs.addRawBytes(0x7156, 0xc, "UnknownD2_Sound_7156"); dfs.addRawBytes(0x7162, 0x156, "UnknownD2_Sound_7162"); dfs.addRawBytes(0x72b8, 0xe, "UnknownD2_Sound_72b8"); dfs.addRawBytes(0x72c6, 0xe, "UnknownD2_Sound_72c6"); dfs.addRawBytes(0x72d4, 0x2e, "UnknownD2_Sound_72d4"); dfs.addRawBytes(0x7302, 0x241, "UnknownD2_Sound_7302"); dfs.addRawBytes(0x7543, 0x8, "UnknownD2_Sound_7543"); dfs.addRawBytes(0x754b, 0x6, "UnknownD2_Sound_754b"); dfs.addRawBytes(0x7551, 0x3c, "UnknownD2_Sound_7551"); dfs.addRawBytes(0x758d, 0x8, "UnknownD2_Sound_758d"); dfs.addRawBytes(0x7595, 0x6, "UnknownD2_Sound_7595"); dfs.addRawBytes(0x759b, 0x61, "UnknownD2_Sound_759b"); dfs.addRawBytes(0x75fc, 0x4, "UnknownD2_Sound_75fc"); dfs.addRawBytes(0x7600, 0x2, "UnknownD2_Sound_7600"); dfs.addRawBytes(0x7602, 0x31, "UnknownD2_Sound_7602"); dfs.addRawBytes(0x7633, 0x8, "UnknownD2_Sound_7633"); dfs.addRawBytes(0x763b, 0x6, "UnknownD2_Sound_763b"); dfs.addRawBytes(0x7641, 0x22, "UnknownD2_Sound_7641"); dfs.addRawBytes(0x7663, 0x209, "UnknownD2_Sound_7663"); dfs.addRawBytes(0x786c, 0xa, "UnknownD2_Sound_786c"); dfs.addRawBytes(0x7876, 0x8, "UnknownD2_Sound_7876"); dfs.addRawBytes(0x787e, 0x8, "UnknownD2_Sound_787e"); dfs.addRawBytes(0x7886, 0x17a, "UnknownD2_Sound_7886"); dfs.addRawBytes(0x7a00, 0x26, "UnknownD2_Sound_7a00"); dfs.addRawBytes(0x7a26, 0x4, "UnknownD2_Sound_7a26"); dfs.addRawBytes(0x7a2a, 0x45, "UnknownD2_Sound_7a2a"); dfs.addRawBytes(0x7a6f, 0x4, "UnknownD2_Sound_7a6f"); dfs.addRawBytes(0x7a73, 0x2, "UnknownD2_Sound_7a73"); dfs.addRawBytes(0x7a75, 0x6a, "UnknownD2_Sound_7a75"); dfs.addRawBytes(0x7adf, 0x4, "UnknownD2_Sound_7adf"); dfs.addRawBytes(0x7ae3, 0x2, "UnknownD2_Sound_7ae3"); dfs.addRawBytes(0x7ae5, 0x2, "UnknownD2_Sound_7ae5"); dfs.addRawBytes(0x7ae7, 0x7e, "UnknownD2_Sound_7ae7"); dfs.addRawBytes(0x7b65, 0x6, "UnknownD2_Sound_7b65"); dfs.addRawBytes(0x7b6b, 0x4, "UnknownD2_Sound_7b6b"); dfs.addRawBytes(0x7b6f, 0x4, "UnknownD2_Sound_7b6f"); dfs.addRawBytes(0x7b73, 0xb1, "UnknownD2_Sound_7b73"); dfs.addRawBytes(0x7c24, 0x4, "UnknownD2_Sound_7c24"); dfs.addRawBytes(0x7c28, 0x2, "UnknownD2_Sound_7c28"); dfs.addRawBytes(0x7c2a, 0x2, "UnknownD2_Sound_7c2a"); dfs.addRawBytes(0x7c2c, 0xcd, "UnknownD2_Sound_7c2c"); dfs.addRawBytes(0x7cf9, 0x6, "UnknownD2_Sound_7cf9"); dfs.addRawBytes(0x7cff, 0x12, "UnknownD2_Sound_7cff"); dfs.addRawBytes(0x7d11, 0x10, "UnknownD2_Sound_7d11"); dfs.addRawBytes(0x7d21, 0x123, "UnknownD2_Sound_7d21"); dfs.addRawBytes(0x7e44, 0x4, "UnknownD2_Sound_7e44"); dfs.addRawBytes(0x7e48, 0x2, "UnknownD2_Sound_7e48"); dfs.addRawBytes(0x7e4a, 0x2, "UnknownD2_Sound_7e4a"); dfs.addRawBytes(0x7e4c, 0x45, "UnknownD2_Sound_7e4c"); dfs.addRawBytes(0x7e91, 0xc, "UnknownD2_Sound_7e91"); dfs.addRawBytes(0x7e9d, 0xc, "UnknownD2_Sound_7e9d"); dfs.addRawBytes(0x7ea9, 0xc, "UnknownD2_Sound_7ea9"); dfs.addRawBytes(0x7eb5, 0x13b, "UnknownD2_Sound_7eb5"); } dfs.addRawBytes(0x657b, 0x4, "Unknown_Sound_657b"); dfs.addRawBytes(0x657f, 0x4, "Unknown_Sound_657f"); dfs.addRawBytes(0x659b, 0x5, "Unknown_Sound_659b"); dfs.addRawBytes(0x65a0, 0x5, "Unknown_Sound_65a0"); dfs.addRawBytes(0x65a5, 0x5, "Unknown_Sound_65a5"); dfs.addRawBytes(0x65e7, 0x5, "Unknown_Sound_65e7"); dfs.addRawBytes(0x65ec, 0x5, "Unknown_Sound_65ec"); dfs.addRawBytes(0x6623, 0x5, "Unknown_Sound_6623"); dfs.addRawBytes(0x6640, 0x5, "Unknown_Sound_6640"); dfs.addRawBytes(0x6645, 0x5, "Unknown_Sound_6645"); dfs.addRawBytes(0x664a, 0x5, "Unknown_Sound_664a"); dfs.addRawBytes(0x664f, 0x5, "Unknown_Sound_664f"); dfs.addRawBytes(0x6695, 0x5, "Unknown_Sound_6695"); dfs.addRawBytes(0x669a, 0xb, "Unknown_Sound_669a"); dfs.addRawBytes(0x66a5, 0xa, "Unknown_Sound_66a5"); dfs.addRawBytes(0x66ec, 0x5, "Unknown_Sound_66ec"); dfs.addRawBytes(0x66f1, 0x6, "Unknown_Sound_66f1"); dfs.addRawBytes(0x66f7, 0x5, "Unknown_Sound_66f7"); dfs.addRawBytes(0x6740, 0x5, "Unknown_Sound_6740"); dfs.addRawBytes(0x6745, 0x4, "Unknown_Sound_6745"); dfs.addRawBytes(0x6749, 0x4, "Unknown_Sound_6749"); dfs.addRawBytes(0x674d, 0x4, "Unknown_Sound_674d"); dfs.addRawBytes(0x6751, 0x4, "Unknown_Sound_6751"); dfs.addRawBytes(0x6755, 0x24, "Unknown_Sound_6755"); dfs.addRawBytes(0x6779, 0x24, "Unknown_Sound_6779"); dfs.addRawBytes(0x67fb, 0x5, "Unknown_Sound_67fb"); dfs.addRawBytes(0x6857, 0x3, "Unknown_Sound_6857"); dfs.addRawBytes(0x685a, 0x2, "Unknown_Sound_685a"); dfs.addRawBytes(0x685c, 0x3, "Unknown_Sound_685c"); dfs.addRawBytes(0x685f, 0x2, "Unknown_Sound_685f"); dfs.addRawBytes(0x6861, 0x3, "Unknown_Sound_6861"); dfs.addRawBytes(0x6864, 0x2, "Unknown_Sound_6864"); dfs.addRawBytes(0x6866, 0x3, "Unknown_Sound_6866"); dfs.addRawBytes(0x6869, 0x2, "Unknown_Sound_6869"); dfs.addByteArray(0x6abe, 17, "Unknown_Sound_6abe", ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX, ROM.FORMAT_HEX); dfs.addFunction(0x6d9d, ".unused_6d9d"); dfs.addFunction(0x6da1, ".unused_6da1"); dfs.addRawBytes(0x6dcb, 0x37, "Unknown_Sound_6dcb"); dfs.addRawBytes(0x6e02, 0x92, "Unknown_Sound_6e02"); dfs.addRawBytes(0x6e94, 0x15, "Unknown_Sound_6e94"); dfs.addRawBytes(0x6ea9, 0x20, "Unknown_Sound_6ea9"); dfs.addRawBytes(0x6ec9, 0x10, "Unknown_Sound_6ec9"); dfs.addRawBytes(0x6ed9, 0x10, "Unknown_Sound_6ed9"); dfs.addRawBytes(0x6ee9, 0x10, "Unknown_Sound_6ee9"); dfs.addFunction(0x2a7f, "DMARoutine"); }
7
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equals("voyageur")) { if (currentVoyageur != null) { throw new IllegalStateException("already processing a voyageur"); } currentVoyageur = new voyageur(); } else if (qName.equals("id_voyageur")) { idTag = "open"; } else if (qName.equals("nom")) { nomTag = "open"; } else if (qName.equals("prenom")) { prenomTag = "open"; }else if (qName.equals("e_mail")) { emailTag = "open"; } else if (qName.equals("password")) { passwordTag = "open"; } else if (qName.equals("date_inscription")) { date_inscriptionTag = "open"; } }
8
public int getNum() { return num; }
0
public void run() { synchronized (fQuitTimerObject) { // // Loop forever. // while (true) { while (fQuitTimerStart == false) { try { fQuitTimerObject.wait(); } catch (InterruptedException e) {} } // // Thread.sleep() cannot be used here for sleeping, // because fQuitTimerObject is locked here. Therefore // use wait() for sleeping. // try { fQuitTimerObject.wait(1000); } catch (InterruptedException e) {} // // Check fQuitTimerStart to see if timer is running. // If the timer is still running, then decrement // fQuitTimerCounter. If fQuitTimerCounter <= 0, // then set Visible to false, so that the quit dialog // winodw will disappear. // if (fQuitTimerStart) { fQuitTimerCounter --; if (fQuitTimerCounter <= 0) setVisible(false); } } } }
6
@Override public void xterminated(Pipe pipe_) { if (!anonymous_pipes.remove(pipe_)) { Outpipe old = outpipes.remove(pipe_.get_identity()); assert(old != null); fq.terminated (pipe_); if (pipe_ == current_out) current_out = null; } }
2
public Vector<String> getBelegung(String sessionID){ Vector<String> resString = new Vector<String>(); CSVFileManager csvMgr = new CSVFileManager(); String stundenplan = "https://puls.uni-potsdam.de/qisserver/rds;jsessionid=" + sessionID + ".node11?state=wplan&amp;week=-2&amp;act=show&amp;pool=&amp;show=liste&amp;P.vx=lang&amp;P.subc=plan"; try{ answer = new SimpleHttpReader().readURL(stundenplan); SimpleMatchParser parser = new SimpleMatchParser(TokenType.parse(csvMgr .readFile("res/belegung.txt").getCSVObject())); List<Token> result = parser.parse(answer); for (Token tkn : result){ System.out.println("--------------" + tkn.content.split("\"")[3]); } } catch (Exception e){ System.out.println("++++++++++++ Link " + stundenplan); System.out.println("++++++++++++ Error " + e.getMessage()); answer = e.getMessage(); } return null; }
2
public void teleopInit() { shooter.enable(); new SpinDown().start(); SmartDashboard.putBoolean("Enabled", true); if (autonomouse != null) { autonomouse.cancel(); } if (teleop != null) { teleop.start(); } }
2
private String addOptionalsToLaTex() { String palautettava = ""; if (volume != 0) { palautettava += "VOLUME = {" + volume + "},\n"; } if (number != 0) { palautettava += "NUMBER = {" + number + "},\n"; } if (pages != null) { palautettava += "PAGES = {" + parser.parse(pages) + "},\n"; } if (month != null) { palautettava += "MONTH = {" + parser.parse(month) + "},\n"; } if (note != null) { palautettava += "NOTE = {" + parser.parse(note) + "},\n"; } if (key != null) { palautettava += "KEY = {" + parser.parse(key) + "},\n"; } return palautettava; }
6
private int mapSingle(String s) { switch (s){ case "M": return 1000; case "D": return 500; case "C": return 100; case "L": return 50; case "X": return 10; case "V": return 5; case "I": return 1; default: return 0; } }
7