text
stringlengths
14
410k
label
int32
0
9
@Override public final void addComment(String key, String... comment) { if (containsKey(key)) { if (comment != null && comment.length > 0) { List<String> the_comments = comments.containsKey(key) ? comments.get(key) : new LinkedList<String>(); for (int i = 0; i < comment.length; i++) { if (comment[i] == null) { comment[i] = ""; } if (!comment[i].startsWith(";") && !comment[i].startsWith("#")) { comment[i] = ";".concat(comment[i]); } the_comments.add(comment[i]); } if (!comments.containsKey(key)) { //Basicly, the list pointer should be enough to change the list in the map without re-adding comments.put(key, the_comments); } } } }
9
private boolean jj_3R_27() { if (jj_scan_token(RETURN)) return true; if (jj_3R_76()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; }
3
private void overwriteCircleDefault(Attributes attrs) { // loop through all attributes, setting appropriate values for (int i = 0; i < attrs.getLength(); i++) { if (attrs.getQName(i).equals("color")) circleDef.setColor(new Color(Integer.valueOf(attrs.getValue(i), 16))); else if (attrs.getQName(i).equals("thickness")) circleDef.setThickness(Integer.valueOf(attrs.getValue(i))); else if (attrs.getQName(i).equals("fill")) circleDef.setFill(Boolean.valueOf(attrs.getValue(i))); else if (attrs.getQName(i).equals("alpha")) circleDef.setAlpha(Integer.valueOf(attrs.getValue(i))); else if (attrs.getQName(i).equals("filltype")) circleDef.setFillType(Integer.valueOf(attrs.getValue(i))); } }
6
public void saveEndereco() { switch (opcaoHeader) { case "cadastrar cidade": try { genericDAO.save(cidade); searchCidade(); } catch (Exception ex) { Logger.getLogger(UnidadeMB.class.getName()).log(Level.SEVERE, null, ex); } break; case "cadastrar bairro": try { genericDAO.save(bairro); searchBairro(); } catch (Exception ex) { Logger.getLogger(UnidadeMB.class.getName()).log(Level.SEVERE, null, ex); } break; case "cadastrar logradouro": try { genericDAO.save(logradouro); } catch (Exception ex) { Logger.getLogger(UnidadeMB.class.getName()).log(Level.SEVERE, null, ex); } break; } facesContext = FacesContext.getCurrentInstance(); facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Salvo com Sucesso", "Prossiga")); }
6
public static void main(String[] args) { int numeroActual = -1; int num1; System.out.println(args[0]); num1 = Integer.parseInt(args[0].toString()); while (num1>numeroActual){ numeroActual++; System.out.println(numeroActual); } if (num1%3==0){ num1++; // si el numero es divisible dentro de 3 imprima "Flip" System.out.println("Flip");} else if(num1%5==0){ // si el numero es divisible dentro de 5 imprima "Flop" System.out.println("Flop");} if((num1%3==0) && (num1%5==0)){ // si el numero es divisible dentro de 3 y 5 imprima "FlipFlop" System.out.println("FlipFlop");} else{ // de lo contrario, imprima el numero System.out.println(numeroActual); } }
5
public boolean searchFAT32Element() throws UnsupportedEncodingException { //получение корневого элемента FAT32 byte[] rootBytes = new byte[32]; for (int i = BPB_RootClus * BPB_BytsPerSec; i < (BPB_RootClus * BPB_BytsPerSec + 32); i++) { rootBytes[i - BPB_RootClus * BPB_BytsPerSec] = imageBytes[i]; } rootElement = new FAT32Directory(rootBytes); //явная установка имени (для удобства отображения) rootElement.setShortName("\\"); // первый байт области данных int firstDataByte = firstDataSector * BPB_BytsPerSec; buildHierarchy(rootElement, firstDataByte); return true; }
1
private void lireFichier(String chemin_ficher) throws FileNotFoundException, IOException { contenu_fichier = new StringBuilder() ; f = new File(chemin_ficher) ; if(!f.getName().endsWith(".plic")) throw new ArrayIndexOutOfBoundsException() ; BufferedReader b = new BufferedReader(new FileReader(f)) ; String line = null ; while((line= b.readLine()) != null) contenu_fichier.append(line+"\n") ; }
2
public static boolean isNumericSpace(String str) { if (str == null) { return false; } int sz = str.length(); for (int i = 0; i < sz; i++) { if ((Character.isDigit(str.charAt(i)) == false) && (str.charAt(i) != ' ')) { return false; } } return true; }
4
public boolean shouldExecute() { if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) { return false; } else { if (this.targetClass == EntityPlayer.class) { EntityPlayer var1 = this.taskOwner.worldObj.getClosestVulnerablePlayerToEntity(this.taskOwner, (double)this.targetDistance); if (this.func_48376_a(var1, false)) { this.targetEntity = var1; return true; } } else { List var5 = this.taskOwner.worldObj.getEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand((double)this.targetDistance, 4.0D, (double)this.targetDistance)); Collections.sort(var5, this.field_48387_g); Iterator var2 = var5.iterator(); while (var2.hasNext()) { Entity var3 = (Entity)var2.next(); EntityLiving var4 = (EntityLiving)var3; if (this.func_48376_a(var4, false)) { this.targetEntity = var4; return true; } } } return false; } }
6
public void fillMemory(int[] memory) { int xDimSize = model.getPanelWidth(); int xStart = model.getXnull() + model.getX() - model.getSize()/2; int yStart = model.getYnull() - model.getY() + model.getSize()/2; int xStop = xStart + model.getSize(); int yStop = yStart - model.getSize(); if (xStart < - model.getSize()){ xStart = 0; xStop = 0; } if (yStart > model.getPanelHeight() - 1){ yStart = model.getPanelHeight() - 1; } if (xStop > model.getPanelWidth()){ xStop = model.getPanelWidth(); } if (yStop < 0){ yStop = 0; } int r = 255; int g = 255; int b = 240; int color = (r << 16) | (g << 8) | b; for(int i = 0; i < memory.length; i++){ memory[i] = color; } r = 140; g = 140; b = 140; color = (r << 16) | (g << 8) | b; for (int i = xStart; i < xStop; i++){ if (i < 0 ) i = 0; for(int j = yStart; j > yStop; j--){ memory[j* xDimSize + i] = color; } } }
8
public ArraysDataBase getArraysDataBase(){ return arraysDataBase; }
0
private boolean isValidInput(final String s) { return s.matches("[!-+--~]+[,][!-+--~]+"); }
0
public void mouseMoved(MouseEvent me) { meX = me.getX(); meY = me.getY(); if(mouseOverTab(meX, meY)){ controlCursor(); tabbedPane.repaint(); } }
1
@Override public Types.MOVEMENT passiveMovement(VGDLSprite sprite) { if(sprite.isFirstTick) { sprite.isFirstTick = false; return Types.MOVEMENT.STILL; } double speed; if(sprite.speed == -1) speed = 1; else speed = sprite.speed; if(speed != 0 && sprite.is_oriented) { if(sprite._updatePos(sprite.orientation, (int)(speed * this.gridsize.width))) return Types.MOVEMENT.MOVE; } return Types.MOVEMENT.STILL; }
5
@DBCommand public boolean start(CommandSender sender, Iterator<String> args) { if(!sender.hasPermission("db.start")) { sender.sendMessage(RED + "You don't have permission to use this command!"); return true; } if(!args.hasNext()) { sender.sendMessage( "Not enough parameters!\n/minigame help <command1> <command2> ... for more info"); return false; } String name = args.next(); final Dodgeball m = mm.getMinigame(name); if(m == null) { sender.sendMessage(RED + "Minigame doesn't exist!"); return true; } mm.startMinigameDelayed(m); return true; }
3
@Override public void valueChanged(ListSelectionEvent e) { if ( !e.getValueIsAdjusting() ) delete.setEnabled(true); }
1
private Person onCircle(double nx, double ny){ for (Person p : model.getPersons()){ Circle c = (Circle) p.getShape(); if(c.getCenterX()+2*c.getRadius()>nx && c.getCenterX()-2*c.getRadius()<nx && c.getCenterY()+2*c.getRadius()>ny && c.getCenterY()-2*c.getRadius()<ny ){ return p; } } return null; }
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Lendable other = (Lendable) obj; if (file == null) { if (other.file != null) return false; } else if (!file.equals(other.file)) return false; if (type != other.type) return false; return true; }
7
public void createEnemies(String mapName){ String thisLine; Path mapPath = Paths.get(MAP_FOLDER, (mapName + TXT_FILE_END)); File inFile = mapPath.toFile(); // open input stream test.txt for reading purpose. List<String> mapLines = new ArrayList<String>(); try { BufferedReader bufferedReader = new BufferedReader(new FileReader(inFile)); try { thisLine = bufferedReader.readLine(); while (thisLine != null) { mapLines.add(thisLine); thisLine = bufferedReader.readLine(); } }finally { bufferedReader.close(); } }catch (IOException e){ e.printStackTrace(); } int enemyXCoord = ENEMIES_STARTING_X_COORD; for (int n =0; n < mapLines.size(); n++) { thisLine = mapLines.get(n); for (int row = 0; row < thisLine.length(); row++) { char brick = thisLine.charAt(row); if (brick == SQUARE) { theModel.addObstacle(new Obstacle(enemyXCoord, (theModel.getHeightOffset() - (row+1)*BRICK_SIZE),new SquareShape(),ObstacleTypes.SQUARE)); //(row+1) To get the Obstacle above the floor } else if (brick == OVAL) { theModel.addObstacle((new Obstacle(enemyXCoord, (theModel.getHeightOffset() - (row+1)*BRICK_SIZE),new OvalShape(),ObstacleTypes.OVAL))); } else if (brick == TRIANGLE) { theModel.addObstacle((new Obstacle(enemyXCoord, (theModel.getHeightOffset() - (row+1)*BRICK_SIZE),new TriangleShape(),ObstacleTypes.TRIANGLE))); } } enemyXCoord += BRICK_SIZE; } }
7
public Configuration[] getInitialConfigurations(String input) { Configuration[] configs = new Configuration[1]; configs[0] = new FSAConfiguration(myAutomaton.getInitialState(), null, input, input); return configs; }
0
final ObjectDefinition getObject(int i, int i_0_) { anInt3351++; ObjectDefinition class51; synchronized (aClass60_3350) { class51 = (ObjectDefinition) aClass60_3350.method583((long) i_0_, i ^ 0x32); } if (class51 != null) return class51; byte[] is; synchronized (aClass45_3343) { is = aClass45_3343.getChildArchive(Class239_Sub29.method1850(i_0_, 111), Class5_Sub1.method185(i_0_, (byte) -90)); } class51 = new ObjectDefinition(); ((ObjectDefinition) class51).anInt941 = i_0_; ((ObjectDefinition) class51).aClass263_933 = this; if (is != null) class51.method479((byte) 0, new ByteBuffer(is)); class51.method488(-105); if (i != 0) ((ObjectLoader) this).aClass60_3361 = null; if (!((ObjectLoader) this).aBoolean3359 && ((ObjectDefinition) class51).aBoolean942) { ((ObjectDefinition) class51).anIntArray917 = null; ((ObjectDefinition) class51).aStringArray913 = null; } if (((ObjectDefinition) class51).aBoolean876) { ((ObjectDefinition) class51).anInt920 = 0; ((ObjectDefinition) class51).aBoolean896 = false; } synchronized (aClass60_3350) { aClass60_3350.method582(class51, (long) i_0_, (byte) -109); } return class51; }
6
public int[] getLeastNumbers(Integer[] data, int length , int k){ if(data == null || length <= 0 || k<=0 || k > k){ throw new IndexOutOfBoundsException("input error!"); } int[] result = new int[k]; int start = 0 , end = length -1 ; int index = s.partition(data, length, start, end); while(index != k-1){ if(index > k-1){ end = index - 1; index = s.partition(data, length, start, end); }else{ start = index + 1; index = s.partition(data, length, start, end); } } for (int i = 0; i < result.length; i++) { result[i] = data[i]; } return result; }
7
@Override public Integer getNodeId(Integer playerId) { Integer Position = null; // loops through detectives and there is an ID match - returns the // detective position for (Detective a : listDetectives) { if (a.getID().equals(playerId)) { Position = a.getPosition(); } } // loops through Mr X's and if there is an ID match - returns the Mr X // position for (MrX a : listMrX) { if (a.getID().equals(playerId)) { Position = a.getPosition(); } } return Position; }
4
public static List<Term> combineEntities(List<Term> sentence) { List<Term> newSentence = new ArrayList<Term>(); int idx = 0; StringBuilder builder = new StringBuilder(); while (idx < sentence.size()) { Term term = sentence.get(idx); if (isPerson(term)) { builder.append(term.getText()).append("_"); } else if (idx < sentence.size()-1 && isPerson(sentence.get(idx+1)) && term.getText().equals("-LRB-")) { builder.append("("); } else if (idx > 0 && isPerson(sentence.get(idx-1)) && term.getText().equals("-RRB-")) { builder.deleteCharAt(builder.length()-1); builder.append(")_"); } else { if (builder.length() > 0) { builder.deleteCharAt(builder.length()-1); Term newTerm = new Term(builder.toString()); newTerm.setNETag("PERSON"); newSentence.add(newTerm); builder = new StringBuilder(); } newSentence.add(term); } idx += 1; } return newSentence; }
9
protected boolean CheckMousePositionRegion(int posX, int posY, int width, int height, boolean checkInside) { //Defining the result variable boolean result = false; //External check if (checkInside == true) { //Checking inside the region if (game.objInputManager.shortMouseX >= posX && game.objInputManager.shortMouseX <= (posX + width) && game.objInputManager.shortMouseY >= posY && game.objInputManager.shortMouseY <= (posY + height)) { //Setting the result boolean to true result = true; } } else { //Checking outside the region if (game.objInputManager.shortMouseX < posX || game.objInputManager.shortMouseX > (posX + width) || game.objInputManager.shortMouseY < posY || game.objInputManager.shortMouseY > (posY + height)) { //Setting the result boolean to true result = true; } } //Returning the result return result; }
9
private void processPlayer(int time) { // TODO player death player.tryRegen(); if (northPressed || southPressed || westPressed || eastPressed) { player.setIsMoving(true); Rectangle[] monsterBounds = new Rectangle[map.monsters.size()]; for (int i = 0; i < map.monsters.size(); i++) { monsterBounds[i] = map.monsters.get(i).getBounds(); } if (northPressed) { map.move(player, Maze.NORTH, getDistance(player.getSpeed(), time), monsterBounds); player.setDirection(Maze.NORTH); } if (southPressed) { map.move(player, Maze.SOUTH, getDistance(player.getSpeed(), time), monsterBounds); player.setDirection(Maze.SOUTH); } if (westPressed) { map.move(player, Maze.WEST, getDistance(player.getSpeed(), time), monsterBounds); player.setDirection(Maze.WEST); } if (eastPressed) { map.move(player, Maze.EAST, getDistance(player.getSpeed(), time), monsterBounds); player.setDirection(Maze.EAST); } } else { player.setIsMoving(false); } map.checkForItems(player, this); calculateWindow(); }
9
public static int[] intersectTwoSortedArrays(int[] array1, int[] array2){ // create a new array having the smallest size between the two arrays final int newArraySize = (array1.length < array2.length) ? array1.length : array2.length; int[] newArray = new int[newArraySize]; int pos1 = 0; int pos2 = 0; int posNewArray = 0; while(pos1 < array1.length && pos2 < array2.length) { if(array1[pos1] < array2[pos2]) { pos1++; }else if(array2[pos2] < array1[pos1]) { pos2++; }else { // if they are the same newArray[posNewArray] = array1[pos1]; posNewArray++; pos1++; pos2++; } } // return the subrange of the new array that is full. return Arrays.copyOfRange(newArray, 0, posNewArray); }
5
private void detectBlock() throws LangDetectException { cleaningText(); ArrayList<String> ngrams = extractNGrams(); if (ngrams.size()==0) throw new LangDetectException(ErrorCode.CantDetectError, "no features in text"); langprob = new double[langlist.size()]; Random rand = new Random(); for (int t = 0; t < n_trial; ++t) { double[] prob = initProbability(); double alpha = this.alpha + rand.nextGaussian() * ALPHA_WIDTH; for (int i = 0;; ++i) { int r = rand.nextInt(ngrams.size()); updateLangProb(prob, ngrams.get(r), alpha); if (i % 5 == 0) { if (normalizeProb(prob) > CONV_THRESHOLD || i>=ITERATION_LIMIT) break; if (verbose) System.out.println("> " + sortProbability(prob)); } } for(int j=0;j<langprob.length;++j) langprob[j] += prob[j] / n_trial; if (verbose) System.out.println("==> " + sortProbability(prob)); } }
9
public void addRecords() { AccountRecord record = new AccountRecord(); Scanner input = new Scanner(System.in); System.out.println("To terminate input, type the end-of-file indicator" + "\nwhen you are promted to enter input." + "\nOn UNIX/Linux/Mac OS X type <ctrl> d then press Enter"); System.out.println("Enter account number ( > 0), first name " + ", last name and balance ? "); while (input.hasNext()) { try { record.setAccount(input.nextInt()); record.setFirstName(input.next()); record.setLastName(input.next()); record.setBalance(input.nextDouble()); if (record.getAccount() > 0) { System.out.println("Here --------------"); output.format("%d %s %s %.2f\n", record.getAccount(), record.getFirstName(), record.getLastName(), record.getBalance()); System.out.println("Pass Trough --------------"); } else { System.out.println("Account number must be greater than 0."); } } catch (FormatterClosedException formatterClosedException) { System.err.println("Error writing to file."); return; } catch (NoSuchElementException noSuchElementException) { System.err.println("Invalid input. please try again."); input.nextLine(); } System.out.println("Enter account number ( > 0), " + "first name, last name anad balance. " + "\n ? "); } }
4
public static void main(String... args) throws Exception { File file = new File("/Users/babyduncan/github/javanio/files/sourceFile.txt"); File disFile = new File("/Users/babyduncan/github/javanio/files/disFile.txt"); FileInputStream fileInputStream = new FileInputStream(file); FileChannel fileChannel = fileInputStream.getChannel(); // use allocateDirect to avoid system buffer ,can be faster . ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024); FileOutputStream fileOutputStream = new FileOutputStream(disFile); FileChannel disFileChannel = fileOutputStream.getChannel(); while (true) { // 首先把缓冲区清除 byteBuffer.clear(); // 从文件中读入数据 int i = fileChannel.read(byteBuffer); // 如果数据都读完了,那么就结束 if (i == -1) { break; } // 把指针回到buffer开头 byteBuffer.flip(); // 写入数据 disFileChannel.write(byteBuffer); } System.out.println("copy done !!"); }
2
private void initHandler() { mouseHandler = mouseEvent -> { final Object SOURCE = mouseEvent.getSource(); if (MouseEvent.MOUSE_PRESSED == mouseEvent.getEventType()) { MenuItem menuItem = items.get(SOURCE); if (menuItem.isSelectable()) { menuItem.setSelected(!menuItem.isSelected()); if (menuItem.isSelected()) { fireItemEvent(new ItemEvent(menuItem, this, null, ItemEvent.ITEM_SELECTED)); } else { fireItemEvent(new ItemEvent(menuItem, this, null, ItemEvent.ITEM_DESELECTED)); } } else { click(menuItem); fireItemEvent(new ItemEvent(menuItem, this, null, ItemEvent.ITEM_CLICKED)); } } }; }
3
public void run(){ synchronized(this){ this.runningThread = Thread.currentThread(); } openServerSocket(); while(! isStopped()){ Socket clientSocket = null; try { clientSocket = this.serverSocket.accept(); } catch (IOException e) { if(isStopped()) { System.out.println("Server Stopped.") ; return; } throw new RuntimeException( "Error accepting client connection", e); } this.threadPool.execute( new WorkerRunnable(clientSocket, "Thread Pooled Server")); } this.threadPool.shutdown(); System.out.println("Server Stopped.") ; }
3
private void test(String testPath) throws IOException { int hit = 0; int total = 0; BufferedReader scanner = null; try { scanner = new BufferedReader(new FileReader(new File(testPath))); //new Scanner(new File(testPath)); } catch (FileNotFoundException e) { e.printStackTrace(); } String path = null; while ((path = scanner.readLine()) != null){ total += 1; //String path = scanner.nextLine(); int result = 0; try { result = bayse(path); } catch (IOException e) { e.printStackTrace(); } if(Pattern.matches("con.*", path) && result == 1){ hit++; }else if(Pattern.matches("lib.*", path) && result == 0) { hit++; } } System.out.printf("Accuracy: %.04f", (hit * 1.0) / (total * 1.0)); }
7
public void setSelectionRange(SelectionRange selectionRange){ if (selectionRange != null){ this.selectionRange = selectionRange; } }
1
public static boolean isValid(File f) { if (f.isDirectory()) { return false; } String extension = FileTools.getExtension(f); if (extension != null) { if (extension.equals(".zip") || extension.equals(".tar") || extension.equals(".rar") || extension.equals(".sskin") || extension.equals(".jar")) { return true; } else { return false; } } return false; }
7
private static int Permutate(char[] workingSet, int workingIndex, HashSet<String> seenAlready, HashSet<String> toMatch) { int result = 0; if (workingSet.length - 1 < workingIndex) { String permutation = new String(workingSet); if (!seenAlready.contains(permutation) && toMatch.contains(permutation)) { seenAlready.add(permutation); return 1; } } else { char head = workingSet[workingIndex]; result += Permutate(workingSet, workingIndex + 1, seenAlready, toMatch); for (int i = workingIndex + 1; i < workingSet.length; i++) { char replacedHead = workingSet[i]; if (head == replacedHead) { continue; } workingSet[workingIndex] = replacedHead; workingSet[i] = head; result += Permutate(workingSet, workingIndex + 1, seenAlready, toMatch); workingSet[i] = replacedHead; workingSet[workingIndex] = head; } } return result; }
5
private void addGame(Game game) { games.put(game.getGameId(), game); }
0
@Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.scale(scale, scale); int[] size = antWorld.getGridSize(); for(int i=0; i<size[0]; i++) { for(int j=0; j<size[1]; j++) { int x = (int) (i*64+(10*(1/scale))); if(j%2!=0) { x += 32; } int y = (int) (j*55+(10*(1/scale))); g2d.drawImage(images[antWorld.getHexagon(i, j).getType()], startX+x, startY+y, null); if(antWorld.getHexagon(i, j).hasFood()) { int food = antWorld.getHexagon(i, j).getFood(); if(food<5) { g2d.drawImage(images[4], startX+x+24, startY+y+30, null); } else if(food<10) { g2d.drawImage(images[5], startX+x+24, startY+y+30, null); } else if(food<20) { g2d.drawImage(images[6], startX+x+24, startY+y+30, null); } else { g2d.drawImage(images[7], startX+x+24, startY+y+30, null); } } } } }
7
public boolean SurviveSingleVision(int inSeer, int inTarget, byte inVision){ boolean output = true; if(this.playerTest(inSeer) == 2){ if(inTarget == 0) return true; // No vision was had, therefore no conflict. output = ((playerTest(inTarget) <= (-3)) || (playerTest(inTarget) >= 3)); // output is now // true if the Seer saw a wolf. output = (((inVision == 2) && output) || ((inVision == 1) && !output)); } return output; }
6
public SimpleDoubleProperty wrapWidthProperty() { return wrapWidth; }
0
protected void initView() { this.add(new TooltipAction("Step", "Moves existing valid " + "configurations to the next " + "configurations.") { public void actionPerformed(ActionEvent e) { controller.step(blockStep); } }); this.add(new TooltipAction("Reset", "Resets the simulation to " + "start conditions.") { public void actionPerformed(ActionEvent e) { controller.reset(); } }); /* * Add Focus and Defocus buttons only if it is a Turing machine. */ if(controller.isTuringMachine()) { this.add(new AbstractAction("Focus") { public void actionPerformed(ActionEvent e) { controller.focus(); } }); this.add(new AbstractAction("Defocus") { public void actionPerformed(ActionEvent e) { controller.defocus(); } }); } this.add(new AbstractAction("Freeze") { public void actionPerformed(ActionEvent e) { controller.freeze(); } }); this.add(new AbstractAction("Thaw") { public void actionPerformed(ActionEvent e) { controller.thaw(); } }); this.add(new AbstractAction("Trace") { public void actionPerformed(ActionEvent e) { controller.trace(); } }); this.add(new AbstractAction("Remove") { public void actionPerformed(ActionEvent e) { controller.remove(); } }); }
1
public void movePlayer(Point dir) { Point destination = Point.add(player.world_position, dir); int moveprior = Move.rate(destination); int attackprior = Attack.rate(destination); int entprior = Activate.rate(destination); double ap_val = 0; if (moveprior > attackprior && moveprior > entprior) { if (moveprior != 0) { Move.execute(player); ap_val = player.characterSheet.speed; } } else if (attackprior > moveprior && attackprior > entprior) { Attack.executePlayer(); ap_val = player.characterSheet.equiped_weapon.getSpeed(); } else if (entprior > 0) { Activate.executePlayer(); ap_val = 1.0; } game.actorHandler.run_turn = true; game.gameLogic.performedAction(ap_val); }
6
@Override public void run() { while(repeat > 0){ ObjectOutputStream out = null; ObjectInputStream in = null; try { long time1 = System.currentTimeMillis(); Command[] commands = new Command[inputs.length]; for(int i=0; i!=inputs.length; ++i){ commands[i] = Command.parse(inputs[i]); } console.append(inputs.length + " commands parsed successfuly\n"); long time2 = System.currentTimeMillis(); console.append("Parsing time: " + (time2 - time1) + " ms\n"); // prepare socket, input and output streams Random r = new Random(); int index = r.nextInt(nodes.length); console.append("Connecting to " + nodes[index] +'\n'); socket = new Socket(nodes[index].host, nodes[index].port); out = new ObjectOutputStream(socket.getOutputStream()); in = new ObjectInputStream(socket.getInputStream()); console.append("Connected to " + nodes[index] +'\n'); for(int i=0; i!=commands.length; ++i){ long time4 = System.currentTimeMillis(); // send to the node out.writeObject(Message.CLIENT); out.writeObject(commands[i]); console.append("Command " + i + " sent: " + commands[i].input + "\n"); // receive from the node if(commands[i].type == Command.SELECT_TABLE){ resetIndecies(); Data data = (Data)in.readObject(); int countSelected = 0; while(data.nomoreselected == false){ if(checkDataForSelect(data)){ data.display(commands[i].type, console); ++countSelected; } data = (Data)in.readObject(); } console.append(countSelected + " row selected\n"); }else{ Data data = (Data)in.readObject(); data.display(commands[i].type, console); } long time5 = System.currentTimeMillis(); console.append(" + - - - - - - - - - - - - - Elapsed time: " + (time5-time4) + " ms.- - - - - - - - - - - - - - +\n"); } out.writeObject(Message.TERMINATE); long time3 = System.currentTimeMillis(); console.append("Total execution time: " + (time3 - time2) + " ms.\n"); // close socket socket.close(); socket = null; repeat = 0; } catch (UnknownHostException e) { console.append("1. " + e.getMessage() + "\n"); } catch (IOException e) { console.append("2. " + e.getMessage() + "\n"); } catch (Exception e) { console.append("3. " + e.getMessage() + "\n"); }finally{ --repeat; } } }
9
public void leaveState(MouseListenerHandler mouseListenerHandler) { BoardDisplay bd = mouseListenerHandler.getBoardDisplay(); // Remove all listeners, both MouseListener and MouseMoitionListener for (MouseListener ml : bd.getMouseListeners()) { bd.removeMouseListener(ml); } for (MarkDisplay md : bd.getMarkDisplays()) { md.setCursor(Cursor.getDefaultCursor()); for (MouseListener ma : md.getMouseListeners()) { md.removeMouseListener(ma); } for (MouseMotionListener ma : md.getMouseMotionListeners()) { md.removeMouseMotionListener(ma); } } button.setEnabled(true); }
4
public boolean isValidField (char row, byte column) { if(row >= 97 && row <= 104 && column <= 7 && column >= 0) { return true; } return false; }
4
private boolean callUpdateScore(String scheduleID) { if (scheduleID==null) return false; boolean result = false; int m=0; do { result = APIRequest.getInstance().updateGameBoxscore(Sport.NBA, scheduleID); } while (!result && ++m < tries); return result; }
3
public void importArchive(Archive archive) { dull = true; CacheIndice indice = cache.getIndice(0); try { byte[] data = null; String location = SwingUtils.getFilePath("Select Archive", Constants.getExportDirectory(), false, new JAGFileFilter()); if (location != null) { data = DataUtils.readFile(location); } if (archive == interfaces) { if (data != null) { indice.updateFile(3, data); } } if (archive == media) { if (data != null) { indice.updateFile(4, data); } } if (data != null) { cache.rebuildCache(); JOptionPane.showMessageDialog(this, "Archive replaced successfully."); } else { JOptionPane.showMessageDialog(this, "An error occurred while replacing the archive."); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "An error occurred while replacing the archive."); e.printStackTrace(); } dull = false; }
7
public static boolean isApplicable(Object object) { return object instanceof LSystem; }
0
private static String numberToString(int n) { if (n < 1 || n > 1000) { return ""; } if (n <= 20) { return numberMap.get(n); } if (n == 1000) { return "onethousand"; } String result = ""; if (n >= 100) { int hundredsDigit = n / 100; result += numberMap.get(hundredsDigit) + "hundred"; n = n % 100; if (n == 0) { return result; } result += "and"; } if (n <= 20) { return result + numberMap.get(n); } int tensDigit = n / 10; int onesDigit = n % 10; result += numberMap.get(tensDigit * 10) + numberMap.get(onesDigit); return result; }
7
public int minDistance(String word1, String word2) { int m = word1.length(); int n = word2.length(); int[][] distances = new int[m + 1][n + 1]; //insert for (int i = 0; i <= m; i++) { distances[i][0] = i; } //delete for (int i = 0; i <= n; i++) { distances[0][i] = i; } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { //if match, no change, no step if (word1.charAt(i) == word2.charAt(j)) { distances[i + 1][j + 1] = distances[i][j]; } else { //current position, replace int replace = 1 + distances[i][j]; int insert = 1 + distances[i + 1][j]; int delete = 1 + distances[i][j + 1]; distances[i + 1][j + 1] = Math.min((Math.min(replace, insert)), delete); } } } return distances[m][n]; }
5
public void handleBeingMobSniffed(CMMsg msg) { if(!(msg.target() instanceof MOB)) return; final MOB sniffingmob=msg.source(); final MOB sniffedmob=(MOB)msg.target(); if((sniffedmob.playerStats()!=null) &&(sniffedmob.soulMate()==null) &&(sniffedmob.playerStats().getHygiene()>=PlayerStats.HYGIENE_DELIMIT)) { final int x=(int)(sniffedmob.playerStats().getHygiene()/PlayerStats.HYGIENE_DELIMIT); if(x<=1) sniffingmob.tell(L("@x1 has a slight aroma about @x2.",sniffedmob.name(sniffingmob),sniffedmob.charStats().himher())); else if(x<=3) sniffingmob.tell(L("@x1 smells pretty sweaty.",sniffedmob.name(sniffingmob))); else if(x<=7) sniffingmob.tell(L("@x1 stinks pretty bad.",sniffedmob.name(sniffingmob))); else if(x<15) sniffingmob.tell(L("@x1 smells most foul.",sniffedmob.name(sniffingmob))); else sniffingmob.tell(L("@x1 reeks of noxious odors.",sniffedmob.name(sniffingmob))); } }
8
public static void startupXml() { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$.get(); try { Native.setSpecial(Stella.$MODULE$, Stella.$STELLA_MODULE$); Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get()))); if (Stella.currentStartupTimePhaseP(2)) { _StartupXml.helpStartupXml1(); _StartupXml.helpStartupXml2(); } if (Stella.currentStartupTimePhaseP(4)) { Stella.$XML_ELEMENT_NULL_NAMESPACE_TABLE$ = StringHashTable.newStringHashTable(); Stella.$XML_ELEMENT_HASH_TABLE$ = StringHashTable.newStringHashTable(); Stella.$XML_GLOBAL_ATTRIBUTE_HASH_TABLE$ = StringHashTable.newStringHashTable(); Stella.$XML_BASE_ENTITY_TABLE$ = Stella.makeXmlEntityTable(); Stella.$XML_TOKENIZER_TABLE_DEFINITION$ = Cons.list$(Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_SKIP_WHITESPACE, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SKIP_WHITESPACE, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_SKIP_WHITESPACE, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("<"), Cons.cons(Stella.KWD_OPEN_TAG, Cons.cons(Stella.KWD_EOF, Cons.cons(Stella.KWD_EOF, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_CONTENT, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_CONTENT, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("<"), Cons.cons(Stella.KWD_OPEN_TAG, Cons.cons(Stella.KWD_EOF, Cons.cons(Stella.KWD_EOF, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_CONTENT, Cons.cons(Stella.NIL, Stella.NIL)))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_END_TAG, Cons.cons(StringWrapper.wrapString("?"), Cons.cons(Stella.KWD_OPEN_PI_TAG, Cons.cons(StringWrapper.wrapString("!"), Cons.cons(Stella.KWD_OPEN_DECLARATION_TAG, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_OPEN_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_NAME, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_PI_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_ANY, Cons.cons(Stella.KWD_START_PI_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_PI_TAG, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("?"), Cons.cons(Stella.KWD_OPEN_PI_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_PI_TAG_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_PI_TAG, Cons.cons(Stella.NIL, Stella.NIL))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_PI_TAG_DATA, Cons.cons(StringWrapper.wrapString("?"), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_PI_TAG_DATA_OR_END, Cons.cons(Stella.KWD_PI_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_PI_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_PI_TAG_DATA_OR_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_PI_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_PI_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ERROR, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_END_TAG, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_END_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_END_TAG, Cons.cons(Stella.NIL, Stella.NIL))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_END_TAG, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_END_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_END_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_NAME, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_NAME, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ATTRIBUTE_NAME, Cons.cons(Stella.NIL, Stella.NIL))))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_ATTRIBUTE_NAME, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter('='), Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_VALUE, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ATTRIBUTE_NAME, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_VALUE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter('='), Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_VALUE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("'"), Cons.cons(Stella.KWD_SINGLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("\""), Cons.cons(Stella.KWD_DOUBLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_UNQUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SINGLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(StringWrapper.wrapString("'"), Cons.cons(Stella.KWD_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_SINGLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DOUBLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(StringWrapper.wrapString("\""), Cons.cons(Stella.KWD_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_DOUBLE_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_QUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_NAME, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_UNQUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(StringWrapper.wrapString("/"), Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_SKIP_TO_ATTRIBUTE_NAME, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_UNQUOTED_ATTRIBUTE_VALUE, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_DECLARATION_TAG, Cons.cons(StringWrapper.wrapString("-"), Cons.cons(Stella.KWD_START_TAG_OR_COMMENT, Cons.cons(StringWrapper.wrapString("["), Cons.cons(Stella.KWD_OPEN_SPECIAL_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_DECLARATION_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_DECLARATION_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_DECLARATION_WHITESPACE, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_DECLARATION_TAG, Cons.cons(Stella.NIL, Stella.NIL))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DECLARATION_WHITESPACE, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_DECLARATION_WHITESPACE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("["), Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA_START, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("'"), Cons.cons(Stella.KWD_SINGLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("\""), Cons.cons(Stella.KWD_DOUBLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_DECLARATION_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))))))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DECLARATION_TAG_DATA, Cons.cons(Stella.SYM_STELLA_x, Cons.cons(Cons.list$(Cons.cons(CharacterWrapper.wrapCharacter(' '), Cons.cons(CharacterWrapper.wrapCharacter('\t'), Cons.cons(CharacterWrapper.wrapCharacter('\n'), Cons.cons(CharacterWrapper.wrapCharacter('\r'), Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Stella.KWD_DECLARATION_WHITESPACE, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("["), Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA_START, Cons.cons(StringWrapper.wrapString("'"), Cons.cons(Stella.KWD_SINGLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(StringWrapper.wrapString("\""), Cons.cons(Stella.KWD_DOUBLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_DECLARATION_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL)))))))))))))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SINGLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(StringWrapper.wrapString("'"), Cons.cons(Stella.KWD_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_SINGLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DOUBLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(StringWrapper.wrapString("\""), Cons.cons(Stella.KWD_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_DOUBLE_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_QUOTED_DECLARATION_TAG_DATA, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_DECLARATION_WHITESPACE, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA_START, Cons.cons(StringWrapper.wrapString("]"), Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA_START, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DECLARATION_TAG_MARKUP_DATA, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ERROR, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_SPECIAL_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_ANY, Cons.cons(Stella.KWD_START_SPECIAL_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_SPECIAL_TAG, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString("["), Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_SPECIAL_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(StringWrapper.wrapString("]"), Cons.cons(Stella.KWD_SPECIAL_TAG_DATA_OR_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SPECIAL_TAG_DATA_OR_END, Cons.cons(StringWrapper.wrapString("]"), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SPECIAL_TAG_DATA_OR_END2, Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_SPECIAL_TAG_DATA_OR_END2, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_DATA_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_SPECIAL_TAG_DATA, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_TAG_OR_COMMENT, Cons.cons(StringWrapper.wrapString("-"), Cons.cons(Stella.KWD_COMMENT_BODY, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_START_TAG, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_COMMENT_BODY, Cons.cons(StringWrapper.wrapString("-"), Cons.cons(Stella.KWD_END_COMMENT_OR_COMMENT, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_COMMENT_BODY, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_END_COMMENT_OR_COMMENT, Cons.cons(StringWrapper.wrapString("-"), Cons.cons(Stella.KWD_END_COMMENT_OR_COMMENT2, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_COMMENT_BODY, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_END_COMMENT_OR_COMMENT2, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_COMMENT, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ERROR, Cons.cons(Stella.NIL, Stella.NIL))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_COMMENT, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_START_TAG_END, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_DATA_TAG_END, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_END_TAG_END, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_OPEN_EMPTY_TAG_END, Cons.cons(Stella.SYM_STELLA_$, Cons.cons(StringWrapper.wrapString(">"), Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.KWD_OTHERWISE, Cons.cons(Stella.KWD_ERROR, Cons.cons(Stella.NIL, Stella.NIL)))))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_EMPTY_TAG_END, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Cons.list$(Cons.cons(Stella.KWD_ERROR, Cons.cons(Stella.KWD_INCLUDE, Cons.cons(Stella.KWD_START, Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(Stella.NIL, Stella.NIL)))))))))))))))))))))))))))))))))))))))))))))); } if (Stella.currentStartupTimePhaseP(5)) { _StartupXml.helpStartupXml3(); } if (Stella.currentStartupTimePhaseP(6)) { Stella.finalizeClasses(); } if (Stella.currentStartupTimePhaseP(7)) { _StartupXml.helpStartupXml4(); Stella.defineFunctionObject("XML-GLOBAL-ATTRIBUTE-MATCH?", "(DEFUN (XML-GLOBAL-ATTRIBUTE-MATCH? BOOLEAN) ((ATTRIBUTE XML-GLOBAL-ATTRIBUTE) (NAME STRING) (NAMESPACE STRING)) :GLOBALLY-INLINE? TRUE (RETURN (AND (STRING-EQL? (NAME ATTRIBUTE) NAME) (EQL? (NAMESPACE-URI ATTRIBUTE) NAMESPACE))))", Native.find_java_method("edu.isi.stella.XmlGlobalAttribute", "xmlGlobalAttributeMatchP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.XmlGlobalAttribute"), Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("XML-LOCAL-ATTRIBUTE-MATCH?", "(DEFUN (XML-LOCAL-ATTRIBUTE-MATCH? BOOLEAN) ((ATTRIBUTE XML-LOCAL-ATTRIBUTE) (NAME STRING) (ELEMENT-NAME STRING) (ELEMENT-NAMESPACE STRING)) :PUBLIC? TRUE :GLOBALLY-INLINE? TRUE :DOCUMENTATION \"Return true if `attribute' is a local attribute with `name' and whose\nparent element matches `element-name' and `element-namespace'.\" (RETURN (AND (STRING-EQL? (NAME ATTRIBUTE) NAME) (XML-ELEMENT-MATCH? (PARENT-ELEMENT ATTRIBUTE) ELEMENT-NAME ELEMENT-NAMESPACE))))", Native.find_java_method("edu.isi.stella.XmlLocalAttribute", "xmlLocalAttributeMatchP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.XmlLocalAttribute"), Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("XML-LOOKUP-ATTRIBUTE", "(DEFUN (XML-LOOKUP-ATTRIBUTE STRING) ((ATTRIBUTES CONS) (NAME STRING) (NAMESPACE STRING)) :DOCUMENTATION \"Find the XML attribute in `attributes' with `name' and `namespace' and\nreturn its value. Note that it is assumed that all `attributes' come from\nthe same known tag, hence, the parent elements of any local attributes are\nnot considered by the lookup.\" :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Cons", "xmlLookupAttribute", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("EXPAND-XML-TAG-CASE", "(DEFUN (EXPAND-XML-TAG-CASE CONS) ((ITEM SYMBOL) (CLAUSES (CONS OF CONS))))", Native.find_java_method("edu.isi.stella.Symbol", "expandXmlTagCase", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("XML-TAG-CASE", "(DEFUN XML-TAG-CASE ((ITEM OBJECT) |&BODY| (CLAUSES CONS)) :TYPE OBJECT :MACRO? TRUE :PUBLIC? TRUE :DOCUMENTATION \"A case form for matching `item' against XML element tags. Each\nelement of `clauses' should be a clause with the form\n (\\\"tagname\\\" ...) or\n ((\\\"tagname\\\" \\\"namespace-uri\\\") ...)\nThe clause heads can optionally be symbols instead of strings. The key forms the\nparameters to the method `xml-element-match?', with a missing namespace argument\npassed as NULL.\n\nThe namespace argument will be evaluated, so one can use bound variables in\nplace of a fixed string. As a special case, if the namespace argument is\n:ANY, then the test will be done for a match on the tag name alone.\")", Native.find_java_method("edu.isi.stella.Stella_Object", "xmlTagCase", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("PRINT-XML-NON-ELEMENT-ATTRIBUTES", "(DEFUN PRINT-XML-NON-ELEMENT-ATTRIBUTES ((STREAM OUTPUT-STREAM) (ATTRIBUTES CONS)))", Native.find_java_method("edu.isi.stella.OutputStream", "printXmlNonElementAttributes", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("PRINT-XML-ELEMENT-ATTRIBUTES", "(DEFUN PRINT-XML-ELEMENT-ATTRIBUTES ((STREAM OUTPUT-STREAM) (ATTRIBUTES CONS)))", Native.find_java_method("edu.isi.stella.OutputStream", "printXmlElementAttributes", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("PRINT-XML-EXPRESSION", "(DEFUN PRINT-XML-EXPRESSION ((STREAM OUTPUT-STREAM) (XML-EXPRESSION CONS) (INDENT INTEGER)) :DOCUMENTATION \"Prints `xml-expression' on `stream'. Indentation begins with the\nvalue of `indent'. If this is the `null' integer, no indentation is\nperformed. Otherwise it should normally be specified as 0 (zero) for\ntop-level calls.\n\nIt is assumed that the `xml-expression' is a well-formed CONS-list\nrepresentation of an XML form. It expects a form like that form\nreturned by `read-XML-expression'.\n\nAlso handles a list of xml forms such as that returned by `XML-expressions'.\nIn that case, each of the forms is indented by `indent' spaces.\" :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.OutputStream", "printXmlExpression", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.Cons"), java.lang.Integer.TYPE}), null); Stella.defineFunctionObject("STARTUP-XML", "(DEFUN STARTUP-XML () :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella._StartupXml", "startupXml", new java.lang.Class [] {}), null); { MethodSlot function = Symbol.lookupFunction(Stella.SYM_STELLA_STARTUP_XML); KeyValueList.setDynamicSlotValue(function.dynamicSlots, Stella.SYM_STELLA_METHOD_STARTUP_CLASSNAME, StringWrapper.wrapString("_StartupXml"), Stella.NULL_STRING_WRAPPER); } } if (Stella.currentStartupTimePhaseP(8)) { Stella.finalizeSlots(); Stella.cleanupUnfinalizedClasses(); } if (Stella.currentStartupTimePhaseP(9)) { Stella_Object.inModule(((StringWrapper)(Stella_Object.copyConsTree(StringWrapper.wrapString("/STELLA"))))); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFCONSTANT *XML-URN* STRING \"http://www.w3.org/XML/1998/namespaces\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFCONSTANT *HTML-V4-0-URN* STRING \"http://www.w3.org/TR/REC-html40\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-ELEMENT-NULL-NAMESPACE-TABLE* (STRING-HASH-TABLE OF STRING XML-ELEMENT) (NEW (STRING-HASH-TABLE OF STRING XML-ELEMENT)) :DOCUMENTATION \"Hash Table for interning XML elements that don't appear in any namespace.\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-ELEMENT-HASH-TABLE* (STRING-HASH-TABLE OF STRING (STRING-HASH-TABLE OF STRING XML-ELEMENT)) (NEW (STRING-HASH-TABLE OF STRING (STRING-HASH-TABLE OF STRING XML-ELEMENT))) :DOCUMENTATION \"Hash Table mapping URI's (for namespaces) to a Hash Table\nfor interning XML elements.\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-GLOBAL-ATTRIBUTE-HASH-TABLE* (STRING-HASH-TABLE OF STRING (STRING-HASH-TABLE OF STRING XML-ATTRIBUTE)) (NEW (STRING-HASH-TABLE OF STRING (STRING-HASH-TABLE OF STRING XML-ATTRIBUTE))) :DOCUMENTATION \"Hash Table mapping URI's (for namespaces) to a Hash Table\nfor interning XML global attributes.\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-BASE-ENTITY-TABLE* (KEY-VALUE-LIST OF STRING-WRAPPER STRING-WRAPPER) (MAKE-XML-ENTITY-TABLE))"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-TOKENIZER-TABLE-DEFINITION* CONS (BQUOTE ((:START :INCLUDE :SKIP-WHITESPACE) (:SKIP-WHITESPACE ! (#\\ #\\Tab #\\Linefeed #\\Return) :SKIP-WHITESPACE ! \"<\" :OPEN-TAG :EOF :EOF * :OTHERWISE :CONTENT) (:CONTENT ! \"<\" :OPEN-TAG :EOF :EOF :OTHERWISE :CONTENT) (:OPEN-TAG * \">\" :START-TAG-END ! \"/\" :OPEN-END-TAG \"?\" :OPEN-PI-TAG \"!\" :OPEN-DECLARATION-TAG (#\\ #\\Tab #\\Linefeed #\\Return) :OPEN-TAG * :OTHERWISE :START-TAG) (:START-TAG * \">\" :START-TAG-END ! \"/\" :OPEN-EMPTY-TAG-END ! (#\\ #\\Tab #\\Linefeed #\\Return) :SKIP-TO-ATTRIBUTE-NAME :OTHERWISE :START-TAG) (:OPEN-PI-TAG * :ANY :START-PI-TAG) (:START-PI-TAG ! \"?\" :OPEN-PI-TAG-END * (#\\ #\\Tab #\\Linefeed #\\Return) :PI-TAG-DATA :OTHERWISE :START-PI-TAG) (:PI-TAG-DATA \"?\" (:PI-TAG-DATA-OR-END :PI-TAG-DATA) :OTHERWISE :PI-TAG-DATA) (:PI-TAG-DATA-OR-END * \">\" :EMPTY-TAG-END :OTHERWISE :PI-TAG-DATA) (:OPEN-PI-TAG-END * \">\" :EMPTY-TAG-END :OTHERWISE :ERROR) (:OPEN-END-TAG ! \">\" :END-TAG-END * :OTHERWISE :END-TAG) (:END-TAG ! \">\" :END-TAG-END :OTHERWISE :END-TAG) (:SKIP-TO-ATTRIBUTE-NAME * \">\" :START-TAG-END ! \"/\" :OPEN-EMPTY-TAG-END ! (#\\ #\\Tab #\\Linefeed #\\Return) :SKIP-TO-ATTRIBUTE-NAME * :OTHERWISE :ATTRIBUTE-NAME) (:ATTRIBUTE-NAME * \">\" :START-TAG-END ! \"/\" :OPEN-EMPTY-TAG-END ! (#\\= #\\ #\\Tab #\\Linefeed #\\Return) :SKIP-TO-ATTRIBUTE-VALUE :OTHERWISE :ATTRIBUTE-NAME) (:SKIP-TO-ATTRIBUTE-VALUE * \">\" :START-TAG-END ! \"/\" :OPEN-EMPTY-TAG-END (#\\= #\\ #\\Tab #\\Linefeed #\\Return) :SKIP-TO-ATTRIBUTE-VALUE * \"'\" :SINGLE-QUOTED-ATTRIBUTE-VALUE * \"\\\"\" :DOUBLE-QUOTED-ATTRIBUTE-VALUE * :OTHERWISE :UNQUOTED-ATTRIBUTE-VALUE) (:SINGLE-QUOTED-ATTRIBUTE-VALUE \"'\" :QUOTED-ATTRIBUTE-VALUE :OTHERWISE :SINGLE-QUOTED-ATTRIBUTE-VALUE) (:DOUBLE-QUOTED-ATTRIBUTE-VALUE \"\\\"\" :QUOTED-ATTRIBUTE-VALUE :OTHERWISE :DOUBLE-QUOTED-ATTRIBUTE-VALUE) (:QUOTED-ATTRIBUTE-VALUE :INCLUDE :SKIP-TO-ATTRIBUTE-NAME) (:UNQUOTED-ATTRIBUTE-VALUE * \">\" :START-TAG-END ! \"/\" :OPEN-EMPTY-TAG-END ! (#\\ #\\Tab #\\Linefeed #\\Return) :SKIP-TO-ATTRIBUTE-NAME :OTHERWISE :UNQUOTED-ATTRIBUTE-VALUE) (:OPEN-DECLARATION-TAG \"-\" :START-TAG-OR-COMMENT \"[\" :OPEN-SPECIAL-TAG * :OTHERWISE :START-DECLARATION-TAG) (:START-DECLARATION-TAG * \">\" :EMPTY-TAG-END ! (#\\ #\\Tab #\\Linefeed #\\Return) :DECLARATION-WHITESPACE :OTHERWISE :START-DECLARATION-TAG) (:DECLARATION-WHITESPACE ! (#\\ #\\Tab #\\Linefeed #\\Return) :DECLARATION-WHITESPACE * \">\" :EMPTY-TAG-END * \"[\" :DECLARATION-TAG-MARKUP-DATA-START * \"'\" :SINGLE-QUOTED-DECLARATION-TAG-DATA * \"\\\"\" :DOUBLE-QUOTED-DECLARATION-TAG-DATA * :OTHERWISE :DECLARATION-TAG-DATA) (:DECLARATION-TAG-DATA ! (#\\ #\\Tab #\\Linefeed #\\Return) :DECLARATION-WHITESPACE * \">\" :EMPTY-TAG-END * \"[\" :DECLARATION-TAG-MARKUP-DATA-START \"'\" :SINGLE-QUOTED-DECLARATION-TAG-DATA \"\\\"\" :DOUBLE-QUOTED-DECLARATION-TAG-DATA :OTHERWISE :DECLARATION-TAG-DATA) (:SINGLE-QUOTED-DECLARATION-TAG-DATA \"'\" :QUOTED-DECLARATION-TAG-DATA :OTHERWISE :SINGLE-QUOTED-DECLARATION-TAG-DATA) (:DOUBLE-QUOTED-DECLARATION-TAG-DATA \"\\\"\" :QUOTED-DECLARATION-TAG-DATA :OTHERWISE :DOUBLE-QUOTED-DECLARATION-TAG-DATA) (:QUOTED-DECLARATION-TAG-DATA :INCLUDE :DECLARATION-WHITESPACE) (:DECLARATION-TAG-MARKUP-DATA-START \"]\" :DECLARATION-TAG-MARKUP-DATA :OTHERWISE :DECLARATION-TAG-MARKUP-DATA-START) (:DECLARATION-TAG-MARKUP-DATA * \">\" :EMPTY-TAG-END :OTHERWISE :ERROR) (:OPEN-SPECIAL-TAG * :ANY :START-SPECIAL-TAG) (:START-SPECIAL-TAG * \"[\" :SPECIAL-TAG-DATA :OTHERWISE :START-SPECIAL-TAG) (:SPECIAL-TAG-DATA \"]\" :SPECIAL-TAG-DATA-OR-END :OTHERWISE :SPECIAL-TAG-DATA) (:SPECIAL-TAG-DATA-OR-END \"]\" (:SPECIAL-TAG-DATA-OR-END2 :SPECIAL-TAG-DATA) :OTHERWISE :SPECIAL-TAG-DATA) (:SPECIAL-TAG-DATA-OR-END2 * \">\" :DATA-TAG-END :OTHERWISE :SPECIAL-TAG-DATA) (:START-TAG-OR-COMMENT \"-\" :COMMENT-BODY * :OTHERWISE :START-TAG) (:COMMENT-BODY \"-\" :END-COMMENT-OR-COMMENT :OTHERWISE :COMMENT-BODY) (:END-COMMENT-OR-COMMENT \"-\" :END-COMMENT-OR-COMMENT2 :OTHERWISE :COMMENT-BODY) (:END-COMMENT-OR-COMMENT2 \">\" :COMMENT :OTHERWISE :ERROR) (:COMMENT :INCLUDE :START) (:START-TAG-END :INCLUDE :START) (:DATA-TAG-END :INCLUDE :START) (:END-TAG-END :INCLUDE :START) (:OPEN-EMPTY-TAG-END * \">\" :EMPTY-TAG-END :OTHERWISE :ERROR) (:EMPTY-TAG-END :INCLUDE :START) (:ERROR :INCLUDE :START))))"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *XML-TOKENIZER-TABLE* TOKENIZER-TABLE NULL)"); Stella.$XML_TOKENIZER_TABLE$ = Cons.parseTokenizerDefinition(Stella.$XML_TOKENIZER_TABLE_DEFINITION$); } } finally { Stella.$CONTEXT$.set(old$Context$000); Stella.$MODULE$.set(old$Module$000); } } }
7
public static boolean isAnagrams(String s,String t){ if( s== null || t == null){ return false; } if(s.length() != t.length()){ return false; } char[] u = s.toCharArray(); Arrays.sort(u); char[] v = t.toCharArray(); Arrays.sort(v); if(new String(u).equals(new String(v))){ return true; } else{ return false; } }
4
public void onScrubGeo(long userId, long upToStatusId) { //System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId); }
0
public static void main(String[] args) { int n=10; PolyominoGenerator.generatePolyomino(n); ArrayList<boolean[][]> polys = new ArrayList<>(); boolean[][] poly = {{false,false,false},{false,false,false},{false,false,false}}; try { PolyominoInputStream i = new PolyominoInputStream(n); while(poly!=null){ poly = i.read(); if (poly != null) polys.add(poly); } } catch (FileNotFoundException ex) { Logger.getLogger(PolyominoGeneratorTester.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(PolyominoGeneratorTester.class.getName()).log(Level.SEVERE, null, ex); } for (boolean[][] p:polys){ System.out.println(arr(p)); } System.out.println(polys.size()); }
5
@EventHandler public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (HyperPVP.getSpectators().containsKey(event.getPlayer().getName()) || HyperPVP.isCycling() && !event.getPlayer().isOp()) { event.setCancelled(true); } }
3
public static void main(String[] args) throws Exception { System.out.println("Main Harness"); final int lowestPower = 1; final int highestPower = 7; for (int expon = lowestPower; expon <= highestPower; expon++) { final int rowCount = (int) Math.round(Math.pow(10, expon)); int[] source = readSource(rowCount); int[] target; // check that all algorithms return same result for the smallest data set Map<String, int[]> correctnessMap = new HashMap<String, int[]>(); for (Algorithm algorithm : Arrays.asList(new OriginalSort(), new QueueSort())) { System.out.println(String.format("\n%s", algorithm.getName())); long startTime = System.nanoTime(); target = algorithm.go(source); long estimatedTime = System.nanoTime() - startTime; System.out.println(String.format("%s %s", rowCount, estimatedTime)); if (expon == 1) { for (int i = 0; i < rowCount; i++) { correctnessMap.put(algorithm.getName(), target); } } } if (expon == 1) { String firstName = null; int[] firstTarget = null; for (Map.Entry<String, int[]> entry : correctnessMap.entrySet()) { if (firstTarget == null) { firstName = entry.getKey(); firstTarget = entry.getValue(); continue; } String curName = entry.getKey(); int[] curTarget = entry.getValue(); for (int i = 0; i < rowCount; i++) { if (curTarget[i] != firstTarget[i]) { System.out.println(String.format("%s returned different target values than %s", firstName, curName)); System.out.println(String.format("%s: %s, %s", source[i], firstTarget[i], curTarget[i])); System.exit(1); } } } } } }
9
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this.opt(i)); } return jo; }
4
private void process() { // Get the first command off the command queue and process it if (m_oCommandQueue != null && m_oCommandQueue.size() > 0) { // TODO: Optimise this method for (int i= this.getCommandProcessCount(); i>0 && m_oCommandQueue.size() > 0; i--) { ICommand<?, ?> loCommand; synchronized (m_oCommandQueue) { loCommand = m_oCommandQueue.poll(); m_oCurrent = loCommand; } if (loCommand != null) { try { loCommand.execute(); } catch (Throwable ex) { Application.getInstance().log(ex); } // TODO: Implement this with asynchronous commands as well addCompletedCommand(loCommand); if (m_oCurrent == loCommand) { m_oCurrent = null; } } } } }
9
static HashMap<IntPair, HashSet<AAAtom>> generateAll(int aCount, int archCount) { HashMap<IntPair, HashSet<AAAtom>> result = new HashMap<>(); result.put(new IntPair(0, 0), new HashSet<AAAtom>()); HashSet<AAAtom> aSet = new HashSet<>(); aSet.add(new AAAtom()); result.put(new IntPair(1, 0), aSet); for (int i = 2; i <= aCount; i++) { result.put(new IntPair(i, 0), new HashSet<AAAtom>()); } HashSet<AAAtom> ASet = new HashSet<>(); ASet.add(new AAAtom(new AASystem())); result.put(new IntPair(0, 1), ASet); for (int a = 1; a <= aCount; a++) { ArrayList<AAAtom> as = new ArrayList<>(); for (int i = 0; i < a; i++) { as.add(new AAAtom()); } HashSet<AAAtom> t = new HashSet<>(); t.add(new AAAtom(new AASystem(as))); result.put(new IntPair(a, 1), t); } for (int arch = 2; arch <= archCount; arch++) { for (int a = 0; a <= aCount; a++) { HashSet<AAAtom> t = new HashSet<>(); for (int preArch = 1; preArch <= arch; preArch++) { for (int preA = 0; preA <= a; preA++) { int postArch = arch - preArch; int postA = a - preA; for (AAAtom postAtom : result.get(new IntPair(postA, postArch))) { for (AAAtom preAtom : result.get(new IntPair(preA, preArch))) { ArrayList<AAAtom> newContents = (ArrayList<AAAtom>) preAtom.contents.atoms.clone(); newContents.add(postAtom); t.add(new AAAtom(new AASystem(newContents))); } } } } result.put(new IntPair(a, arch), t); } } return result; }
9
public static Tag<Map<String, Tag>> newCompound(Map<String, ?> data) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, NoSuchMethodException, NBTLibDisabledException, UnknownTagException { Map<String, Tag> map; try { for (final Object o : data.values().toArray()) Tag.class.cast(o); map = (Map<String, Tag>) data; } catch (final ClassCastException e) { map = new HashMap<String, Tag>(); for (final Map.Entry<String, ?> entry : data.entrySet()) map.put(entry.getKey(), parse(entry.getValue())); } return new Tag<Map<String, Tag>>(NBT.COMPOUND, map); }
5
private void editSensorEx(){ Form form = new Form(); form.add("unity", "mm"); form.add("name", "Capteur_Pluie"); form.add("statementFrequency", -1); form.add("samplingFrenquency", 1234); try { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); Client client = Client.create(clientConfig); WebResource webResource = client.resource(URL_SERVEUR); ClientResponse response = webResource.path("rest").path("sensor").path("2").type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form); if (response.getStatus() != Response.Status.OK.getStatusCode()) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } String output = response.getEntity(String.class); System.out.println("Sensor : " + output); } catch (Exception e) { e.printStackTrace(); } }
2
public boolean isEmpty() { return size == 0; }
0
public static int[] getPosition(PositionQueue queue, int[] prevPosition){ Position p = queue.poll(); if (p == null) return prevPosition; else{ return p.getPosition(); } }
1
private void pushFile_fileManagerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pushFile_fileManagerButtonActionPerformed File source = null; String dest = directoryLabel_fileManagerLabel.getText(); JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle(parser.parse("fileManager:pushFileDialogTitle")); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setMultiSelectionEnabled(false); int result = fileChooser.showOpenDialog(this); if (result == JOptionPane.OK_OPTION) source = fileChooser.getSelectedFile(); else return; try { logger.log(Level.INFO, "ADB Output: " + selectedDevice.getFileSystem().push(source, dest)); } catch (IOException ex) { logger.log(Level.ERROR, "An error occurred while pushing a file to the device " + selectedDevice.getSerial() + ": " + ex.toString() + "\n" + "The error stack trace will be printed to the console..."); ex.printStackTrace(System.err); } }//GEN-LAST:event_pushFile_fileManagerButtonActionPerformed
2
@Test public void testNoTestLinkAnnotationFailure() { assertTrue(false); }
0
public static void fillTable(ResultSet aResult, JTable aTable) throws SQLException { ((DefaultTableModel) aTable.getModel()).setRowCount(0); ((DefaultTableModel) aTable.getModel()).setColumnCount(0); ResultSet results = aResult; ResultSetMetaData metadata = results.getMetaData(); cols = metadata.getColumnCount(); rowData = new Object[cols]; colNames = new String[cols]; for (int i = 0; i < cols; i++) { colNames[i] = metadata.getColumnName(i + 1); } for (int i = 0; i < cols; i++) { ((DefaultTableModel) aTable.getModel()).addColumn(colNames[i]); } while (results.next()) { for (int i = 0; i < cols; i++) { if (metadata.getColumnName(i + 1).equals("DateCreated") || metadata.getColumnName(i + 1).equals("_dateModified")) { rowData[i] = StrVal.formatTimestamp(results.getTimestamp(i + 1)); } else { rowData[i] = results.getString(i + 1); } } ((DefaultTableModel) aTable.getModel()).addRow(rowData); } }
6
public void calculate(FibonacciHeapNode source) { NotTreatedNodes = new FibonacciHeap(); distances = new HashMap<FibonacciHeapNode, Integer>(); predecessors = new HashMap<FibonacciHeapNode, FibonacciHeapNode>(); // set infinity to all other node than myself for (FibonacciHeapNode entry : distances.keySet()) { distances.put(entry, Integer.MAX_VALUE); } for (FibonacciHeapNode node : this.nodes) { if (node == source) { NotTreatedNodes.insert(source, 0); } else { NotTreatedNodes.insert(node, Integer.MAX_VALUE); } } distances.put(source, 0); // tant que N' != V while (!NotTreatedNodes.isEmpty()) { // find u not in N' such that D(u) is minimum FibonacciHeapNode closestNode = NotTreatedNodes.removeMin(); // for each v adjacent to u List<FibonacciHeapNode> adjacentNodes = getNeighbors(closestNode); for (FibonacciHeapNode target : adjacentNodes) { // if you have Integer.Max_Value and add a distance, it makes a negative distance (took me a while debugging that) // if you have Integer.Max_Value and add a distance, it makes a negative distance (took me a while debugging that) int somme = 0; if (getShortestDistance(closestNode) == Integer.MAX_VALUE || getDistance(closestNode, target) == Integer.MAX_VALUE) { somme = Integer.MAX_VALUE; } else { somme = getShortestDistance(closestNode) + getDistance(closestNode, target); } if ( getShortestDistance(target) > somme) { distances.put(target, getShortestDistance(closestNode) + getDistance(closestNode, target)); predecessors.put(target, closestNode); NotTreatedNodes.decreaseKey(target, getShortestDistance(closestNode) + getDistance(closestNode, target)); } } } }
8
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof User)) { return false; } final User user = (User) o; return !(username != null ? !username.equals(user.getUsername()) : user.getUsername() != null); }
3
@Test public void testGetList() throws Exception { Set<Product> products = new HashSet<Product>(); products.add(new Product(0, "desc0", "cat0")); products.add(new Product(1, "desc1", "cat0")); products.add(new Product(2, "desc2", "cat1")); products.add(new Product(3, "desc3", "cat1")); products.add(new Product(4, "desc3", "cat1")); for(Product product : products) { database.persistProduct(product); } Set<Product> productsExpected = new HashSet<Product>(products); List<Product> storedProducts = database.getList(null, new Db2Product(), Tables.PRODUCTS, Tables.PRODUCTS); for(Product storedProduct : storedProducts) { productsExpected.remove(storedProduct); } assertTrue(productsExpected.size() == 0); //with filter Set<Product> productsNotExpected = new HashSet<Product>(products); storedProducts = database.getList(cat1Filter, new Db2Product(), Tables.PRODUCTS, Tables.PRODUCTS); for(Product storedProduct : storedProducts) { productsNotExpected.remove(storedProduct); } assertTrue(productsNotExpected.size() == 2); //with sort storedProducts = database.getList(null, new Db2Product(), Tables.PRODUCTS, Tables.PRODUCTS, new FieldSortOrder(Tables.Products.DESC, SortOrder.ASC)); assertEquals(storedProducts.get(0).getDescription(), "desc0"); assertEquals(storedProducts.get(1).getDescription(), "desc1"); assertEquals(storedProducts.get(2).getDescription(), "desc2"); assertEquals(storedProducts.get(3).getDescription(), "desc3"); assertEquals(storedProducts.get(4).getDescription(), "desc3"); storedProducts = database.getList(null, new Db2Product(), Tables.PRODUCTS, Tables.PRODUCTS, new FieldSortOrder(Tables.Products.DESC, SortOrder.DESC)); assertEquals(storedProducts.get(0).getDescription(), "desc3"); assertEquals(storedProducts.get(1).getDescription(), "desc3"); assertEquals(storedProducts.get(2).getDescription(), "desc2"); assertEquals(storedProducts.get(3).getDescription(), "desc1"); assertEquals(storedProducts.get(4).getDescription(), "desc0"); }
3
@EventHandler public void WitherNightVision(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Wither.NightVision.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (damager instanceof WitherSkull) { WitherSkull a = (WitherSkull) event.getDamager(); LivingEntity shooter = a.getShooter(); if (plugin.getWitherConfig().getBoolean("Wither.NightVision.Enabled", true) && shooter instanceof Wither && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, plugin.getWitherConfig().getInt("Wither.NightVision.Time"), plugin.getWitherConfig().getInt("Wither.NightVision.Power"))); } } }
7
@Override public BasicValue newValue(final Type type) { if (type == null) { return BasicValue.UNINITIALIZED_VALUE; } boolean isArray = type.getSort() == Type.ARRAY; if (isArray) { switch (type.getElementType().getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: return new BasicValue(type); } } BasicValue v = super.newValue(type); if (BasicValue.REFERENCE_VALUE.equals(v)) { if (isArray) { v = newValue(type.getElementType()); String desc = v.getType().getDescriptor(); for (int i = 0; i < type.getDimensions(); ++i) { desc = '[' + desc; } v = new BasicValue(Type.getType(desc)); } else { v = new BasicValue(type); } } return v; }
9
public void addSample(String sampleReference, Distribution sampleDistribution, int sampleSize) { if ((sampleSize > 0) && (sampleDistribution != null)) { // if the sample is already contained in the list, we need to // remove it first and subtract its size from the sum of sizes prior // to replacing it. if (this.sampleSizes.containsKey(sampleReference)) { int oldsize = this.sampleSizes.get(sampleReference); this.sampleSizes.remove(sampleReference); this.sampleDistributions.remove(sampleReference); this.sampleSizeSum -= oldsize; if (this.largestSample.equals(sampleReference) && (oldsize > sampleSize)) { // the largest sample is replaced by a smaller sample. So we // have to search for a newest largest sample among all // others String currentLargest = null; int currentsize = 0; for (String sample : this.getSampleReferences()) { int size = this.getSampleSize(sample); if (size > currentsize) { currentLargest = sample; } } this.largestSample = currentLargest; } } // update reference to largest sample if necessary if ((this.largestSample == null) || (this.getSampleSize(this.largestSample) < sampleSize)) { this.largestSample = sampleReference; } this.sampleDistributions.put(sampleReference, sampleDistribution); this.sampleSizes.put(sampleReference, sampleSize); this.sampleSizeSum += sampleSize; } else { throw new IllegalArgumentException("Sample size must be positive"); } }
9
public boolean colides(SchlangenKopf head) { return getBounds().intersects(head.getBounds()) && this != head; }
1
public void close() throws IOException { try { int bufferLength = this.buffer.length(); for (;;) { String str = ""; char ch; if (this.bufferIndex >= bufferLength) { str = XMLUtil.read(this.reader, '&'); ch = str.charAt(0); } else { ch = this.buffer.charAt(this.bufferIndex); this.bufferIndex++; continue; // don't interprete chars in the buffer } if (ch == '<') { this.reader.unread(ch); break; } if ((ch == '&') && (str.length() > 1)) { if (str.charAt(1) != '#') { XMLUtil.processEntity(str, this.reader, this.resolver); } } } } catch (XMLParseException e) { throw new IOException(e.getMessage()); } }
7
public void rMayusVerticesNoLocal() { Iterator elemFuente; Elemento entrada,salida; Iterator elemDestino = destino.listaElementos(); double sumaDistancias,sumaValores,distancia,ponderacion,rMayor; double dist[]; int count; while(elemDestino.hasNext()) //Recorre elementos destino { sumaDistancias = sumaValores = 0; // inicializa sumas salida = (Elemento)((Entry)elemDestino.next()).getValue(); elemFuente = fuente.listaElementos(); //carga fuentes rMayor = 0; dist = new double[fuente.numeElementos()]; count = 0; while(elemFuente.hasNext()) //recorre elementos fuente { entrada = (Elemento)((Entry)elemFuente.next()).getValue(); distancia = distancia(entrada,salida); dist[count] = distancia; count ++; rMayor = (distancia > rMayor)?distancia:rMayor; } elemFuente = fuente.listaElementos(); count = 0; while(elemFuente.hasNext()) //recorre elementos fuente { double pow = Math.pow((rMayor - dist[count])/(rMayor * dist[count]),2); sumaDistancias += pow; sumaValores += pow * ((Elemento)((Entry)elemFuente.next()).getValue()).valor(); count ++; } salida.valor(sumaValores / sumaDistancias); } }
4
public Path2D drawablePath2D(Node to) { List<Node> nodes = dij.getRoute(to); Path2D path = new Path2D.Double(); for (Node n : nodes) { if (n.equals(nodes.get(0))) { path.moveTo(n.getxCoord(), n.getyCoord()); } else { path.lineTo(n.getxCoord(), n.getyCoord()); } System.out.println(n.getxCoord() + " " + n.getyCoord()); } System.out.println(path.getBounds()); return path; }
2
public void MarketCannotFulfill(Market market, Map<String, Integer> provided){ Do(market.getName()+" cannot fulfill"); synchronized(marketOrders){ for(MarketOrder mo : marketOrders){ if(mo.market.equals(market.getName())){ mo.provided = provided; } } } for(String food : foodToOrder.keySet()){ foodToOrder.put(food, foodToOrder.get(food)-provided.get(food)); } for(int i=0; i<markets.size(); i++){ if(markets.get(i)==market&&(i+1)<markets.size()){ marketOrders.add(new MarketOrder(markets.get(i+1))); markets.get(i+1).HereIsOrder(foodToOrder); return; } } }
6
protected void listAll() { if(myCases.size() == myLemma.numCasesTotal()) myMessage.setText("All cases for m = " + myLemma.getM() + " are already shown."); else { myLemma.doAll(); myMessage.setText("All cases for m = " + myLemma.getM() + " shown."); refresh(); } }
1
public static void main(String[] args) throws Exception { int i; System.out.println("1: for train and predict"); System.out.println("2: for test"); System.out.println("3: for excute meta"); if (args.length == 0) { System.out.println("input a method"); System.exit(0); } else if (args.length == 1) { i = Integer.valueOf(args[0]); // Scanner scan = new Scanner(System.in); // i = scan.nextInt(); if (i == 1) write1("exec.sh"); if (i == 2) write2("text/CRF/test.sh"); if (i == 3) write3("exutmeta.sh"); if(i==4) write4("stanford.sh"); if(i==5) write5("text/CRF/20.sh"); if(i==6){ write6("/home/lizhou/Desktop/exe.sh"); } } else{ System.out.println("invalid args, input one"); System.exit(0); } }
8
@Test public void recomTest1() { userInput.add("hello"); userInput.add("hi"); userInput.add("luiz"); userInput.add("what can i eat with pork today"); //Covering approval userInput.add("yes"); userInput.add("what can i eat with fish tomorrow"); //Covering different week days userInput.add("beef monday"); userInput.add("cow tuesday"); userInput.add("vegan wednesday"); //Covering approval userInput.add("no"); userInput.add("vegetarian thursday"); //Covering error handling userInput.add("blablabla"); userInput.add("pork sunday"); userInput.add("pork saturday"); runMainActivityWithTestInput(userInput); assertTrue(nlgResults.get(4).contains("else") && nlgResults.get(9).contains("else") && nlgResults.get(12).contains("closed") && nlgResults.get(13).contains("closed")); }
3
public void setjTextFieldLieux(JTextField jTextFieldLieux) { this.jTextFieldLieux = jTextFieldLieux; }
0
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { //Special handling for Privateer classes when building with Maven //Maven does not set the classpath but instead uses a custom //classloader to load test classes which means the compiler //tool cannot normally see standard Privateer classes so //we put in a workaround here if (StandardLocation.CLASS_PATH == location && kinds.contains(Kind.CLASS)) { List<JavaFileObject> results = new ArrayList<JavaFileObject>(); Iterable<JavaFileObject> superResults = super.list(location, packageName, kinds, recurse); for (JavaFileObject superResult : superResults) { results.add(superResult); } //Now process classpath URLs for (URL curClassPathUrl : classPathUrls) { String directory = packageName.replace('.', '/') + '/'; URL loadUrl = new URL(curClassPathUrl, directory); try { List<JavaFileObject> additionalClasses = listClassesFromUrl(loadUrl, packageName); results.addAll(additionalClasses); } catch (IOException e) { //This happens if the file does not exist //Move onto next one } } return results; } else { Iterable<JavaFileObject> results = super.list(location, packageName, kinds, recurse); return results; } }
5
StunServerReceiverThread(DatagramSocket datagramSocket) { this.receiverSocket = datagramSocket; for (DatagramSocket socket : sockets) { if ((socket.getLocalPort() != receiverSocket.getLocalPort()) && (socket.getLocalAddress().equals(receiverSocket.getLocalAddress()))) changedPort = socket; if ((socket.getLocalPort() == receiverSocket.getLocalPort()) && (!socket.getLocalAddress().equals(receiverSocket.getLocalAddress()))) changedIP = socket; if ((socket.getLocalPort() != receiverSocket.getLocalPort()) && (!socket.getLocalAddress().equals(receiverSocket.getLocalAddress()))) changedPortIP = socket; } }
7
@Override protected Integer compute() { Integer ret = 0; MyWorkerThread thread = (MyWorkerThread) Thread.currentThread(); thread.addTask(); for(int i = start ; i < end;i ++){ ret += array[i]; } return ret; }
1
public Point minus(Point p) { if (!(p == null || p.properties == null || properties == null)) { for (int i = 0; i < properties.size(); i++) { set(i, get(i) - p.get(i)); } } return this; }
4
@Override public int reportFake(@Nonnull GamePlayer player, @Nonnull Status[] tweets) throws RemoteException { tweetsProvider.delay(); final GamePlayerData playerData = getGamePlayerData(player); try { if (tweets.length < MIN_FAKE_TWEETS_BATCH) throw new IllegalArgumentException("Invalid fake tweeets size"); final List<Long> ids = new ArrayList<>(); GamePlayerData source = null; for (Status tweet : tweets) { if (tweet == null) throw new NullPointerException(TWEET_FIELD); if (source == null) source = getGamePlayerData(tweet.getSource(), false); else if (!source.getId().equals(tweet.getSource())) throw new IllegalArgumentException("Not all tweets from the same source"); if (ids.contains(tweet.getId())) throw new IllegalArgumentException("Tweet repeated"); ids.add(tweet.getId()); tweetsProvider.registerFakeTweet(tweet, source.player, source.hash); } assert source != null; if (source.getId().equals(player.getId())) throw new IllegalArgumentException("You cannot report yourself!"); final boolean isBanned = source.isBanned; source.isBanned = true; final int playerScore = isBanned ? ALREADY_BANNED_SCORE : FIRST_BANNED_SCORE; return playerData.addAndGet(playerScore); } catch (IllegalArgumentException e) { playerData.banned(); throw e; } }
9
@Override public String encrypt(String plainText) { String text = processInput(plainText); int r = transpositionLevel; int length = text.length(); int c=length/transpositionLevel; char mat[][] = new char[r][c]; int k=0; String cipherText=""; for(int i=0;i< c;i++) { for(int j=0;j< r;j++) { if(k!=length) mat[j][i]=text.charAt(k++); else mat[j][i]='X'; } } for(int i=0;i< r;i++) { for(int j=0;j< c;j++) { cipherText+=mat[i][j]; } } return cipherText; }
5
public static void main(String[] args) { int max = Integer.MAX_VALUE; System.out.println("Overflow:"); System.out.println(max); // 2147483647 System.out.println(max + 1); // -2147483648 System.out.println(max + 2); // -2147483647 int min = Integer.MIN_VALUE; System.out.println("Unceerflow:"); System.out.println(min); // -2147483648 System.out.println(max - 1); // 2147483647 System.out.println(max - 2); // 2147483646 }
0
public State(int id, Point point, Automaton automaton) { this.point = point; this.id = id; this.automaton = automaton; }
0
public ShapeElempun(SimpleFeature f, String tipo) { super(f, tipo); shapeId = "ELEMPUN" + super.newShapeId(); // Elempun trae la geometria en formato Point if ( f.getDefaultGeometry().getClass().getName().equals("com.vividsolutions.jts.geom.Point")){ Point p = (Point) f.getDefaultGeometry(); coor = p.getCoordinate(); } else { System.out.println("["+new Timestamp(new Date().getTime())+"] Formato geometrico "+ f.getDefaultGeometry().getClass().getName() +" desconocido dentro del shapefile ELEMPUN"); } // Los demas atributos son metadatos y de ellos sacamos ttggss = (String) f.getAttribute("TTGGSS"); // Para agrupar geometrias segun su codigo de masa que como en este caso no existe se // asigna el del nombre del fichero shapefile codigoMasa = "ELEMPUN-" + ttggss; // Si queremos coger todos los atributos del .shp /*this.atributos = new ArrayList<ShapeAttribute>(); for (int x = 1; x < f.getAttributes().size(); x++){ atributos.add(new ShapeAttribute(f.getFeatureType().getDescriptor(x).getType(), f.getAttributes().get(x))); }*/ }
1
public Stub440 localise() { Class<? extends Stub440> c = null; try { c = (Class<? extends Stub440>) Class.forName(remoteInterfaceName + "_Stub").asSubclass(Stub440.class); } catch (ClassNotFoundException e) { //TODO: Download .class file from code base e.printStackTrace(); System.exit(-1); } Constructor<?> constructor = null; Stub440 stub = null; try { constructor = c.getConstructor(new Class[]{RemoteObjectRef.class}); stub = (Stub440)constructor.newInstance(this); } catch (Exception e) { e.printStackTrace(); } return stub; }
5
@SuppressWarnings("unchecked") @Test public void testLastWeek() { SimpleValidator simpleValidator = new SimpleValidator(); DateRangeBean bean; Set<?> validations; for (int days = -2014; days <= -14; days += 100) { bean = new DateRangeBean(); bean.setDate4(util.add(new Date(), Calendar.DAY_OF_MONTH, days)); validations = simpleValidator.validate(bean); TestUtil.assertValid((Set<ConstraintViolation<?>>) validations, "date4"); } for (int days = 0; days <= 2000; days += 100) { bean = new DateRangeBean(); bean.setDate4(util.add(new Date(), Calendar.DAY_OF_MONTH, days)); validations = simpleValidator.validate(bean); TestUtil.assertValid((Set<ConstraintViolation<?>>) validations, "date4"); } bean = new DateRangeBean(); bean.setDate7(util.add(new Date(), Calendar.WEEK_OF_YEAR, -1)); validations = simpleValidator.validate(bean); TestUtil.assertValid((Set<ConstraintViolation<?>>) validations); bean = new DateRangeBean(); bean.setDate7(new Date()); validations = simpleValidator.validate(bean); TestUtil.assertValid((Set<ConstraintViolation<?>>) validations, "date7"); bean = new DateRangeBean(); bean.setDate7(util.add(new Date(), Calendar.WEEK_OF_YEAR, -2)); validations = simpleValidator.validate(bean); TestUtil.assertValid((Set<ConstraintViolation<?>>) validations, "date7"); }
8
public void inferir(BaseReglas baseCon) throws IOException { baseCon.cargar(); Archivos a = new Archivos(); float min = 1,temp=1; int i; while(baseCon.tieneRegistros()) { //Obtener regla baseCon.siguienteRegla(); for (i = 0; i < baseCon.noAnt(); i++) { //Obtener grados de pertenencia de cada uno temp = buscar(baseCon.nombreAntecedente(i),baseCon.etiquetaRegla(i),varDifusa); //Calcular el mínimo min = Math.min(min,temp); //System.out.println("\tValor de la regla: " +min); } //Asignar al(a los) consecuente(s) el máximo entre su valor anterior y el minimo for (int j = 0; j < baseCon.noCon(); j++) { temp = buscar(baseCon.nombreConsecuente(j),baseCon.etiquetaConsec(j),salDifusa); if(temp < min || temp == 0.0f) inserta(baseCon.nombreConsecuente(j),baseCon.etiquetaConsec(j),min); } //Fin de reglas //Salida difusa } }
5
public void parseFile() { LineNumberReader lnr = null; try { lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(file))); String s; while ((s = lnr.readLine()) != null) { if (!s.startsWith("[")) { continue; } parseCell(s); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (lnr != null) { lnr.close(); } } catch (IOException e) { // ignore } } }
6
public void OperandBody(OperandTypeDecl td) throws ParseException { jj_consume_token(LBRACKET); label_8: while (true) { switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case READ: case WRITE: case 81: break; default: jj_la1[17] = jj_gen; break label_8; } switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case READ: ReadMethod(td); break; case WRITE: WriteMethod(td); break; case 81: SubOperand(td); break; default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } jj_consume_token(RBRACKET); }
9
public TreeNode build(int[] A) { TreeNode root = new TreeNode(A[0]); TreeNode last = root; Stack<TreeNode> S = new Stack<>(); boolean left = false; for (int i = 1; i < A.length; i++) { if (last == null && S.isEmpty()) break; last = last == null ? S.pop() : last; if (A[i] != -1) { TreeNode node = new TreeNode(A[i]); if (!left) { S.push(last); last.left = node; last = last.left; } else { last.right = node; last = last.right; } left = false; } else if (A[i] == -1) { if (!left) left = true; else last = null; } } return root; }
8
public final void testFall() { DiscogParser parser = new DiscogParser(); try { Record r = parser.parseDiscogRelease(DISCOG_FALL); System.err.println("TRACKS = " + r.getTracks().size()); assert (r.getTracks().size() == 50); // Check the last track has a correct title for (Track t : r.getTracks()) if (t.getTrackNumber() == 50) assert (t.getTitle().equals("Middle Mass (Live)")); } catch (Exception e) { e.printStackTrace(); assert (false); } }
3
public Enrolment(Student s, ClassGroup c) { if (s == null || c == null) throw new IllegalArgumentException(); this.enrolledStudent = s; this.enrolledClass = c; }
2
public String toString() { String s = ""; for (int i = 2; i < a.length; i++) s += (a[i] ? i + " " : ""); return s; }
2