idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
18,900 | public static RelationalBinding equalBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . EQUAL , value ) ) ; } | Creates an EQUAL binding . |
18,901 | public static RelationalBinding notEqualBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . NOT_EQUAL , value ) ) ; } | Creates a NOT_EQUAL binding . |
18,902 | public static RelationalBinding lessThanBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . LESS_THAN , value ) ) ; } | Creates a LESS_THAN binding . |
18,903 | public static RelationalBinding lessEqualBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . LESS_EQUAL , value ) ) ; } | Creates a LESS_EQUAL binding . |
18,904 | public static RelationalBinding greaterThanBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . GREATER_THAN , value ) ) ; } | Creates a GREATER_THAN binding . |
18,905 | public static RelationalBinding greaterEqualBinding ( final String property , final Object value ) { return ( new RelationalBinding ( property , Relation . GREATER_EQUAL , value ) ) ; } | Creates a GREATER_EQUAL binding . |
18,906 | public List < ISubmission > getSubmissions ( ) throws Exception { List < ISubmission > submissions = new ArrayList < ISubmission > ( ) ; LRImporter importer = new LRImporter ( node . getHost ( ) , node . getScheme ( ) ) ; submissions = getMoreSubmissions ( importer , submissions , null ) ; return submissions ; } | Get the submissions associated with the resource |
18,907 | private List < ISubmission > getMoreSubmissions ( LRImporter importer , List < ISubmission > submissions , String resumptionToken ) throws Exception { LRResult result ; if ( resumptionToken == null ) { result = importer . getObtainJSONData ( widgetIdentifier , true , false , false ) ; } else { result = importer . getObtainJSONData ( resumptionToken ) ; } if ( result == null || result . getDocuments ( ) . size ( ) == 0 ) return submissions ; JSONArray records = result . getDocuments ( ) . get ( 0 ) . getJSONArray ( "document" ) ; for ( int i = 0 ; i < records . length ( ) ; i ++ ) { JSONObject record = records . getJSONObject ( i ) ; ISubmission rating = SubmissionFactory . createSubmission ( record , this . widgetIdentifier ) ; if ( rating != null ) { submissions . add ( rating ) ; } } if ( result . getResumptionToken ( ) != null && ! result . getResumptionToken ( ) . equals ( "null" ) ) { submissions = getMoreSubmissions ( importer , submissions , result . getResumptionToken ( ) ) ; } return submissions ; } | Recursively add submissions by paging through a result set |
18,908 | public static < S extends Subscribable , E > AddEvent < S , E > addEvent ( final S source , final E element ) { return new AddEvent < S , E > ( source , element ) ; } | Returns a new AddEvent instance |
18,909 | public static < S extends Subscribable , E > RemoveEvent < S , E > removeEvent ( final S source , final E element ) { return new RemoveEvent < S , E > ( source , element ) ; } | Returns a new RemoveEvent instance |
18,910 | public static < S extends Subscribable , E > ModifyEvent < S , E > modifyEvent ( final S source , final E element , final E oldValue ) { return new ModifyEvent < S , E > ( source , element , oldValue ) ; } | Returns a new ModifyEvent instance |
18,911 | public static < S extends Subscribable , X extends Throwable > ExceptionEvent < S , X > exceptionEvent ( final S source , final X exception ) { return new ExceptionEvent < S , X > ( source , exception ) ; } | Returns a new ExceptionEvent instance |
18,912 | public void recover ( ) { try { this . messages . clear ( ) ; this . dataLogger . prepareForRead ( ) ; this . dataLogger . recover ( this ) ; } catch ( Exception e ) { throw new DelegatedRuntimeException ( e ) ; } } | recovers the dataRecorder all messages are removed and all the messsages of the logger are recoverd |
18,913 | public void release ( ) { rewind ( ) ; try { this . dataLogger . prepareForWrite ( this . getXADataRecorderId ( ) ) ; } catch ( Exception e ) { throw new DelegatedRuntimeException ( e ) ; } if ( dataRecorderLifycycleListner != null ) { this . dataRecorderLifycycleListner . recorderDataRecorderReleased ( this ) ; } } | rewinds the recorder and resets the dataLogger . Information of the dataLogger is removed |
18,914 | public void destroy ( ) { if ( dataRecorderLifycycleListner != null ) { this . dataRecorderLifycycleListner . recorderDataRecorderClosed ( this ) ; } try { this . dataLogger . destroy ( ) ; } catch ( IOException e ) { throw new DelegatedRuntimeException ( e ) ; } } | destroys the current dataLogger |
18,915 | public static String toHex ( byte [ ] data , int length ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = 0 ; i != length ; i ++ ) { int v = data [ i ] & 0xff ; buffer . append ( DIGITS . charAt ( v >> 4 ) ) ; buffer . append ( DIGITS . charAt ( v & 0xf ) ) ; } return buffer . toString ( ) ; } | Return length many bytes of the passed in byte array as a hex string . |
18,916 | protected void append ( ILoggingEvent eventObject ) { Trace < ILoggingEvent > trace = traceManager . getTrace ( ) ; if ( trace != null ) { trace . addEvent ( eventObject ) ; } } | Appends the logging event to the trace if one is currently in progress |
18,917 | public static void replaceNodeValue ( final Document doc , final String xPath , final String newValue ) { final Text textNode = doc . createTextNode ( newValue ) ; try { final Node node = ( Node ) s_path . evaluate ( xPath , doc , XPathConstants . NODE ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Found node: " + node . getNodeName ( ) ) ; } if ( node == null ) { LOG . warn ( "Could not find xPath: " + xPath ) ; return ; } node . replaceChild ( textNode , node . getFirstChild ( ) ) ; } catch ( final XPathExpressionException e ) { LOG . error ( "Bad XPath: " + xPath , e ) ; } } | Replaces the text value of a node in a document with the specified value using XPath . |
18,918 | public static SecurityManager createSecurityManager ( SystemMail systemMail , Main main ) throws IllegalAccessException { if ( ! exists ) { SecurityManager securityManager = new SecurityManager ( systemMail , main ) ; exists = true ; return securityManager ; } throw new IllegalAccessException ( "Cannot create more than one instance of IzouSecurityManager" ) ; } | Creates a SecurityManager . There can only be one single SecurityManager so calling this method twice will cause an illegal access exception . |
18,919 | public Optional < AddOnModel > getAddOnModelForClassLoader ( ) { Class [ ] classes = getClassContext ( ) ; for ( int i = classes . length - 1 ; i >= 0 ; i -- ) { if ( classes [ i ] . getClassLoader ( ) instanceof IzouPluginClassLoader && ! classes [ i ] . getName ( ) . toLowerCase ( ) . contains ( IzouPluginClassLoader . PLUGIN_PACKAGE_PREFIX_IZOU_SDK ) ) { ClassLoader classLoader = classes [ i ] . getClassLoader ( ) ; return main . getAddOnInformationManager ( ) . getAddOnForClassLoader ( classLoader ) ; } } return Optional . empty ( ) ; } | Gets the current AddOnModel that is the AddOnModel for the class loader to which the class belongs that triggered the security manager call or throws a IzouPermissionException |
18,920 | private < T > void check ( T t , BiConsumer < T , AddOnModel > specific ) { if ( ! shouldCheck ( ) ) { return ; } secureAccess . doElevated ( this :: getAddOnModelForClassLoader ) . ifPresent ( addOnModel -> secureAccess . doElevated ( ( ) -> specific . accept ( t , addOnModel ) ) ) ; } | this method first performs some basic checks and then performs the specific check |
18,921 | public void setBeans ( Collection < ? > beans ) { if ( ! CollectionUtils . isEmpty ( beans ) ) { for ( Object bean : beans ) { register ( bean ) ; } } } | Sets the beans . |
18,922 | private String genXML ( Set nodes ) throws IOException { Iterator it = nodes . iterator ( ) ; StringBuffer buf = new StringBuffer ( 1024 ) ; buf . append ( StateHelper . XML_DOC_START ) ; buf . append ( getSynchInterval ( ) ) ; buf . append ( StateHelper . XML_DOC_START_END ) ; while ( it . hasNext ( ) ) { Node n = ( Node ) it . next ( ) ; buf . append ( StateHelper . XML_NODE_TAG_START ) ; buf . append ( StateHelper . encodeMACAddress ( n . getNodeIdentifier ( ) ) ) ; buf . append ( StateHelper . XML_NODE_TAG_AFTER_ID ) ; buf . append ( n . getClockSequence ( ) ) ; buf . append ( StateHelper . XML_NODE_TAG_AFTER_CSEQ ) ; buf . append ( n . getLastTimestamp ( ) ) ; buf . append ( StateHelper . XML_NODE_TAG_END ) ; } buf . append ( StateHelper . XML_DOC_END ) ; return buf . toString ( ) ; } | Returns an XML string of the node Set . |
18,923 | public String nextStringIdentifier ( ) { long currentRandom = randomizer . nextLong ( ) ; if ( currentRandom < 0 ) { currentRandom = - currentRandom ; } currentRandom %= MAX_RANDOM_LEN ; currentRandom += MAX_RANDOM_LEN ; long currentTimeValue = 0 ; int currentCount = 0 ; synchronized ( this ) { currentTimeValue = ( System . currentTimeMillis ( ) / TIC_DIFFERENCE ) ; currentTimeValue %= MAX_TIME_SECTION_LEN ; currentTimeValue += MAX_TIME_SECTION_LEN ; if ( lastTimeValue != currentTimeValue ) { lastTimeValue = currentTimeValue ; counter = 0 ; } currentCount = counter ++ ; } StringBuffer id = new StringBuffer ( AbstractStringIdentifierGenerator . DEFAULT_ALPHANUMERIC_IDENTIFIER_SIZE ) ; id . append ( Long . toString ( currentRandom , AbstractStringIdentifierGenerator . ALPHA_NUMERIC_CHARSET_SIZE ) . substring ( 1 ) ) ; id . append ( Long . toString ( currentTimeValue , AbstractStringIdentifierGenerator . ALPHA_NUMERIC_CHARSET_SIZE ) . substring ( 1 ) ) ; id . append ( Long . toString ( currentCount , AbstractStringIdentifierGenerator . ALPHA_NUMERIC_CHARSET_SIZE ) ) ; return id . toString ( ) ; } | Gets the next new identifier . |
18,924 | protected synchronized PrefixedProperties createProperties ( ) { if ( myProperties == null ) { PrefixedProperties resultProperties = null ; String environment = defaultPrefix ; if ( environmentFactory != null ) { environment = environmentFactory . getEnvironment ( ) ; } else if ( defaultPrefixSystemPropertyKey != null ) { environment = System . getProperty ( defaultPrefixSystemPropertyKey ) ; if ( environment == null ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( String . format ( "Didn't found system property key to set default prefix: %1s" , defaultPrefixSystemPropertyKey ) ) ; } } } if ( prefixConfigList != null ) { resultProperties = PrefixedProperties . createCascadingPrefixProperties ( prefixConfigList ) ; } else { if ( environment != null ) { resultProperties = PrefixedProperties . createCascadingPrefixProperties ( environment ) ; } else { resultProperties = new PrefixedProperties ( ) ; } } resultProperties . setDefaultPrefix ( environment ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( String . format ( "Setting default prefix to: %1s" , environment ) ) ; } resultProperties . setMixDefaultAndLocalPrefixSettings ( mixDefaultAndLocalPrefixConfigurations ) ; myProperties = resultProperties ; } return myProperties ; } | Creates the properties . |
18,925 | @ ManagedAttribute ( ) public List < String > getEffectiveProperties ( ) { final List < String > properties = new LinkedList < String > ( ) ; for ( final String key : myProperties . stringPropertyNames ( ) ) { properties . add ( key + "=" + myProperties . get ( key ) ) ; } return properties ; } | Gets the effective properties . |
18,926 | public static DocumentFactory getInstance ( ) { if ( CONFIGURED_INSTANCE == null ) { synchronized ( DocumentFactory . class ) { if ( CONFIGURED_INSTANCE == null ) { CONFIGURED_INSTANCE = new DocumentFactory ( ) ; } } } return CONFIGURED_INSTANCE ; } | Gets instance of the document factory configured using configuration settings . |
18,927 | private int bufferedPeek ( final int offset ) throws IOException { if ( buffer . size ( ) > offset ) { final ListIterator < Integer > iterator = buffer . listIterator ( offset ) ; return iterator . next ( ) ; } while ( buffer . size ( ) <= offset ) { final int current = in . read ( ) ; if ( current < 0 ) return - 1 ; buffer . add ( current ) ; } return bufferedPeek ( offset ) ; } | Reads throw the buffer up to the given index filling the buffer from the underlying stream if necessary . Returns - 1 if the underlying stream terminates before the given offset can be reached . |
18,928 | public void setValue ( String columnName , Object value ) { D6ModelClassFieldInfo fieldInfo = mFieldMap . get ( columnName ) ; if ( fieldInfo != null ) { fieldInfo . value = value ; } else { final String [ ] parts = columnName . split ( "__" ) ; if ( parts . length > 0 && mFieldMap . containsKey ( parts [ 0 ] ) ) { D6ModelClassFieldInfo compositTypeFieldInfo = mFieldMap . get ( parts [ 0 ] ) ; if ( compositTypeFieldInfo . valuesForSpecialType == null ) { compositTypeFieldInfo . valuesForSpecialType = new ArrayList < Object > ( ) ; } compositTypeFieldInfo . valuesForSpecialType . add ( value ) ; } } } | Set the value to a field of the model object . The field is associated with DB column name by DBColumn annotation . |
18,929 | public T getAsObject ( ) { try { T modelClassObj = modelClazz . newInstance ( ) ; Set < String > columnNameSet = mFieldMap . keySet ( ) ; for ( String columnName : columnNameSet ) { D6ModelClassFieldInfo fieldInfo = mFieldMap . get ( columnName ) ; final Field field = fieldInfo . field ; final Object value = fieldInfo . value ; if ( value != null ) { try { field . set ( modelClassObj , null ) ; } catch ( Exception e ) { } try { field . set ( modelClassObj , value ) ; } catch ( IllegalAccessException e ) { loge ( "#getAsObject" , e ) ; } catch ( IllegalArgumentException e ) { final String name = field . getName ( ) ; final Class < ? > type = field . getType ( ) ; String msg = "The value of '" + columnName + "'=" + value + "(" + value . getClass ( ) + ") couldn't set to variable '" + name + "'(" + type + ")" ; loge ( "#getAsObject " + msg ) ; } } else { final List < Object > compositObjValues = fieldInfo . valuesForSpecialType ; if ( field . getType ( ) == org . riversun . d6 . model . Geometry . class ) { if ( compositObjValues != null && compositObjValues . size ( ) > 1 ) { final org . riversun . d6 . model . Geometry newGeometryObj = new org . riversun . d6 . model . Geometry ( ) ; newGeometryObj . x = ( Double ) compositObjValues . get ( 0 ) ; newGeometryObj . y = ( Double ) compositObjValues . get ( 1 ) ; field . set ( modelClassObj , newGeometryObj ) ; } } } } return modelClassObj ; } catch ( IllegalAccessException e ) { throw new D6RuntimeException ( e ) ; } catch ( InstantiationException e ) { throw new D6RuntimeException ( "Cannot instanciate model object from '" + modelClazz . getName ( ) + "' If you declare '" + modelClazz . getName ( ) + "' as inner class, please make it static." ) ; } } | Get the model object populated with the value of the DB search results |
18,930 | public User login ( Credentials credentials ) throws SecurityException { User loggedInUser = getUser ( ) ; if ( loggedInUser != null ) { logout ( ) ; } User user = accessManager . authenticate ( credentials ) ; if ( user != null ) { this . user = user ; userSettings = user . getSettings ( ) ; } return user ; } | Authenticates a user for a certain realm based on credentials . |
18,931 | public void onDestruction ( ) { for ( Component component : agentComponents . values ( ) ) { System . out . println ( component + " " + Arrays . asList ( component . getInterfaces ( ) ) . contains ( SessionDestructionListener . class ) ) ; if ( Arrays . asList ( component . getInterfaces ( ) ) . contains ( SessionDestructionListener . class ) ) { try { component . invoke ( "onSessionDestruction" ) ; } catch ( InvocationTargetException e ) { throw new ConfigurationException ( e ) ; } catch ( NoSuchMethodException e ) { throw new ConfigurationException ( e ) ; } } accessManager . removeAgent ( component ) ; } attributes . clear ( ) ; } | Performs destruction of agents and closes message receivers . |
18,932 | public void load ( InputStream stream , String separator ) throws IOException , PropertiesException { try ( DataInputStream data = new DataInputStream ( stream ) ; Reader reader = new InputStreamReader ( data ) ; BufferedReader br = new BufferedReader ( reader ) ) { String line ; StringBuilder buffer = new StringBuilder ( ) ; while ( ( line = br . readLine ( ) ) != null ) { if ( Strings . trimRight ( line ) . startsWith ( LINE_COMMENT_START ) ) { continue ; } else { if ( line . endsWith ( CONTINUE_ON_NEW_LINE ) ) { buffer . append ( line . replaceFirst ( "\\\\$" , "" ) ) ; continue ; } else { buffer . append ( line ) ; } } line = buffer . toString ( ) . trim ( ) ; buffer . setLength ( 0 ) ; int index = - 1 ; if ( line . length ( ) > 0 && ( index = line . lastIndexOf ( separator ) ) != - 1 ) { String key = line . substring ( 0 , index ) . trim ( ) ; String value = line . substring ( index + separator . length ( ) ) . trim ( ) ; if ( "@" . equals ( key ) ) { logger . trace ( "including and overriding values defined so far with file '{}'" , value ) ; load ( value , separator ) ; } else { logger . trace ( "adding '{}' => '{}'" , key , value ) ; this . put ( key . trim ( ) , value . trim ( ) ) ; } } } if ( buffer . length ( ) > 0 ) { logger . warn ( "multi-line property '{}' is not properly terminated" , buffer ) ; } } } | Loads the properties from an input stream . |
18,933 | public void merge ( Properties properties ) throws PropertiesException { if ( isLocked ( ) ) { throw new PropertiesException ( "properties map is locked, its contents cannot be altered." ) ; } assert properties != null ; for ( Entry < String , String > entry : properties . entrySet ( ) ) { this . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } | Merges the contents of another property set into this ; if this object and the other one both contain the same keys those is the other object will override this object s . |
18,934 | public String put ( String key , String value ) throws PropertiesException { if ( isLocked ( ) ) { throw new PropertiesException ( "properties map is locked, its contents cannot be altered." ) ; } return super . put ( key , value ) ; } | Puts a new value into the properties map . |
18,935 | public static ExecutorService getExitingExecutorService ( ThreadPoolExecutor executor , long terminationTimeout , TimeUnit timeUnit ) { return new Application ( ) . getExitingExecutorService ( executor , terminationTimeout , timeUnit ) ; } | Converts the given ThreadPoolExecutor into an ExecutorService that exits when the application is complete . It does so by using daemon threads and adding a shutdown hook to wait for their completion . |
18,936 | public static ScheduledExecutorService getExitingScheduledExecutorService ( ScheduledThreadPoolExecutor executor , long terminationTimeout , TimeUnit timeUnit ) { return new Application ( ) . getExitingScheduledExecutorService ( executor , terminationTimeout , timeUnit ) ; } | Converts the given ScheduledThreadPoolExecutor into a ScheduledExecutorService that exits when the application is complete . It does so by using daemon threads and adding a shutdown hook to wait for their completion . |
18,937 | public static boolean shutdownAndAwaitTermination ( ExecutorService service , long timeout , TimeUnit unit ) { checkNotNull ( unit ) ; service . shutdown ( ) ; try { long halfTimeoutNanos = TimeUnit . NANOSECONDS . convert ( timeout , unit ) / 2 ; if ( ! service . awaitTermination ( halfTimeoutNanos , TimeUnit . NANOSECONDS ) ) { service . shutdownNow ( ) ; service . awaitTermination ( halfTimeoutNanos , TimeUnit . NANOSECONDS ) ; } } catch ( InterruptedException ie ) { Thread . currentThread ( ) . interrupt ( ) ; service . shutdownNow ( ) ; } return service . isTerminated ( ) ; } | Shuts down the given executor gradually first disabling new submissions and later cancelling existing tasks . |
18,938 | public synchronized void startSection ( String section ) { section = section . toLowerCase ( ) ; if ( this . startTime . containsKey ( section ) ) throw new IllegalArgumentException ( "Section \"" + section + "\" had already been started!" ) ; this . startTime . put ( section , System . nanoTime ( ) ) ; this . trace . push ( section ) ; } | Starts a profiling section . |
18,939 | public static void setInitFilePath ( String filePath ) { filePath = getPropertiesFilePath ( filePath ) ; if ( staticFileProperties == null ) { staticFileProperties = new FileProperties ( filePath ) ; } else { staticFileProperties . setInitFilePath ( filePath ) ; } } | Define el fichero del cual se van a leer las propiedades . |
18,940 | public boolean isStopWord ( HString text ) { if ( text == null ) { return true ; } else if ( text . isInstance ( Types . TOKEN ) ) { return isTokenStopWord ( Cast . as ( text ) ) ; } return text . tokens ( ) . stream ( ) . allMatch ( this :: isTokenStopWord ) ; } | Is stop word . |
18,941 | public boolean hasStopWord ( HString text ) { if ( text == null ) { return true ; } else if ( text . isInstance ( Types . TOKEN ) ) { return isTokenStopWord ( Cast . as ( text ) ) ; } return text . tokens ( ) . stream ( ) . anyMatch ( this :: isTokenStopWord ) ; } | Returns true if any token in the supplied text is a stop word . |
18,942 | public void onSessionUpdate ( Request currentRequest , Session session ) { HttpServletResponse response = ( HttpServletResponse ) httpResponse . get ( ) ; storeSessionDataInCookie ( SESSION_TOKEN_KEY , session . getToken ( ) , response ) ; if ( session . getUser ( ) != null ) { storeSessionDataInCookie ( USER_ID_KEY , session . getUser ( ) . getId ( ) , response ) ; } else { storeSessionDataInCookie ( USER_ID_KEY , null , response ) ; } } | Notification of a session registration event . |
18,943 | public void onSessionDestruction ( Request currentRequest , Session session ) { HttpServletResponse response = ( HttpServletResponse ) httpResponse . get ( ) ; storeSessionDataInCookie ( SESSION_TOKEN_KEY , null , response ) ; storeSessionDataInCookie ( USER_ID_KEY , null , response ) ; } | Notification of a session destruction . |
18,944 | public void doFilter ( ServletRequest servletRequest , ServletResponse servletResponse , FilterChain chain ) throws ServletException , IOException { servletRequest . setCharacterEncoding ( "UTF-8" ) ; httpRequest . set ( servletRequest ) ; httpResponse . set ( servletResponse ) ; Request appRequest = null ; try { String sessionToken = ServletSupport . getCookieValue ( servletRequest , SESSION_TOKEN_KEY ) ; String userId = ServletSupport . getCookieValue ( servletRequest , USER_ID_KEY ) ; if ( "" . equals ( sessionToken ) ) { sessionToken = null ; } if ( "" . equals ( userId ) ) { userId = null ; } if ( accessManager != null ) { appRequest = accessManager . bindRequest ( this ) ; Session session = appRequest . resolveSession ( sessionToken , userId ) ; } if ( this . syncUserPrefs && appRequest . getTimesEntered ( ) == 0 ) { ServletSupport . importCookieValues ( servletRequest , appRequest . getUserSettings ( ) ) ; ServletSupport . exportCookieValues ( servletResponse , appRequest . getUserSettings ( ) , "/" , userPrefsMaxAge , Arrays . asList ( new String [ ] { SESSION_TOKEN_KEY } ) ) ; } if ( userId == null ) { User user = appRequest . getUser ( ) ; if ( user != null ) { storeSessionDataInCookie ( USER_ID_KEY , user . getId ( ) , servletResponse ) ; } } chain . doFilter ( servletRequest , servletResponse ) ; } catch ( Throwable t ) { if ( appRequest != null && appRequest . getTimesEntered ( ) > 1 ) { ServletSupport . rethrow ( t ) ; } handleException ( servletRequest , servletResponse , t ) ; } finally { if ( accessManager != null ) { accessManager . releaseRequest ( ) ; } } } | Must handle all incoming http requests . Contains hooks for request and session management . |
18,945 | protected List < EquPart > multiplize ( final List < EquPart > oldTokens ) { final EquPart [ ] equParts = oldTokens . toArray ( new EquPart [ 0 ] ) ; final EquPart [ ] fixed = new EquPart [ equParts . length * 2 ] ; fixed [ 0 ] = equParts [ 0 ] ; EquPart m ; int left = 0 ; for ( int right = 1 ; right < equParts . length ; right ++ ) { if ( fixed [ left ] . multiplize ( equParts [ right ] ) ) { m = new OpMultiply ( fixed [ left ] ) ; left ++ ; fixed [ left ] = m ; } left ++ ; fixed [ left ] = equParts [ right ] ; } final List < EquPart > tokens = new ArrayList < > ( ) ; for ( int i = 0 ; i < fixed . length ; i ++ ) if ( fixed [ i ] != null ) tokens . add ( fixed [ i ] ) ; return tokens ; } | put implied multipliers into the equation |
18,946 | protected List < EquPart > negatize ( final List < EquPart > equParts ) { int left = 0 ; for ( int right = 1 ; right < equParts . size ( ) ; right ++ ) { left = right - 1 ; if ( equParts . get ( left ) instanceof OpSubtract ) if ( left == 0 ) equParts . set ( left , new OpNegate ( equParts . get ( left ) ) ) ; else { if ( equParts . get ( left - 1 ) . negatize ( equParts . get ( right ) ) ) equParts . set ( left , new OpNegate ( equParts . get ( left ) ) ) ; } } return equParts ; } | change subtractions to negations if necessary |
18,947 | protected List < EquPart > rpnize ( final List < EquPart > oldTokens ) { final List < EquPart > _rpn = new Stack < > ( ) ; final Stack < EquPart > ops = new Stack < > ( ) ; Operation leftOp ; Operation rightOp ; for ( final EquPart token : oldTokens ) if ( token instanceof Token ) _rpn . add ( token ) ; else { rightOp = ( Operation ) token ; if ( ops . empty ( ) ) { if ( rightOp . includeInRpn ( ) ) ops . push ( rightOp ) ; } else { leftOp = ( Operation ) ops . peek ( ) ; if ( leftOp . preceeds ( rightOp ) ) { _rpn . add ( ops . pop ( ) ) ; int level = rightOp . getLevel ( ) ; if ( rightOp instanceof OpRightParen ) level = level + 1 ; Operation compareOp = rightOp ; while ( ! ops . empty ( ) ) { leftOp = ( Operation ) ops . peek ( ) ; if ( leftOp . getLevel ( ) < level ) break ; if ( leftOp . preceeds ( compareOp ) ) { _rpn . add ( ops . pop ( ) ) ; compareOp = leftOp ; } else break ; break ; } } if ( rightOp . includeInRpn ( ) ) ops . push ( rightOp ) ; } } while ( ! ops . empty ( ) ) _rpn . add ( ops . pop ( ) ) ; return _rpn ; } | Create a reverse Polish notation form of the equation |
18,948 | public Result < Void > deleteDataPoints ( Series series , Interval interval ) { checkNotNull ( series ) ; checkNotNull ( interval ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/data/" , API_VERSION , urlencode ( series . getKey ( ) ) ) ) ; addIntervalToURI ( builder , interval ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s, interval: %s" , series . getKey ( ) , interval ) ; throw new IllegalArgumentException ( message , e ) ; } HttpRequest request = buildRequest ( uri . toString ( ) , HttpMethod . DELETE ) ; Result < Void > result = execute ( request , Void . class ) ; return result ; } | Deletes a range of datapoints for a Series specified by key . |
18,949 | public Result < DeleteSummary > deleteSeries ( Filter filter ) { URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/" , API_VERSION ) ) ; addFilterToURI ( builder , filter ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with input - filter: %s" , filter ) ; throw new IllegalArgumentException ( message , e ) ; } HttpRequest request = buildRequest ( uri . toString ( ) , HttpMethod . DELETE ) ; Result < DeleteSummary > result = execute ( request , DeleteSummary . class ) ; return result ; } | Deletes set of series by a filter . |
18,950 | public Result < DeleteSummary > deleteAllSeries ( ) { URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/" , API_VERSION ) ) ; builder . addParameter ( "allow_truncation" , "true" ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = "Could not build URI" ; throw new IllegalArgumentException ( message , e ) ; } HttpRequest request = buildRequest ( uri . toString ( ) , HttpMethod . DELETE ) ; Result < DeleteSummary > result = execute ( request , DeleteSummary . class ) ; return result ; } | Deletes all Series in a database . |
18,951 | public Result < Series > getSeries ( String key ) { checkNotNull ( key ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/" , API_VERSION , urlencode ( key ) ) ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s" , key ) ; throw new IllegalArgumentException ( message , e ) ; } HttpRequest request = buildRequest ( uri . toString ( ) ) ; Result < Series > result = execute ( request , Series . class ) ; return result ; } | Returns a Series referenced by key . |
18,952 | public Cursor < Series > getSeries ( Filter filter ) { URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/" , API_VERSION ) ) ; addFilterToURI ( builder , filter ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with input - filter: %s" , filter ) ; throw new IllegalArgumentException ( message , e ) ; } Cursor < Series > cursor = new SeriesCursor ( uri , this ) ; return cursor ; } | Returns a cursor of series specified by a filter . |
18,953 | public Result < Summary > readSummary ( Series series , Interval interval ) { checkNotNull ( series ) ; checkNotNull ( interval ) ; DateTimeZone timezone = interval . getStart ( ) . getChronology ( ) . getZone ( ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/summary/" , API_VERSION , urlencode ( series . getKey ( ) ) ) ) ; addIntervalToURI ( builder , interval ) ; addTimeZoneToURI ( builder , timezone ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s, interval: %s, timezone: %s" , series . getKey ( ) , interval . toString ( ) , timezone . toString ( ) ) ; throw new IllegalArgumentException ( message , e ) ; } HttpRequest request = buildRequest ( uri . toString ( ) ) ; Result < Summary > result = execute ( request , Summary . class ) ; return result ; } | Reads summary statistics for a series for the specified interval . |
18,954 | public Cursor < DataPoint > readDataPoints ( Series series , Interval interval , DateTimeZone timezone , Rollup rollup , Interpolation interpolation ) { checkNotNull ( series ) ; checkNotNull ( interval ) ; checkNotNull ( timezone ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/segment/" , API_VERSION , urlencode ( series . getKey ( ) ) ) ) ; addInterpolationToURI ( builder , interpolation ) ; addIntervalToURI ( builder , interval ) ; addRollupToURI ( builder , rollup ) ; addTimeZoneToURI ( builder , timezone ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s, interval: %s, rollup: %s, timezone: %s" , series . getKey ( ) , interval , rollup , timezone ) ; throw new IllegalArgumentException ( message , e ) ; } Cursor < DataPoint > cursor = new DataPointCursor ( uri , this ) ; return cursor ; } | Returns a cursor of datapoints specified by series . |
18,955 | public Cursor < MultiDataPoint > readMultiRollupDataPoints ( Series series , Interval interval , DateTimeZone timezone , MultiRollup rollup , Interpolation interpolation ) { checkNotNull ( series ) ; checkNotNull ( interval ) ; checkNotNull ( timezone ) ; checkNotNull ( rollup ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/data/rollups/segment/" , API_VERSION , urlencode ( series . getKey ( ) ) ) ) ; addInterpolationToURI ( builder , interpolation ) ; addIntervalToURI ( builder , interval ) ; addMultiRollupToURI ( builder , rollup ) ; addTimeZoneToURI ( builder , timezone ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s, interval: %s, rollup: %s, timezone: %s" , series . getKey ( ) , interval , rollup , timezone ) ; throw new IllegalArgumentException ( message , e ) ; } Cursor < MultiDataPoint > cursor = new MultiRollupDataPointCursor ( uri , this ) ; return cursor ; } | Returns a cursor of datapoints specified by series with multiple rollups . |
18,956 | public Result < Void > writeDataPoints ( Series series , List < DataPoint > data ) { checkNotNull ( series ) ; checkNotNull ( data ) ; URI uri = null ; try { URIBuilder builder = new URIBuilder ( String . format ( "/%s/series/key/%s/data/" , API_VERSION , urlencode ( series . getKey ( ) ) ) ) ; uri = builder . build ( ) ; } catch ( URISyntaxException e ) { String message = String . format ( "Could not build URI with inputs: key: %s" , series . getKey ( ) ) ; throw new IllegalArgumentException ( message , e ) ; } Result < Void > result = null ; String body = null ; try { body = Json . dumps ( data ) ; } catch ( JsonProcessingException e ) { String message = "Error serializing the body of the request. More detail: " + e . getMessage ( ) ; result = new Result < Void > ( null , GENERIC_ERROR_CODE , message ) ; return result ; } HttpRequest request = buildRequest ( uri . toString ( ) , HttpMethod . POST , body ) ; result = execute ( request , Void . class ) ; return result ; } | Writes datapoints to single Series . |
18,957 | public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { HttpServletRequest httpServletRequest = WebFilter . request . get ( ) ; try { WebFilter . request . set ( ( HttpServletRequest ) request ) ; chain . doFilter ( request , response ) ; } finally { WebFilter . request . set ( httpServletRequest ) ; } } | Associates the current HTTP servlet request with the current thread until filter chain ends . |
18,958 | public static HttpSession session ( ) { HttpServletRequest httpServletRequest = request . get ( ) ; return ( httpServletRequest == null ) ? null : httpServletRequest . getSession ( ) ; } | Returns the HTTP session associated with the current thread . |
18,959 | public static Predicate < Quad > filterWithPrefer ( final Prefer prefer ) { final Set < String > include = new HashSet < > ( DEFAULT_REPRESENTATION ) ; ofNullable ( prefer ) . ifPresent ( p -> { p . getOmit ( ) . forEach ( include :: remove ) ; p . getInclude ( ) . forEach ( include :: add ) ; } ) ; return quad -> quad . getGraphName ( ) . filter ( x -> x instanceof IRI ) . map ( x -> ( IRI ) x ) . map ( IRI :: getIRIString ) . filter ( include :: contains ) . isPresent ( ) ; } | Create a filter based on a Prefer header |
18,960 | public static Function < Quad , Quad > unskolemizeQuads ( final ResourceService svc , final String baseUrl ) { return quad -> rdf . createQuad ( quad . getGraphName ( ) . orElse ( PreferUserManaged ) , ( BlankNodeOrIRI ) svc . toExternal ( svc . unskolemize ( quad . getSubject ( ) ) , baseUrl ) , quad . getPredicate ( ) , svc . toExternal ( svc . unskolemize ( quad . getObject ( ) ) , baseUrl ) ) ; } | Convert quads from a skolemized form to an external form |
18,961 | public static Function < Quad , Quad > skolemizeQuads ( final ResourceService svc , final String baseUrl ) { return quad -> rdf . createQuad ( quad . getGraphName ( ) . orElse ( PreferUserManaged ) , ( BlankNodeOrIRI ) svc . toInternal ( svc . skolemize ( quad . getSubject ( ) ) , baseUrl ) , quad . getPredicate ( ) , svc . toInternal ( svc . skolemize ( quad . getObject ( ) ) , baseUrl ) ) ; } | Convert quads from an external form to a skolemized form |
18,962 | public static IRI getProfile ( final List < MediaType > acceptableTypes , final RDFSyntax syntax ) { for ( final MediaType type : acceptableTypes ) { if ( RDFSyntax . byMediaType ( type . toString ( ) ) . filter ( syntax :: equals ) . isPresent ( ) && type . getParameters ( ) . containsKey ( "profile" ) ) { return rdf . createIRI ( type . getParameters ( ) . get ( "profile" ) . split ( " " ) [ 0 ] . trim ( ) ) ; } } return null ; } | Given a list of acceptable media types and an RDF syntax get the relevant profile data if relevant |
18,963 | public static Boolean isDeleted ( final Resource res ) { return LDP . Resource . equals ( res . getInteractionModel ( ) ) && res . getTypes ( ) . contains ( DeletedResource ) ; } | Check if the resource has a deleted mark |
18,964 | @ SuppressWarnings ( "rawtypes" ) public static String unqualifiedClassName ( Class type ) { if ( type . isArray ( ) ) { return unqualifiedClassName ( type . getComponentType ( ) ) + "Array" ; } String name = type . getName ( ) ; return name . substring ( name . lastIndexOf ( '.' ) + 1 ) ; } | Returns the root name of the class . |
18,965 | public static String capitalize ( String name ) { if ( name == null || name . length ( ) == 0 ) { return name ; } return name . substring ( 0 , 1 ) . toUpperCase ( ENGLISH ) + name . substring ( 1 ) ; } | Returns a String which capitalizes the first letter of the string . |
18,966 | public Resource getZanataResource ( final String id ) throws NotModifiedException { ClientResponse < Resource > response = null ; try { final ISourceDocResource client = proxyFactory . getSourceDocResource ( details . getProject ( ) , details . getVersion ( ) ) ; response = client . getResource ( id , null ) ; final Status status = Response . Status . fromStatusCode ( response . getStatus ( ) ) ; if ( status == Response . Status . OK ) { final Resource entity = response . getEntity ( ) ; return entity ; } else if ( status == Status . NOT_MODIFIED ) { throw new NotModifiedException ( ) ; } } catch ( final Exception ex ) { if ( ex instanceof NotModifiedException ) { throw ( NotModifiedException ) ex ; } else { log . error ( "Failed to retrieve the Zanata Source Document" , ex ) ; } } finally { if ( response != null ) response . releaseConnection ( ) ; performZanataRESTCallWaiting ( ) ; } return null ; } | Get a specific Source Document from Zanata . |
18,967 | public List < ResourceMeta > getZanataResources ( ) { ClientResponse < List < ResourceMeta > > response = null ; try { final ISourceDocResource client = proxyFactory . getSourceDocResource ( details . getProject ( ) , details . getVersion ( ) ) ; response = client . get ( null ) ; final Status status = Response . Status . fromStatusCode ( response . getStatus ( ) ) ; if ( status == Response . Status . OK ) { final List < ResourceMeta > entities = response . getEntity ( ) ; return entities ; } else { log . error ( "REST call to get() did not complete successfully. HTTP response code was " + status . getStatusCode ( ) + ". Reason " + "was " + status . getReasonPhrase ( ) ) ; } } catch ( final Exception ex ) { log . error ( "Failed to retrieve the list of Zanata Source Documents" , ex ) ; } finally { if ( response != null ) response . releaseConnection ( ) ; performZanataRESTCallWaiting ( ) ; } return null ; } | Get all of the Document ID s available from Zanata for the configured project . |
18,968 | public boolean createFile ( final Resource resource , boolean copyTrans ) throws UnauthorizedException { ClientResponse < String > response = null ; try { final ISourceDocResource client = proxyFactory . getSourceDocResource ( details . getProject ( ) , details . getVersion ( ) ) ; response = client . post ( resource , null , false ) ; final Status status = Response . Status . fromStatusCode ( response . getStatus ( ) ) ; if ( status == Response . Status . CREATED ) { final String entity = response . getEntity ( ) ; if ( entity . trim ( ) . length ( ) != 0 ) log . info ( entity ) ; if ( copyTrans ) { runCopyTrans ( resource . getName ( ) , true ) ; } return true ; } else if ( status == Status . UNAUTHORIZED ) { throw new UnauthorizedException ( ) ; } else { log . error ( "REST call to createResource() did not complete successfully. HTTP response code was " + status . getStatusCode ( ) + ". Reason was " + status . getReasonPhrase ( ) ) ; } } catch ( final Exception ex ) { log . error ( "Failed to create the Zanata Document" , ex ) ; if ( ex instanceof UnauthorizedException ) { throw ( UnauthorizedException ) ex ; } } finally { if ( response != null ) response . releaseConnection ( ) ; performZanataRESTCallWaiting ( ) ; } return false ; } | Create a Document in Zanata . |
18,969 | public TranslationsResource getTranslations ( final String id , final LocaleId locale ) throws NotModifiedException { ClientResponse < TranslationsResource > response = null ; try { final ITranslatedDocResource client = proxyFactory . getTranslatedDocResource ( details . getProject ( ) , details . getVersion ( ) ) ; response = client . getTranslations ( id , locale , null ) ; final Status status = Response . Status . fromStatusCode ( response . getStatus ( ) ) ; if ( status == Response . Status . FORBIDDEN ) { localeManager . removeLocale ( locale ) ; } else if ( status == Status . NOT_MODIFIED ) { throw new NotModifiedException ( ) ; } else if ( status == Response . Status . OK ) { final TranslationsResource retValue = response . getEntity ( ) ; return retValue ; } } catch ( final Exception ex ) { if ( ex instanceof NotModifiedException ) { throw ( NotModifiedException ) ex ; } else { log . error ( "Failed to retrieve the Zanata Translated Document" , ex ) ; } } finally { if ( response != null ) response . releaseConnection ( ) ; performZanataRESTCallWaiting ( ) ; } return null ; } | Get a Translation from Zanata using the Zanata Document ID and Locale . |
18,970 | public boolean runCopyTrans ( final String zanataId , boolean waitForFinish ) { log . debug ( "Running Zanata CopyTrans for " + zanataId ) ; try { final CopyTransResource copyTransResource = proxyFactory . getCopyTransResource ( ) ; copyTransResource . startCopyTrans ( details . getProject ( ) , details . getVersion ( ) , zanataId ) ; performZanataRESTCallWaiting ( ) ; if ( waitForFinish ) { while ( ! isCopyTransCompleteForSourceDocument ( copyTransResource , zanataId ) ) { Thread . sleep ( 750 ) ; } } return true ; } catch ( Exception e ) { log . error ( "Failed to run copyTrans for " + zanataId , e ) ; } finally { performZanataRESTCallWaiting ( ) ; } return false ; } | Run copy trans against a Source Document in zanata and then wait for it to complete |
18,971 | protected boolean isCopyTransCompleteForSourceDocument ( final CopyTransResource copyTransResource , final String zanataId ) { final CopyTransStatus status = copyTransResource . getCopyTransStatus ( details . getProject ( ) , details . getVersion ( ) , zanataId ) ; performZanataRESTCallWaiting ( ) ; return ! status . isInProgress ( ) ; } | Check if copy trans has finished processing a source document . |
18,972 | public Cache delete ( Regex regex ) { logger . debug ( "deleting all files named according to /{}/" , regex ) ; storage . delete ( regex ) ; return this ; } | Deletes all resources that match the given resource name criteria . |
18,973 | public Cache delete ( String resource , boolean caseInsensitive ) { logger . debug ( "deleting all files named according to '{}' (case insensitive)" , resource ) ; storage . delete ( resource , caseInsensitive ) ; return this ; } | Deletes all resource that match the given resource name criteria . |
18,974 | public Cache copyAs ( String source , String destination ) throws CacheException { if ( ! Strings . areValid ( source , destination ) ) { logger . error ( "invalid input parameters for copy from '{}' to '{}'" , source , destination ) ; throw new CacheException ( "invalid input parameters (source: '" + source + "', destination: '" + destination + "')" ) ; } try ( InputStream input = storage . retrieve ( source ) ; OutputStream output = storage . store ( destination ) ) { long copied = Streams . copy ( input , output ) ; logger . trace ( "copied {} bytes from '{}' to '{}'" , copied , source , destination ) ; } catch ( IOException e ) { logger . error ( "error copying from '" + source + "' to '" + destination + "'" , e ) ; throw new CacheException ( "error copying from '" + source + "' to '" + destination + "'" , e ) ; } return this ; } | Copies data from one resource to another possibly replacing the destination resource if one exists . |
18,975 | public boolean contains ( String resource ) { boolean result = storage . contains ( resource ) ; logger . debug ( "resource '{}' {} in cache" , resource , ( result ? "is" : "is not" ) ) ; return result ; } | Checks whether the cache contains the given resource . |
18,976 | public OutputStream put ( String resource ) throws CacheException { if ( Strings . isValid ( resource ) ) { return storage . store ( resource ) ; } return null ; } | Tells the cache to store under the given resource name the contents that will be written to the output stream ; the method creates a new resource entry and opens an output stream to it then returns the stream to the caller so this can copy its data into it . It is up to the caller to close the steam once all data have been written to it . This mechanism actually by - passes the cache and the miss handlers and provides direct access to the underlying storage engine thus providing a highly efficient way of storing data into the cache . |
18,977 | public void addAndRegisterAddOns ( List < AddOnModel > addOns ) { this . addOns . addAll ( addOns ) ; registerAllAddOns ( this . addOns ) ; initialized ( ) ; } | Registers all AddOns . |
18,978 | private void createAddOnInfos ( IdentifiableSet < AddOnModel > addOns ) { addOns . stream ( ) . forEach ( addOn -> addOnInformationManager . registerAddOn ( addOn ) ) ; } | Checks that addOns have all required properties and creating the addOn information list if they do |
18,979 | public Float computeInitialConditions ( String key , Map < String , String > fullCurrentSoil , Map < String , String > previousSoil ) { Float newValue = ( parseFloat ( fullCurrentSoil . get ( key ) ) * parseFloat ( fullCurrentSoil . get ( SLLB ) ) + parseFloat ( previousSoil . get ( key ) ) * parseFloat ( previousSoil . get ( SLLB ) ) ) ; newValue = newValue / ( parseFloat ( fullCurrentSoil . get ( SLLB ) ) + parseFloat ( previousSoil . get ( SLLB ) ) ) ; return newValue ; } | Perform initial condition convertion for icnh4 and icno3 it s important to take into account the deep of the layer for computing the aggregated value . |
18,980 | public HashMap < String , String > computeSoil ( Map < String , String > fullCurrentSoil , Map < String , String > previousSoil ) { HashMap < String , String > aggregatedSoil ; String fullCurrentValue ; String previousValue ; Float newValue ; newValue = 0f ; aggregatedSoil = new HashMap < String , String > ( ) ; for ( String p : allParams ) { if ( SLLB . equals ( p ) ) { newValue = ( parseFloat ( fullCurrentSoil . get ( p ) ) + parseFloat ( previousSoil . get ( p ) ) ) ; } else if ( ( ICNH4 . equals ( p ) && fullCurrentSoil . containsKey ( ICNH4 ) && previousSoil . containsKey ( ICNH4 ) ) || ICNO3 . equals ( p ) && fullCurrentSoil . containsKey ( ICNO3 ) && previousSoil . containsKey ( ICNO3 ) ) { newValue = computeInitialConditions ( p , fullCurrentSoil , previousSoil ) ; } else { fullCurrentValue = fullCurrentSoil . get ( p ) == null ? LayerReducerUtil . defaultValue ( p ) : fullCurrentSoil . get ( p ) ; previousValue = previousSoil . get ( p ) == null ? LayerReducerUtil . defaultValue ( p ) : previousSoil . get ( p ) ; newValue = ( parseFloat ( fullCurrentValue ) + parseFloat ( previousValue ) ) / 2f ; } aggregatedSoil . put ( p , newValue . toString ( ) ) ; } return aggregatedSoil ; } | Create a new soil filled with aggregated data coming from soils set as input parameters . |
18,981 | public InputStream openConfig ( String name ) { InputStream is = null ; String configPath = configHome + "/" + name ; try { return FileUtils . readResource ( configPath ) ; } catch ( Throwable e ) { LOG . debug ( "Config " + name + " (" + configPath + ") not found" , e ) ; } return is ; } | Do not forget to close InputStream |
18,982 | URL getURL ( ) throws HttpClientException , MalformedURLException { String buffer = url ; if ( method == HttpMethod . GET ) { buffer = url + ( url . contains ( "?" ) ? "&" : "?" ) + HttpParameter . concatenate ( parameters ) ; } logger . trace ( "real request URL: '{}'" , buffer ) ; return new URL ( buffer ) ; } | Returns the destination URL of this request . |
18,983 | public HttpRequest withHeader ( String header , String value ) { if ( Strings . isValid ( header ) ) { if ( Strings . isValid ( value ) ) { headers . put ( header , value ) ; } else { withoutHeader ( header ) ; } } return this ; } | Sets the value of the given header replacing whatever was already in there ; if the value is null or empty the header is dropped altogether . |
18,984 | public HttpRequest withoutHeader ( String header ) { if ( headers . containsKey ( header ) ) { headers . remove ( header ) ; } return this ; } | Resets the value of the given header . |
18,985 | public HttpRequest withParameter ( HttpParameter parameter ) { if ( parameter != null ) { parameters . add ( parameter ) ; } else { withoutParameter ( parameter ) ; } return this ; } | Sets the value of the given parameter replacing whatever was already in there ; if the value is null or empty the parameter is dropped altogether . |
18,986 | public HttpRequest withoutParameter ( String parameter ) { if ( Strings . isValid ( parameter ) ) { for ( HttpParameter p : parameters ) { if ( parameter . equals ( p . getName ( ) ) ) { parameters . remove ( p ) ; } } } return this ; } | Resets the value of the given parameter . |
18,987 | private Set < IWatchedCondition > copyConditions ( ) { Set < IWatchedCondition > copiedConditions = null ; synchronized ( conditions ) { Set < IObjectReference < IWatchedCondition > > copiedObjref = new HashSet < IObjectReference < IWatchedCondition > > ( this . conditions ) ; copiedConditions = new HashSet < IWatchedCondition > ( this . conditions . size ( ) ) ; this . conditions . clear ( ) ; IWatchedCondition cond = null ; for ( Iterator < IObjectReference < IWatchedCondition > > iterator = copiedObjref . iterator ( ) ; iterator . hasNext ( ) ; ) { IObjectReference < IWatchedCondition > objRef = iterator . next ( ) ; cond = objRef . get ( ) ; if ( ! objRef . isStale ( ) && cond != null && ! cond . isUseless ( ) ) { copiedConditions . add ( cond ) ; this . conditions . add ( objRef ) ; } } } return copiedConditions ; } | copies the current set of conditions and cleans up the current set of conditions |
18,988 | public synchronized void stop ( ) { try { this . kill ( ) ; } finally { this . killed = false ; this . restartCondition . setUseless ( false ) ; this . restartCondition . setActive ( false ) ; } } | stops the executing thread but does not kill the thread . It can be restarted |
18,989 | private synchronized void evaluateConditions ( ) { Set < IWatchedCondition > copiedConditions = this . copyConditions ( ) ; for ( Iterator < IWatchedCondition > iterator = copiedConditions . iterator ( ) ; iterator . hasNext ( ) ; ) { IWatchedCondition cond = iterator . next ( ) ; synchronized ( cond ) { if ( cond . isActive ( ) && ! cond . checkCondition ( ) ) { cond . conditionViolated ( ) ; } } } return ; } | evaluate the conditions |
18,990 | public void start ( ) { LoggerContext loggerFactory = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; setContext ( loggerFactory ) ; loggerFactory . addTurboFilter ( this ) ; super . start ( ) ; } | Initialize and add this turbo filter to the loggerFactory . |
18,991 | public final void registerTaskSubmitter ( TaskSubmitter taskSubmitter ) { if ( taskSubmitter == null ) { throw new TaskExeception ( "TaskSubmitter can't be NULL" ) ; } this . taskSubmitters . put ( taskSubmitter . getClass ( ) , taskSubmitter . getTaskSubmitterId ( ) ) ; } | Registers the task submitter . DO NOT USE THIS METHOD UNLESS YOU ARE DEVELOPING A NEW TASK SUBMITTER . |
18,992 | public final void registerExecutionType ( ExecutionType executionType ) { if ( executionType == null ) { throw new TaskExeception ( ExecutionType . class . getSimpleName ( ) + " NULL" ) ; } this . executionType = executionType ; } | Registers the executor type . DO NOT USE THIS METHOD UNLESS YOU ARE DEVELOPING A NEW TASK EXECUTOR . |
18,993 | public final void registerStatus ( TaskStatus status ) { TaskStatus . validate ( this . status , status ) ; this . status = status ; if ( status . equals ( TaskStatus . SUBMITTED ) ) { clear ( ) ; } } | Registers a new status . DO NOT USE THIS METHOD UNLESS YOU ARE DEVELOPING A NEW TASK EXECUTOR . |
18,994 | public List < ISubmission > getSubmissions ( String resourceUrl ) throws Exception { ParadataFetcher fetcher = new ParadataFetcher ( node , resourceUrl ) ; return fetcher . getSubmissions ( ) ; } | Return all paradata for a resource of all types from all submitters for the resource |
18,995 | public List < ISubmission > getExternalSubmissions ( String resourceUrl ) throws Exception { return new SubmitterSubmissionsFilter ( ) . omit ( getSubmissions ( resourceUrl ) , submitter ) ; } | Return all paradata for a resource of all types from other submitters for the resource |
18,996 | public List < ISubmission > getExternalStats ( String resourceUrl ) throws Exception { return getExternalSubmissions ( resourceUrl , IStats . VERB ) ; } | Return all stats from other submitters for the resource |
18,997 | public List < ISubmission > getExternalRatingSubmissions ( String resourceUrl ) throws Exception { return getExternalSubmissions ( resourceUrl , IRating . VERB ) ; } | Return all rating submissions from other submitters for the resource |
18,998 | public List < ISubmission > getExternalSubmissions ( String resourceUrl , String verb ) throws Exception { return new SubmitterSubmissionsFilter ( ) . omit ( new NormalizingFilter ( verb ) . filter ( getSubmissions ( resourceUrl ) ) , submitter ) ; } | Return all submissions using the specified verb from other submitters for the resource |
18,999 | public List < ISubmission > getSubmissionsForSubmitter ( ISubmitter submitter , String resourceUrl , String verb ) throws Exception { return new SubmitterSubmissionsFilter ( ) . include ( new NormalizingFilter ( IRating . VERB ) . filter ( getSubmissions ( resourceUrl ) ) , submitter ) ; } | Return all submissions using the specified verb from the specified submitter for the resource |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.