rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
int choice = 1; if (currentFile != null) { File file = currentFile; try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } | saveFile(evt); | public void actionPerformed(ActionEvent evt) { int choice = 1; if (currentFile != null) { File file = currentFile; //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } } // prompt to save if not already saved else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { // same as save as: saveAs(); } } |
else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { saveAs(); } } | public void actionPerformed(ActionEvent evt) { int choice = 1; if (currentFile != null) { File file = currentFile; //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } } // prompt to save if not already saved else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { // same as save as: saveAs(); } } |
|
File tmp = new File("tmp.html"); try { saveAsHTML(tmp, "ca/strangebrew/data/recipeToSimpleHtml.xslt"); HTMLViewer view = new HTMLViewer(owner, tmp.toURL()); view.setModal(true); view.setVisible(true); } catch (Exception e) { e.printStackTrace(); } tmp.delete(); | processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); | public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard// save file as xml, then transform it to html File tmp = new File("tmp.html"); try { saveAsHTML(tmp, "ca/strangebrew/data/recipeToSimpleHtml.xslt"); HTMLViewer view = new HTMLViewer(owner, tmp.toURL()); view.setModal(true); view.setVisible(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } tmp.delete(); } |
processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); | PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); | public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); } |
PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); | ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); | public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } |
ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); | MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); | public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } |
MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); | aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); | public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } |
bandwidthController.getAvailableByteCount( true ); | bandwidthController.getAvailableByteCount( 1, true, true ); | public int read() throws IOException { bandwidthController.getAvailableByteCount( true ); int val = inStream.read(); bandwidthController.markBytesUsed( 1 ); return val; } |
bandwidthController.markBytesUsed( 1 ); | public int read() throws IOException { bandwidthController.getAvailableByteCount( true ); int val = inStream.read(); bandwidthController.markBytesUsed( 1 ); return val; } |
|
public synchronized void markBytesUsed( int byteCount ) | public synchronized void markBytesUsed( int byteCount ) throws IOException | public synchronized void markBytesUsed( int byteCount ) { updateWindow( false ); bytesRemaining -= byteCount; if ( bytesRemaining < 0 ) { updateWindow( true ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "[" + controllerName + "] !Mark bytes used " + byteCount + " - remaining: " + bytesRemaining + "."); } if ( shortTransferAvg != null ) { shortTransferAvg.addValue( byteCount ); } if ( longTransferAvg != null ) { longTransferAvg.addValue( byteCount ); } // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { nextContollerInChain.markBytesUsed( byteCount ); } } |
bytesRemaining = Math.max( bytesRemaining, -15 * WINDOWS_PER_SECONDS * bytesPerWindow ); | public synchronized void markBytesUsed( int byteCount ) { updateWindow( false ); bytesRemaining -= byteCount; if ( bytesRemaining < 0 ) { updateWindow( true ); } short logLevel = NLogger.LOG_LEVEL_DEBUG; if ( bytesRemaining < 0 ) { logLevel = NLogger.LOG_LEVEL_ERROR; } if ( NLogger.isEnabled( logLevel, NLoggerNames.BANDWIDTH ) ) { NLogger.log( logLevel, NLoggerNames.BANDWIDTH, "[" + controllerName + "] !Mark bytes used " + byteCount + " - remaining: " + bytesRemaining + "."); } if ( shortTransferAvg != null ) { shortTransferAvg.addValue( byteCount ); } if ( longTransferAvg != null ) { longTransferAvg.addValue( byteCount ); } // If there is another controller we are chained to, call it. if( nextContollerInChain != null ) { nextContollerInChain.markBytesUsed( byteCount ); } } |
|
numberOfParameters = 0; | numberOfParameters = 0; curNumberOfParameters = 0; | public PostfixMathCommand() { numberOfParameters = 0; } |
Iterator e = seismos.keySet().iterator(); while(e.hasNext()) seismos.put(e.next(), b); | public synchronized void set(MicroSecondDate b, TimeInterval t){ displayInterval = t; beginTime = b; updateTimeSyncListeners(); } |
|
public void removeAll(MouseEvent me){ | public void removeAll(){ logger.debug("removing all displays"); | public void removeAll(MouseEvent me){ this.stopImageCreation(); seismograms.removeAll(); remove(seismograms); basicDisplays = new LinkedList(); sorter = new SeismogramSorter(); globalTimeRegistrar = new TimeConfigRegistrar(); globalAmpRegistrar = new AmpConfigRegistrar(); repaint(); } |
this.time.setText(" Time: "); this.amp.setText(" Amplitude: "); | public void removeAll(MouseEvent me){ this.stopImageCreation(); seismograms.removeAll(); remove(seismograms); basicDisplays = new LinkedList(); sorter = new SeismogramSorter(); globalTimeRegistrar = new TimeConfigRegistrar(); globalAmpRegistrar = new AmpConfigRegistrar(); repaint(); } |
|
logger.debug("removing a display with " + basicDisplays.size() + " left"); | public void removeDisplay(BasicSeismogramDisplay display){ if(basicDisplays.size() == 1){ this.removeAll(); return; } seismograms.remove(display); basicDisplays.remove(display); ((SeismogramDisplay)basicDisplays.getFirst()).addTopTimeBorder(); ((SeismogramDisplay)basicDisplays.getLast()).addBottomTimeBorder(); seismograms.revalidate(); repaint(); } |
|
private ChangeLogSet calcChangeSet() { | private ChangeLogSet<? extends Entry> calcChangeSet() { | private ChangeLogSet calcChangeSet() { File changelogFile = new File(getRootDir(), "changelog.xml"); if(!changelogFile.exists()) return ChangeLogSet.EMPTY; try { return scm.parse(this,changelogFile); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } return ChangeLogSet.EMPTY; } |
public ChangeLogSet<?> getChangeSet() { | public ChangeLogSet<? extends Entry> getChangeSet() { | public ChangeLogSet<?> getChangeSet() { if(scm==null) scm = new CVSChangeLogParser(); if(changeSet==null) // cached value changeSet = calcChangeSet(); return changeSet; } |
public synchronized Map<String,String> getRevisionMap() throws IOException { | public synchronized Map<String,Integer> getRevisionMap() throws IOException { | public synchronized Map<String,String> getRevisionMap() throws IOException { if(revisionMap==null) revisionMap = SubversionSCM.parseRevisionFile(build); return revisionMap; } |
Options opts = new Options(); | opts = new Options(); mash = new Mash(this); | public Recipe() { Options opts = new Options(); name = "My Recipe"; created = new GregorianCalendar(); efficiency = opts.getDProperty("optEfficiency"); //preBoilVol.setUnits(opts.getProperty("optSizeU")); // preBoilVol.setAmount(opts.getDProperty("optPreBoilVol")); // postBoilVol.setUnits(opts.getProperty("optSizeU")); // postBoilVol.setAmount(opts.getDProperty("optPostBoilVol")); attenuation = opts.getDProperty("optAttenuation"); boilMinutes = opts.getIProperty("optBoilTime"); ibuCalcMethod = opts.getProperty("optIBUCalcMethod"); ibuHopUtil = opts.getDProperty("optHopsUtil"); hopUnits = opts.getProperty("optHopsU"); maltUnits = opts.getProperty("optMaltU"); brewer = opts.getProperty("optBrewer"); evapMethod = opts.getProperty("optEvapCalcMethod"); evap = opts.getDProperty("optEvaporation"); alcMethod = opts.getProperty("optAlcCalcMethod"); colourMethod = opts.getProperty("optColourMethod"); kettleLoss = opts.getDProperty("optKettleLoss"); trubLoss = opts.getDProperty("optTrubLoss"); miscLoss = opts.getDProperty("optMiscLoss"); pelletHopPct = opts.getDProperty("optPelletHopsPct"); bottleU = opts.getProperty("optBottleU"); bottleSize = opts.getDProperty("optBottleSize"); otherCost = opts.getDProperty("optMiscCost"); dilution = new DilutedRecipe(); version = ""; // trigger the first re-calc: setPostBoil(opts.getDProperty("optPostBoilVol")); setVolUnits(opts.getProperty("optSizeU")); } |
private double calcColour(double lov) { | private double calcColour(double lov, String method) { | private double calcColour(double lov) { double colour = 0; if (colourMethod.equals("EBC")) { // From Greg Noonan's article at // http://brewingtechniques.com/bmg/noonan.html colour = 1.4922 * Math.pow(lov, 0.6859); // SRM // EBC is apr. SRM * 2.65 - 1.2 colour = (colour * 2.65) - 1.2; } else { // calculates SRM based on MCU (degrees LOV) if (lov > 0) colour = 1.4922 * Math.pow(lov, 0.6859); else colour = 0; } return colour; } |
if (colourMethod.equals("EBC")) { | if (method.equals("EBC")) { | private double calcColour(double lov) { double colour = 0; if (colourMethod.equals("EBC")) { // From Greg Noonan's article at // http://brewingtechniques.com/bmg/noonan.html colour = 1.4922 * Math.pow(lov, 0.6859); // SRM // EBC is apr. SRM * 2.65 - 1.2 colour = (colour * 2.65) - 1.2; } else { // calculates SRM based on MCU (degrees LOV) if (lov > 0) colour = 1.4922 * Math.pow(lov, 0.6859); else colour = 0; } return colour; } |
srm = calcColour(mcu); | srm = calcColour(mcu, "SRM"); ebc = calcColour(mcu, "EBC"); | public void calcMaltTotals() { if (!allowRecalcs) return; double maltPoints = 0; double mcu = 0; totalMaltLbs = 0; totalMaltCost = 0; totalMashLbs = 0; // first figure out the total we're dealing with for (int i = 0; i < fermentables.size(); i++) { Fermentable m = ((Fermentable) fermentables.get(i)); totalMaltLbs += (m.getAmountAs("lb")); if (m.getMashed()) { // apply efficiency and add to mash weight maltPoints += (m.getPppg() - 1) * m.getAmountAs("lb") * efficiency / postBoilVol.getValueAs("gal"); totalMashLbs += (m.getAmountAs("lb")); } else maltPoints += (m.getPppg() - 1) * m.getAmountAs("lb") * 100 / postBoilVol.getValueAs("gal"); mcu += m.getLov() * m.getAmountAs("lb") / postBoilVol.getValueAs("gal"); totalMaltCost += m.getCostPerU() * m.getAmountAs(m.getUnits()); } // now set the malt % by weight: for (int i = 0; i < fermentables.size(); i++) { Fermentable m = ((Fermentable) fermentables.get(i)); if (m.getAmountAs("lb") == 0) m.setPercent(0); else m.setPercent((m.getAmountAs("lb") / totalMaltLbs * 100)); } // set the fields in the object estOg = (maltPoints / 100) + 1; estFg = 1 + ((estOg - 1) * ((100 - attenuation) / 100)); srm = calcColour(mcu); // mash.setMaltWeight(totalMashLbs); calcAlcohol(getAlcMethod()); // do the water calcs w/ the updated mash: chillShrinkQTS = getPostBoilVol("qt") * CHILLPERCENT; // spargeQTS = getPreBoilVol("qt") - (mash.getTotalWaterQts() - mash.getAbsorbedQts()); totalWaterQTS = mash.getTotalWaterQts() + mash.getSpargeVol(); finalWortVolQTS = postBoilVol.getValueAs("qt") - (chillShrinkQTS + Quantity.convertUnit(getVolUnits(), "qt", kettleLoss) + Quantity.convertUnit(getVolUnits(), "qt", trubLoss) + Quantity .convertUnit(getVolUnits(), "qt", miscLoss)); } |
SearchButton btn = new SearchButton( search ); | SearchButton btn = new SearchButton( search, searchTab ); | public void searchAdded( Search search, int position ) { SearchButton btn = new SearchButton( search ); btn.addActionListener( buttonHandler ); synchronized ( accessLock ) { searchButtonMap.put(search, btn); searchButtonGroup.add(btn); addButton( btn ); } if ( displayedDataModel != null && search == displayedDataModel.getSearch() ) {// select the button of the displayed model btn.setSelected(true); } } |
j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,true); | j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); | public void processEquation(Node node) throws Exception { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); } |
j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,false); | j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); | public void processEquation(Node node) throws Exception { DJep j = (DJep) this.j; if(verbose) { print("Parsed:\t\t"); println(j.toString(node)); } Node processed = j.preprocess(node); if(verbose) { print("Processed:\t"); println(j.toString(processed)); } Node simp = j.simplify(processed); if(verbose) print("Simplified:\t"); println(j.toString(simp)); if(verbose) { print("Full Brackets, no variable expansion:\n\t\t"); j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,true); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,false); println(j.toString(simp)); j.getPrintVisitor().setMode(DPrintVisitor.PRINT_PARTIAL_EQNS,true); j.getPrintVisitor().setMode(DPrintVisitor.FULL_BRACKET,false); } Object val = j.evaluate(simp); String s = j.getPrintVisitor().formatValue(val); println("Value:\t\t"+s); } |
cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_GWebCacheContains" ), cc.xy( 2, 5 ) ); gWebCacheStatLabel = new JLabel( ); cacheStatusBuilder.add( gWebCacheStatLabel, cc.xy( 4, 5 ) ); cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_Caches" ), cc.xy( 6, 5 ) ); final JButton queryWebCache = new JButton( Localizer.getString( "QueryGWebCache" ) ); queryWebCache.setToolTipText( Localizer.getString( "TTTQueryGWebCache" ) ); queryWebCache.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { queryWebCache.setEnabled( false ); Runnable runner = new Runnable() { public void run() { try { gWebCacheCont.queryMoreHosts( false ); gWebCacheCont.queryMoreGWebCaches( false ); } catch ( Throwable th ) { NLogger.error( NLoggerNames.GLOBAL, th, th ); } finally { queryWebCache.setEnabled( true ); } } }; ThreadPool.getInstance().addJob( runner, "UserGWebCacheQuery-" + Integer.toHexString(runner.hashCode()) ); } } ); cacheStatusBuilder.add( queryWebCache, cc.xywh( 2, 7, 5, 1 ) ); | public void initComponent( DGuiSettings guiSettings ) { CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout( "2dlu, fill:d:grow, 2dlu", // columns "2dlu, fill:d:grow, 4dlu, d, 2dlu"); //rows PanelBuilder contentBuilder = new PanelBuilder( layout, this ); //JPanel upperPanel = new FormDebugPanel(); JPanel upperPanel = new JPanel( ); FWElegantPanel upperElegantPanel = new FWElegantPanel( Localizer.getString("Connections"), upperPanel ); layout = new FormLayout( "0dlu, d, 2dlu, d, 10dlu:grow, d, 2dlu, d, 2dlu, d, 0dlu", // columns "fill:d:grow, 3dlu, p"); //rows PanelBuilder upperBuilder = new PanelBuilder( layout, upperPanel ); networkModel = new NetworkTableModel(); DTable xmlTable = GUIUtils.getDGuiTableByIdentifier( guiSettings, NETWORK_TABLE_IDENTIFIER ); buildNetworkTableColumnModel( xmlTable ); networkTable = new FWTable( new FWSortedTableModel( networkModel ), networkColumnModel ); // TODO3 try for a improced table sorting strategy. //((FWSortedTableModel)networkTable.getModel()).setTable( networkTable ); networkTable.activateAllHeaderActions(); networkTable.setAutoResizeMode( JTable.AUTO_RESIZE_OFF ); networkTable.getSelectionModel().addListSelectionListener( new SelectionHandler() ); MouseHandler mouseHandler = new MouseHandler(); networkTable.addMouseListener( mouseHandler ); networkTableScrollPane = FWTable.createFWTableScrollPane( networkTable ); networkTableScrollPane.addMouseListener( mouseHandler ); upperBuilder.add( networkTableScrollPane, cc.xywh( 2, 1, 9, 1 ) ); JLabel label = new JLabel( Localizer.getString( "NetworkTab_MyAddress" ) ); upperBuilder.add( label, cc.xy( 2, 3 ) ); myIPLabel = new JLabel( "" ); myIPLabel.addMouseListener( new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { popupMenu((Component)e.getSource(), e.getX(), e.getY()); } } public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { popupMenu((Component)e.getSource(), e.getX(), e.getY()); } } private void popupMenu(Component source, int x, int y) { JPopupMenu menu = new JPopupMenu(); menu.add( new CopyMyIpAction() ); menu.show( source, x, y ); } }); upperBuilder.add( myIPLabel, cc.xy( 4, 3 ) ); label = new JLabel( Localizer.getString( "ConnectTo" ) + Localizer.getChar( "ColonSign" ) ); upperBuilder.add( label, cc.xy( 6, 3 ) );// TODO2 add connection and disconnect network buttons to ConnectTo status line// because it is not available from toolbar anymore... ConnectToHostHandler connectToHostHandler = new ConnectToHostHandler(); connectToComboModel = new DefaultComboBoxModel( NetworkTabPrefs.ConnectToHistory.get().toArray() ); connectToComboBox = new JComboBox( connectToComboModel ); connectToComboBox.setEditable( true ); JTextField editor = ((JTextField)connectToComboBox.getEditor().getEditorComponent()); Keymap keymap = JTextField.addKeymap( "ConnectToEditor", editor.getKeymap() ); editor.setKeymap( keymap ); keymap.addActionForKeyStroke( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), connectToHostHandler ); GUIUtils.assignKeymapToComboBoxEditor( keymap, connectToComboBox ); connectToComboBox.setSelectedItem( "" ); connectToComboBox.setPrototypeDisplayValue("123.123.123.123:12345"); upperBuilder.add( connectToComboBox, cc.xy( 8, 3 ) ); JButton connectHostButton = new JButton( Localizer.getString( "Connect" ) ); connectHostButton.addActionListener( connectToHostHandler ); upperBuilder.add( connectHostButton, cc.xy( 10, 3 ) ); /////////////////////////// Lower Panel //////////////////////////////// JPanel lowerPanel = new JPanel(); //JPanel lowerPanel = new FormDebugPanel(); layout = new FormLayout( "d, fill:10dlu:grow, d", // columns "top:p"); //rows layout.setColumnGroups( new int[][]{{1, 3}} ); PanelBuilder lowerBuilder = new PanelBuilder( layout, lowerPanel ); NetFavoritesPanel favoritesPanel = new NetFavoritesPanel(); lowerBuilder.add( favoritesPanel, cc.xy( 1, 1 ) ); JPanel cacheStatusPanel = new JPanel( ); //JPanel cacheStatusPanel = new FormDebugPanel(); layout = new FormLayout( "8dlu, right:d, 2dlu, right:d, 2dlu, d, 2dlu:grow, 8dlu", // columns "p, 3dlu, p, 3dlu, p, 3dlu, bottom:p:grow"); //rows PanelBuilder cacheStatusBuilder = new PanelBuilder( layout, cacheStatusPanel ); lowerBuilder.add( cacheStatusPanel, cc.xy( 3, 1 ) ); cacheStatusBuilder.addSeparator( Localizer.getString( "NetworkTab_ConnectionInfo" ), cc.xywh( 1, 1, 8, 1 ) ); cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_HostCacheContains" ), cc.xy( 2, 3 ) ); catcherStatLabel = new JLabel( ); cacheStatusBuilder.add( catcherStatLabel, cc.xy( 4, 3 ) ); cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_Hosts" ), cc.xy( 6, 3 ) ); cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_GWebCacheContains" ), cc.xy( 2, 5 ) ); gWebCacheStatLabel = new JLabel( ); cacheStatusBuilder.add( gWebCacheStatLabel, cc.xy( 4, 5 ) ); cacheStatusBuilder.addLabel( Localizer.getString( "NetworkTab_Caches" ), cc.xy( 6, 5 ) ); final JButton queryWebCache = new JButton( Localizer.getString( "QueryGWebCache" ) ); queryWebCache.setToolTipText( Localizer.getString( "TTTQueryGWebCache" ) ); queryWebCache.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { queryWebCache.setEnabled( false ); Runnable runner = new Runnable() { public void run() { try { gWebCacheCont.queryMoreHosts( false ); gWebCacheCont.queryMoreGWebCaches( false ); } catch ( Throwable th ) { NLogger.error( NLoggerNames.GLOBAL, th, th ); } finally { queryWebCache.setEnabled( true ); } } }; ThreadPool.getInstance().addJob( runner, "UserGWebCacheQuery-" + Integer.toHexString(runner.hashCode()) ); } } ); cacheStatusBuilder.add( queryWebCache, cc.xywh( 2, 7, 5, 1 ) ); // Workaround for very strange j2se 1.4 split pane layout behaivor /*Dimension nullDim = new Dimension( 0, 0 ); upperPanel.setMinimumSize( nullDim ); lowerPanel.setMinimumSize( nullDim ); Dimension dim = new Dimension( 400, 200 ); upperPanel.setPreferredSize( dim ); lowerPanel.setPreferredSize( dim ); JSplitPane splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, upperPanel, lowerPanel ); splitPane.setBorder( BorderFactory.createEmptyBorder( 4, 4, 4, 4) ); splitPane.setDividerSize( 4 ); splitPane.setOneTouchExpandable( false ); splitPane.setResizeWeight( 0.5 ); splitPane.setDividerLocation( 0.25 );*/ contentBuilder.add( upperElegantPanel, cc.xy( 2, 2 ) ); contentBuilder.add( lowerPanel, cc.xy( 2, 4 ) ); //add(BorderLayout.CENTER, upperPanel ); //add(BorderLayout.SOUTH, lowerPanel ); // Set up cell renderer to provide the correct colour based on connection. NetworkRowRenderer networkRowRenderer = new NetworkRowRenderer(); Enumeration enumr = networkColumnModel.getColumns(); while ( enumr.hasMoreElements() ) { TableColumn column = (TableColumn)enumr.nextElement(); column.setCellRenderer( networkRowRenderer ); } // Setup popup menu... networkPopup = new FWPopupMenu(); FWAction action; action = new DisconnectHostAction(); addTabAction( DISCONNECT_HOST_ACTION_KEY, action ); networkTable.getActionMap().put( DISCONNECT_HOST_ACTION_KEY, action); networkTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( (KeyStroke)action.getValue(FWAction.ACCELERATOR_KEY), DISCONNECT_HOST_ACTION_KEY ); networkPopup.addAction( action ); networkPopup.addSeparator(); action = new AddToFavoritesAction(); addTabAction( ADD_TO_FAVORITES_ACTION_KEY, action ); networkPopup.addAction( action ); action = new BrowseHostAction(); addTabAction( BROWSE_HOST_ACTION_KEY, action ); //networkToolbar.addAction( action ); networkPopup.addAction( action ); action = new ChatToHostAction(); addTabAction( CHAT_TO_HOST_ACTION_KEY, action ); //networkToolbar.addAction( action ); networkPopup.addAction( action ); BanHostActionProvider banHostActionProvider = new BanHostActionProvider(); BanHostActionUtils.BanHostActionMenu bhActionMenu = BanHostActionUtils.createActionMenu( banHostActionProvider ); networkPopup.add( bhActionMenu.menu ); addTabActions( bhActionMenu.actions ); networkPopup.addSeparator(); JMenu netMenu = new JMenu( Localizer.getString( "Network" ) ); netMenu.add( GUIRegistry.getInstance().getGlobalAction( GUIRegistry.CONNECT_NETWORK_ACTION ) ); netMenu.add( GUIRegistry.getInstance().getGlobalAction( GUIRegistry.DISCONNECT_NETWORK_ACTION ) ); /*netMenu.add( GUIRegistry.getInstance().getGlobalAction( GUIRegistry.JOIN_NETWORK_ACTION ) );*/ networkPopup.add( netMenu ); NetworkManager networkMgr = NetworkManager.getInstance(); IPChangedListener ipListener = new IPChangedListener(); ipListener.networkIPChanged( networkMgr.getLocalAddress() ); networkMgr.addNetworkListener( ipListener ); } |
|
gWebCacheStatLabel.setText( String.valueOf( gWebCacheCont.getGWebCacheCount() ) ); | public void refresh() { catcherStatLabel.setText( String.valueOf( hostMgr.getCaughtHostsContainer().getCaughtHostsCount() ) ); gWebCacheStatLabel.setText( String.valueOf( gWebCacheCont.getGWebCacheCount() ) ); networkModel.fireTableDataChanged(); } |
|
throw new IOException("revision check failed"); | throw new IOException("svn info failed"); | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info --xml "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); Digester digester = new Digester(); digester.push(info); digester.addBeanPropertySetter("info/entry/url"); digester.addSetProperties("info/entry/commit","revision","revision"); // set attributes. in particular @revision try { digester.parse(new ByteArrayInputStream(baos.toByteArray())); } catch (SAXException e) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); e.printStackTrace(listener.fatalError("Failed to parse Subversion output")); throw new IOException("Unabled to parse svn info output"); } if(!info.isComplete()) throw new IOException("No revision in the svn info output"); return info; } |
File module = workspace.child(url).getLocal(); | File module = workspace.child(moduleName).getLocal(); | private boolean isUpdatable(FilePath workspace,BuildListener listener) { StringTokenizer tokens = new StringTokenizer(modules); while(tokens.hasMoreTokens()) { String url = tokens.nextToken(); String moduleName = getLastPathComponent(url); File module = workspace.child(url).getLocal(); try { SvnInfo svnInfo = SvnInfo.parse(moduleName, createEnvVarMap(false), workspace, listener); if(!svnInfo.url.equals(url)) { listener.getLogger().println("Checking out a fresh workspace because the workspace is not "+url); return false; } } catch (IOException e) { listener.getLogger().println("Checking out a fresh workspace because Hudson failed to detect the current workspace "+module); e.printStackTrace(listener.error(e.getMessage())); } } return true; } |
return false; | private boolean isUpdatable(FilePath workspace,BuildListener listener) { StringTokenizer tokens = new StringTokenizer(modules); while(tokens.hasMoreTokens()) { String url = tokens.nextToken(); String moduleName = getLastPathComponent(url); File module = workspace.child(url).getLocal(); try { SvnInfo svnInfo = SvnInfo.parse(moduleName, createEnvVarMap(false), workspace, listener); if(!svnInfo.url.equals(url)) { listener.getLogger().println("Checking out a fresh workspace because the workspace is not "+url); return false; } } catch (IOException e) { listener.getLogger().println("Checking out a fresh workspace because Hudson failed to detect the current workspace "+module); e.printStackTrace(listener.error(e.getMessage())); } } return true; } |
|
new Node[]{djep.deepCopy(children[1])})), | new Node[]{djep.deepCopy(children[0])})), | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { OperatorSet op = djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); TreeUtils tu = djep.getTreeUtils(); FunctionTable funTab = djep.getFunctionTable(); int nchild = node.jjtGetNumChildren(); if(nchild!=2) throw new ParseException("Too many children "+nchild+" for "+node+"\n"); // x^y -> n*(pow(x,y-1)) x' + ln(y) pow(x,y) y' if(tu.isConstant(children[1])) { ASTConstant c = (ASTConstant) children[1]; Object value = c.getValue(); if(value instanceof Double) { // x^m -> m * x^(m-1) * x'// Node a = TreeUtils.deepCopy(children[1]);// Node b = TreeUtils.deepCopy(children[0]);// Node cc = TreeUtils.createConstant( ((Double) value).doubleValue()-1.0);// Node d = opSet.buildPowerNode(b,cc);// Node e = opSet.buildMultiplyNode(a,d); return nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[1]), nf.buildOperatorNode(op.getMultiply(), nf.buildOperatorNode(op.getPower(), djep.deepCopy(children[0]), nf.buildConstantNode( tu.getNumber(((Double) value).doubleValue()-1.0))), dchildren[0])); } else { return nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[1]), nf.buildOperatorNode(op.getMultiply(), nf.buildOperatorNode(op.getPower(), djep.deepCopy(children[0]), nf.buildOperatorNode(op.getSubtract(), djep.deepCopy(children[1]), nf.buildConstantNode(tu.getONE()))), dchildren[0])); } } else // z * y^(z-1) * diff(y,x) + y^z * ln(z) * diff(z,x) { return nf.buildOperatorNode(op.getAdd(), nf.buildOperatorNode(op.getMultiply(), // z * y^(z-1) * diff(y,x) nf.buildOperatorNode(op.getMultiply(), // z * y^(z-1) djep.deepCopy(children[1]), // z nf.buildOperatorNode(op.getPower(), // y^(z-1) djep.deepCopy(children[0]), // y nf.buildOperatorNode(op.getSubtract(), // z-1 djep.deepCopy(children[1]), // z djep.getNodeFactory().buildConstantNode(tu.getONE()) ))), dchildren[0]), // diff(y,x) nf.buildOperatorNode(op.getMultiply(), // + y^z * ln(z) * diff(z,x) nf.buildOperatorNode(op.getMultiply(), nf.buildOperatorNode(op.getPower(), // y^z djep.deepCopy(children[0]), djep.deepCopy(children[1])), djep.getNodeFactory().buildFunctionNode("ln",funTab.get("ln"), // ln(z) new Node[]{djep.deepCopy(children[1])})), dchildren[1])); // TODO will NaturalLog always have the name "ln" } } |
for (Fingerprint e : f.getFingerprints().values()) if(e.getOriginal().is(this)) | for (Fingerprint e : f.getFingerprints().values()) { BuildPtr o = e.getOriginal(); if(o!=null && o.is(this)) | public RangeSet getDownstreamRelationship(Project that) { RangeSet rs = new RangeSet(); FingerprintAction f = getAction(FingerprintAction.class); if(f==null) return rs; // look for fingerprints that point to this build as the source, and merge them all for (Fingerprint e : f.getFingerprints().values()) if(e.getOriginal().is(this)) rs.add(e.getRangeSet(that)); return rs; } |
} | public RangeSet getDownstreamRelationship(Project that) { RangeSet rs = new RangeSet(); FingerprintAction f = getAction(FingerprintAction.class); if(f==null) return rs; // look for fingerprints that point to this build as the source, and merge them all for (Fingerprint e : f.getFingerprints().values()) if(e.getOriginal().is(this)) rs.add(e.getRangeSet(that)); return rs; } |
|
if(o.is(that)) | if(o!=null && o.is(that)) | public int getUpstreamRelationship(Project that) { FingerprintAction f = getAction(FingerprintAction.class); if(f==null) return -1; // look for fingerprints that point to the given project as the source, and merge them all for (Fingerprint e : f.getFingerprints().values()) { BuildPtr o = e.getOriginal(); if(o.is(that)) return o.getNumber(); } return -1; } |
props.putAll(getProperties()); | for (Map.Entry o : ((Map<?,?>)getProperties()).entrySet()) { if(o.getValue()!=null) props.put(o.getKey(),o.getValue()); } | public Session createSession() { Properties props = new Properties(System.getProperties()); props.putAll(getProperties()); return Session.getInstance(props); } |
this.opSet=(MatrixOperatorSet) mdjep.getOperatorSet(); | public MatrixNodeI preprocess(Node node,MatrixJep mdjep) throws ParseException { this.mjep=mdjep; this.nf=(MatrixNodeFactory) mdjep.getNodeFactory(); this.vt=(DSymbolTable) mdjep.getSymbolTable(); this.opSet=(MatrixOperatorSet) mdjep.getOperatorSet(); return (MatrixNodeI) node.jjtAccept(this,null); } |
|
children[i] = (MatrixNodeI) no; | children[i] = no; | public MatrixNodeI[] visitChildrenAsArray(Node node,Object data) throws ParseException { int nchild = node.jjtGetNumChildren(); MatrixNodeI children[] = new MatrixNodeI[nchild]; for(int i=0;i<nchild;++i) {// System.out.println("vcaa "+i+" "+node.jjtGetChild(i)); MatrixNodeI no = (MatrixNodeI) node.jjtGetChild(i).jjtAccept(this,data);// System.out.println("vcaa "+i+" "+node.jjtGetChild(i)+" done "+no); children[i] = (MatrixNodeI) no; } return children; } |
dims[i]=((MatrixNodeI) children[i]).getDim(); | dims[i]=children[i].getDim(); | public Object visitOp(ASTFunNode node, Object data) throws ParseException { PostfixMathCommandI pfmc=node.getPFMC(); MatrixNodeI children[] = visitChildrenAsArray(node,data); if(pfmc instanceof BinaryOperatorI) { if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); BinaryOperatorI bin = (BinaryOperatorI) pfmc; Dimensions dim = bin.calcDim(children[0].getDim(),children[1].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof UnaryOperatorI) { if(children.length!=1) throw new ParseException("Operator "+node.getOperator().getName()+" must have one elements, it has "+children.length); UnaryOperatorI uni = (UnaryOperatorI) pfmc; Dimensions dim = uni.calcDim(children[0].getDim()); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else if(pfmc instanceof NaryOperatorI) { Dimensions dims[] = new Dimensions[children.length]; for(int i=0;i<children.length;++i) dims[i]=((MatrixNodeI) children[i]).getDim(); NaryOperatorI uni = (NaryOperatorI) pfmc; Dimensions dim = uni.calcDim(dims); return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } else { //throw new ParseException("Operator must be unary or binary. It is "+op); Dimensions dim = Dimensions.ONE; return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,dim); } } |
Search search = ((SearchButton)e.getSource()).getSearch(); | Search search = searchButton.getSearch(); | public void actionPerformed(ActionEvent e) { try { searchTab.refreshTabActions(); Search search = ((SearchButton)e.getSource()).getSearch(); if ( search == null ) { return; } SearchResultsDataModel dataModel = SearchResultsDataModel.lookupResultDataModel( search ); searchTab.setDisplayedSearch( dataModel ); } catch ( Exception exp) {// catch all handler NLogger.error( NLoggerNames.USER_INTERFACE, exp, exp ); } } |
if ( updateDisplayTimer == null ) { updateDisplayTimer = new Timer( 2000, new UpdateButtonsTimerAction()); } updateDisplayTimer.start(); | public void addNotify() { super.addNotify(); searchContainer.addSearchListChangeListener( this ); } |
|
if( updateDisplayTimer != null ) { updateDisplayTimer.stop(); updateDisplayTimer = null; } | public void removeNotify() { super.removeNotify(); searchContainer.removeSearchListChangeListener( this ); } |
|
searchButtonMap.put(search, btn); searchButtonGroup.add(btn); addButton( btn ); | synchronized ( accessLock ) { searchButtonMap.put(search, btn); searchButtonGroup.add(btn); addButton( btn ); } | public void searchAdded( Search search, int position ) { SearchButton btn = new SearchButton( search ); btn.addActionListener( buttonHandler ); searchButtonMap.put(search, btn); searchButtonGroup.add(btn); addButton( btn ); if ( displayedDataModel != null && search == displayedDataModel.getSearch() ) {// select the button of the displayed model btn.setSelected(true); } } |
searchButtonGroup.remove( btn ); removeButton( btn ); | synchronized ( accessLock ) { searchButtonGroup.remove( btn ); removeButton( btn ); } | public void searchRemoved( Search search, int position ) { SearchButton btn = (SearchButton) searchButtonMap.remove(search); searchButtonGroup.remove( btn ); removeButton( btn ); } |
if (param instanceof Number) { | if (param instanceof Complex) { return new Double(((Complex)param).arg()); } else if (param instanceof Number) { | public Number arg(Object param) throws ParseException { if (param instanceof Number) { return (ONE); } else if (param instanceof Complex) { return new Double(((Complex)param).arg()); } throw new ParseException("Invalid parameter type"); } |
} else if (param instanceof Complex) { return new Double(((Complex)param).arg()); } | } | public Number arg(Object param) throws ParseException { if (param instanceof Number) { return (ONE); } else if (param instanceof Complex) { return new Double(((Complex)param).arg()); } throw new ParseException("Invalid parameter type"); } |
if(!this.author.equals(that.author)) | if(this.author==null || that.author==null || !this.author.equals(that.author)) | public boolean canBeMergedWith(CVSChangeLog that) { if(!this.date.equals(that.date)) return false; if(!this.time.equals(that.time)) // TODO: perhaps check this loosely? return false; if(!this.author.equals(that.author)) return false; if(!this.msg.equals(that.msg)) return false; return true; } |
digester.addBeanPropertySetter("*/entry/author"); | digester.addBeanPropertySetter("*/entry/author","user"); | public static CVSChangeLogSet parse( java.io.File f ) throws IOException, SAXException { Digester digester = new Digester(); ArrayList<CVSChangeLog> r = new ArrayList<CVSChangeLog>(); digester.push(r); digester.addObjectCreate("*/entry",CVSChangeLog.class); digester.addBeanPropertySetter("*/entry/date"); digester.addBeanPropertySetter("*/entry/time"); digester.addBeanPropertySetter("*/entry/author"); digester.addBeanPropertySetter("*/entry/msg"); digester.addSetNext("*/entry","add"); digester.addObjectCreate("*/entry/file",File.class); digester.addBeanPropertySetter("*/entry/file/name"); digester.addBeanPropertySetter("*/entry/file/revision"); digester.addBeanPropertySetter("*/entry/file/prevrevision"); digester.addCallMethod("*/entry/file/dead","setDead"); digester.addSetNext("*/entry/file","addFile"); digester.parse(f); // merge duplicate entries. Ant task somehow seems to report duplicate entries. for(int i=r.size()-1; i>=0; i--) { CVSChangeLog log = r.get(i); boolean merged = false; for(int j=0;j<i;j++) { CVSChangeLog c = r.get(j); if(c.canBeMergedWith(log)) { c.merge(log); merged = true; break; } } if(merged) r.remove(log); } return new CVSChangeLogSet(r); } |
if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); | if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) { errorOutput.write(msg); errorOutput.write('\n'); } | private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } } |
task.setDir(build.getProject().getWorkspace().getLocal()); | File baseDir = build.getProject().getWorkspace().getLocal(); task.setDir(baseDir); | private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } } |
if(changedFiles!=null) task.setFile(changedFiles); else { | if(changedFiles!=null) { for (String filePath : changedFiles) { if(new File(baseDir,filePath).getParentFile().exists()) task.addFile(filePath); } } else { | private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } } |
listener.getLogger().print(errorOutput); | private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } } |
|
if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); | if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) { errorOutput.write(msg); errorOutput.write('\n'); } | public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } |
public int compare( Object obj1, Object obj2 ) | public int compare( SWDownloadCandidate candidate1, SWDownloadCandidate candidate2 ) | public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } } |
if ( obj1 == obj2 || obj1.equals(obj2) ) | if ( candidate1 == candidate2 || candidate1.equals(candidate2) ) | public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } } |
SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; | public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } } |
|
Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) | for ( SWDownloadCandidate altCandidate : queuedCandidatesSet ) | public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } } |
SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); | public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } } |
|
candidate = (SWDownloadCandidate)badCandidatesList.get(currentIndex); | candidate = badCandidatesList.get(currentIndex); | private SWDownloadCandidate allocateBadCandidate( SWDownloadWorker worker ) { SWDownloadCandidate candidate = null; synchronized( candidatesLock ) { int numCandidates = badCandidatesList.size(); // return quickly if there are no candidates if ( numCandidates == 0 ) { return null; } // sanity check on persistent index, because since the last call to this method, // the number of candidates may have decreased, leaving the persistent index // out of range. if ( badCandidatePosition >= numCandidates ) { badCandidatePosition = 0; } // Iterate over candidates to find the next available for (int i=0; i < numCandidates; i++) { // currentIndex holds the index of the candidate that will be // checked for availability int currentIndex = i + badCandidatePosition; if (currentIndex >= numCandidates) { currentIndex -= numCandidates; } candidate = (SWDownloadCandidate)badCandidatesList.get(currentIndex); if ( candidate.isAbleToBeAllocated() && !allocatedCandidateWorkerMap.containsKey( candidate ) ) { NLogger.debug( NLoggerNames.Download_Candidate_Allocate, "Allocating bad candidate " + candidate + " from " + worker ); candidate.addToCandidateLog("Allocating as bad candidate."); // Sets the segment to be allocated by a worker. allocatedCandidateWorkerMap.put( candidate, worker ); badCandidatePosition = currentIndex + 1; return candidate; } } } // No valid candidate found // Don't bother updating the persistent index, because it probably // doesn't matter where we begin the search from on the next call. return null; } |
return memoryFile.allocateMissingScopeForCandidate( this, candidateScopeList, | return memoryFile.allocateMissingScopeForCandidate( candidateScopeList, | private DownloadScope allocateSegmentForRangeSet( DownloadScopeList candidateScopeList, long preferredSize) { assert fileSize != UNKNOWN_FILE_SIZE : "Cant allocate segment for range set with unknown end."; NLogger.debug( NLoggerNames.Download_Segment_Allocate, "allocateSegmentForRangeSet() size: " + preferredSize); if( candidateScopeList == null ) { // create scope covering the whole file. candidateScopeList = new DownloadScopeList(); candidateScopeList.add( new DownloadScope( 0, fileSize - 1 ) ); } return memoryFile.allocateMissingScopeForCandidate( this, candidateScopeList, preferredSize ); } |
xjbFile.setIncompleteFileName( incompleteFile.getAbsolutePath() ); | if ( incompleteFile != null ) { xjbFile.setIncompleteFileName( incompleteFile.getAbsolutePath() ); } | public XJBSWDownloadFile createXJBSWDownloadFile() throws JAXBException { ObjectFactory objFactory = new ObjectFactory(); XJBSWDownloadFile xjbFile = objFactory.createXJBSWDownloadFile(); xjbFile.setLocalFileName( destinationFile.getName() ); xjbFile.setIncompleteFileName( incompleteFile.getAbsolutePath() ); xjbFile.setFileSize( fileSize ); xjbFile.setSearchTerm( researchSetting.getSearchTerm() ); xjbFile.setCreatedTime( createdDate.getTime() ); xjbFile.setModifiedTime( modifiedDate.getTime() ); if ( fileURN != null ) { xjbFile.setFileURN( fileURN.getAsString() ); } xjbFile.setStatus( status ); synchronized ( candidatesLock ) { List list = xjbFile.getCandidateList(); Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = mediumCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = badCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getStatus() == CandidateStatus.IGNORED ) { continue; } XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } } memoryFile.createXJBFinishedScopes(xjbFile); return xjbFile; } |
return (SWDownloadCandidate) allCandidatesList.get( index ); | return allCandidatesList.get( index ); | public SWDownloadCandidate getCandidate( int index ) { if ( index < 0 || index >= allCandidatesList.size() ) { return null; } return (SWDownloadCandidate) allCandidatesList.get( index ); } |
return memoryFile.getRatedScopeList( this ); | return memoryFile.getRatedScopeList( ); | public RatedDownloadScopeList getRatedScopeList() { return memoryFile.getRatedScopeList( this ); } |
return (SWDownloadCandidate)transferCandidatesList.get( index ); | return transferCandidatesList.get( index ); | public SWDownloadCandidate getTransferCandidate( int index ) { if ( index < 0 || index >= transferCandidatesList.size() ) { return null; } return (SWDownloadCandidate)transferCandidatesList.get( index ); } |
Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) | for ( SWDownloadCandidate candidate : goodCandidatesList ) | public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } } |
SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); | public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } } |
|
Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) | for ( SWDownloadCandidate candidate : transferCandidatesList ) | private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } } |
SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) | CandidateStatus candStatus = candidate.getStatus(); switch ( candStatus ) | private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } } |
memoryFile.writeBuffersToDisk(); | memoryFile.requestBufferWriting(); | public void verifyStatus() { forceCollectionOfTransferData(); synchronized( candidatesLock ) { if ( !isFileCompletedOrMoved() && memoryFile.getFinishedBufferedLength() == getTotalDataSize() ) { // trigger data write down to disk... // this will also adjust the status in case file really turns // out to be complete memoryFile.writeBuffersToDisk(); return; } SWDownloadCandidate candidate; Iterator iterator = allocatedCandidateWorkerMap.keySet().iterator(); CandidateStatus highestStatus = CandidateStatus.WAITING; while ( iterator.hasNext() && highestStatus != CandidateStatus.DOWNLOADING) { candidate = (SWDownloadCandidate)iterator.next(); switch ( candidate.getStatus() ) { case DOWNLOADING: { highestStatus = CandidateStatus.DOWNLOADING; break; } case REMOTLY_QUEUED: { highestStatus = CandidateStatus.REMOTLY_QUEUED; break; } } } // when we are here no download is running... // we dont need to set status if file is stopped or completed if ( !isDownloadStopped() && !isFileCompletedOrMoved() ) { switch ( highestStatus ) { case REMOTLY_QUEUED: setStatus( STATUS_FILE_QUEUED ); break; case DOWNLOADING: setStatus( STATUS_FILE_DOWNLOADING ); break; default: setStatus( STATUS_FILE_WAITING ); break; } } } } |
public DownloadScope allocateMissingScopeForCandidate( SWDownloadFile downloadFile, DownloadScopeList candidateScopeList, long preferredSize ) | public DownloadScope allocateMissingScopeForCandidate( DownloadScopeList candidateScopeList, long preferredSize ) | public DownloadScope allocateMissingScopeForCandidate( SWDownloadFile downloadFile, DownloadScopeList candidateScopeList, long preferredSize ) { synchronized( missingScopeList ) { DownloadScopeList wantedScopeList = (DownloadScopeList)missingScopeList.clone(); wantedScopeList.addAll( missingScopeList ); wantedScopeList.retainAll( candidateScopeList ); if ( wantedScopeList.size() == 0 ) { return null; } DownloadScope scope = scopeSelectionStrategy.selectDownloadScope( downloadFile, wantedScopeList, preferredSize ); if ( scope == null ) { return null; } missingScopeList.remove( scope ); synchronized( blockedScopeList ) { blockedScopeList.add( scope ); } return scope; } } |
public List getFinishedScopeListCopy() | public List<DownloadScope> getFinishedScopeListCopy() | public List getFinishedScopeListCopy() { return finishedScopeList.getScopeListCopy(); } |
public RatedDownloadScopeList getRatedScopeList( SWDownloadFile downloadFile ) | public RatedDownloadScopeList getRatedScopeList() | public RatedDownloadScopeList getRatedScopeList( SWDownloadFile downloadFile ) { long now = System.currentTimeMillis(); if ( ratedScopeListBuildTime + SWDownloadConstants.RATED_SCOPE_LIST_TIMEOUT > now ) { return ratedScopeList; } if ( ratedScopeList == null ) { ratedScopeList = new RatedDownloadScopeList(); } else { ratedScopeList.clear(); } ratedScopeList.addAll( missingScopeList ); downloadFile.rateDownloadScopeList( ratedScopeList ); ratedScopeListBuildTime = System.currentTimeMillis(); return ratedScopeList; } |
isBufferWritingRequested = false; | public MemoryFile( SWDownloadFile downloadFile ) { this.downloadFile = downloadFile; missingScopeList = new DownloadScopeList(); blockedScopeList = new DownloadScopeList(); bufferedDataScopeList = new ArrayList<DataDownloadScope>(); //bufferedScopeList = new DownloadScopeList(); finishedScopeList = new DownloadScopeList(); long fileSize = downloadFile.getTotalDataSize(); if ( fileSize == SWDownloadConstants.UNKNOWN_FILE_SIZE ) { missingScopeList.add( new DownloadScope( 0, Long.MAX_VALUE ) ); } else { missingScopeList.add( new DownloadScope( 0, fileSize - 1 ) ); } scopeSelectionStrategy = ScopeSelectionStrategyProvider.getAvailBeginRandSelectionStrategy(); } |
|
bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); | bytesPerWindow = Math.max( (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS), 1 ) ; | public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); } |
bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); | bytesRemaining = bytesRemaining < bytesPerWindow ? Math.min( bytesRemaining, bytesPerWindow ) : bytesRemaining; | public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); } |
public Host(DestAddress address, Connection connection) | public Host() | public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; } |
this(); hostAddress = address; this.connection = connection; | hostsContainer = HostManager.getInstance().getNetworkHostsContainer(); connection = null; status = HostStatus.NOT_CONNECTED; type = TYPE_OUTGOING; mHasWorker = false; isConnectionStable = false; connectionType = CONNECTION_NORMAL; isQueryRoutingSupported = false; isUPQueryRoutingSupported = false; isDynamicQuerySupported = false; isVendorMessageSupported = false; mReceivedCount = 0; mSentCount = 0; mDropCount = 0; maxTTL = DynamicQueryConstants.DEFAULT_MAX_TTL; hopsFlowLimit = -1; | public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; } |
public Object sqrt(Object param) throws ParseException { | public Object sqrt(Object param) throws ParseException { if (param instanceof Complex) return ((Complex)param).sqrt(); | public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); } |
if (value < 0) { | if (value < 0.0) { | public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); } |
} else if (param instanceof Complex) { return ((Complex)param).sqrt(); | public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); } |
|
req.setCharacterEncoding("UTF-8"); | public static void doTrackback( Object it, StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { String title = req.getParameter("title"); String url = req.getParameter("url"); String excerpt = req.getParameter("excerpt"); String blog_name = req.getParameter("blog_name"); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setContentType("application/xml; charset=UTF-8"); PrintWriter pw = rsp.getWriter(); pw.println("<response>"); pw.println("<error>"+(url!=null?0:1)+"</error>"); if(url==null) { pw.println("<message>url must be specified</message>"); } pw.println("</response>"); pw.close(); } |
|
public void println(Node node) { println(node,System.out); } | public void println(Node node,PrintStream out) { print(node,out); out.println(""); } | public void println(Node node) { println(node,System.out); } |
if(subdirs==null) throw new IOException("Unable to create "+projectsDir+"\nPermission issue?"); | private void load() throws IOException { XmlFile cfg = getConfigFile(); if(cfg.exists()) cfg.unmarshal(this); File projectsDir = new File(root,"jobs"); projectsDir.mkdirs(); File[] subdirs = projectsDir.listFiles(new FileFilter() { public boolean accept(File child) { return child.isDirectory(); } }); jobs.clear(); for (File subdir : subdirs) { try { Job p = Job.load(this,subdir); jobs.put(p.getName(), p); } catch (IOException e) { e.printStackTrace(); // TODO: logging } } } |
|
public Recipe getRecipe() {return r;} | public Recipe getRecipe() { r.setAllowRecalcs(true); return r;} | public Recipe getRecipe() {return r;} |
r.setAllowRecalcs(false); | public void startElement(String namespaceURI, String lName, // local unit String qName, // qualified unit Attributes attrs) throws SAXException { String eName = lName; // element unit if ("".equals(eName)) eName = qName; // namespaceAware = false currentElement = eName; currentAttributes = attrs; if (eName.equalsIgnoreCase("STRANGEBREWRECIPE")) { importType = "STRANGEBREW"; r = new Recipe(); emit("StrangeBrew recipe detected."); } else if (eName.equalsIgnoreCase("RECIPE")) { if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String s = attrs.getLocalName(i); // Attr name if ("".equalsIgnoreCase(s)) s = attrs.getQName(i); if (s.equalsIgnoreCase("generator")&& "qbrew".equalsIgnoreCase(attrs.getValue(i))){ importType = "QBREW"; r = new Recipe(); emit("QBrew recipe detected."); } } } } else if (importType == "STRANGEBREW") { // call SB start element sbStartElement(eName); } else if (importType == "QBREW") { // call SB start element qbStartElement(eName); } } |
|
public ServiceFactoryComponent(Config config, Dictionary overriddenProps) { super(config, overriddenProps); services = new Hashtable(); } | public ServiceFactoryComponent(Config config, Dictionary overriddenProps) { super(config, overriddenProps); } | public ServiceFactoryComponent(Config config, Dictionary overriddenProps) { super(config, overriddenProps); services = new Hashtable(); } |
Object service = services.get(bundle); | Component component = services.get(bundle); | public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; } |
if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); | if (component == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); component = copy.createComponent(); component.enable(); services.put(bundle, component); } return component.getService(bundle, reg); | public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; } |
return service; } | public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; } |
|
public void ungetService(Bundle bundle, ServiceRegistration reg, Object instance) { super.ungetService(bundle, reg, instance); services.remove(bundle); } | public void ungetService(Bundle bundle, ServiceRegistration reg, Object instance) { super.ungetService(bundle, reg, instance); Component component = services.remove(bundle); if (component != null) { component.ungetService(bundle, reg, instance); component.disable(); } } | public void ungetService(Bundle bundle, ServiceRegistration reg, Object instance) { super.ungetService(bundle, reg, instance); services.remove(bundle); } |
String encodedUrl = null; try { encodedUrl = URLEncoder.encode(build.getUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); } buf.append("See ").append(baseUrl).append(encodedUrl).append("\n\n"); | buf.append("See ").append(baseUrl).append(build.getUrl()).append("\n\n"); | private void appendBuildUrl(Build build, StringBuffer buf) { String baseUrl = DESCRIPTOR.getUrl(); if(baseUrl!=null) { String encodedUrl = null; try { encodedUrl = URLEncoder.encode(build.getUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // UTF-8 is supported everywhere } buf.append("See ").append(baseUrl).append(encodedUrl).append("\n\n"); } } |
Object val = Scaler.getInstance(lhs.getEle(0)); | Object val = lhs.getEle(0); | public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs) throws ParseException { if(!(res instanceof Scaler)) throw new ParseException("vsum: result must be a scaler"); Object val = Scaler.getInstance(lhs.getEle(0)); for(int i=1;i<lhs.getNumEles();++i) val = add.add(val,lhs.getEle(i)); res.setEle(0,val); return res; } |
public Comparator getColumnComparator( int column ) | public Comparator<?> getColumnComparator( int column ) | public Comparator getColumnComparator( int column ) { switch( column ) { case HOST_MODEL_INDEX: return new DestAddressComparator(); case PROGRESS_MODEL_INDEX: return ComparableComparator.getInstance(); // for all other columns use default comparator default: return null; } } |
return ""; | return null; | public Object getComparableValueAt( int row, int column ) { SWDownloadCandidate candidate = downloadFile.getCandidate( row ); if ( candidate == null ) { return ""; } switch( column ) { case PROGRESS_MODEL_INDEX: { DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { return null; } return new Long( availableScopeList.getAggregatedLength() ); } case TOTAL_DOWNLOAD_MODEL_INDEX: return new Long( candidate.getTotalDownloadSize() ); case STATUS_MODEL_INDEX: CandidateStatus status = candidate.getStatus(); if ( status == CandidateStatus.REMOTLY_QUEUED ) { int queuePosition = candidate.getXQueueParameters().getPosition().intValue(); Double doubObj = new Double( status.ordinal() + 1.0 - Math.min( (double)queuePosition, (double)10000 ) / 10000.0 ); return doubObj; } else { long timeLeft = candidate.getStatusTimeLeft(); double val; if ( timeLeft == 0 ) { val = status.ordinal(); } else {// timeLeft is not 0.. checked above.. val = status.ordinal() - 1.0 + 1 / (double)timeLeft; } return new Double( val ); } case RATE_MODEL_INDEX: { SWDownloadSegment segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTransferSpeed() ); } } return getValueAt( row, column ); } |
if (param instanceof Number) | if (param instanceof Complex) { return new Double(((Complex)param).abs()); } else if (param instanceof Number) | public Object abs(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); } |
} else if (param instanceof Complex) { return new Double(((Complex)param).abs()); | public Object abs(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); } |
|
int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); | int toUse = controller.getAvailableByteCount( 1000, true, false ); | public void testRandThroughput() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); Thread.sleep( (long)(Math.random() * 1000.0) ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); } |
int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); | int toUse = controller.getAvailableByteCount( 1000, true, false ); | public void testThroughput2() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); } |
public synchronized void doArtifact( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { | public void doArtifact( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { | public synchronized void doArtifact( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { serveFile(req, rsp, getArtifactsDir(), "package.gif", true); } |
myRecipeNavigationGroup.dispose(); | public void dispose() { myFolder.dispose(); myDisplay.dispose(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.