idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
16,800 | public static OpenCycUnsupportedFeatureException fromThrowable ( Throwable cause ) { return ( cause instanceof OpenCycUnsupportedFeatureException ) ? ( OpenCycUnsupportedFeatureException ) cause : new OpenCycUnsupportedFeatureException ( cause ) ; } | Converts a Throwable to a OpenCycUnsupportedFeatureException . If the Throwable is a OpenCycUnsupportedFeatureException it will be passed through unmodified ; otherwise it will be wrapped in a new OpenCycUnsupportedFeatureException . |
16,801 | public static OpenCycUnsupportedFeatureException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof OpenCycUnsupportedFeatureException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( OpenCycUnsupportedFeatureException ) cause : new OpenCycUnsupportedFeatureException ( message , cause ) ; } | Converts a Throwable to a OpenCycUnsupportedFeatureException with the specified detail message . If the Throwable is a OpenCycUnsupportedFeatureException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new OpenCycUnsupportedFeatureException with the detail message . |
16,802 | public static CreateException fromThrowable ( Throwable cause ) { return ( cause instanceof CreateException ) ? ( CreateException ) cause : new CreateException ( cause ) ; } | Converts a Throwable to a CreateException . If the Throwable is a CreateException it will be passed through unmodified ; otherwise it will be wrapped in a new CreateException . |
16,803 | public static CreateException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof CreateException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( CreateException ) cause : new CreateException ( message , cause ) ; } | Converts a Throwable to a CreateException with the specified detail message . If the Throwable is a CreateException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new CreateException with the detail message . |
16,804 | public static SessionManagerConfigurationException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionManagerConfigurationException ) ? ( SessionManagerConfigurationException ) cause : new SessionManagerConfigurationException ( cause ) ; } | Converts a Throwable to a SessionManagerConfigurationException . If the Throwable is a SessionManagerConfigurationException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionManagerConfigurationException . |
16,805 | public static SessionManagerConfigurationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionManagerConfigurationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionManagerConfigurationException ) cause : new SessionManagerConfigurationException ( message , cause ) ; } | Converts a Throwable to a SessionManagerConfigurationException with the specified detail message . If the Throwable is a SessionManagerConfigurationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionManagerConfigurationException with the detail message . |
16,806 | private static boolean isAPortOffset ( int offset ) { return ( offset == STANDARD_ASCII_PORT_OFFSET ) || ( offset == STANDARD_HTTP_PORT_OFFSET ) || ( offset == STANDARD_SERVLET_PORT_OFFSET ) || ( offset == STANDARD_CFASL_PORT_OFFSET ) ; } | Tests whether an int is a known port offset . |
16,807 | public static SessionCommandException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionCommandException ) ? ( SessionCommandException ) cause : new SessionCommandException ( cause ) ; } | Converts a Throwable to a SessionCommandException . If the Throwable is a SessionCommandException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionCommandException . |
16,808 | public static SessionCommandException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionCommandException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionCommandException ) cause : new SessionCommandException ( message , cause ) ; } | Converts a Throwable to a SessionCommandException with the specified detail message . If the Throwable is a SessionCommandException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionCommandException with the detail message . |
16,809 | public static UnsupportedCycOperationException fromThrowable ( Throwable cause ) { return ( cause instanceof UnsupportedCycOperationException ) ? ( UnsupportedCycOperationException ) cause : new UnsupportedCycOperationException ( cause ) ; } | Converts a Throwable to a UnsupportedCycOperationException . If the Throwable is a UnsupportedCycOperationException it will be passed through unmodified ; otherwise it will be wrapped in a new UnsupportedCycOperationException . |
16,810 | public static UnsupportedCycOperationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof UnsupportedCycOperationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( UnsupportedCycOperationException ) cause : new UnsupportedCycOperationException ( message , cause ) ; } | Converts a Throwable to a UnsupportedCycOperationException with the specified detail message . If the Throwable is a UnsupportedCycOperationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new UnsupportedCycOperationException with the detail message . |
16,811 | public static void unregisterActivityLifecycleCallbacks ( Application application , ActivityLifecycleCallbacksCompat callback ) { if ( PRE_ICS ) { preIcsUnregisterActivityLifecycleCallbacks ( callback ) ; } else { postIcsUnregisterActivityLifecycleCallbacks ( application , callback ) ; } } | Unregisters a previously registered callback . |
16,812 | public static SessionRuntimeException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionRuntimeException ) ? ( SessionRuntimeException ) cause : new SessionRuntimeException ( cause ) ; } | Converts a Throwable to a SessionRuntimeException . If the Throwable is a SessionRuntimeException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionRuntimeException . |
16,813 | public static SessionRuntimeException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionRuntimeException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionRuntimeException ) cause : new SessionRuntimeException ( message , cause ) ; } | Converts a Throwable to a SessionRuntimeException with the specified detail message . If the Throwable is a SessionRuntimeException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionRuntimeException with the detail message . |
16,814 | protected ByteSource stream ( final String resourceId ) { return new ByteSource ( ) { public InputStream openStream ( ) throws IOException { return loader . getResource ( resourceId ) . getInputStream ( ) ; } } ; } | Wouldn t it be nice if we wrote some tests? |
16,815 | public static QueryRuntimeException fromThrowable ( Throwable t ) { return ( t instanceof QueryRuntimeException ) ? ( QueryRuntimeException ) t : new QueryRuntimeException ( t ) ; } | Converts a Throwable to a QueryRuntimeException . If the Throwable is a QueryRuntimeException it will be passed through unmodified ; otherwise it will be wrapped in a new QueryRuntimeException . |
16,816 | public static QueryRuntimeException fromThrowable ( String message , Throwable t ) { return ( t instanceof QueryRuntimeException && Objects . equals ( message , t . getMessage ( ) ) ) ? ( QueryRuntimeException ) t : new QueryRuntimeException ( message , t ) ; } | Converts a Throwable to a QueryRuntimeException with the specified detail message . If the Throwable is a QueryRuntimeException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new QueryRuntimeException with the detail message . |
16,817 | public static ProofViewException fromThrowable ( Throwable cause ) { return ( cause instanceof ProofViewException ) ? ( ProofViewException ) cause : new ProofViewException ( cause ) ; } | Converts a Throwable to a ProofViewException . If the Throwable is a ProofViewException it will be passed through unmodified ; otherwise it will be wrapped in a new ProofViewException . |
16,818 | public static ProofViewException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof ProofViewException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( ProofViewException ) cause : new ProofViewException ( message , cause ) ; } | Converts a Throwable to a ProofViewException with the specified detail message . If the Throwable is a ProofViewException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new ProofViewException with the detail message . |
16,819 | public static KbException fromThrowable ( Throwable cause ) { return ( cause instanceof KbException ) ? ( KbException ) cause : new KbException ( cause ) ; } | Converts a Throwable to a KbException . If the Throwable is a KbException it will be passed through unmodified ; otherwise it will be wrapped in a new KbException . |
16,820 | public static KbException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof KbException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( KbException ) cause : new KbException ( message , cause ) ; } | Converts a Throwable to a KbException with the specified detail message . If the Throwable is a KbException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new KbException with the detail message . |
16,821 | public static DeleteException fromThrowable ( Throwable cause ) { return ( cause instanceof DeleteException ) ? ( DeleteException ) cause : new DeleteException ( cause ) ; } | Converts a Throwable to a DeleteException . If the Throwable is a DeleteException it will be passed through unmodified ; otherwise it will be wrapped in a new DeleteException . |
16,822 | public static DeleteException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof DeleteException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( DeleteException ) cause : new DeleteException ( message , cause ) ; } | Converts a Throwable to a DeleteException with the specified detail message . If the Throwable is a DeleteException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new DeleteException with the detail message . |
16,823 | public void initialize ( ) { if ( this . initializationState . setInitializing ( ) ) { if ( this . visibility == null ) { this . visibility = VisibilityModifier . PUBLIC ; } this . initializationState . setInitialized ( ) ; } } | This method initializes this class . It has to be called after construction and injection is completed . |
16,824 | public List < ModuleBuildFuture > getExtraBuilds ( ) { return extraBuilds == null ? Collections . < ModuleBuildFuture > emptyList ( ) : Collections . unmodifiableList ( extraBuilds ) ; } | Returns the list of additional futures that should be processed along with this build this future |
16,825 | public double getCoverDelta ( GrammarRuleRecord rule ) { int new_cover = 0 ; int overlapping_cover = 0 ; for ( RuleInterval i : rule . getRuleIntervals ( ) ) { int start = i . getStart ( ) ; int end = i . getEnd ( ) ; for ( int j = start ; j < end ; j ++ ) { if ( range [ j ] ) { overlapping_cover ++ ; } else { new_cover ++ ; } } } if ( 0 == new_cover ) { return 0.0 ; } if ( 0 == overlapping_cover ) { return ( double ) new_cover / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; } return ( ( double ) new_cover / ( double ) ( new_cover + overlapping_cover ) ) / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; } | Computes the delta value for the suggested rule candidate . |
16,826 | private boolean isCompletelyCoveredBy ( int [ ] isCovered , List < RuleInterval > intervals ) { for ( RuleInterval i : intervals ) { for ( int j = i . getStart ( ) ; j < i . getEnd ( ) ; j ++ ) { if ( isCovered [ j ] == 0 ) { return false ; } } } return true ; } | Checks if the cover is complete . |
16,827 | public void expand ( ) { join ( p , r . first ( ) ) ; join ( r . last ( ) , n ) ; r . theGuard . r = null ; r . theGuard = null ; } | This symbol is the last reference to its rule . The contents of the rule are substituted in its place . |
16,828 | public void insert ( String str , int lineno , int colno ) { final String sourceMethod = "insert" ; if ( isTraceLogging ) { log . entering ( JSSource . class . getName ( ) , sourceMethod , new Object [ ] { str , lineno , colno } ) ; } PositionLocator locator = new PositionLocator ( lineno , colno ) ; locator . insert ( str ) ; if ( isTraceLogging ) { log . exiting ( JSSource . class . getName ( ) , sourceMethod , "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")" ) ; } } | Inserts the specified string into the source at the specified location |
16,829 | public void appendln ( String str ) { BufferedReader rdr = new BufferedReader ( new StringReader ( str ) ) ; while ( true ) { String line = null ; try { line = rdr . readLine ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } if ( line != null ) { lines . add ( new LineInfo ( line ) ) ; continue ; } break ; } } | Appends the lines in the specified string to the current source . |
16,830 | public void disposeAndValidate ( ) throws ObjectNotFoundException , ComposedException { List < NlsObject > errorList = this . duplicateIdErrors ; this . duplicateIdErrors = null ; for ( Resolver resolver : this . id2callableMap . values ( ) ) { if ( ! resolver . resolved ) { errorList . add ( this . bundle . errorObjectNotFound ( resolver . type , resolver . id ) ) ; } } this . id2valueMap = null ; this . id2callableMap = null ; int errorCount = errorList . size ( ) ; if ( errorCount > 0 ) { NlsObject [ ] errors = errorList . toArray ( new NlsObject [ errorCount ] ) ; throw new ComposedException ( errors ) ; } } | This method disposes this context and performs a validation that all IDs have been resolved . |
16,831 | public void setNamespace ( String prefix , String uri ) { this . prefix2namespace . put ( prefix , uri ) ; this . namespace2prefix . put ( uri , prefix ) ; } | This method is used to declare a namespace in this context . |
16,832 | private ChocoConstraint build ( Constraint cstr ) throws SchedulerException { ChocoMapper mapper = params . getMapper ( ) ; ChocoConstraint cc = mapper . get ( cstr ) ; if ( cc == null ) { throw new SchedulerModelingException ( origin , "No implementation mapped to '" + cstr . getClass ( ) . getSimpleName ( ) + "'" ) ; } return cc ; } | Build a sat constraint |
16,833 | private static void checkNodesExistence ( Model mo , Collection < Node > ns ) throws SchedulerModelingException { for ( Node node : ns ) { if ( ! mo . getMapping ( ) . contains ( node ) ) { throw new SchedulerModelingException ( mo , "Unknown node '" + node + "'" ) ; } } } | Check for the existence of nodes in a model |
16,834 | public SingleRunnerStatistics getStatistics ( ) { if ( rp != null ) { Measures m = rp . getSolver ( ) . getMeasures ( ) ; stats . setMetrics ( new Metrics ( m ) ) ; stats . setCompleted ( m . getSearchState ( ) . equals ( SearchState . TERMINATED ) || m . getSearchState ( ) . equals ( SearchState . NEW ) ) ; } return stats ; } | Get the statistics about the solving process . |
16,835 | protected double calcDistTSAndPattern ( double [ ] ts , double [ ] pValue ) { double INF = 10000000000000000000f ; double bestDist = INF ; int patternLen = pValue . length ; int lastStartP = ts . length - pValue . length + 1 ; if ( lastStartP < 1 ) return bestDist ; Random rand = new Random ( ) ; int startP = rand . nextInt ( ( lastStartP - 1 - 0 ) + 1 ) ; double [ ] slidingWindow = new double [ patternLen ] ; System . arraycopy ( ts , startP , slidingWindow , 0 , patternLen ) ; bestDist = eculideanDistNorm ( pValue , slidingWindow ) ; for ( int i = 0 ; i < lastStartP ; i ++ ) { System . arraycopy ( ts , i , slidingWindow , 0 , patternLen ) ; double tempDist = eculideanDistNormEAbandon ( pValue , slidingWindow , bestDist ) ; if ( tempDist < bestDist ) { bestDist = tempDist ; } } return bestDist ; } | Calculating the distance between time series and pattern . |
16,836 | protected double eculideanDistNormEAbandon ( double [ ] ts1 , double [ ] ts2 , double bsfDist ) { double dist = 0 ; double tsLen = ts1 . length ; double bsf = Math . pow ( tsLen * bsfDist , 2 ) ; for ( int i = 0 ; i < ts1 . length ; i ++ ) { double diff = ts1 [ i ] - ts2 [ i ] ; dist += Math . pow ( diff , 2 ) ; if ( dist > bsf ) return Double . NaN ; } return Math . sqrt ( dist ) / tsLen ; } | Normalized early abandoned Euclidean distance . |
16,837 | protected double eculideanDistNorm ( double [ ] ts1 , double [ ] ts2 ) { double dist = 0 ; double tsLen = ts1 . length ; for ( int i = 0 ; i < ts1 . length ; i ++ ) { double diff = ts1 [ i ] - ts2 [ i ] ; dist += Math . pow ( diff , 2 ) ; } return Math . sqrt ( dist ) / tsLen ; } | Normalized Euclidean distance . |
16,838 | private static void toAbsoluteFreeResources ( TIntIntHashMap changes , int [ ] sortedMoments ) { for ( int i = 1 ; i < sortedMoments . length ; i ++ ) { int t = sortedMoments [ i ] ; int lastT = sortedMoments [ i - 1 ] ; int lastFree = changes . get ( lastT ) ; changes . put ( t , changes . get ( t ) + lastFree ) ; } } | Translation for a relatives resources changes to an absolute free resources . |
16,839 | private void addLinkConstraints ( ReconfigurationProblem rp ) { List < Task > tasksListUp = new ArrayList < > ( ) ; List < Task > tasksListDown = new ArrayList < > ( ) ; List < IntVar > heightsListUp = new ArrayList < > ( ) ; List < IntVar > heightsListDown = new ArrayList < > ( ) ; for ( Link l : net . getLinks ( ) ) { for ( VM vm : rp . getVMs ( ) ) { VMTransition a = rp . getVMAction ( vm ) ; if ( a instanceof RelocatableVM && ! a . getDSlice ( ) . getHoster ( ) . isInstantiatedTo ( a . getCSlice ( ) . getHoster ( ) . getValue ( ) ) ) { Node src = source . getMapping ( ) . getVMLocation ( vm ) ; Node dst = rp . getNode ( a . getDSlice ( ) . getHoster ( ) . getValue ( ) ) ; List < Link > path = net . getRouting ( ) . getPath ( src , dst ) ; if ( path . contains ( l ) ) { LinkDirection linkDirection = net . getRouting ( ) . getLinkDirection ( src , dst , l ) ; if ( linkDirection == LinkDirection . UPLINK ) { tasksListUp . add ( ( ( RelocatableVM ) a ) . getMigrationTask ( ) ) ; heightsListUp . add ( ( ( RelocatableVM ) a ) . getBandwidth ( ) ) ; } else { tasksListDown . add ( ( ( RelocatableVM ) a ) . getMigrationTask ( ) ) ; heightsListDown . add ( ( ( RelocatableVM ) a ) . getBandwidth ( ) ) ; } } } } if ( ! tasksListUp . isEmpty ( ) ) { csp . post ( csp . cumulative ( tasksListUp . toArray ( new Task [ tasksListUp . size ( ) ] ) , heightsListUp . toArray ( new IntVar [ heightsListUp . size ( ) ] ) , csp . intVar ( l . getCapacity ( ) ) , true ) ) ; tasksListUp . clear ( ) ; heightsListUp . clear ( ) ; } if ( ! tasksListDown . isEmpty ( ) ) { csp . post ( csp . cumulative ( tasksListDown . toArray ( new Task [ tasksListDown . size ( ) ] ) , heightsListDown . toArray ( new IntVar [ heightsListDown . size ( ) ] ) , csp . intVar ( l . getCapacity ( ) ) , true ) ) ; tasksListDown . clear ( ) ; heightsListDown . clear ( ) ; } } } | Add the cumulative constraints for each link . |
16,840 | public static void fill ( Mapping src , Mapping dst ) { for ( Node off : src . getOfflineNodes ( ) ) { dst . addOfflineNode ( off ) ; } for ( VM r : src . getReadyVMs ( ) ) { dst . addReadyVM ( r ) ; } for ( Node on : src . getOnlineNodes ( ) ) { dst . addOnlineNode ( on ) ; for ( VM r : src . getRunningVMs ( on ) ) { dst . addRunningVM ( r , on ) ; } for ( VM s : src . getSleepingVMs ( on ) ) { dst . addSleepingVM ( s , on ) ; } } } | Fill a destination mapping with all the elements in a source mapping |
16,841 | public String toRuleString ( ) { if ( 0 == this . ruleNumber ) { return this . grammar . r0String ; } return this . first . toString ( ) + SPACE + this . second . toString ( ) + SPACE ; } | Return the prefixed with R rule . |
16,842 | public int [ ] getOccurrences ( ) { int [ ] res = new int [ this . occurrences . size ( ) ] ; for ( int i = 0 ; i < this . occurrences . size ( ) ; i ++ ) { res [ i ] = this . occurrences . get ( i ) ; } return res ; } | Gets occurrences . |
16,843 | static public boolean isProvisional ( Iterable < ICacheKeyGenerator > keyGens ) { boolean provisional = false ; for ( ICacheKeyGenerator keyGen : keyGens ) { if ( keyGen . isProvisional ( ) ) { provisional = true ; break ; } } return provisional ; } | Return true if any of the cache key generators in the array is a provisional cache key generator . |
16,844 | public static < E > Collection < E > unionColl ( Collection < E > c1 , Collection < E > c2 ) { return new UColl < E > ( c1 , c2 ) ; } | Returns the immutable union of two collections . |
16,845 | protected void unfoldModulesHelper ( Object obj , String path , String [ ] aPrefixes , Map < Integer , String > modules ) throws IOException , JSONException { final String sourceMethod = "unfoldModulesHelper" ; if ( isTraceLogging ) { log . entering ( RequestedModuleNames . class . getName ( ) , sourceMethod , new Object [ ] { obj , path , aPrefixes != null ? Arrays . asList ( aPrefixes ) : null , modules } ) ; } if ( obj instanceof JSONObject ) { JSONObject jsonobj = ( JSONObject ) obj ; Iterator < ? > it = jsonobj . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { String key = ( String ) it . next ( ) ; String newpath = path + "/" + key ; unfoldModulesHelper ( jsonobj . get ( key ) , newpath , aPrefixes , modules ) ; } } else if ( obj instanceof String ) { String [ ] values = ( ( String ) obj ) . split ( "-" ) ; int idx = Integer . parseInt ( values [ 0 ] ) ; if ( modules . get ( idx ) != null ) { throw new BadRequestException ( ) ; } modules . put ( idx , values . length > 1 ? ( ( aPrefixes != null ? aPrefixes [ Integer . parseInt ( values [ 1 ] ) ] : values [ 1 ] ) + "!" + path ) : path ) ; } else { throw new BadRequestException ( ) ; } if ( isTraceLogging ) { log . exiting ( RequestedModuleNames . class . getName ( ) , sourceMethod , modules ) ; } } | Helper routine to unfold folded module names |
16,846 | public static < K , V > MapFactory < K , V > cow ( MapFactory < K , V > underMapFact ) { throw new UnsupportedOperationException ( "Not implemented yet" ) ; } | Copy - on - write maps . UNIMPLEMENTED YET . |
16,847 | private void sealObject ( ScriptableObject obj ) { obj . sealObject ( ) ; Object [ ] ids = obj . getIds ( ) ; for ( Object id : ids ) { Object child = obj . get ( id ) ; if ( child instanceof ScriptableObject ) { sealObject ( ( ScriptableObject ) child ) ; } } } | Recursively seals the specified object and all the objects it contains . |
16,848 | protected String _resolve ( String name , Features features , Set < String > dependentFeatures , boolean resolveAliases , boolean evaluateHasPluginConditionals , int recursionCount , StringBuffer sb ) { final String sourceMethod = "_resolve" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( ConfigImpl . class . getName ( ) , sourceMethod , new Object [ ] { name , features , dependentFeatures , resolveAliases , evaluateHasPluginConditionals , recursionCount , sb } ) ; } String result = name ; if ( name != null && name . length ( ) != 0 ) { if ( recursionCount >= MAX_RECURSION_COUNT ) { throw new IllegalStateException ( "Excessive recursion in resolver: " + name ) ; } int idx = name . indexOf ( "!" ) ; if ( idx != - 1 && HAS_PATTERN . matcher ( name . substring ( 0 , idx ) ) . find ( ) ) { result = resolveHasPlugin ( name . substring ( idx + 1 ) , features , dependentFeatures , resolveAliases , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; result = result . contains ( "?" ) ? ( name . substring ( 0 , idx + 1 ) + result ) : result ; } else if ( resolveAliases && getAliases ( ) != null ) { if ( idx != - 1 ) { Matcher m = plugins2 . matcher ( name ) ; StringBuffer sbResult = new StringBuffer ( ) ; while ( m . find ( ) ) { String replacement = _resolve ( m . group ( 0 ) , features , dependentFeatures , true , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; m . appendReplacement ( sbResult , replacement ) ; } m . appendTail ( sbResult ) ; result = sbResult . toString ( ) ; } String candidate = resolveAliases ( name , features , dependentFeatures , sb ) ; if ( candidate != null && candidate . length ( ) > 0 && ! candidate . equals ( name ) ) { if ( sb != null ) { sb . append ( ", " ) . append ( MessageFormat . format ( Messages . ConfigImpl_6 , new Object [ ] { name + " + candidate } ) ) ; } result = _resolve ( candidate , features , dependentFeatures , true , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; } } } if ( isTraceLogging ) { log . exiting ( ConfigImpl . class . getName ( ) , sourceMethod , result ) ; } return result ; } | Resolves a module id by applying alias resolution and has! loader plugin resolution . |
16,849 | protected URI loadConfigUri ( ) throws URISyntaxException , FileNotFoundException { Collection < String > configNames = getAggregator ( ) . getInitParams ( ) . getValues ( InitParams . CONFIG_INITPARAM ) ; if ( configNames . size ( ) != 1 ) { throw new IllegalArgumentException ( InitParams . CONFIG_INITPARAM ) ; } String configName = configNames . iterator ( ) . next ( ) ; return new URI ( configName ) ; } | Initializes and returns the URI to the server - side config JavaScript |
16,850 | protected Location loadBaseURI ( Scriptable cfg ) throws URISyntaxException { Object baseObj = cfg . get ( BASEURL_CONFIGPARAM , cfg ) ; Location result ; if ( baseObj == Scriptable . NOT_FOUND ) { result = new Location ( getConfigUri ( ) . resolve ( "." ) ) ; } else { Location loc = loadLocation ( baseObj , true ) ; Location configLoc = new Location ( getConfigUri ( ) , loc . getOverride ( ) != null ? getConfigUri ( ) : null ) ; result = configLoc . resolve ( loc ) ; } return result ; } | Initializes and returns the base URI specified by the baseUrl property in the server - side config JavaScript |
16,851 | protected Scriptable loadConfig ( String configScript ) throws IOException { configScript = processConfig ( configScript ) ; Context cx = Context . enter ( ) ; Scriptable config ; try { sharedScope = cx . initStandardObjects ( null , true ) ; IOptions options = aggregator . getOptions ( ) ; if ( options != null ) { optionsUpdated ( options , 1 ) ; } InitParams initParams = aggregator . getInitParams ( ) ; if ( initParams != null ) { Scriptable jsInitParams = cx . newObject ( sharedScope ) ; Collection < String > names = initParams . getNames ( ) ; for ( String name : names ) { Collection < String > values = initParams . getValues ( name ) ; Object value = Context . javaToJS ( values . toArray ( new String [ values . size ( ) ] ) , sharedScope ) ; ScriptableObject . putProperty ( jsInitParams , name , value ) ; } ScriptableObject . putProperty ( sharedScope , "initParams" , jsInitParams ) ; } if ( aggregator . getPlatformServices ( ) != null ) { if ( aggregator . getPlatformServices ( ) . getHeaders ( ) != null ) { Dictionary < String , String > headers = ( Dictionary < String , String > ) ( aggregator . getPlatformServices ( ) . getHeaders ( ) ) ; Scriptable jsHeaders = cx . newObject ( sharedScope ) ; Enumeration < String > keys = headers . keys ( ) ; while ( keys . hasMoreElements ( ) ) { String key = keys . nextElement ( ) ; Object value = Context . javaToJS ( headers . get ( key ) , sharedScope ) ; ScriptableObject . putProperty ( jsHeaders , key , value ) ; } ScriptableObject . putProperty ( sharedScope , "headers" , jsHeaders ) ; } } Console console = newConsole ( ) ; Object jsConsole = Context . javaToJS ( console , sharedScope ) ; ScriptableObject . putProperty ( sharedScope , "console" , jsConsole ) ; GetPropertyFunction getPropertyFn = newGetPropertyFunction ( sharedScope , aggregator ) ; ScriptableObject . putProperty ( sharedScope , "getProperty" , getPropertyFn ) ; callConfigScopeModifiers ( sharedScope ) ; cx . evaluateString ( sharedScope , "var config = " + aggregator . substituteProps ( configScript , new IAggregator . SubstitutionTransformer ( ) { public String transform ( String name , String value ) { return value . replace ( "\\" , "\\\\" ) ; } } ) , getConfigUri ( ) . toString ( ) , 1 , null ) ; config = ( Scriptable ) sharedScope . get ( "config" , sharedScope ) ; if ( config == Scriptable . NOT_FOUND ) { throw new IllegalStateException ( "config is not defined." ) ; } } finally { Context . exit ( ) ; } return config ; } | Loads the config JavaScript and returns the parsed config in a Map |
16,852 | protected Map < String , IPackage > loadPackages ( Scriptable cfg ) throws URISyntaxException { Object obj = cfg . get ( PACKAGES_CONFIGPARAM , cfg ) ; Map < String , IPackage > packages = new HashMap < String , IPackage > ( ) ; if ( obj instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) obj ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object pkg = ( ( Scriptable ) obj ) . get ( ( Integer ) i , ( Scriptable ) obj ) ; IPackage p = newPackage ( pkg ) ; if ( ! packages . containsKey ( p . getName ( ) ) ) { packages . put ( p . getName ( ) , p ) ; } } } } return packages ; } | Initializes and returns the map of packages based on the information in the server - side config JavaScript |
16,853 | protected Map < String , Location > loadPaths ( Scriptable cfg ) throws URISyntaxException { Object pathlocs = cfg . get ( PATHS_CONFIGPARAM , cfg ) ; Map < String , Location > paths = new HashMap < String , Location > ( ) ; if ( pathlocs instanceof Scriptable ) { for ( Object key : ( ( Scriptable ) pathlocs ) . getIds ( ) ) { String name = toString ( key ) ; if ( ! paths . containsKey ( name ) && key instanceof String ) { Location location = loadLocation ( ( ( Scriptable ) pathlocs ) . get ( name , ( Scriptable ) pathlocs ) , false ) ; paths . put ( name , getBase ( ) . resolve ( location ) ) ; } } } return paths ; } | Initializes and returns the map of paths based on the information in the server - side config JavaScript |
16,854 | protected List < IAlias > loadAliases ( Scriptable cfg ) throws IOException { Object aliasList = cfg . get ( ALIASES_CONFIGPARAM , cfg ) ; List < IAlias > aliases = new LinkedList < IAlias > ( ) ; if ( aliasList instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) aliasList ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) aliasList ) . get ( ( Integer ) i , ( Scriptable ) aliasList ) ; if ( entry instanceof Scriptable ) { Scriptable vec = ( Scriptable ) entry ; Object pattern = vec . get ( 0 , vec ) ; Object replacement = vec . get ( 1 , vec ) ; if ( pattern == Scriptable . NOT_FOUND || replacement == Scriptable . NOT_FOUND ) { throw new IllegalArgumentException ( toString ( entry ) ) ; } if ( pattern instanceof Scriptable && "RegExp" . equals ( ( ( Scriptable ) pattern ) . getClassName ( ) ) ) { String regexlit = toString ( pattern ) ; String regex = regexlit . substring ( 1 , regexlit . lastIndexOf ( "/" ) ) ; String flags = regexlit . substring ( regexlit . lastIndexOf ( "/" ) + 1 ) ; int options = 0 ; if ( flags . contains ( "i" ) ) { options |= Pattern . CASE_INSENSITIVE ; } pattern = Pattern . compile ( regex , options ) ; } else { pattern = toString ( pattern ) ; } if ( ! ( replacement instanceof Scriptable ) || ! "Function" . equals ( ( ( Scriptable ) replacement ) . getClassName ( ) ) ) { replacement = toString ( replacement ) ; } aliases . add ( newAlias ( pattern , replacement ) ) ; } else { throw new IllegalArgumentException ( Context . toString ( ALIASES_CONFIGPARAM + "[" + i + "] = " + Context . toString ( entry ) ) ) ; } } else { throw new IllegalArgumentException ( "Unrecognized type for " + ALIASES_CONFIGPARAM + " - " + aliasList . getClass ( ) . toString ( ) ) ; } } } return aliases ; } | Initializes and returns the list of aliases defined in the server - side config JavaScript |
16,855 | protected List < String > loadDeps ( Scriptable cfg ) { final String methodName = "loadDeps" ; Object depsList = cfg . get ( DEPS_CONFIGPARAM , cfg ) ; List < String > deps = new LinkedList < String > ( ) ; if ( depsList instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) depsList ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) depsList ) . get ( ( Integer ) i , ( Scriptable ) depsList ) ; deps . add ( toString ( entry ) ) ; } } log . logp ( Level . WARNING , ConfigImpl . class . getName ( ) , methodName , Messages . ConfigImpl_0 ) ; } return deps ; } | Initializes and returns the list of module dependencies specified in the server - side config JavaScript . |
16,856 | protected int loadExpires ( Scriptable cfg ) { int expires = 0 ; Object oExpires = cfg . get ( EXPIRES_CONFIGPARAM , cfg ) ; if ( oExpires != Scriptable . NOT_FOUND ) { try { expires = Integer . parseInt ( toString ( oExpires ) ) ; } catch ( NumberFormatException ignore ) { throw new IllegalArgumentException ( EXPIRES_CONFIGPARAM + "=" + oExpires ) ; } } return expires ; } | Initializes and returns the expires time from the server - side config JavaScript |
16,857 | protected boolean loadDepsIncludeBaseUrl ( Scriptable cfg ) { boolean result = false ; Object value = cfg . get ( DEPSINCLUDEBASEURL_CONFIGPARAM , cfg ) ; if ( value != Scriptable . NOT_FOUND ) { result = TypeUtil . asBoolean ( toString ( value ) , false ) ; } return result ; } | Initializes and returns the flag indicating if files and directories located under the base directory should be scanned for javascript files when building the module dependency mappings . The default is false . |
16,858 | protected boolean loadCoerceUndefinedToFalse ( Scriptable cfg ) { boolean result = false ; Object value = cfg . get ( COERCEUNDEFINEDTOFALSE_CONFIGPARAM , cfg ) ; if ( value != Scriptable . NOT_FOUND ) { result = TypeUtil . asBoolean ( toString ( value ) , false ) ; } return result ; } | Initializes and returns the flag indicating if features not specified in the feature set from the request should be treated as false when evaluating has conditionals in javascript code . The default is false . |
16,859 | protected Set < String > loadPluginDelegators ( Scriptable cfg , String name ) { Set < String > result = null ; Object delegators = cfg . get ( name , cfg ) ; if ( delegators != Scriptable . NOT_FOUND && delegators instanceof Scriptable ) { result = new HashSet < String > ( ) ; for ( Object id : ( ( Scriptable ) delegators ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) delegators ) . get ( ( Integer ) i , ( Scriptable ) delegators ) ; result . add ( entry . toString ( ) ) ; } } result = Collections . unmodifiableSet ( result ) ; } else { result = Collections . emptySet ( ) ; } return result ; } | Common routine to load text or js plugin delegators |
16,860 | protected void callConfigModifiers ( Scriptable rawConfig ) { if ( aggregator . getPlatformServices ( ) != null ) { IServiceReference [ ] refs = null ; try { refs = aggregator . getPlatformServices ( ) . getServiceReferences ( IConfigModifier . class . getName ( ) , "(name=" + getAggregator ( ) . getName ( ) + ")" ) ; } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } if ( refs != null ) { for ( IServiceReference ref : refs ) { IConfigModifier modifier = ( IConfigModifier ) aggregator . getPlatformServices ( ) . getService ( ref ) ; if ( modifier != null ) { try { modifier . modifyConfig ( getAggregator ( ) , rawConfig ) ; } catch ( Exception e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } finally { aggregator . getPlatformServices ( ) . ungetService ( ref ) ; } } } } } } | Calls the registered config modifiers to give them an opportunity to modify the raw config before config properties are evaluated . |
16,861 | protected void callConfigScopeModifiers ( Scriptable scope ) { if ( aggregator . getPlatformServices ( ) != null ) { IServiceReference [ ] refs = null ; try { refs = aggregator . getPlatformServices ( ) . getServiceReferences ( IConfigScopeModifier . class . getName ( ) , "(name=" + getAggregator ( ) . getName ( ) + ")" ) ; } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } if ( refs != null ) { for ( IServiceReference ref : refs ) { IConfigScopeModifier adaptor = ( IConfigScopeModifier ) aggregator . getPlatformServices ( ) . getService ( ref ) ; if ( adaptor != null ) { try { adaptor . modifyScope ( getAggregator ( ) , scope ) ; } catch ( Exception e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } finally { aggregator . getPlatformServices ( ) . ungetService ( ref ) ; } } } } } } | Calls the registered config scope modifiers to give them an opportunity to prepare the scope object prior to evaluating the config JavaScript |
16,862 | protected boolean isValidType ( Class < ? > type , Annotation [ ] classAnnotations ) { if ( type == null ) return false ; if ( annotated ) { return checkAnnotation ( type ) ; } else if ( scanpackages != null ) { String classPackage = type . getPackage ( ) . getName ( ) ; for ( String pkg : scanpackages ) { if ( classPackage . startsWith ( pkg ) ) { if ( annotated ) { return checkAnnotation ( type ) ; } else return true ; } } return false ; } else if ( clazzes != null ) { for ( Class < ? > cls : clazzes ) { if ( cls == type ) return true ; } return false ; } return true ; } | Check whether a class can be serialized or deserialized . It can check based on packages annotations on entities or explicit classes . |
16,863 | public void writeTo ( Object t , Class < ? > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , Object > httpHeaders , OutputStream entityStream ) throws IOException , WebApplicationException { SerializeFilter filter = null ; if ( pretty ) { if ( fastJsonConfig . serializerFeatures == null ) fastJsonConfig . serializerFeatures = new SerializerFeature [ ] { SerializerFeature . PrettyFormat } ; else { List < SerializerFeature > serializerFeatures = Arrays . asList ( fastJsonConfig . serializerFeatures ) ; serializerFeatures . add ( SerializerFeature . PrettyFormat ) ; fastJsonConfig . serializerFeatures = serializerFeatures . toArray ( new SerializerFeature [ ] { } ) ; } } if ( fastJsonConfig . serializeFilters != null ) filter = fastJsonConfig . serializeFilters . get ( type ) ; String jsonStr = toJSONString ( t , filter , fastJsonConfig . serializerFeatures ) ; if ( jsonStr != null ) entityStream . write ( jsonStr . getBytes ( ) ) ; } | Method that JAX - RS container calls to serialize given value . |
16,864 | public Object readFrom ( Class < Object > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , String > httpHeaders , InputStream entityStream ) throws IOException , WebApplicationException { String input = null ; try { input = IOUtils . inputStreamToString ( entityStream ) ; } catch ( Exception e ) { } if ( input == null ) { return null ; } if ( fastJsonConfig . features == null ) return JSON . parseObject ( input , type , fastJsonConfig . parserConfig , JSON . DEFAULT_PARSER_FEATURE ) ; else return JSON . parseObject ( input , type , fastJsonConfig . parserConfig , JSON . DEFAULT_PARSER_FEATURE , fastJsonConfig . features ) ; } | Method that JAX - RS container calls to deserialize given value . |
16,865 | public static ArrayList < SameLengthMotifs > performPruning ( double [ ] ts , GrammarRules grammarRules , double thresholdLength , double thresholdCom , double fractionTopDist ) { RuleOrganizer ro = new RuleOrganizer ( ) ; ArrayList < SameLengthMotifs > allClassifiedMotifs = ro . classifyMotifs ( thresholdLength , grammarRules ) ; allClassifiedMotifs = ro . removeOverlappingInSimiliar ( allClassifiedMotifs , grammarRules , ts , thresholdCom ) ; ArrayList < SameLengthMotifs > newAllClassifiedMotifs = ro . refinePatternsByClustering ( grammarRules , ts , allClassifiedMotifs , fractionTopDist ) ; return newAllClassifiedMotifs ; } | Performs clustering . |
16,866 | public static ArrayList < PackedRuleRecord > getPackedRule ( ArrayList < SameLengthMotifs > newAllClassifiedMotifs ) { ArrayList < PackedRuleRecord > arrPackedRuleRecords = new ArrayList < PackedRuleRecord > ( ) ; int i = 0 ; for ( SameLengthMotifs subsequencesInClass : newAllClassifiedMotifs ) { int classIndex = i ; int subsequencesNumber = subsequencesInClass . getSameLenMotifs ( ) . size ( ) ; int minLength = subsequencesInClass . getMinMotifLen ( ) ; int maxLength = subsequencesInClass . getMaxMotifLen ( ) ; PackedRuleRecord packedRuleRecord = new PackedRuleRecord ( ) ; packedRuleRecord . setClassIndex ( classIndex ) ; packedRuleRecord . setSubsequenceNumber ( subsequencesNumber ) ; packedRuleRecord . setMinLength ( minLength ) ; packedRuleRecord . setMaxLength ( maxLength ) ; arrPackedRuleRecords . add ( packedRuleRecord ) ; i ++ ; } return arrPackedRuleRecords ; } | Gets packed rules set . |
16,867 | protected Dictionary < ? , ? > getBundleHeaders ( String bundleName ) throws NotFoundException { final String sourceMethod = "getBundleHeaders" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( BundleVersionsHashBase . class . getName ( ) , sourceMethod , new Object [ ] { bundleName } ) ; } Bundle result = "." . equals ( bundleName ) ? contributingBundle : bundleResolver . getBundle ( bundleName ) ; if ( result == null ) { throw new NotFoundException ( "Bundle " + bundleName + " not found." ) ; } if ( isTraceLogging ) { log . exiting ( BundleVersionsHashBase . class . getName ( ) , sourceMethod , result . getHeaders ( ) ) ; } return result . getHeaders ( ) ; } | Returns the bundle headers for the specified bundle . |
16,868 | public boolean checkConformance ( BtrPlaceTree t , List < BtrpOperand > ops ) { if ( ops . size ( ) != getParameters ( ) . length ) { t . ignoreError ( "'" + pretty ( ops ) + "' cannot be casted to '" + getSignature ( ) + "'" ) ; return false ; } for ( int i = 0 ; i < ops . size ( ) ; i ++ ) { BtrpOperand o = ops . get ( i ) ; ConstraintParam < ? > p = params [ i ] ; if ( o == IgnorableOperand . getInstance ( ) ) { return false ; } if ( ! p . isCompatibleWith ( t , o ) ) { t . ignoreError ( "'" + pretty ( ops ) + "' cannot be casted to '" + getSignature ( ) + "'" ) ; return false ; } } return true ; } | Check if the provided parameters match the constraint signature |
16,869 | public Script build ( File f ) throws ScriptBuilderException { int k = f . getAbsolutePath ( ) . hashCode ( ) ; if ( dates . containsKey ( k ) && dates . get ( k ) == f . lastModified ( ) && cache . containsKey ( f . getPath ( ) ) ) { LOGGER . debug ( "get '" + f . getName ( ) + "' from the cache" ) ; return cache . get ( f . getPath ( ) ) ; } LOGGER . debug ( f . getName ( ) + " is built from the file" ) ; dates . put ( k , f . lastModified ( ) ) ; String name = f . getName ( ) ; try { Script v = build ( new ANTLRFileStream ( f . getAbsolutePath ( ) ) ) ; if ( ! name . equals ( v . getlocalName ( ) + Script . EXTENSION ) ) { throw new ScriptBuilderException ( "Script '" + v . getlocalName ( ) + "' must be declared in a file named '" + v . getlocalName ( ) + Script . EXTENSION ) ; } cache . put ( f . getPath ( ) , v ) ; return v ; } catch ( IOException e ) { throw new ScriptBuilderException ( e . getMessage ( ) , e ) ; } } | Build a script from a file . |
16,870 | @ SuppressWarnings ( "squid:S1166" ) private Script build ( CharStream cs ) throws ScriptBuilderException { Script v = new Script ( ) ; ANTLRBtrplaceSL2Lexer lexer = new ANTLRBtrplaceSL2Lexer ( cs ) ; ErrorReporter errorReporter = errBuilder . build ( v ) ; lexer . setErrorReporter ( errorReporter ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; ANTLRBtrplaceSL2Parser parser = new ANTLRBtrplaceSL2Parser ( tokens ) ; parser . setErrorReporter ( errorReporter ) ; SymbolsTable t = new SymbolsTable ( ) ; parser . setTreeAdaptor ( new BtrPlaceTreeAdaptor ( v , model , namingServiceNodes , namingServiceVMs , tpls , errorReporter , t , includes , catalog ) ) ; try { BtrPlaceTree tree = ( BtrPlaceTree ) parser . script_decl ( ) . getTree ( ) ; if ( tree != null ) { if ( tree . token != null ) { tree . go ( tree ) ; } else { for ( int i = 0 ; i < tree . getChildCount ( ) ; i ++ ) { tree . getChild ( i ) . go ( tree ) ; } } } } catch ( RecognitionException e ) { throw new ScriptBuilderException ( e . getMessage ( ) , e ) ; } catch ( UnsupportedOperationException e ) { errorReporter . append ( 0 , 0 , e . getMessage ( ) ) ; } if ( ! errorReporter . getErrors ( ) . isEmpty ( ) ) { throw new ScriptBuilderException ( errorReporter ) ; } return v ; } | Internal method to check a script from a stream . |
16,871 | public Graph generateRandomMMapGraph ( String graphName , int size , float dens ) { Graph graph = null ; String dir = "graphs/MMap/" + graphName ; SerializationUtils . deleteMMapGraph ( dir ) ; graph = new Graph ( new MMapGraphStructure ( dir ) ) ; Random rand = new Random ( ) ; for ( int i = 0 ; i < size ; i ++ ) graph . addNode ( new Node ( i ) ) ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = i + 1 ; j < size ; j ++ ) { if ( rand . nextFloat ( ) < dens ) { int randomCost = Math . abs ( rand . nextInt ( 50 ) ) + 1 ; Edge e = new Edge ( i , j , randomCost ) ; e . setBidirectional ( rand . nextBoolean ( ) ) ; graph . addEdge ( e ) ; } } } return graph ; } | Create a new Graph which has the given graphName size and dens . |
16,872 | public static Map < IntVar , VM > makePlacementMap ( ReconfigurationProblem rp ) { Map < IntVar , VM > m = new HashMap < > ( rp . getFutureRunningVMs ( ) . size ( ) ) ; for ( VM vm : rp . getFutureRunningVMs ( ) ) { IntVar v = rp . getVMAction ( vm ) . getDSlice ( ) . getHoster ( ) ; m . put ( v , vm ) ; } return m ; } | Map a map where keys are the placement variable of the future - running VMs and values are the VM identifier . |
16,873 | public final void validate ( StringBuilder source ) { int length = source . length ( ) ; source . append ( '/' ) ; source . append ( getSourceIdentifier ( ) ) ; doValidate ( source ) ; source . setLength ( length ) ; } | This method validates this segment recursively to ensure the correctness of the configured format . |
16,874 | public ShareableResource setConsumption ( VM vm , int val ) { if ( val < 0 ) { throw new IllegalArgumentException ( String . format ( "The '%s' consumption of VM '%s' must be >= 0" , rcId , vm ) ) ; } vmsConsumption . put ( vm , val ) ; return this ; } | Set the resource consumption of a VM . |
16,875 | public ShareableResource setConsumption ( int val , VM ... vms ) { Stream . of ( vms ) . forEach ( v -> setConsumption ( v , val ) ) ; return this ; } | Set the resource consumption of VMs . |
16,876 | public ShareableResource setCapacity ( Node n , int val ) { if ( val < 0 ) { throw new IllegalArgumentException ( String . format ( "The '%s' capacity of node '%s' must be >= 0" , rcId , n ) ) ; } nodesCapacity . put ( n , val ) ; return this ; } | Set the resource consumption of a node . |
16,877 | public ShareableResource setCapacity ( int val , Node ... nodes ) { Stream . of ( nodes ) . forEach ( n -> this . setCapacity ( n , val ) ) ; return this ; } | Set the resource consumption of nodes . |
16,878 | public int sumConsumptions ( Collection < VM > ids , boolean undef ) { int s = 0 ; for ( VM u : ids ) { if ( consumptionDefined ( u ) || undef ) { s += vmsConsumption . get ( u ) ; } } return s ; } | Get the cumulative VMs consumption . |
16,879 | public int sumCapacities ( Collection < Node > ids , boolean undef ) { int s = 0 ; for ( Node u : ids ) { if ( capacityDefined ( u ) || undef ) { s += nodesCapacity . get ( u ) ; } } return s ; } | Get the cumulative nodes capacity . |
16,880 | public static ShareableResource get ( Model mo , String id ) { return ( ShareableResource ) mo . getView ( VIEW_ID_BASE + id ) ; } | Get the view associated to a model if exists |
16,881 | public String getlocalName ( ) { if ( fqn . contains ( "." ) ) { return this . fqn . substring ( fqn . lastIndexOf ( '.' ) + 1 , this . fqn . length ( ) ) ; } return fqn ; } | Get the local name of the script . |
16,882 | public boolean add ( Collection < BtrpElement > elems ) { boolean ret = false ; for ( BtrpElement el : elems ) { ret |= add ( el ) ; } return ret ; } | Add a collection of nodes or elements . |
16,883 | public boolean add ( BtrpElement el ) { switch ( el . type ( ) ) { case VM : if ( ! this . vms . add ( ( VM ) el . getElement ( ) ) ) { return false ; } break ; case NODE : if ( ! this . nodes . add ( ( Node ) el . getElement ( ) ) ) { return false ; } break ; default : return false ; } return true ; } | Add a VM or a node to the script . |
16,884 | public List < BtrpOperand > getImportables ( String ns ) { List < BtrpOperand > importable = new ArrayList < > ( ) ; for ( String symbol : getExported ( ) ) { if ( canImport ( symbol , ns ) ) { importable . add ( getImportable ( symbol , ns ) ) ; } } return importable ; } | Get all the operand a given script can import |
16,885 | public BtrpOperand getImportable ( String label , String namespace ) { if ( canImport ( label , namespace ) ) { return exported . get ( label ) ; } return null ; } | Get the exported operand from its label . |
16,886 | public boolean canImport ( String label , String namespace ) { if ( ! exported . containsKey ( label ) ) { return false ; } Set < String > scopes = exportScopes . get ( label ) ; for ( String scope : scopes ) { if ( scope . equals ( namespace ) ) { return true ; } else if ( scope . endsWith ( "*" ) && namespace . startsWith ( scope . substring ( 0 , scope . length ( ) - 1 ) ) ) { return true ; } } return false ; } | Indicates whether a namespace can import an exported variable or not . To be imported the label must point to an exported variable with no import restrictions or with a given namespace compatible with the restrictions . |
16,887 | public String fullyQualifiedSymbolName ( String name ) { if ( name . equals ( SymbolsTable . ME ) ) { return "$" . concat ( id ( ) ) ; } else if ( name . startsWith ( "$" ) ) { return "$" + id ( ) + '.' + name . substring ( 1 ) ; } return id ( ) + '.' + name ; } | Get the fully qualified name of a symbol . |
16,888 | public String prettyDependencies ( ) { StringBuilder b = new StringBuilder ( ) ; b . append ( id ( ) ) . append ( '\n' ) ; for ( Iterator < Script > ite = dependencies . iterator ( ) ; ite . hasNext ( ) ; ) { Script n = ite . next ( ) ; prettyDependencies ( b , ! ite . hasNext ( ) , 0 , n ) ; } return b . toString ( ) ; } | Textual representation for the dependencies . |
16,889 | public void addNode ( Node n ) { try { structure . addNode ( n ) ; for ( NodeListener listener : nodeListeners ) listener . onInsert ( n ) ; } catch ( DuplicatedNodeException e ) { duplicatedNodesCounter ++ ; } } | Adds a new node to the graph given the Node object . If a node already exists with an id equal to the given node a DuplicatedNodeException is thrown . |
16,890 | public void addEdge ( Edge e ) { structure . addEdge ( e ) ; for ( EdgeListener listener : edgeListeners ) listener . onInsert ( e ) ; } | Adds a new edge to this graph given a new Edge object . It uses the GraphStructure attribute s addEdge method to add the new edge to this graph . If one of the node ids of the given Edge object does not exists in this graph a NodeNotFoundException is thrown . Otherwise the edge is successfully added to this graph . |
16,891 | public Iterator < Long > getNeighborhoodIterator ( final long id ) { return new Iterator < Long > ( ) { Iterator < Edge > iter = structure . getExistingOutEdgesIterator ( id ) ; public boolean hasNext ( ) { return iter . hasNext ( ) ; } public Long next ( ) { Edge e = iter . next ( ) ; return e . getFromNodeId ( ) == id ? e . getToNodeId ( ) : e . getFromNodeId ( ) ; } } ; } | Gets the neighborhood from a node represented by a given id . If the graph has any Node object with the given id this function returns an Iterator object representing all the neighboring Node objects to the given node . The neighboring nodes are given according to the outgoing edges of the Node object of the graph that has the given id . |
16,892 | public static JSONObject toJSON ( Attributes attributes ) { JSONObject res = new JSONObject ( ) ; JSONObject vms = new JSONObject ( ) ; JSONObject nodes = new JSONObject ( ) ; for ( Element e : attributes . getDefined ( ) ) { JSONObject el = new JSONObject ( ) ; for ( String k : attributes . getKeys ( e ) ) { el . put ( k , attributes . get ( e , k ) ) ; } if ( e instanceof VM ) { vms . put ( Integer . toString ( e . id ( ) ) , el ) ; } else { nodes . put ( Integer . toString ( e . id ( ) ) , el ) ; } } res . put ( "vms" , vms ) ; res . put ( "nodes" , nodes ) ; return res ; } | Serialise attributes . |
16,893 | private void fullKnapsack ( ) throws ContradictionException { for ( int bin = 0 ; bin < prop . nbBins ; bin ++ ) { for ( int d = 0 ; d < prop . nbDims ; d ++ ) { knapsack ( bin , d ) ; } } } | Propagate a knapsack on every node and every dimension . |
16,894 | public void postInitialize ( ) throws ContradictionException { final int [ ] biggest = new int [ prop . nbDims ] ; for ( int i = 0 ; i < prop . bins . length ; i ++ ) { for ( int d = 0 ; d < prop . nbDims ; d ++ ) { biggest [ d ] = Math . max ( biggest [ d ] , prop . iSizes [ d ] [ i ] ) ; } if ( ! prop . bins [ i ] . isInstantiated ( ) ) { final DisposableValueIterator it = prop . bins [ i ] . getValueIterator ( true ) ; try { while ( it . hasNext ( ) ) { candidate . get ( it . next ( ) ) . set ( i ) ; } } finally { it . dispose ( ) ; } } } for ( int b = 0 ; b < prop . nbBins ; b ++ ) { for ( int d = 0 ; d < prop . nbDims ; d ++ ) { dynBiggest [ d ] [ b ] = prop . getVars ( ) [ 0 ] . getEnvironment ( ) . makeInt ( biggest [ d ] ) ; } } fullKnapsack ( ) ; } | initialize the lists of candidates . |
16,895 | @ SuppressWarnings ( "squid:S3346" ) public void postRemoveItem ( int item , int bin ) { assert candidate . get ( bin ) . get ( item ) ; candidate . get ( bin ) . clear ( item ) ; } | update the candidate list of a bin when an item is removed |
16,896 | private void knapsack ( int bin , int d ) throws ContradictionException { final int maxLoad = prop . loads [ d ] [ bin ] . getUB ( ) ; final int free = maxLoad - prop . assignedLoad [ d ] [ bin ] . get ( ) ; if ( free >= dynBiggest [ d ] [ bin ] . get ( ) ) { return ; } if ( free > 0 ) { int newMax = - 1 ; for ( int i = candidate . get ( bin ) . nextSetBit ( 0 ) ; i >= 0 ; i = candidate . get ( bin ) . nextSetBit ( i + 1 ) ) { if ( prop . iSizes [ d ] [ i ] > free ) { if ( prop . bins [ i ] . removeValue ( bin , prop ) ) { prop . removeItem ( i , bin ) ; if ( prop . bins [ i ] . isInstantiated ( ) ) { prop . assignItem ( i , prop . bins [ i ] . getValue ( ) ) ; } } } else { newMax = Math . max ( newMax , prop . iSizes [ d ] [ i ] ) ; } } dynBiggest [ d ] [ bin ] . set ( newMax ) ; } } | Propagate a knapsack on a given dimension and bin . If the usage of an item exceeds the bin free capacity it is filtered out . |
16,897 | public void add ( Metrics m ) { timeCount += m . timeCount ; readingTimeCount += m . readingTimeCount ; nodes += m . nodes ; backtracks += m . backtracks ; fails += m . fails ; restarts += m . restarts ; } | Add metrics . All the metrics are aggregated to the current instance |
16,898 | protected String generateCacheKey ( HttpServletRequest request , Map < String , ICacheKeyGenerator > cacheKeyGenerators ) throws IOException { String cacheKey = null ; if ( cacheKeyGenerators != null ) { Map < String , ICacheKeyGenerator > gens = new TreeMap < String , ICacheKeyGenerator > ( ) ; for ( ICacheKeyGenerator gen : cacheKeyGenerators . values ( ) ) { List < ICacheKeyGenerator > constituentGens = gen . getCacheKeyGenerators ( request ) ; addCacheKeyGenerators ( gens , constituentGens == null ? Arrays . asList ( new ICacheKeyGenerator [ ] { gen } ) : constituentGens ) ; } cacheKey = KeyGenUtil . generateKey ( request , gens . values ( ) ) ; } return cacheKey ; } | Generates a cache key for the layer . |
16,899 | private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; _validateLastModified = new AtomicBoolean ( true ) ; _cacheKeyGenMutex = new Semaphore ( 1 ) ; _isReportCacheInfo = false ; } | De - serialize this object from an ObjectInputStream |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.