idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
17,000 | public static RePairGrammar buildGrammar ( SAXRecords saxRecords ) { RePairGrammar grammar = NewRepair . parse ( saxRecords . getSAXString ( SPACE ) ) ; return grammar ; } | Builds a repair grammar given a set of SAX records . |
17,001 | public static RePairGrammar buildGrammar ( String inputString ) { RePairGrammar grammar = NewRepair . parse ( inputString ) ; return grammar ; } | Builds a grammar given a string of terminals delimeted by space . |
17,002 | public String getValue ( String name ) { String result = null ; for ( InitParam initParam : initParams ) { if ( initParam . getName ( ) . equals ( name ) ) { result = initParam . getValue ( ) ; break ; } } return result ; } | Returns the value of the first instance of the named init - param or null if the init - param is not found . |
17,003 | public Collection < String > getNames ( ) { Collection < String > names = new HashSet < String > ( ) ; for ( InitParam initParam : initParams ) { names . add ( initParam . getName ( ) ) ; } return names ; } | Returns a collection of the init - param names or an empty collection if there are no init - params |
17,004 | public void setRefreshDelayInSeconds ( int refreshDelayInSeconds ) { ValueOutOfRangeException . checkRange ( Integer . valueOf ( refreshDelayInSeconds ) , MIN_DELAY , Integer . valueOf ( Integer . MAX_VALUE ) , getClass ( ) . getSimpleName ( ) + ".refreshDelayInSeconds" ) ; this . refreshDelayInSeconds = refreshDelayInSeconds ; } | This method sets the refresh - delay in seconds . A reasonable value should be at least 5 seconds but better in the range of minutes . |
17,005 | public void register ( ModelViewConverter < ? extends ModelView > c ) { java2json . put ( c . getSupportedView ( ) , c ) ; json2java . put ( c . getJSONId ( ) , c ) ; } | Register a converter for a specific view . |
17,006 | public ModelView fromJSON ( Model mo , JSONObject in ) throws JSONConverterException { checkKeys ( in , ModelViewConverter . IDENTIFIER ) ; Object id = in . get ( ModelViewConverter . IDENTIFIER ) ; ModelViewConverter < ? extends ModelView > c = json2java . get ( id . toString ( ) ) ; if ( c == null ) { throw new JSONConverterException ( "No converter available for a view having id '" + id + "'" ) ; } return c . fromJSON ( mo , in ) ; } | Convert a json - encoded view . |
17,007 | public JSONObject toJSON ( ModelView o ) throws JSONConverterException { ModelViewConverter c = java2json . get ( o . getClass ( ) ) ; if ( c == null ) { throw new JSONConverterException ( "No converter available for a view with the '" + o . getClass ( ) + "' className" ) ; } return c . toJSON ( o ) ; } | Serialise a view . |
17,008 | public DistanceElement getElement ( long id ) { if ( ! vector . containsKey ( id ) ) vector . put ( id , new DistanceElement ( id ) ) ; return vector . get ( id ) ; } | Gets an element of the distance vector based on the given node id . If a DistanceElement object with the given id does not exist in the vector a new object with the id is added to it . Then the element with the given id as key is returned in the end . |
17,009 | public void printPathTo ( long targetId ) { System . out . println ( getPath ( targetId ) . stream ( ) . map ( String :: valueOf ) . reduce ( ( s1 , s2 ) -> s1 + " -> " + s2 ) . get ( ) ) ; } | Prints the path between a source node and a target node if it exists . If it does not exist a message indicating this is shown . Is a path does exist a sequence of nodes is printed to show the path that the nodes share . |
17,010 | public String evaluate ( Features features , Set < String > discovered , boolean coerceUndefinedToFalse ) { if ( feature != null && discovered != null ) { discovered . add ( feature ) ; } if ( feature == null ) { return nodeName ; } else if ( ! coerceUndefinedToFalse && ! features . contains ( feature ) ) { return null ; } else { if ( features . isFeature ( feature ) ) { return trueNode . evaluate ( features , discovered , coerceUndefinedToFalse ) ; } else { return falseNode . evaluate ( features , discovered , coerceUndefinedToFalse ) ; } } } | Evaluate the has plugin for the given set of features . |
17,011 | public void replaceWith ( HasNode node ) { feature = node . feature ; nodeName = node . nodeName ; trueNode = node . trueNode ; falseNode = node . falseNode ; } | Replaces the properties of the current node with the properties of the specified node . |
17,012 | public void replaceWith ( String nodeName ) { feature = null ; this . nodeName = nodeName ; trueNode = falseNode = null ; } | Replaces the properties of the current node with the specified node name making this node into an end point node . |
17,013 | protected String invoke ( CommandProvider provider , CommandInterpreterWrapper interpreter ) throws Exception { Method method = provider . getClass ( ) . getMethod ( "_aggregator" , new Class [ ] { CommandInterpreter . class } ) ; method . invoke ( provider , new Object [ ] { interpreter } ) ; return interpreter . getOutput ( ) ; } | Invokes the aggregator command processor using reflection in order avoid framework dependencies on the aggregator classes . |
17,014 | public static final void setWriter ( String format , TreeWriter writer ) { String key = format . toLowerCase ( ) ; writers . put ( key , writer ) ; if ( JSON . equals ( key ) ) { cachedJsonWriter = writer ; } } | Binds the given TreeWriter instance to the specified data format . |
17,015 | public static < T > Predicate < T > TRUE ( ) { return new Predicate < T > ( ) { public boolean check ( T obj ) { return true ; } } ; } | Returns an always - true predicate . |
17,016 | public static < T > Predicate < T > FALSE ( ) { return Predicate . < T > NOT ( Predicate . < T > TRUE ( ) ) ; } | Returns an always - false predicate . |
17,017 | public static < T > Predicate < T > NOT ( final Predicate < T > pred ) { return new Predicate < T > ( ) { public boolean check ( T obj ) { return ! pred . check ( obj ) ; } } ; } | Predicate negation . |
17,018 | public static < T > Predicate < T > AND ( final Predicate < T > a , final Predicate < T > b ) { return new Predicate < T > ( ) { public boolean check ( T obj ) { return a . check ( obj ) && b . check ( obj ) ; } } ; } | Short - circuited AND operation . |
17,019 | public static < T > Predicate < T > OR ( final Predicate < T > a , final Predicate < T > b ) { return new Predicate < T > ( ) { public boolean check ( T obj ) { return a . check ( obj ) || b . check ( obj ) ; } } ; } | Short - circuited OR operation . |
17,020 | public void fillVMIndex ( TIntIntHashMap index , int p ) { for ( Node n : scope ) { for ( VM v : parent . getRunningVMs ( n ) ) { index . put ( v . id ( ) , p ) ; } for ( VM v : parent . getSleepingVMs ( n ) ) { index . put ( v . id ( ) , p ) ; } } for ( VM v : ready ) { index . put ( v . id ( ) , p ) ; } } | Fill an index with the VM presents in this mapping |
17,021 | public Boolean getIncludeStatus ( ) { if ( formula . isTrue ( ) ) { return Boolean . TRUE ; } else if ( formula . isFalse ( ) ) { return Boolean . FALSE ; } return null ; } | Returns a Boolean value indicating the value of the formula expression or null if the formula expression contains undefined features . The formula is NOT simplified prior to returning the result for performance reasons so some expressions that may simplify to TRUE can return a null value . |
17,022 | public ModuleDepInfo andWith ( ModuleDepInfo other ) { if ( other == null ) { return this ; } formula . andWith ( other . formula ) ; if ( ! isPluginNameDeclared && other . isPluginNameDeclared ) { pluginName = other . pluginName ; isPluginNameDeclared = true ; } else if ( pluginName == null ) { pluginName = other . pluginName ; isPluginNameDeclared = other . isPluginNameDeclared ; } return this ; } | logically ands the provided terms with the formula belonging to this object updating this object with the result . |
17,023 | public boolean add ( ModuleDepInfo other ) { Boolean modified = false ; if ( formula . isTrue ( ) ) { return false ; } if ( other . formula . isTrue ( ) ) { modified = ! formula . isTrue ( ) ; formula = new BooleanFormula ( true ) ; if ( modified && other . comment != null && other . commentTermSize < commentTermSize ) { comment = other . comment ; commentTermSize = other . commentTermSize ; } return modified ; } modified = formula . addAll ( other . formula ) ; if ( ! isPluginNameDeclared && other . isPluginNameDeclared ) { pluginName = other . pluginName ; isPluginNameDeclared = true ; modified = true ; } if ( other . comment != null && other . commentTermSize < commentTermSize ) { comment = other . comment ; commentTermSize = other . commentTermSize ; } return modified ; } | Adds the terms and comments from the specified object to this object . |
17,024 | public void setMinMaxLength ( int [ ] lengths ) { Arrays . sort ( lengths ) ; this . minLength = lengths [ 0 ] ; this . maxLength = lengths [ lengths . length - 1 ] ; } | Set min and max lengths . |
17,025 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) protected AbstractGenericType < T > create ( Type genericType , GenericType < ? > genericDefiningType ) { return new GenericTypeImpl ( genericType , genericDefiningType ) ; } | This method creates a new instance of this class . It may be overridden to create the appropriate sub - type . |
17,026 | public static < T > void inOrder ( T root , BinTreeNavigator < T > binTreeNav , Action < T > action ) { for ( Iterator < T > it = inOrder ( root , binTreeNav ) ; it . hasNext ( ) ; ) { T treeVertex = it . next ( ) ; action . action ( treeVertex ) ; } } | Executes an action on all nodes from a tree in inorder . For trees with sharing the same tree node object will be visited multiple times . |
17,027 | private Map < Link , Boolean > getFirstPhysicalPath ( Map < Link , Boolean > currentPath , Switch sw , Node dst ) { for ( Link l : net . getConnectedLinks ( sw ) ) { if ( currentPath . containsKey ( l ) ) { continue ; } currentPath . put ( l , ! l . getSwitch ( ) . equals ( sw ) ) ; if ( l . getElement ( ) instanceof Node ) { if ( l . getElement ( ) . equals ( dst ) ) { return currentPath ; } } else { Map < Link , Boolean > recall = getFirstPhysicalPath ( currentPath , l . getSwitch ( ) . equals ( sw ) ? ( Switch ) l . getElement ( ) : l . getSwitch ( ) , dst ) ; if ( ! recall . isEmpty ( ) ) { return recall ; } } currentPath . remove ( l ) ; } return new LinkedHashMap < > ( ) ; } | Recursive method to get the first physical path found from a switch to a destination node |
17,028 | public Bundle getBundle ( String symbolicName ) { final String sourceMethod = "getBundle" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , new Object [ ] { symbolicName } ) ; } Bundle [ ] candidates = Platform . getBundles ( symbolicName , null ) ; if ( isTraceLogging ) { log . finer ( "candidate bundles = " + Arrays . toString ( candidates ) ) ; } if ( candidates == null || candidates . length == 0 ) { if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , null ) ; } return null ; } if ( candidates . length == 1 ) { if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , candidates [ 0 ] ) ; } return candidates [ 0 ] ; } if ( fw == null ) { if ( isTraceLogging ) { log . finer ( "Framework wiring not available. Returning bundle with latest version" ) ; log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , candidates [ 0 ] ) ; } return candidates [ 0 ] ; } Bundle result = null ; for ( Bundle candidate : candidates ) { Collection < Bundle > bundles = fw . getDependencyClosure ( Arrays . asList ( new Bundle [ ] { candidate } ) ) ; for ( Bundle bundle : bundles ) { if ( bundle . equals ( contributingBundle ) ) { result = candidate ; break ; } } if ( result != null ) { break ; } } if ( result == null ) { if ( isTraceLogging ) { log . finer ( "No wired bundle found amoung candidates. Returning bundle with most recent version." ) ; } result = candidates [ 0 ] ; } if ( isTraceLogging ) { log . exiting ( FrameworkWiringBundleResolver . class . getName ( ) , sourceMethod , result ) ; } return result ; } | Returns the bundle with the requested symbolic name that is wired to the contributing bundle or the bundle with the latest version if unable to determine wiring . |
17,029 | protected String getSourcesMappingEpilogue ( ) { String root = "" ; String contextPath = request . getRequestURI ( ) ; if ( contextPath != null ) { if ( contextPath . endsWith ( ILayer . SOURCEMAP_RESOURCE_PATH ) ) { contextPath = contextPath . substring ( 0 , contextPath . length ( ) - ( ILayer . SOURCEMAP_RESOURCE_PATHCOMP . length ( ) + 1 ) ) ; } int idx = contextPath . lastIndexOf ( "/" ) ; root = contextPath . substring ( idx != - 1 ? idx + 1 : 0 ) ; if ( root . length ( ) > 0 && ! root . endsWith ( "/" ) ) { root += "/" ; } } StringBuffer sb = new StringBuffer ( ) ; sb . append ( "//# sourceMappingURL=" ) . append ( root ) . append ( ILayer . SOURCEMAP_RESOURCE_PATHCOMP ) ; String queryString = request . getQueryString ( ) ; if ( queryString != null ) { sb . append ( "?" ) . append ( queryString ) ; } return sb . toString ( ) ; } | Returns the source mapping epilogue for the layer that gets added to the end of the response . |
17,030 | protected List < ModuleBuildFuture > collectFutures ( ModuleList moduleList , HttpServletRequest request ) throws IOException { final String sourceMethod = "collectFutures" ; final boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { moduleList , request } ) ; } IAggregator aggr = ( IAggregator ) request . getAttribute ( IAggregator . AGGREGATOR_REQATTRNAME ) ; List < ModuleBuildFuture > futures = new ArrayList < ModuleBuildFuture > ( ) ; IModuleCache moduleCache = aggr . getCacheManager ( ) . getCache ( ) . getModules ( ) ; for ( ModuleList . ModuleListEntry moduleListEntry : moduleList ) { IModule module = moduleListEntry . getModule ( ) ; Future < ModuleBuildReader > future = null ; try { future = moduleCache . getBuild ( request , module ) ; } catch ( NotFoundException e ) { if ( log . isLoggable ( Level . FINER ) ) { log . logp ( Level . FINER , sourceClass , sourceMethod , moduleListEntry . getModule ( ) . getModuleId ( ) + " not found." ) ; } future = new NotFoundModule ( module . getModuleId ( ) , module . getURI ( ) ) . getBuild ( request ) ; if ( ! moduleListEntry . isServerExpanded ( ) ) { if ( options . isDevelopmentMode ( ) || options . isDebugMode ( ) ) { request . setAttribute ( ILayer . NOCACHE_RESPONSE_REQATTRNAME , Boolean . TRUE ) ; } else { throw e ; } } else { if ( options . isDevelopmentMode ( ) || options . isDebugMode ( ) ) { try { nonErrorMessages . add ( future . get ( ) . getErrorMessage ( ) ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } } if ( isTraceLogging ) { log . logp ( Level . FINER , sourceClass , sourceMethod , "Ignoring exception for server expanded module " + e . getMessage ( ) , e ) ; } continue ; } } catch ( UnsupportedOperationException ex ) { if ( moduleListEntry . isServerExpanded ( ) ) { if ( isTraceLogging ) { log . logp ( Level . FINER , sourceClass , sourceMethod , "Ignoring exception for server expanded module " + ex . getMessage ( ) , ex ) ; } continue ; } else { throw ex ; } } futures . add ( new ModuleBuildFuture ( module , future , moduleListEntry . getSource ( ) ) ) ; } if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , futures ) ; } return futures ; } | Dispatch the modules specified in the request to the module builders and collect the build futures returned by the builders into the returned list . |
17,031 | protected String notifyLayerListeners ( ILayerListener . EventType type , HttpServletRequest request , IModule module ) throws IOException { StringBuffer sb = new StringBuffer ( ) ; List < IServiceReference > refs = null ; if ( aggr . getPlatformServices ( ) != null ) { try { IServiceReference [ ] ary = aggr . getPlatformServices ( ) . getServiceReferences ( ILayerListener . class . getName ( ) , "(name=" + aggr . getName ( ) + ")" ) ; if ( ary != null ) refs = Arrays . asList ( ary ) ; } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } if ( refs != null ) { if ( type == EventType . END_LAYER ) { refs = new ArrayList < IServiceReference > ( refs ) ; Collections . reverse ( refs ) ; } for ( IServiceReference ref : refs ) { ILayerListener listener = ( ILayerListener ) aggr . getPlatformServices ( ) . getService ( ref ) ; try { Set < String > depFeatures = new HashSet < String > ( ) ; String str = listener . layerBeginEndNotifier ( type , request , type == ILayerListener . EventType . BEGIN_MODULE ? Arrays . asList ( new IModule [ ] { module } ) : umLayerListenerModuleList , depFeatures ) ; dependentFeatures . addAll ( depFeatures ) ; if ( str != null ) { sb . append ( str ) ; } } finally { aggr . getPlatformServices ( ) . ungetService ( ref ) ; } } } } return sb . toString ( ) ; } | Calls the registered layer listeners . |
17,032 | public static String getModuleName ( URI uri ) { String name = uri . getPath ( ) ; if ( name . endsWith ( "/" ) ) { name = name . substring ( 0 , name . length ( ) - 1 ) ; } int idx = name . lastIndexOf ( "/" ) ; if ( idx != - 1 ) { name = name . substring ( idx + 1 ) ; } if ( name . endsWith ( ".js" ) ) { name = name . substring ( 0 , name . length ( ) - 3 ) ; } return name ; } | Returns the module name for the specified URI . This is the name part of the URI with path information removed and with the . js extension removed if present . |
17,033 | public static String getExtension ( String path ) { int idx = path . lastIndexOf ( "/" ) ; String filename = idx == - 1 ? path : path . substring ( idx + 1 ) ; idx = filename . lastIndexOf ( "." ) ; return idx == - 1 ? "" : filename . substring ( idx + 1 ) ; } | Returns the file extension part of the specified path |
17,034 | private boolean tryAddModule ( IAggregator aggregator , List < String > list , String bundleRoot , IResource bundleRootRes , String locale , String resource , Collection < String > availableLocales ) throws IOException { if ( availableLocales != null && ! availableLocales . contains ( locale ) ) { return false ; } boolean result = false ; URI uri = bundleRootRes . getURI ( ) ; URI testUri = uri . resolve ( locale + "/" + resource + ".js" ) ; IResource testResource = aggregator . newResource ( testUri ) ; if ( availableLocales != null || testResource . exists ( ) ) { String mid = bundleRoot + "/" + locale + "/" + resource ; list . add ( mid ) ; result = true ; } return result ; } | Adds the source for the locale specific i18n resource if it exists . |
17,035 | private static < A > ForwardNavigator < RegExp < A > > unionNav ( ) { return new ForwardNavigator < RegExp < A > > ( ) { private Visitor < A , List < RegExp < A > > > unionVis = new Visitor < A , List < RegExp < A > > > ( ) { public List < RegExp < A > > visit ( Union < A > ure ) { return Arrays . < RegExp < A > > asList ( ure . left , ure . right ) ; } public List < RegExp < A > > visit ( RegExp < A > re ) { return Collections . < RegExp < A > > emptyList ( ) ; } } ; public List < RegExp < A > > next ( RegExp < A > re ) { return re . accept ( unionVis ) ; } } ; } | forward navigator through the sons of Union nodes . |
17,036 | private static < A > ForwardNavigator < RegExp < A > > concatNav ( ) { return new ForwardNavigator < RegExp < A > > ( ) { private Visitor < A , List < RegExp < A > > > concatVis = new Visitor < A , List < RegExp < A > > > ( ) { public List < RegExp < A > > visit ( Concat < A > ure ) { return Arrays . < RegExp < A > > asList ( ure . left , ure . right ) ; } public List < RegExp < A > > visit ( RegExp < A > re ) { return Collections . < RegExp < A > > emptyList ( ) ; } } ; public List < RegExp < A > > next ( RegExp < A > re ) { return re . accept ( concatVis ) ; } } ; } | forward navigator through the sons of Concat nodes . |
17,037 | private Transformer createTransformer ( boolean indent ) { try { Transformer result = this . transformerFactory . newTransformer ( ) ; if ( indent ) { result . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; } return result ; } catch ( TransformerConfigurationException e ) { throw new IllegalStateException ( "XML Transformer misconfigured!" + " Probably your JVM does not support the required JAXP version!" , e ) ; } } | This method creates a new transformer . |
17,038 | public Parameters parameters ( ) { Parameters ps = new DefaultParameters ( ) . setTimeLimit ( timeout ) . doRepair ( repair ) . doOptimize ( optimize ) ; if ( single ( ) ) { ps . setVerbosity ( verbosity ) ; } if ( chunk ) { ps . setEnvironmentFactory ( mo -> new EnvironmentBuilder ( ) . fromChunk ( ) . build ( ) ) ; } return ps ; } | Get the parameters from the options . |
17,039 | public Stream < LabelledInstance > instances ( ) throws IOException { if ( single ( ) ) { return Collections . singletonList ( instance ( new File ( instance ) ) ) . stream ( ) ; } @ SuppressWarnings ( "resource" ) Stream < String > s = Files . lines ( Paths . get ( instances ) , StandardCharsets . UTF_8 ) ; return s . map ( x -> instance ( new File ( x ) ) ) ; } | List all the instances to solve . |
17,040 | public File output ( ) throws IOException { File o = new File ( output ) ; if ( ! o . exists ( ) && ! o . mkdirs ( ) ) { throw new IOException ( "Unable to create output folder '" + output + "'" ) ; } return o ; } | Get the output directory . |
17,041 | public static LabelledInstance instance ( File f ) { String path = f . getAbsolutePath ( ) ; return new LabelledInstance ( path , JSON . readInstance ( f ) ) ; } | Make an instance . |
17,042 | public static < T1 , T2 , T3 > Function < T1 , T3 > comp ( final Function < T2 , T3 > func1 , final Function < T1 , T2 > func2 ) { return new Function < T1 , T3 > ( ) { public T3 f ( T1 x ) { return func1 . f ( func2 . f ( x ) ) ; } } ; } | Computes the composition of two functions . |
17,043 | public Collection < VM > getAssociatedVGroup ( VM u ) { for ( Collection < VM > vGrp : sets ) { if ( vGrp . contains ( u ) ) { return vGrp ; } } return Collections . emptySet ( ) ; } | Get the group of VMs that contains the given VM . |
17,044 | protected Properties loadProps ( Properties props ) { File file = getPropsFile ( ) ; if ( file != null ) { if ( file . exists ( ) ) { try { URL url = file . toURI ( ) . toURL ( ) ; loadFromUrl ( props , url ) ; } catch ( MalformedURLException ex ) { if ( log . isLoggable ( Level . WARNING ) ) { log . log ( Level . WARNING , ex . getMessage ( ) , ex ) ; } } } } return props ; } | Loads the Options properties from the aggregator properties file into the specified properties object . If the properties file does not exist then try to load from the bundle . |
17,045 | protected void saveProps ( Properties props ) throws IOException { if ( loadFromPropertiesFile ) { File file = getPropsFile ( ) ; if ( file != null ) { FileWriter writer = new FileWriter ( file ) ; try { props . store ( writer , null ) ; } finally { writer . close ( ) ; } } } } | Saves the specified Options properties to the properties file for the aggregator . |
17,046 | protected void updateNotify ( long sequence ) { IServiceReference [ ] refs = null ; try { if ( aggregator != null && aggregator . getPlatformServices ( ) != null ) { refs = aggregator . getPlatformServices ( ) . getServiceReferences ( IOptionsListener . class . getName ( ) , "(name=" + registrationName + ")" ) ; if ( refs != null ) { for ( IServiceReference ref : refs ) { IOptionsListener listener = ( IOptionsListener ) aggregator . getPlatformServices ( ) . getService ( ref ) ; if ( listener != null ) { try { listener . optionsUpdated ( this , sequence ) ; } catch ( Throwable ignore ) { } finally { aggregator . getPlatformServices ( ) . ungetService ( ref ) ; } } } } } } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } } | Notify options change listeners that Options have been updated |
17,047 | protected void propertiesFileUpdated ( Properties updated , long sequence ) { Properties newProps = new Properties ( getDefaultOptions ( ) ) ; Enumeration < ? > propsEnum = updated . propertyNames ( ) ; while ( propsEnum . hasMoreElements ( ) ) { String name = ( String ) propsEnum . nextElement ( ) ; newProps . setProperty ( name , updated . getProperty ( name ) ) ; } setProps ( newProps ) ; updateNotify ( sequence ) ; } | Listener method for being informed of changes to the properties file by another instance of this class . Called by other instances of this class for instances that use the same properties file when properties are saved . |
17,048 | protected void propsFileUpdateNotify ( Properties updatedProps , long sequence ) { if ( aggregator == null || aggregator . getPlatformServices ( ) == null || ! loadFromPropertiesFile ) return ; IPlatformServices platformServices = aggregator . getPlatformServices ( ) ; try { IServiceReference [ ] refs = platformServices . getServiceReferences ( OptionsImpl . class . getName ( ) , "(propsFileName=" + getPropsFile ( ) . getAbsolutePath ( ) . replace ( "\\" , "\\\\" ) + ")" ) ; if ( refs != null ) { for ( IServiceReference ref : refs ) { String name = ref . getProperty ( "name" ) ; if ( ! registrationName . equals ( name ) ) { OptionsImpl impl = ( OptionsImpl ) platformServices . getService ( ref ) ; if ( impl != null ) { try { impl . propertiesFileUpdated ( updatedProps , sequence ) ; } catch ( Throwable ignore ) { } finally { platformServices . ungetService ( ref ) ; } } } } } } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } } | Notify implementations of this class that are listening for properties file updates on the same properties file that the properties file has been updated . |
17,049 | protected Properties initDefaultOptions ( ) { Properties defaultValues = new Properties ( ) ; defaultValues . putAll ( defaults ) ; ClassLoader cl = OptionsImpl . class . getClassLoader ( ) ; URL url = cl . getResource ( getPropsFilename ( ) ) ; if ( url != null ) { loadFromUrl ( defaultValues , url ) ; } if ( aggregator != null ) { url = aggregator . getPlatformServices ( ) . getResource ( getPropsFilename ( ) ) ; if ( url != null ) { loadFromUrl ( defaultValues , url ) ; } } Map < String , String > map = new HashMap < String , String > ( ) ; for ( String name : defaultValues . stringPropertyNames ( ) ) { map . put ( name , ( String ) defaultValues . getProperty ( name ) ) ; } defaultOptionsMap = Collections . unmodifiableMap ( map ) ; return defaultValues ; } | Returns the default options for this the aggregator service . |
17,050 | void setFromFractions ( final double latFraction , final double lonFraction , final double latFractionDelta , final double lonFractionDelta ) { assert ( lonFractionDelta >= 0.0 ) ; assert ( latFractionDelta != 0.0 ) ; lonFractionMin = lonFraction ; lonFractionMax = lonFraction + lonFractionDelta ; if ( latFractionDelta < 0 ) { latFractionMin = latFraction + 1 + latFractionDelta ; latFractionMax = latFraction + 1 ; } else { latFractionMin = latFraction ; latFractionMax = latFraction + latFractionDelta ; } } | Generate upper and lower limits based on x and y and delta s . |
17,051 | public boolean applyAction ( Model c ) { Mapping map = c . getMapping ( ) ; return ! map . isOffline ( node ) && map . addOfflineNode ( node ) ; } | Put the node offline on a model |
17,052 | public static void join ( SAXSymbol left , SAXSymbol right ) { if ( left . n != null ) { left . deleteDigram ( ) ; } left . n = right ; right . p = left ; } | Links left and right symbols together i . e . removes this symbol from the string also removing any old digram from the hash table . |
17,053 | public void substitute ( SAXRule r ) { r . addIndex ( this . originalPosition ) ; this . cleanUp ( ) ; this . n . cleanUp ( ) ; SAXNonTerminal nt = new SAXNonTerminal ( r ) ; nt . originalPosition = this . originalPosition ; this . p . insertAfter ( nt ) ; if ( ! p . check ( ) ) { p . n . check ( ) ; } } | Replace a digram with a non - terminal . |
17,054 | public void match ( SAXSymbol theDigram , SAXSymbol matchingDigram ) { SAXRule rule ; SAXSymbol first , second ; if ( matchingDigram . p . isGuard ( ) && matchingDigram . n . n . isGuard ( ) ) { rule = ( ( SAXGuard ) matchingDigram . p ) . r ; theDigram . substitute ( rule ) ; } else { rule = new SAXRule ( ) ; try { first = ( SAXSymbol ) theDigram . clone ( ) ; second = ( SAXSymbol ) theDigram . n . clone ( ) ; rule . theGuard . n = first ; first . p = rule . theGuard ; first . n = second ; second . p = first ; second . n = rule . theGuard ; rule . theGuard . p = second ; theDigrams . put ( first , first ) ; matchingDigram . substitute ( rule ) ; theDigram . substitute ( rule ) ; } catch ( CloneNotSupportedException c ) { c . printStackTrace ( ) ; } } if ( rule . first ( ) . isNonTerminal ( ) && ( ( ( SAXNonTerminal ) rule . first ( ) ) . r . count == 1 ) ) ( ( SAXNonTerminal ) rule . first ( ) ) . expand ( ) ; rule . assignLevel ( ) ; } | Deals with a matching digram . |
17,055 | protected static String getPayload ( SAXSymbol symbol ) { if ( symbol . isGuard ( ) ) { return "guard of the rule " + ( ( SAXGuard ) symbol ) . r . ruleIndex ; } else if ( symbol . isNonTerminal ( ) ) { return "nonterminal " + ( ( SAXNonTerminal ) symbol ) . value ; } return "symbol " + symbol . value ; } | This routine is used for the debugging . |
17,056 | public List < String > getExtraModules ( ) { return extraModules == null ? Collections . < String > emptyList ( ) : Collections . unmodifiableList ( extraModules ) ; } | Returns the list of additional modules that should be included ahead of this module build in the layer |
17,057 | public DefaultReconfigurationProblemBuilder setNextVMsStates ( Set < VM > ready , Set < VM > running , Set < VM > sleeping , Set < VM > killed ) { runs = running ; waits = ready ; sleep = sleeping ; over = killed ; return this ; } | Set the next state of the VMs . Sets must be disjoint |
17,058 | public DefaultReconfigurationProblem build ( ) throws SchedulerException { if ( runs == null ) { Mapping map = model . getMapping ( ) ; runs = new HashSet < > ( ) ; sleep = new HashSet < > ( ) ; for ( Node n : map . getOnlineNodes ( ) ) { runs . addAll ( map . getRunningVMs ( n ) ) ; sleep . addAll ( map . getSleepingVMs ( n ) ) ; } waits = map . getReadyVMs ( ) ; over = Collections . emptySet ( ) ; } if ( manageable == null ) { manageable = new HashSet < > ( ) ; manageable . addAll ( model . getMapping ( ) . getSleepingVMs ( ) ) ; manageable . addAll ( model . getMapping ( ) . getRunningVMs ( ) ) ; manageable . addAll ( model . getMapping ( ) . getReadyVMs ( ) ) ; } if ( ps == null ) { ps = new DefaultParameters ( ) ; } return new DefaultReconfigurationProblem ( model , ps , waits , runs , sleep , over , manageable ) ; } | Build the problem |
17,059 | public static String inputStreamToString ( InputStream in ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; StringBuffer buffer = new StringBuffer ( ) ; String line ; while ( ( line = br . readLine ( ) ) != null ) { buffer . append ( line ) ; } return buffer . toString ( ) ; } | read a String from an InputStream object . |
17,060 | public int compareTo ( RepairDigramRecord o ) { if ( this . freq > o . freq ) { return 1 ; } else if ( this . freq < o . freq ) { return - 1 ; } return 0 ; } | A comparator built upon occurrence frequency only . |
17,061 | protected Class < ? > getNIOFileResourceClass ( ) { final String method = "getNIOFileResourceClass" ; if ( tryNIO && nioFileResourceClass == null ) { try { nioFileResourceClass = classLoader . loadClass ( "com.ibm.jaggr.core.impl.resource.NIOFileResource" ) ; } catch ( ClassNotFoundException e ) { tryNIO = false ; if ( log . isLoggable ( Level . WARNING ) ) { log . logp ( Level . WARNING , CLAZZ , method , e . getMessage ( ) ) ; log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } } catch ( UnsupportedClassVersionError e ) { tryNIO = false ; if ( log . isLoggable ( Level . WARNING ) ) { log . logp ( Level . WARNING , CLAZZ , method , e . getMessage ( ) ) ; log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } } } return nioFileResourceClass ; } | Utility method for acquiring a reference to the NIOFileResource class without asking the class loader every single time after we know it s not there . |
17,062 | protected Constructor < ? > getNIOFileResourceConstructor ( Class < ? > ... args ) { final String method = "getNIOFileResourceConstructor" ; if ( tryNIO && nioFileResourceConstructor == null ) { try { Class < ? > clazz = getNIOFileResourceClass ( ) ; if ( clazz != null ) nioFileResourceConstructor = clazz . getConstructor ( args ) ; } catch ( NoSuchMethodException e ) { tryNIO = false ; if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } if ( log . isLoggable ( Level . WARNING ) ) log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } catch ( SecurityException e ) { tryNIO = false ; if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } if ( log . isLoggable ( Level . WARNING ) ) log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } } return nioFileResourceConstructor ; } | Utility method for acquiring a reference to the NIOFileResource class constructor without asking the class loader every single time after we know it s not there . |
17,063 | protected Object getNIOInstance ( Constructor < ? > constructor , Object ... args ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException { final String method = "getInstance" ; Object ret = null ; if ( tryNIO ) { if ( constructor != null ) { try { ret = ( IResource ) constructor . newInstance ( args ) ; } catch ( NoClassDefFoundError e ) { if ( log . isLoggable ( Level . WARNING ) ) { log . logp ( Level . WARNING , CLAZZ , method , e . getMessage ( ) ) ; log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } tryNIO = false ; } catch ( UnsupportedClassVersionError e ) { if ( log . isLoggable ( Level . WARNING ) ) { log . logp ( Level . WARNING , CLAZZ , method , e . getMessage ( ) ) ; log . logp ( Level . WARNING , CLAZZ , method , WARN_MESSAGE ) ; } tryNIO = false ; } } } return ret ; } | Utility method to catch class loading issues and prevent repeated attempts to use reflection . |
17,064 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) void complete ( ) { if ( this . range != null ) { AbstractValidatorRange validator = null ; if ( this . valueType != null ) { Class < ? > valueClass = this . valueType . getAssignmentClass ( ) ; if ( this . valueType . isCollection ( ) ) { validator = new ValidatorCollectionSize ( this . range ) ; } else if ( this . valueType . isMap ( ) ) { validator = new ValidatorMapSize ( this . range ) ; } else if ( this . valueType . getComponentType ( ) != null ) { validator = new ValidatorArrayLength ( this . range ) ; } else if ( this . mathUtil . getNumberType ( valueClass ) != null ) { validator = new ValidatorRange < > ( this . range ) ; } } if ( validator == null ) { validator = new ValidatorRangeGeneric < > ( this . range ) ; } this . validatorRegistry . add ( validator ) ; } } | Has to be called at the end to complete the processing . |
17,065 | protected void handleNoGetterForSetter ( PojoPropertyAccessorOneArg setter , Class < ? > targetClass , Object sourceObject , Class < ? > sourceClass ) { throw new PojoPropertyNotFoundException ( sourceClass , setter . getName ( ) ) ; } | Called if the target object of the conversion has a setter that has no corresponding getter in the source object to convert . |
17,066 | private void appendConsoleLogging ( Node root ) { if ( logDebug && consoleDebugOutput . size ( ) > 0 ) { Node node = root ; if ( node . getType ( ) == Token . BLOCK ) { node = node . getFirstChild ( ) ; } if ( node . getType ( ) == Token . SCRIPT ) { if ( source == null ) { Node firstNode = node . getFirstChild ( ) ; for ( List < String > entry : consoleDebugOutput ) { Node call = new Node ( Token . CALL , new Node ( Token . GETPROP , Node . newString ( Token . NAME , "console" ) , Node . newString ( Token . STRING , "log" ) ) ) ; for ( String str : entry ) { call . addChildToBack ( Node . newString ( str ) ) ; } node . addChildAfter ( new Node ( Token . EXPR_RESULT , call ) , firstNode ) ; } } else { for ( List < String > entry : consoleDebugOutput ) { StringBuffer sb = new StringBuffer ( "console.log(" ) ; int i = 0 ; for ( String str : entry ) { sb . append ( ( i ++ == 0 ? "" : "," ) + "\"" + StringUtil . escapeForJavaScript ( str ) + "\"" ) ; } sb . append ( ");\n" ) ; source . appendln ( sb . toString ( ) ) ; } } } } } | Appends the console log output if any to the end of the module |
17,067 | public void close ( ) throws IOException { if ( dataStream != null ) dataStream . close ( ) ; byteStream = null ; dataStream = null ; } | Closes the file . No more reading is possible after the file has been closed . |
17,068 | protected Collection < String > getRequestedLocales ( HttpServletRequest request ) { final String sourceMethod = "getRequestedLocales" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { request . getQueryString ( ) } ) ; } String [ ] locales ; String sLocales = getParameter ( request , REQUESTEDLOCALES_REQPARAMS ) ; if ( sLocales != null ) { locales = sLocales . split ( "," ) ; } else { locales = new String [ 0 ] ; } Collection < String > result = Collections . unmodifiableCollection ( Arrays . asList ( locales ) ) ; if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , result ) ; } return result ; } | Returns the requested locales as a collection of locale strings |
17,069 | protected String getHasConditionsFromRequest ( HttpServletRequest request ) throws IOException { final String sourceMethod = "getHasConditionsFromRequest" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { request } ) ; } String ret = null ; if ( request . getParameter ( FEATUREMAPHASH_REQPARAM ) != null ) { if ( isTraceLogging ) { log . finer ( "has hash = " + request . getParameter ( FEATUREMAPHASH_REQPARAM ) ) ; } Cookie [ ] cookies = request . getCookies ( ) ; if ( cookies != null ) { for ( int i = 0 ; ret == null && i < cookies . length ; i ++ ) { Cookie cookie = cookies [ i ] ; if ( cookie . getName ( ) . equals ( FEATUREMAP_REQPARAM ) && cookie . getValue ( ) != null ) { if ( isTraceLogging ) { log . finer ( "has cookie = " + cookie . getValue ( ) ) ; } ret = URLDecoder . decode ( cookie . getValue ( ) , "US-ASCII" ) ; break ; } } } if ( ret == null ) { if ( log . isLoggable ( Level . WARNING ) ) { StringBuffer url = request . getRequestURL ( ) ; if ( url != null ) { url . append ( "?" ) . append ( request . getQueryString ( ) ) . toString ( ) ; log . warning ( MessageFormat . format ( Messages . AbstractHttpTransport_0 , new Object [ ] { url , request . getHeader ( "User-Agent" ) } ) ) ; } } } } else { ret = request . getParameter ( FEATUREMAP_REQPARAM ) ; if ( isTraceLogging ) { log . finer ( "reading features from has query arg" ) ; } } if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , ret ) ; } return ret ; } | This method checks the request for the has conditions which may either be contained in URL query arguments or in a cookie sent from the client . |
17,070 | protected static String getParameter ( HttpServletRequest request , String [ ] aliases ) { final String sourceMethod = "getParameter" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { request . getQueryString ( ) , Arrays . asList ( aliases ) } ) ; } Map < String , String [ ] > params = request . getParameterMap ( ) ; String result = null ; for ( Map . Entry < String , String [ ] > entry : params . entrySet ( ) ) { String name = entry . getKey ( ) ; for ( String alias : aliases ) { if ( alias . equalsIgnoreCase ( name ) ) { String [ ] values = entry . getValue ( ) ; result = values [ values . length - 1 ] ; } } } if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , result ) ; } return result ; } | Returns the value of the requested parameter from the request or null |
17,071 | protected OptimizationLevel getOptimizationLevelFromRequest ( HttpServletRequest request ) { final String sourceMethod = "getOptimizationLevelFromRequest" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { request . getQueryString ( ) } ) ; } String optimize = getParameter ( request , OPTIMIZATIONLEVEL_REQPARAMS ) ; OptimizationLevel level = OptimizationLevel . SIMPLE ; if ( optimize != null && ! optimize . equals ( "" ) ) { if ( optimize . equalsIgnoreCase ( "whitespace" ) ) level = OptimizationLevel . WHITESPACE ; else if ( optimize . equalsIgnoreCase ( "advanced" ) ) level = OptimizationLevel . ADVANCED ; else if ( optimize . equalsIgnoreCase ( "none" ) ) level = OptimizationLevel . NONE ; } if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , level ) ; } return level ; } | Returns the requested optimization level from the request . |
17,072 | protected String getDynamicLoaderExtensionJavaScript ( HttpServletRequest request ) { final String sourceMethod = "getDynamicLoaderExtensionJavaScript" ; boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod ) ; } StringBuffer sb = new StringBuffer ( ) ; for ( String contribution : getExtensionContributions ( ) ) { sb . append ( contribution ) . append ( "\r\n" ) ; } String cacheBust = AggregatorUtil . getCacheBust ( getAggregator ( ) ) ; if ( cacheBust != null && cacheBust . length ( ) > 0 ) { sb . append ( "if (!require.combo.cacheBust){require.combo.cacheBust = '" ) . append ( cacheBust ) . append ( "';}\r\n" ) ; } contributeBootLayerDeps ( sb , request ) ; if ( moduleIdListHash != null ) { sb . append ( "require.combo.reg(null, [" ) ; for ( int i = 0 ; i < moduleIdListHash . length ; i ++ ) { sb . append ( i == 0 ? "" : ", " ) . append ( ( ( int ) moduleIdListHash [ i ] ) & 0xFF ) ; } sb . append ( "]);\r\n" ) ; } sb . append ( clientRegisterSyntheticModules ( ) ) ; if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , sb . toString ( ) ) ; } return sb . toString ( ) ; } | Returns the dynamic portion of the loader extension javascript for this transport . This includes all registered extension contributions . |
17,073 | protected FeatureListResourceFactory newFeatureListResourceFactory ( URI resourceUri ) { final String methodName = "newFeatureMapJSResourceFactory" ; boolean traceLogging = log . isLoggable ( Level . FINER ) ; if ( traceLogging ) { log . entering ( sourceClass , methodName , new Object [ ] { resourceUri } ) ; } FeatureListResourceFactory factory = new FeatureListResourceFactory ( resourceUri ) ; if ( traceLogging ) { log . exiting ( sourceClass , methodName ) ; } return factory ; } | Returns an instance of a FeatureMapJSResourceFactory . |
17,074 | protected String clientRegisterSyntheticModules ( ) { final String methodName = "clientRegisterSyntheticModules" ; boolean traceLogging = log . isLoggable ( Level . FINER ) ; if ( traceLogging ) { log . entering ( sourceClass , methodName ) ; } StringBuffer sb = new StringBuffer ( ) ; Map < String , Integer > map = getModuleIdMap ( ) ; if ( map != null && getModuleIdRegFunctionName ( ) != null ) { Collection < String > names = getSyntheticModuleNames ( ) ; if ( names != null && names . size ( ) > 0 ) { sb . append ( getModuleIdRegFunctionName ( ) ) . append ( "([[[" ) ; int i = 0 ; for ( String name : names ) { if ( map . get ( name ) != null ) { sb . append ( i ++ == 0 ? "" : "," ) . append ( "\"" ) . append ( name ) . append ( "\"" ) ; } } sb . append ( "]],[[" ) ; i = 0 ; for ( String name : names ) { Integer id = map . get ( name ) ; if ( id != null ) { sb . append ( i ++ == 0 ? "" : "," ) . append ( id . intValue ( ) ) ; } } sb . append ( "]]]);" ) ; } } if ( traceLogging ) { log . exiting ( sourceClass , methodName , sb . toString ( ) ) ; } return sb . toString ( ) ; } | Returns the JavaScript code for calling the client - side module name id registration function to register name ids for the transport synthetic modules . |
17,075 | public static void main ( String [ ] args ) { System . out . println ( LONG_NAME + " - Release " + RELEASE ) ; System . out . println ( ) ; System . out . println ( " " + CREDO ) ; System . out . println ( ) ; System . out . println ( "Project maintainer: " + MAINTAINER ) ; System . out . println ( "Javadoc accessible from the official website on SourceForge:\n\t" + WEBSITE ) ; System . out . println ( "Submit bug reports / feature requests on the website." ) ; } | Prints a small informative message about the current release . |
17,076 | private static int [ ] toBoundaries ( String str ) { int [ ] res = new int [ 9 ] ; String [ ] split = str . split ( "\\s+" ) ; for ( int i = 0 ; i < 9 ; i ++ ) { res [ i ] = Integer . valueOf ( split [ i ] ) . intValue ( ) ; } return res ; } | Converts a param string to boundaries array . |
17,077 | public Slice build ( ) throws SchedulerException { if ( hoster == null ) { hoster = rp . makeHostVariable ( lblPrefix , "_hoster" ) ; } if ( start == null ) { start = rp . getStart ( ) ; } if ( end == null ) { end = rp . getEnd ( ) ; } if ( duration == null ) { duration = makeDuration ( ) ; } if ( ! start . isInstantiatedTo ( 0 ) ) { TaskMonitor . build ( start , duration , end ) ; } return new Slice ( vm , start , end , duration , hoster ) ; } | Build the slice . |
17,078 | private IntVar makeDuration ( ) throws SchedulerException { if ( start . isInstantiated ( ) && end . isInstantiated ( ) ) { int d = end . getValue ( ) - start . getValue ( ) ; return rp . makeDuration ( d , d , lblPrefix , "_duration" ) ; } else if ( start . isInstantiated ( ) ) { if ( start . isInstantiatedTo ( 0 ) ) { return end ; } return rp . getModel ( ) . intOffsetView ( end , - start . getValue ( ) ) ; } int inf = end . getLB ( ) - start . getUB ( ) ; if ( inf < 0 ) { inf = 0 ; } int sup = end . getUB ( ) - start . getLB ( ) ; return rp . makeDuration ( sup , inf , lblPrefix , "_duration" ) ; } | Make the duration variable depending on the others . |
17,079 | public String generateSourceMap ( ) throws IOException { final String sourceMethod = "generateSourceMap" ; final boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { name } ) ; } String result = null ; lineLengths = getLineLengths ( ) ; Compiler compiler = new Compiler ( ) ; sgen = new SourceMapGeneratorV3 ( ) ; compiler . initOptions ( compiler_options ) ; currentLine = currentChar = 0 ; Node node = compiler . parse ( JSSourceFile . fromCode ( name , source ) ) ; if ( compiler . hasErrors ( ) ) { if ( log . isLoggable ( Level . WARNING ) ) { JSError [ ] errors = compiler . getErrors ( ) ; for ( JSError error : errors ) { log . logp ( Level . WARNING , sourceClass , sourceMethod , error . toString ( ) ) ; } } } if ( node != null ) { processNode ( node ) ; StringWriter writer = new StringWriter ( ) ; sgen . appendTo ( writer , name ) ; result = writer . toString ( ) ; } sgen = null ; lineLengths = null ; if ( isTraceLogging ) { log . exiting ( sourceClass , sourceMethod , result ) ; } return result ; } | Generate the identity source map and return the result . |
17,080 | private void processNode ( Node node ) throws IOException { for ( Node cursor = node . getFirstChild ( ) ; cursor != null ; cursor = cursor . getNext ( ) ) { int lineno = cursor . getLineno ( ) - 1 ; int charno = cursor . getCharno ( ) ; if ( lineno > currentLine || lineno == currentLine && charno > currentChar ) { currentLine = lineno ; currentChar = charno ; } FilePosition endPosition = getEndPosition ( cursor ) ; sgen . addMapping ( name , null , new FilePosition ( currentLine , currentChar ) , new FilePosition ( currentLine , currentChar ) , endPosition ) ; if ( cursor . hasChildren ( ) ) { processNode ( cursor ) ; } } } | Recursively processes the input node adding a mapping for the node to the source map generator . |
17,081 | protected void dispatchEvents ( ) { while ( true ) { Object event = this . eventQueue . poll ( ) ; if ( event == null ) { return ; } Collection < Throwable > errors = new LinkedList < > ( ) ; dispatchEvent ( event , errors ) ; if ( ! errors . isEmpty ( ) ) { handleErrors ( errors , event ) ; } } } | Dispatches all events in the event queue . |
17,082 | protected void handleErrors ( Collection < Throwable > errors , Object event ) { if ( this . globalExceptionHandler == null ) { for ( Throwable error : errors ) { LOG . error ( "Failed to dispatch event {}" , event , error ) ; } } else { this . globalExceptionHandler . handleErrors ( event , errors . toArray ( new Throwable [ errors . size ( ) ] ) ) ; } } | This method is called if errors occurred while dispatching events . |
17,083 | public BtrpOperand go ( BtrPlaceTree parent ) { append ( token , "Unhandled token " + token . getText ( ) + " (type=" + token . getType ( ) + ")" ) ; return IgnorableOperand . getInstance ( ) ; } | Parse the root of the tree . |
17,084 | public IgnorableOperand ignoreError ( Exception e ) { append ( token , e . getMessage ( ) ) ; return IgnorableOperand . getInstance ( ) ; } | Report an error from an exception for the current token |
17,085 | public IgnorableOperand ignoreErrors ( ErrorReporter err ) { errors . getErrors ( ) . addAll ( err . getErrors ( ) ) ; return IgnorableOperand . getInstance ( ) ; } | Add all the error messages included in a reporter . |
17,086 | public IgnorableOperand ignoreError ( Token t , String msg ) { append ( t , msg ) ; return IgnorableOperand . getInstance ( ) ; } | Add an error message to a given error |
17,087 | public void append ( Token t , String msg ) { errors . append ( t . getLine ( ) , t . getCharPositionInLine ( ) , msg ) ; } | Add an error message related to a given token |
17,088 | public T execute ( ) { if ( isWindows ( ) ) { return onWindows ( ) ; } else if ( isMac ( ) ) { return onMac ( ) ; } else if ( isUnix ( ) ) { return onUnix ( ) ; } else if ( isSolaris ( ) ) { return onSolaris ( ) ; } else { throw new IllegalStateException ( "Invalid operating system " + os ) ; } } | Main method that should be executed . This will return the proper result depending on your platform . |
17,089 | public BtrpOperand expand ( ) { String head = getChild ( 0 ) . getText ( ) . substring ( 0 , getChild ( 0 ) . getText ( ) . length ( ) - 1 ) ; String tail = getChild ( getChildCount ( ) - 1 ) . getText ( ) . substring ( 1 ) ; BtrpSet res = new BtrpSet ( 1 , BtrpOperand . Type . STRING ) ; for ( int i = 1 ; i < getChildCount ( ) - 1 ; i ++ ) { BtrpOperand op = getChild ( i ) . go ( this ) ; if ( op == IgnorableOperand . getInstance ( ) ) { return op ; } BtrpSet s = ( BtrpSet ) op ; for ( BtrpOperand o : s . getValues ( ) ) { res . getValues ( ) . add ( new BtrpString ( head + o . toString ( ) + tail ) ) ; } } return res ; } | Expand the enumeration . Variables are not evaluated nor checked |
17,090 | public void add ( DepTreeNode child ) { if ( children == null ) { children = new HashMap < String , DepTreeNode > ( ) ; } children . put ( child . getName ( ) , child ) ; child . setParent ( this ) ; } | Add the specified node to this node s children . |
17,091 | public void overlay ( DepTreeNode node ) { if ( node . defineDependencies != null || node . requireDependencies != null ) { setDependencies ( node . defineDependencies , node . requireDependencies , node . dependentFeatures , node . lastModified ( ) , node . lastModifiedDep ( ) ) ; } node . uri = uri ; if ( node . getChildren ( ) == null ) { return ; } for ( Map . Entry < String , DepTreeNode > entry : node . getChildren ( ) . entrySet ( ) ) { DepTreeNode existing = getChild ( entry . getKey ( ) ) ; if ( existing == null ) { add ( entry . getValue ( ) ) ; } else { existing . overlay ( entry . getValue ( ) ) ; } } } | Overlay the specified node and its descendants over this node . The specified node will be merged with this node with the dependencies of any nodes from the specified node replacing the dependencies of the corresponding node in this node s tree . |
17,092 | public DepTreeNode createOrGet ( String path , URI uri ) { if ( path . startsWith ( "/" ) ) { throw new IllegalArgumentException ( path ) ; } if ( path . length ( ) == 0 ) return this ; String [ ] pathComps = path . split ( "/" ) ; DepTreeNode node = this ; int i = 0 ; for ( String comp : pathComps ) { DepTreeNode childNode = node . getChild ( comp ) ; if ( childNode == null ) { childNode = new DepTreeNode ( comp , i == pathComps . length - 1 ? uri : null ) ; node . add ( childNode ) ; } node = childNode ; i ++ ; } return node ; } | Returns the node at the specified path location within the tree or creates it if it is not already in the tree . Will create any required parent nodes . |
17,093 | public void remove ( DepTreeNode child ) { if ( children != null ) { DepTreeNode node = children . get ( child . getName ( ) ) ; if ( node == child ) { children . remove ( child . getName ( ) ) ; } } child . setParent ( null ) ; } | Removes the specified child node |
17,094 | public void prune ( ) { if ( children != null ) { List < String > removeList = new ArrayList < String > ( ) ; for ( Entry < String , DepTreeNode > entry : children . entrySet ( ) ) { DepTreeNode child = entry . getValue ( ) ; child . prune ( ) ; if ( ( child . defineDependencies == null && child . requireDependencies == null && child . uri == null ) && ( child . children == null || child . children . isEmpty ( ) ) ) { removeList . add ( entry . getKey ( ) ) ; } } for ( String key : removeList ) { children . remove ( key ) ; } } } | Recursively walks the node tree removing folder nodes that have not children . |
17,095 | public void setDependencies ( String [ ] defineDependencies , String [ ] requireDependencies , String [ ] dependentFeatures , long lastModifiedFile , long lastModifiedDep ) { this . defineDependencies = defineDependencies ; this . requireDependencies = requireDependencies ; this . dependentFeatures = dependentFeatures ; this . lastModified = lastModifiedFile ; this . lastModifiedDep = lastModifiedDep ; } | Specifies the dependency list of modules for the module named by this node along with the last modified date of the javascript file that the dependency list was obtained from . |
17,096 | private long lastModifiedDepTree ( long lm ) { long result = ( defineDependencies == null && requireDependencies == null ) ? lm : Math . max ( lm , this . lastModifiedDep ) ; if ( children != null ) { for ( Entry < String , DepTreeNode > entry : this . children . entrySet ( ) ) { result = entry . getValue ( ) . lastModifiedDepTree ( result ) ; } } return result ; } | Returns the most recent last modified date for all the dependencies that are descendants of this node including this node . |
17,097 | void populateDepMap ( Map < String , DependencyInfo > depMap ) { if ( uri != null ) { depMap . put ( getFullPathName ( ) , new DependencyInfo ( defineDependencies , requireDependencies , dependentFeatures , uri ) ) ; } if ( children != null ) { for ( Entry < String , DepTreeNode > entry : children . entrySet ( ) ) { entry . getValue ( ) . populateDepMap ( depMap ) ; } } } | Populates the provided map with the dependencies keyed by full path name . This is done to facilitate more efficient lookups of the dependencies . |
17,098 | private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; parent = new WeakReference < DepTreeNode > ( null ) ; if ( children != null ) { for ( Entry < String , DepTreeNode > entry : children . entrySet ( ) ) { entry . getValue ( ) . setParent ( this ) ; } } } | Method called when this object is de - serialized |
17,099 | protected ServiceTracker < IOptions , ? > getOptionsServiceTracker ( BundleContext bundleContext ) throws InvalidSyntaxException { ServiceTracker < IOptions , ? > tracker = new ServiceTracker < IOptions , Object > ( bundleContext , bundleContext . createFilter ( "(&(" + Constants . OBJECTCLASS + "=" + IOptions . class . getName ( ) + ")(name=" + getServletBundleName ( ) + "))" ) , null ) ; tracker . open ( ) ; return tracker ; } | Returns an opened ServiceTracker for the Aggregator options . Aggregator options are created by the bundle activator and are shared by all Aggregator instances created from the same bundle . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.