public void createProcess( File working_dirctory, String[] command, String[] env ) throws PluginException { try{ GeneralUtils.createProcessBuilder( working_dirctory, command, env ).start(); }catch( Throwable f ){ throw( new PluginException("Failed to create process", f )); } }
public void update( int tick_count ) { peak_receive_rate = Math.max( peak_receive_rate, data_receive_speed.getAverage()); peak_send_rate = Math.max( peak_send_rate, data_send_speed.getAverage()); if ( tick_count % current_smoothing_interval == 0 ){ int current_window = GeneralUtils.getSmoothUpdateWindow(); if ( current_smoothing_window != current_window ){ current_smoothing_window = current_window; current_smoothing_interval = GeneralUtils.getSmoothUpdateInterval(); smoothed_receive_rate = GeneralUtils.getSmoothAverage(); smoothed_send_rate = GeneralUtils.getSmoothAverage(); } long up = total_data_bytes_sent; long down = total_data_bytes_received; smoothed_send_rate.update( up - smooth_last_sent ); smoothed_receive_rate.update( down - smooth_last_received ); smooth_last_sent = up; smooth_last_received = down; } } }
@Override public UPnPSpecificService getSpecificService() { if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANIPConnection:")){ return( new UPnPSSWANIPConnectionImpl( this )); }else if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANPPPConnection:")){ return( new UPnPSSWANPPPConnectionImpl( this )); }else if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")){ return( new UPnPSSWANCommonInterfaceConfigImpl( this )); }else if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:VuzeOfflineDownloaderService:")){ return( new UPnPSSOfflineDownloaderImpl( this )); }else{ return( null ); } }
private boolean getStringLiteral( Object[] args, int index ) { Object _arg = args[index]; if ( _arg instanceof String ){ String arg = (String)_arg; if ( GeneralUtils.startsWithDoubleQuote( arg ) && GeneralUtils.endsWithDoubleQuote( arg )){ args[index] = arg.substring( 1, arg.length() - 1 ); return( true ); } } return( false ); }
/** * Creates an auto-updating immediate moving average that will auto-deactivate average maintenance * when values are not being extracted from it, auto-reactivate when required etc. * @param periods * @param adapter * @param instance * @return */ public static <T> long LazySmoothMovingImmediateAverage( final LazyMovingImmediateAverageAdapter<T> adapter, final T instance ) { int update_window = GeneralUtils.getSmoothUpdateWindow(); int update_interval = GeneralUtils.getSmoothUpdateInterval(); return( LazyMovingImmediateAverage( update_window / update_interval, update_interval, adapter, instance )); }
int[] smoothed_recv = new int[history_secs]; MovingImmediateAverage send_average = GeneralUtils.getSmoothAverage(); MovingImmediateAverage recv_average = GeneralUtils.getSmoothAverage(); int smooth_interval = GeneralUtils.getSmoothUpdateInterval();
@Override public String getPlainText() { return GeneralUtils.stripOutHyperlinks(text); }
if ( GeneralUtils.startsWithDoubleQuote( value )){ if ( GeneralUtils.isDoubleQuote( c )){ if ( GeneralUtils.startsWithDoubleQuote( p )){
public static boolean startsWithDoubleQuote( String str ) { return( !str.isEmpty() && isDoubleQuote( str.charAt(0))); }
public static void main(String[] args ) { System.out.println( getUnitMultiplier( "e", false )); System.out.println( getUnitMultiplier( "e", true )); System.out.println( getUnitMultiplier( "pb", false )); System.out.println( getUnitMultiplier( "pb", true )); System.out.println( getUnitMultiplier( "pib", false )); System.out.println( getUnitMultiplier( "pib", true )); } }
i18n[0] = "cmd"; i18n[1] = "/C"; i18n[2] = escapeDosCmd(cmd[0]); for (int counter = 1; counter < cmd.length; counter++) { if (cmd[counter].length() == 0) {
@Override public void cellHover(TableCell cell) { if (cell.getToolTip() != null) { return; } if (!(cell instanceof TableCellSWT)) { return; } if (!Utils.isThisThreadSWT()) { System.err.println("you broke it"); return; } GC gc = new GC(Display.getDefault()); try { GCStringPrinter sp = setupStringPrinter(gc, (TableCellSWT) cell); if (sp.isCutoff()) { cell.setToolTip(GeneralUtils.stripOutHyperlinks(sp.getText())); } } catch (Throwable t) { Debug.out(t); } finally { gc.dispose(); } }
if ( GeneralUtils.startsWithDoubleQuote( str ) && GeneralUtils.endsWithDoubleQuote( str )){
public static boolean endsWithDoubleQuote( String str ) { int len = str.length(); return( len > 0 && isDoubleQuote( str.charAt(len-1))); }
public void setSizeFromHTML(String size) { if(size != null) { size = removeHTMLTags(size); String sizeS = Entities.HTML40.unescape(size).replace((char)160,(char)32); sizeS = sizeS.replaceAll("<[^>]+>", " "); //Add a space between the digits and unit if there is none sizeS = sizeS.replaceFirst("(\\d)([a-zA-Z])", "$1 $2"); try { StringTokenizer st = new StringTokenizer(sizeS," "); double base = Double.parseDouble(st.nextToken()); String unit = "b"; try { unit = st.nextToken().toLowerCase(); } catch(Throwable e) { //No unit } // dunno why this code always uses binary but I just replicated how it worked when abstracting long multiplier = GeneralUtils.getUnitMultiplier( unit, true ); if ( multiplier <= 0 ){ multiplier= 1; // ignore invalid } this.size = (long) (base * multiplier ); } catch(Throwable e) { //e.printStackTrace(); } } }
int current_window = GeneralUtils.getSmoothUpdateWindow(); current_smoothing_interval = GeneralUtils.getSmoothUpdateInterval(); smoothed_receive_rate = GeneralUtils.getSmoothAverage(); smoothed_send_rate = GeneralUtils.getSmoothAverage();
if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANIPConnection:") || GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANPPPConnection:")){ }else if ( GeneralUtils.startsWithIgnoreCase( service_type, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")){
ProcessBuilder pb = GeneralUtils.createProcessBuilder( file.getParentFile(), new String[] { "open", ProcessBuilder pb = GeneralUtils.createProcessBuilder( file.getParentFile(), new String[]{ exe, file.getName()}, null );
if ( GeneralUtils.isDoubleQuote( c )){
long multiplier = GeneralUtils.getUnitMultiplier( unit, false );