idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
11,600 | private static ConcurrentHashMap < Class , List < ParamValidator > > getValidatorsMap ( ) { ConcurrentHashMap < Class , List < ParamValidator > > map = new ConcurrentHashMap ( ) ; addValidators ( map , ParamValidator . class , new ParamValidator ( true ) , new ParamValidator ( false ) ) ; addValidators ( map , FileValidator . class , new FileValidator ( true ) , new FileValidator ( false ) ) ; addValidators ( map , URLValidator . class , new URLValidator ( true ) , new URLValidator ( false ) ) ; addValidators ( map , HEXValidator . class , new HEXValidator ( true ) , new HEXValidator ( false ) ) ; return map ; } | build a map of all Validator implementations by their class type and required value |
11,601 | public static < T extends ParamValidator > T getValidator ( Class < T > clazz , boolean required ) { List < ParamValidator > validators = validatorsMap . get ( clazz ) ; if ( validators != null ) { if ( required ) { return ( T ) validators . get ( 0 ) ; } return ( T ) validators . get ( 1 ) ; } return null ; } | return the relevant Validator by the given class type and required indication |
11,602 | public static ExternalDataStored compose ( ExternalDataLayerStored ... layers ) { ExternalDataStored ed = new ExternalDataStored ( ) ; for ( ExternalDataLayerStored layer : layers ) { ed . layersInOrder [ ExternalDataLayerTag . getFromClass ( layer . getClass ( ) ) . ordinal ( ) ] = layer ; } return ed ; } | Composes the layers into one document . Normally you should not use this method unless you want to manually compose document from the layer pieces . |
11,603 | public boolean hasReferenceTo ( EntitySpec entitySpec ) { if ( entitySpec == null ) { throw new IllegalArgumentException ( "entitySpec cannot be null" ) ; } boolean found = false ; String entitySpecName = entitySpec . name ; for ( ReferenceSpec refSpec : this . referenceSpecs ) { if ( refSpec . getEntityName ( ) . equals ( entitySpecName ) ) { found = true ; continue ; } } return found ; } | Returns whether this entity spec has a reference to another entity spec . |
11,604 | public ReferenceSpec [ ] referencesTo ( EntitySpec entitySpec ) { if ( entitySpec == null ) { throw new IllegalArgumentException ( "entitySpec cannot be null" ) ; } List < ReferenceSpec > result = new ArrayList < > ( ) ; String entitySpecName = entitySpec . name ; for ( ReferenceSpec refSpec : this . referenceSpecs ) { if ( refSpec . getEntityName ( ) . equals ( entitySpecName ) ) { result . add ( refSpec ) ; } } return result . toArray ( new ReferenceSpec [ result . size ( ) ] ) ; } | Returns the reference specs that point to the given entity spec . |
11,605 | public ColumnSpec [ ] getColumnSpecs ( ) { Set < ColumnSpec > results = new HashSet < > ( ) ; addTo ( results , this . baseSpec ) ; addTo ( results , this . codeSpec ) ; addTo ( results , this . constraintSpecs ) ; addTo ( results , this . finishTimeSpec ) ; addTo ( results , this . startTimeOrTimestampSpec ) ; addTo ( results , this . uniqueIdSpecs ) ; addTo ( results , this . valueSpec ) ; addTo ( results , this . createDateSpec ) ; addTo ( results , this . updateDateSpec ) ; addTo ( results , this . deleteDateSpec ) ; for ( PropertySpec propertySpec : this . propertySpecs ) { addTo ( results , propertySpec . getCodeSpec ( ) ) ; } return results . toArray ( new ColumnSpec [ results . size ( ) ] ) ; } | Returns the distinct tables specified in this entity spec not including references to other entity specs . |
11,606 | public static String prepareValue ( Object val ) { StringBuilder result = new StringBuilder ( ) ; boolean numberOrBooleanOrNull ; if ( val != null && ! ( val instanceof Number ) && ! ( val instanceof Boolean ) ) { numberOrBooleanOrNull = false ; result . append ( "'" ) ; } else { numberOrBooleanOrNull = true ; } if ( val instanceof Boolean ) { Boolean boolVal = ( Boolean ) val ; if ( boolVal . equals ( Boolean . TRUE ) ) { result . append ( 1 ) ; } else { result . append ( 0 ) ; } } else { result . append ( val ) ; } if ( ! numberOrBooleanOrNull ) { result . append ( "'" ) ; } return result . toString ( ) ; } | Generates an SQL - ready string for the given value based on its type . |
11,607 | private static Segment < PrimitiveParameter > nextSegmentAfterMatch ( PatternFinderUser def , Segment < PrimitiveParameter > seg , Algorithm algorithm , int minPatternLength , int maxPatternLength ) { if ( seg == null ) { return null ; } int arg ; int x = seg . getFirstIndex ( ) ; int y = seg . getLastIndex ( ) ; Segment < PrimitiveParameter > nextSeg = null ; if ( ( arg = def . getMaxOverlapping ( ) ) > 0 ) { int myCurrentColumn = y - ( arg + 1 ) ; if ( myCurrentColumn - 1 > x ) { nextSeg = resetSegment ( def , seg , myCurrentColumn , getYIndex ( def , myCurrentColumn , seg ) , algorithm , minPatternLength , maxPatternLength ) ; } else { nextSeg = resetSegment ( def , seg , getXIndex ( def , x , seg ) , getYIndex ( def , y + 1 , seg ) , algorithm , minPatternLength , maxPatternLength ) ; } } else { nextSeg = resetSegment ( def , seg , getXIndex ( def , x , seg ) , getYIndex ( def , y + 1 , seg ) , algorithm , minPatternLength , maxPatternLength ) ; } return nextSeg ; } | Return the next segment to be searched if the most recently searched segment matched this rule . The returned segment is calculated according to the this rule s search parameters . |
11,608 | private static int getXIndex ( PatternFinderUser def , int x , Segment < PrimitiveParameter > lastMatch ) { int skipStart = def . getSkipStart ( ) ; if ( lastMatch != null && skipStart > 0 ) { return Math . max ( x , lastMatch . getFirstIndex ( ) + skipStart ) ; } else if ( lastMatch != null && def . getSkip ( ) > 0 ) { return Math . max ( x , lastMatch . getLastIndex ( ) + def . getSkip ( ) ) ; } else { return x ; } } | Return the first value of the next segment to be searched . |
11,609 | private static int getYIndex ( PatternFinderUser def , int y , Segment < PrimitiveParameter > lastMatch ) { int skipEnd = def . getSkipEnd ( ) ; if ( lastMatch != null && skipEnd > 0 ) { return Math . max ( y , lastMatch . getLastIndex ( ) + skipEnd ) ; } else if ( lastMatch != null && def . getSkip ( ) > 0 ) { return Math . max ( y , lastMatch . getLastIndex ( ) + def . getSkip ( ) ) ; } else { return y ; } } | Return the last value of the next segment to be searched . |
11,610 | public void existenceCheck ( final Nodes nodes , final String nodeNameForDebugging ) throws XMLParsingException { if ( nodes . size ( ) == 0 ) { throw new XMLParsingException ( "Message doesn't contain a " + nodeNameForDebugging + "node!" ) ; } } | Does nothing if nodes contains at least one node . Throws InvalidCfgDocException otherwise . |
11,611 | public static void xorCheck ( final Nodes nodes1 , final Nodes nodes2 , final String nodeTypeForDebugging ) throws XMLParsingException { if ( nodes1 . size ( ) > 0 && nodes2 . size ( ) > 0 ) { throw new XMLParsingException ( "Message contains more than one " + nodeTypeForDebugging + " node. Only one permitted." ) ; } } | Does nothing if only one of nodes1 or nodes2 contains more than zero nodes . Throws InvalidCfgDocException otherwise . |
11,612 | public synchronized Map < String , String > getComponentsVersions ( ) { SortedMap < String , String > keys = new TreeMap < > ( componentVersions ) ; return keys ; } | Returns the list of registered Components and Versions as Map . |
11,613 | public synchronized void registerComponent ( Class < ? > _clazz , String _version ) { componentVersions . put ( _clazz . getName ( ) , _version ) ; } | Register a class with version . |
11,614 | private synchronized boolean isIncluded ( String _clazzName ) { if ( includes . size ( ) > 0 ) { for ( String include : includes ) { if ( _clazzName . startsWith ( include ) ) { return true ; } } } return false ; } | Check if the given FQCN matches to any given include pattern . |
11,615 | public synchronized void registerComponent ( Class < ? > _clazz ) { if ( _clazz == null ) { return ; } if ( isIncluded ( _clazz . getName ( ) ) || _clazz . getName ( ) . equals ( this . getClass ( ) . getName ( ) ) ) { String classVersion = getVersionWithReflection ( _clazz ) ; if ( classVersion != null ) { componentVersions . put ( _clazz . getName ( ) , classVersion ) ; } } } | Register a class using the Class - Object . |
11,616 | public synchronized void registerComponent ( String _string ) { if ( isIncluded ( _string ) ) { Class < ? > dummy ; try { dummy = Class . forName ( _string ) ; String classVersion = getVersionWithReflection ( dummy ) ; if ( classVersion != null ) { componentVersions . put ( _string , classVersion ) ; } } catch ( ClassNotFoundException ex ) { logger . trace ( "Unable to call getVersion on " + _string ) ; } } } | Register a component with FQCN only . This method will try to get the class version using reflections! |
11,617 | public static Builder name ( String name ) { if ( name == null || name . trim ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "Name should be defined." ) ; } return new Builder ( name ) ; } | Create new datapoint builder for metric s name . |
11,618 | public static Vector3d transform ( final Quat4d quat4d ) { Vector3d result = new Vector3d ( ) ; double test = quat4d . x * quat4d . z + quat4d . y * quat4d . w ; if ( test >= 0.5 ) { result . x = 0 ; result . y = Math . PI / 2 ; result . z = 2 * Math . atan2 ( quat4d . x , quat4d . w ) ; return result ; } if ( test <= - 0.5 ) { result . x = 0 ; result . y = - Math . PI / 2 ; result . z = - 2 * Math . atan2 ( quat4d . x , quat4d . w ) ; return result ; } double sqx = quat4d . x * quat4d . x ; double sqz = quat4d . y * quat4d . y ; double sqy = quat4d . z * quat4d . z ; result . x = Math . atan2 ( 2 * quat4d . x * quat4d . w - 2 * quat4d . z * quat4d . y , 1 - 2 * sqx - 2 * sqz ) ; result . y = Math . asin ( 2 * test ) ; result . z = Math . atan2 ( 2 * quat4d . z * quat4d . w - 2 * quat4d . x * quat4d . y , 1 - 2 * sqy - 2 * sqz ) ; return result ; } | Conversion from quaternion to Euler rotation . The x value fr |
11,619 | public static < V extends Value > ValueList < V > getInstance ( V ... value ) { ValueList < V > result = new ValueList < > ( value . length ) ; for ( V val : value ) { result . add ( val ) ; } return result ; } | Creates a list of the provided elements in the same order . |
11,620 | private static < V > TreeMap < String , V > getValuesMap ( String prefix , ParamReader < V > reader ) { TreeMap < String , V > map = null ; Iterator iter = config ( ) . getKeys ( prefix ) ; while ( iter . hasNext ( ) ) { String key = iter . next ( ) . toString ( ) ; if ( map == null ) { map = new TreeMap ( keysComparator ) ; } map . put ( key , reader . readValue ( key ) ) ; } return map ; } | return a map with all keys and values where the entries are sorted by the configured order |
11,621 | private void init ( ) { if ( ival == null ) { this . ival = intervalFactory . getInstance ( start , startGran , finish , finishGran ) ; if ( startSide == null ) { startSide = Side . START ; } if ( finishSide == null ) { finishSide = Side . FINISH ; } } } | Complete this object s initialization . This method should be called externally only by Castor . |
11,622 | public static DateValue getInstance ( Date date ) { DateValue result ; if ( date != null ) { synchronized ( cache ) { result = cache . get ( date ) ; if ( result == null ) { result = new DateValue ( date ) ; cache . put ( date , result ) ; } } } else { result = getInstance ( new Date ( ) ) ; } return result ; } | Constructs a new date value from a Java date object . Uses a cache to reuse date value objects . |
11,623 | String eval ( String expr , Map < String , ? extends Object > model ) throws TemplateException { if ( expr == null ) { throw new IllegalArgumentException ( "expr cannot be null" ) ; } try { Template t = new Template ( "t" , "${(" + expr . trim ( ) + ")?c}" , this . cfg ) ; StringWriter w = new StringWriter ( ) ; try ( StringWriter ww = w ) { t . process ( model , ww ) ; } return w . toString ( ) ; } catch ( IOException ex ) { throw new AssertionError ( ex ) ; } } | Evaluates a string as a Freemarker Template Language expression . |
11,624 | static Integer parseTimeConstraint ( Instance instance , String constraint , ConnectionManager cm ) throws KnowledgeSourceReadException { Integer constraintValue = null ; if ( instance != null && constraint != null ) { constraintValue = ( Integer ) cm . getOwnSlotValue ( instance , cm . getSlot ( constraint ) ) ; } return constraintValue ; } | Calculates a time constraint in milliseconds from a pair of time constraint and units values in a Protege instance . |
11,625 | static void setInverseIsAs ( Instance propInstance , AbstractPropositionDefinition propDef , ConnectionManager cm ) throws KnowledgeSourceReadException { Collection < ? > isas = propInstance . getDirectOwnSlotValues ( cm . getSlot ( "inverseIsA" ) ) ; Logger logger = Util . logger ( ) ; if ( isas != null && ! isas . isEmpty ( ) ) { Set < String > inverseIsANames = resolveAndLogDuplicates ( isas , logger , propInstance , "inverseIsA" ) ; String [ ] inverseIsAsArr = inverseIsANames . toArray ( new String [ inverseIsANames . size ( ) ] ) ; propDef . setInverseIsA ( inverseIsAsArr ) ; } } | Sets inverseIsA on the given proposition definition . Automatically resolves duplicate entries but logs a warning . |
11,626 | private static boolean isParameter ( Instance extendedParameter , ConnectionManager cm ) throws KnowledgeSourceReadException { Instance proposition = ( Instance ) cm . getOwnSlotValue ( extendedParameter , cm . getSlot ( "proposition" ) ) ; if ( proposition . hasType ( cm . getCls ( "Parameter" ) ) ) { return true ; } else { return false ; } } | Returns whether a Protege instance is a Parameter . |
11,627 | private static String propositionId ( Instance extendedProposition ) { Instance proposition = ( Instance ) extendedProposition . getOwnSlotValue ( extendedProposition . getKnowledgeBase ( ) . getSlot ( "proposition" ) ) ; if ( proposition . hasType ( proposition . getKnowledgeBase ( ) . getCls ( "ConstantParameter" ) ) ) { throw new IllegalStateException ( "Constant parameters are not yet supported as " + "components of a high level abstraction definition." ) ; } else { return proposition . getName ( ) ; } } | Returns the proposition id for an extended proposition definition . |
11,628 | protected void generateWRAPIDetailFiles ( RootDoc root , WRDoc wrDoc ) { List < String > tagList = new ArrayList < String > ( wrDoc . getWRTags ( ) ) ; for ( String tag : tagList ) { List < OpenAPI > openAPIList = wrDoc . getTaggedOpenAPIs ( ) . get ( tag ) ; Set < String > filesGenerated = new HashSet < String > ( ) ; for ( OpenAPI openAPI : openAPIList ) { Map < String , Object > hashMap = new HashMap < String , Object > ( ) ; hashMap . put ( "openAPI" , openAPI ) ; ObjectMapper mapper = new ObjectMapper ( ) ; mapper . setSerializationInclusion ( JsonInclude . Include . NON_EMPTY ) ; String oasJSONStr = null ; try { oasJSONStr = mapper . writeValueAsString ( this . convertToOAS ( openAPI , this . configurationEx . branchname ) ) ; } catch ( JsonProcessingException e ) { logger . error ( e ) ; } hashMap . put ( "OASV3" , oasJSONStr ) ; String tagsStr = openAPI . getTags ( ) . toString ( ) ; hashMap . put ( "tags" , tagsStr . substring ( 1 , tagsStr . length ( ) - 1 ) ) ; hashMap . put ( "generatedTime" , wrDoc . getDocGeneratedTime ( ) ) ; hashMap . put ( "branchName" , this . configurationEx . branchname ) ; hashMap . put ( "systemName" , this . configurationEx . systemname ) ; if ( StringUtils . isWhitespace ( this . configurationEx . buildid ) || this . configurationEx . buildid . equalsIgnoreCase ( "time" ) ) { hashMap . put ( "buildID" , wrDoc . getDocGeneratedTime ( ) ) ; } else { hashMap . put ( "buildID" , this . configurationEx . buildid ) ; } this . logger . info ( "buildid:" + hashMap . get ( "buildID" ) ) ; String filename = generateWRAPIFileName ( openAPI . getRequestMapping ( ) ) ; hashMap . put ( "filePath" , filename ) ; if ( ! filesGenerated . contains ( filename ) ) { this . configurationEx . getWriterFactory ( ) . getFreemarkerWriter ( ) . generateHtmlFile ( "wrAPIDetail.ftl" , hashMap , this . configurationEx . destDirName , filename ) ; filesGenerated . add ( filename ) ; } } } } | Generate the tag documentation . |
11,629 | public < T > boolean moveToNext ( ElementDescriptor < T > type , XmlPath path ) throws XmlPullParserException , XmlObjectPullParserException , IOException { pullInternal ( type , null , path , true , false ) ; return ! isEndOfDocument ( ) ; } | Moves forward to the start of the next element that matches the given type and path . |
11,630 | public < T > boolean moveToNextSibling ( ElementDescriptor < T > type , XmlPath path ) throws XmlPullParserException , XmlObjectPullParserException , IOException { return pullInternal ( type , null , path , true , true ) != null || mParser . getDepth ( ) == path . length ( ) + 1 ; } | Moves forward to the start of the next element that matches the given type and path without leaving the current sub - tree . If there is no other element of that type in the current sub - tree this mehtod will stop at the closing tab current sub - tree . Calling this methods with the same parameters won t get you any further . |
11,631 | public QualifiedName getCurrentElementQualifiedName ( ) { XmlPullParser parser = mParser ; return QualifiedName . get ( parser . getNamespace ( ) , parser . getName ( ) ) ; } | Returns the qualified name of the current element . |
11,632 | public < T > T pull ( ElementDescriptor < T > type , T recycle , XmlPath path ) throws XmlPullParserException , IOException , XmlObjectPullParserException { return pullInternal ( type , recycle , path , false , false ) ; } | Pull the next object of the given type from the XML stream . If the current position is within such an object the current object is returned . |
11,633 | public Granularity getGranularity ( ) { Interval interval = getInterval ( ) ; if ( interval != null ) { return interval . getStartGranularity ( ) ; } else { return null ; } } | Returns the granularity of this parameter s timestamp . |
11,634 | public void setGranularity ( Granularity granularity ) { Interval interval = getInterval ( ) ; if ( interval != null ) { resetInterval ( interval . getMinStart ( ) , granularity ) ; } else { resetInterval ( null , granularity ) ; } } | Sets the granularity of this parameter s timestamp . |
11,635 | public void evaluate ( KnowledgeHelper arg0 , WorkingMemory arg1 ) { @ SuppressWarnings ( "unchecked" ) List < TemporalProposition > pl = ( List < TemporalProposition > ) arg0 . get ( arg0 . getDeclaration ( "result" ) ) ; Comparator < TemporalProposition > comp ; if ( this . reverse ) { comp = ProtempaUtil . REVERSE_TEMP_PROP_COMP ; } else { comp = ProtempaUtil . TEMP_PROP_COMP ; } Collections . sort ( pl , comp ) ; this . copier . grab ( arg0 ) ; if ( this . merged ) { mergedInterval ( arg0 , pl ) ; } else { for ( ListIterator < TemporalProposition > itr = pl . listIterator ( this . minIndex ) ; itr . hasNext ( ) && itr . nextIndex ( ) < this . maxIndex ; ) { TemporalProposition o = itr . next ( ) ; o . accept ( this . copier ) ; } } this . copier . release ( ) ; } | Called when there exist the minimum necessary number of intervals with the specified proposition id in order to compute the temporal slice corresponding to this rule . |
11,636 | public final void writeValue ( Value inValue , Format inFormat ) throws TabularWriterException { this . valueVisitor . setFormat ( inFormat ) ; inValue . accept ( this . valueVisitor ) ; TabularWriterException exception = this . valueVisitor . getException ( ) ; this . valueVisitor . clear ( ) ; if ( exception != null ) { throw exception ; } } | Writes the provided value taking into account the type of value that it is and the provided formatter . |
11,637 | public static void initialize ( Object backend , BackendInstanceSpec backendInstanceSpec ) { assert backend != null : "backend cannot be null" ; assert backendInstanceSpec != null : "backendInstanceSpec cannot be null" ; for ( Method method : backend . getClass ( ) . getMethods ( ) ) { if ( method . isAnnotationPresent ( BackendProperty . class ) ) { try { BackendProperty annotation = method . getAnnotation ( BackendProperty . class ) ; String propertyName = propertyName ( annotation , method ) ; Object propertyValue = backendInstanceSpec . getProperty ( propertyName ) ; if ( propertyValue != null ) { method . invoke ( backend , new Object [ ] { propertyValue } ) ; } } catch ( IllegalAccessException | InvalidPropertyNameException | InvocationTargetException ex ) { throw new AssertionError ( ex ) ; } } } } | Sets the fields corresponding to the properties in the configuration . |
11,638 | protected L instantiateLaunchable ( ) throws CouldNotPerformException { try { return launchableClass . newInstance ( ) ; } catch ( java . lang . InstantiationException | IllegalAccessException ex ) { throw new CouldNotPerformException ( "Could not load launchable class!" , ex ) ; } } | Method creates a launchable instance without any arguments .. In case the launchable needs arguments you can overwrite this method and instantiate the launchable by ourself . |
11,639 | void validate ( KnowledgeSource knowledgeSource ) throws LinkValidationFailedException , KnowledgeSourceReadException { List < String > invalidPropIds = new ArrayList < > ( ) ; List < PropositionDefinition > propDefs = knowledgeSource . readPropositionDefinitions ( this . propIdsAsSet . toArray ( new String [ this . propIdsAsSet . size ( ) ] ) ) ; Set < String > foundPropIds = new HashSet < > ( ) ; for ( PropositionDefinition propDef : propDefs ) { foundPropIds . add ( propDef . getId ( ) ) ; } for ( String propId : this . propIdsAsSet ) { if ( ! foundPropIds . contains ( propId ) ) { invalidPropIds . add ( propId ) ; } } if ( ! invalidPropIds . isEmpty ( ) ) { throw new LinkValidationFailedException ( "Invalid proposition id(s): " + StringUtils . join ( invalidPropIds , ", " ) ) ; } } | Validates the fields of this link specification against the knowledge source . |
11,640 | final String createHeaderFragment ( String ref ) { int size = this . propIdsAsSet . size ( ) ; boolean sep1Needed = size > 0 && this . constraints . length > 0 ; String sep1 = sep1Needed ? ", " : "" ; String id = size > 0 ? "id=" : "" ; boolean parenNeeded = size > 0 || this . constraints . length > 0 ; String startParen = parenNeeded ? "(" : "" ; String finishParen = parenNeeded ? ")" : "" ; String range = rangeString ( ) ; boolean sep2Needed = sep1Needed && range . length ( ) > 0 ; String sep2 = sep2Needed ? ", " : "" ; return '.' + ref + startParen + id + StringUtils . join ( this . propIdsAsSet , ',' ) + sep1 + constraintHeaderString ( this . constraints ) + finishParen + sep2 + range ; } | Returns the default header fragment for this link . |
11,641 | public void restart ( final long waitTime ) throws CouldNotPerformException { logger . debug ( "Reset timer." ) ; try { synchronized ( lock ) { cancel ( ) ; start ( waitTime ) ; } } catch ( ShutdownInProgressException ex ) { throw ex ; } catch ( CouldNotPerformException ex ) { throw new CouldNotPerformException ( "Could not restart timer!" , ex ) ; } } | Method restarts the timeout . |
11,642 | public void start ( final long waitTime ) throws CouldNotPerformException { try { internal_start ( waitTime ) ; } catch ( CouldNotPerformException | RejectedExecutionException ex ) { if ( ex instanceof RejectedExecutionException && GlobalScheduledExecutorService . getInstance ( ) . getExecutorService ( ) . isShutdown ( ) ) { throw new ShutdownInProgressException ( "GlobalScheduledExecutorService" ) ; } throw new CouldNotPerformException ( "Could not start " + this , ex ) ; } } | Start the timeout with the given wait time . The default wait time is not modified and still the same as before . |
11,643 | private void internal_start ( final long waitTime ) throws RejectedExecutionException , CouldNotPerformException { synchronized ( lock ) { if ( isActive ( ) ) { logger . debug ( "Reject start, not interrupted or expired." ) ; return ; } expired = false ; timerTask = GlobalScheduledExecutorService . schedule ( ( Callable < Void > ) ( ) -> { synchronized ( lock ) { try { logger . debug ( "Wait for timeout TimeOut interrupted." ) ; if ( timerTask . isCancelled ( ) ) { logger . debug ( "TimeOut was canceled." ) ; return null ; } logger . debug ( "Expire..." ) ; expired = true ; } finally { timerTask = null ; } } try { expired ( ) ; } catch ( Exception ex ) { ExceptionPrinter . printHistory ( new CouldNotPerformException ( "Error during timeout handling!" , ex ) , logger , LogLevel . WARN ) ; } logger . debug ( "Worker finished." ) ; return null ; } , waitTime , TimeUnit . MILLISECONDS ) ; } } | Internal synchronized start method . |
11,644 | private Attr [ ] sortAttributes ( NamedNodeMap attrs ) { int len = ( attrs != null ) ? attrs . getLength ( ) : 0 ; Attr [ ] array = new Attr [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { array [ i ] = ( Attr ) attrs . item ( i ) ; } for ( int i = 0 ; i < len - 1 ; i ++ ) { String name = array [ i ] . getNodeName ( ) ; int index = i ; for ( int j = i + 1 ; j < len ; j ++ ) { String curName = array [ j ] . getNodeName ( ) ; if ( curName . compareTo ( name ) < 0 ) { name = curName ; index = j ; } } if ( index != i ) { Attr temp = array [ i ] ; array [ i ] = array [ index ] ; array [ index ] = temp ; } } return ( array ) ; } | Returns a sorted list of attributes . |
11,645 | public void init ( final CONFIG config ) throws InitializationException , InterruptedException { try { try ( final CloseableWriteLockWrapper ignored = getManageWriteLock ( this ) ) { if ( config == null ) { throw new NotAvailableException ( "config" ) ; } currentScope = detectScope ( config ) ; applyConfigUpdate ( config ) ; } super . init ( currentScope ) ; } catch ( CouldNotPerformException ex ) { throw new InitializationException ( this , ex ) ; } } | Initialize the controller with a configuration . |
11,646 | public CONFIG applyConfigUpdate ( final CONFIG config ) throws CouldNotPerformException , InterruptedException { try { boolean scopeChanged ; try ( final CloseableWriteLockWrapper ignored = getManageWriteLock ( this ) ) { this . config = config ; if ( supportsDataField ( TYPE_FIELD_ID ) && hasConfigField ( TYPE_FIELD_ID ) ) { setDataField ( TYPE_FIELD_ID , getConfigField ( TYPE_FIELD_ID ) ) ; } if ( supportsDataField ( TYPE_FIELD_LABEL ) && hasConfigField ( TYPE_FIELD_LABEL ) ) { setDataField ( TYPE_FIELD_LABEL , getConfigField ( TYPE_FIELD_LABEL ) ) ; } scopeChanged = ! currentScope . equals ( detectScope ( config ) ) ; currentScope = detectScope ( ) ; } try { if ( isActive ( ) && scopeChanged ) { super . init ( currentScope ) ; } } catch ( CouldNotPerformException ex ) { throw new CouldNotPerformException ( "Could not verify scope changes!" , ex ) ; } return this . config ; } catch ( CouldNotPerformException ex ) { throw new CouldNotPerformException ( "Could not apply config update!" , ex ) ; } } | Apply an update to the configuration of this controller . |
11,647 | protected String resolvePlaceholder ( String placeholder , Properties props ) { String resolvedPlaceholder = super . resolvePlaceholder ( placeholder , props ) ; if ( null == resolvedPlaceholder ) { LOGGER . trace ( "could not resolve place holder for key: " + placeholder + ". Please check your configuration files." ) ; return resolvedPlaceholder ; } else { return resolvedPlaceholder . trim ( ) ; } } | trim the string value before it is returned to the caller method . |
11,648 | private Map < ElementDescriptor < ? > , Object > getDepthStateMap ( int depth , boolean create ) { if ( mState == null ) { mState = new ArrayList < Map < ElementDescriptor < ? > , Object > > ( Math . max ( 16 , depth + 8 ) ) ; } while ( depth > mState . size ( ) ) { mState . add ( null ) ; } Map < ElementDescriptor < ? > , Object > map = mState . get ( depth - 1 ) ; if ( ! create || map != null ) { return map ; } map = new HashMap < ElementDescriptor < ? > , Object > ( 8 ) ; mState . set ( depth - 1 , map ) ; return map ; } | Return the element state map for the given depth creating non - existing maps if required . |
11,649 | public void addIncludedPackageNames ( String _packageName ) { if ( _packageName . endsWith ( "." ) ) { includePackageNames . add ( _packageName ) ; ComponentRegistry . getInstance ( ) . addPackageToIncludeList ( _packageName ) ; } } | Add a package name which should be loaded with this classloader . |
11,650 | private boolean isIncluded ( String _fqcn ) { if ( includePackageNames . contains ( _fqcn ) ) { return true ; } String packageName = _fqcn . substring ( 0 , _fqcn . lastIndexOf ( '.' ) + 1 ) ; for ( String str : includePackageNames ) { if ( packageName . startsWith ( str ) ) { return true ; } } return false ; } | Check if a certain class is included . |
11,651 | public boolean add ( TemporalExtendedPropositionDefinition tepd ) { if ( tepd != null ) { boolean result = this . abstractedFrom . add ( tepd ) ; if ( result ) { recalculateChildren ( ) ; } return result ; } else { return false ; } } | Adds a proposition id from which this slice definition is abstracted . |
11,652 | public static File extractFileGzip ( String _compressedFile , String _outputFileName ) { return decompress ( CompressionMethod . GZIP , _compressedFile , _outputFileName ) ; } | Extracts a GZIP compressed file to the given outputfile . |
11,653 | public static File compressFileGzip ( String _sourceFile , String _outputFileName ) { return compress ( CompressionMethod . GZIP , _sourceFile , _outputFileName ) ; } | Compresses the given file with GZIP and writes the compressed file to outputFileName . |
11,654 | public static void title ( Writer writer , String title ) throws IOException { if ( title == null || title . isEmpty ( ) ) { return ; } String out = String . format ( "%s\n%s\n\n" , title , Stream . generate ( ( ) -> "=" ) . limit ( title . length ( ) ) . collect ( Collectors . joining ( ) ) ) ; writer . write ( out ) ; } | Simple helper method that prints the specified title underlined with = characters . |
11,655 | private Point3D VecToPoint ( final Vec3DFloat vector ) { return new Point3D ( vector . getX ( ) , vector . getY ( ) , vector . getZ ( ) ) ; } | Transforms a Vec3DFloat object to a Point3D object . |
11,656 | public void update ( final Ray3DFloat ray ) { final Point3D origin = VecToPoint ( ray . getOrigin ( ) ) ; final Point3D direction = VecToPoint ( ray . getDirection ( ) ) ; final Point3D end = origin . add ( direction . normalize ( ) . multiply ( rayLength ) ) ; super . setStartEndPoints ( origin , end ) ; } | Updates the ray orientation and position to the specified data . |
11,657 | private Cls readClass ( String name , String superClass ) throws KnowledgeSourceReadException { Cls cls = this . cm . getCls ( name ) ; Cls superCls = this . cm . getCls ( superClass ) ; if ( cls != null && cls . hasSuperclass ( superCls ) ) { return cls ; } else { return null ; } } | Returns the Cls from Protege if a matching Cls is found with the given ancestor |
11,658 | public boolean validateTLSA ( URL url ) throws ValidSelfSignedCertException { TLSARecord tlsaRecord = getTLSARecord ( url ) ; if ( tlsaRecord == null ) { return false ; } List < Certificate > certs = getUrlCerts ( url ) ; if ( certs == null || certs . size ( ) == 0 ) { return false ; } Certificate matchingCert = getMatchingCert ( tlsaRecord , certs ) ; if ( matchingCert == null ) { return false ; } switch ( tlsaRecord . getCertificateUsage ( ) ) { case TLSARecord . CertificateUsage . CA_CONSTRAINT : if ( isValidCertChain ( matchingCert , certs ) && matchingCert != certs . get ( 0 ) ) { return true ; } break ; case TLSARecord . CertificateUsage . SERVICE_CERTIFICATE_CONSTRAINT : if ( isValidCertChain ( matchingCert , certs ) && matchingCert == certs . get ( 0 ) ) { return true ; } break ; case TLSARecord . CertificateUsage . TRUST_ANCHOR_ASSERTION : if ( isValidCertChain ( certs . get ( 0 ) , certs ) && matchingCert == certs . get ( certs . size ( ) - 1 ) ) { throw new ValidSelfSignedCertException ( matchingCert ) ; } break ; case TLSARecord . CertificateUsage . DOMAIN_ISSUED_CERTIFICATE : throw new ValidSelfSignedCertException ( matchingCert ) ; } return false ; } | Validates a URL s TLSA Record |
11,659 | public boolean isValidCertChain ( Certificate targetCert , List < Certificate > certs ) { try { KeyStore cacerts = this . caCertService . getCaCertKeystore ( ) ; for ( Certificate cert : certs ) { if ( cert == targetCert ) continue ; cacerts . setCertificateEntry ( ( ( X509Certificate ) cert ) . getSubjectDN ( ) . toString ( ) , cert ) ; } return this . chainValidator . validateKeyChain ( ( X509Certificate ) targetCert , cacerts ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return false ; } | Validate whether the target cert is valid using the CA Certificate KeyStore and any included intermediate certificates |
11,660 | public Certificate getMatchingCert ( TLSARecord tlsaRecord , List < Certificate > certs ) { for ( Certificate cert : certs ) { byte [ ] digestMatch = new byte [ 0 ] ; byte [ ] selectorData = new byte [ 0 ] ; try { switch ( tlsaRecord . getSelector ( ) ) { case TLSARecord . Selector . FULL_CERTIFICATE : selectorData = cert . getEncoded ( ) ; break ; case TLSARecord . Selector . SUBJECT_PUBLIC_KEY_INFO : selectorData = cert . getPublicKey ( ) . getEncoded ( ) ; break ; } switch ( tlsaRecord . getMatchingType ( ) ) { case TLSARecord . MatchingType . EXACT : digestMatch = selectorData ; break ; case TLSARecord . MatchingType . SHA256 : digestMatch = MessageDigest . getInstance ( "SHA-256" ) . digest ( selectorData ) ; break ; case TLSARecord . MatchingType . SHA512 : digestMatch = MessageDigest . getInstance ( "SHA-512" ) . digest ( selectorData ) ; break ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( Arrays . equals ( digestMatch , tlsaRecord . getCertificateAssociationData ( ) ) ) { return cert ; } } return null ; } | Returns the certificate matching the TLSA record from the given certs |
11,661 | public List < Certificate > getUrlCerts ( URL url ) { SSLSocket socket = null ; TrustManager trm = new X509TrustManager ( ) { public X509Certificate [ ] getAcceptedIssuers ( ) { return null ; } public void checkClientTrusted ( X509Certificate [ ] certs , String authType ) { } public void checkServerTrusted ( X509Certificate [ ] certs , String authType ) { } } ; try { SSLContext sc = SSLContext . getInstance ( "SSL" ) ; sc . init ( null , new TrustManager [ ] { trm } , null ) ; SSLSocketFactory factory = sc . getSocketFactory ( ) ; socket = ( SSLSocket ) factory . createSocket ( url . getHost ( ) , ( url . getPort ( ) == - 1 ) ? url . getDefaultPort ( ) : url . getPort ( ) ) ; socket . startHandshake ( ) ; SSLSession session = socket . getSession ( ) ; Certificate [ ] certArray = session . getPeerCertificates ( ) ; return new ArrayList < Certificate > ( Arrays . asList ( certArray ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( socket != null && socket . isConnected ( ) ) { try { socket . close ( ) ; } catch ( IOException ignored ) { } } } return new ArrayList < Certificate > ( ) ; } | Gets all certificates from an HTTPS endpoint URL |
11,662 | public TLSARecord getTLSARecord ( URL url ) { String recordValue ; int port = url . getPort ( ) ; if ( port == - 1 ) { port = url . getDefaultPort ( ) ; } String tlsaRecordName = String . format ( "_%s._tcp.%s" , port , DNSUtil . ensureDot ( url . getHost ( ) ) ) ; try { recordValue = this . dnssecResolver . resolve ( tlsaRecordName , Type . TLSA ) ; } catch ( DNSSECException e ) { return null ; } if ( recordValue . equals ( "" ) ) return null ; String [ ] tlsaValues = recordValue . split ( " " ) ; if ( tlsaValues . length != 4 ) return null ; try { return new TLSARecord ( new Name ( tlsaRecordName ) , DClass . IN , 0 , Integer . parseInt ( tlsaValues [ 0 ] ) , Integer . parseInt ( tlsaValues [ 1 ] ) , Integer . parseInt ( tlsaValues [ 2 ] ) , BaseEncoding . base16 ( ) . decode ( tlsaValues [ 3 ] ) ) ; } catch ( TextParseException e ) { return null ; } } | Handle DNSSEC resolution for the URL s associated TLSA record |
11,663 | < T extends TemporalProposition > boolean execute ( PropositionDefinition propDef , Segment < T > tp1 , Segment < T > tp2 ) { if ( tp1 == null || tp2 == null ) { return false ; } return executeInternal ( propDef , tp1 . getInterval ( ) , tp2 . getInterval ( ) ) ; } | Computes whether the union of two segments of temporal propositions should be taken . |
11,664 | String getTarget ( Object source ) { if ( this . mappings != null ) { return this . mappings . getTarget ( source ) ; } else { return null ; } } | Returns the proposition id corresponding to a specified value in this column spec s column . |
11,665 | public ColumnSpec getLastSpec ( ) { if ( this . joinSpec == null ) { return this ; } else { List < ColumnSpec > l = asList ( ) ; return l . get ( l . size ( ) - 1 ) ; } } | Gets the last column spec in the chain of column specs and joins . |
11,666 | public static String toSQLString ( Long position ) { java . util . Date date = AbsoluteTimeGranularityUtil . asDate ( position ) ; return new Timestamp ( date . getTime ( ) ) . toString ( ) ; } | Convenience method to translate a timestamp into the format expected by SQL . |
11,667 | public void fadeForegroundIconColorFromOpaqueToTransparent ( final int cycleCount ) { stopForegroundIconColorFadeAnimation ( ) ; foregroundColorFadeAnimation = Animations . createFadeTransition ( foregroundIcon , JFXConstants . TRANSPARENCY_NONE , JFXConstants . TRANSPARENCY_FULLY , cycleCount , JFXConstants . ANIMATION_DURATION_FADE_SLOW ) ; foregroundColorFadeAnimation . setOnFinished ( event -> foregroundIcon . setOpacity ( JFXConstants . TRANSPARENCY_FULLY ) ) ; foregroundColorFadeAnimation . play ( ) ; } | Apply and play a FadeTransition on the icon in the foregroundIcon . This Transition modifies the opacity of the foregroundIcon from opaque to fully transparent . |
11,668 | public void fadeBackgroundIconColorFromTransparentToOpaque ( final int cycleCount ) { stopBackgroundIconColorFadeAnimation ( ) ; backgroundIconColorFadeAnimation = Animations . createFadeTransition ( backgroundIcon , JFXConstants . TRANSPARENCY_FULLY , JFXConstants . TRANSPARENCY_NONE , 1 , JFXConstants . ANIMATION_DURATION_FADE_SLOW ) ; backgroundIconColorFadeAnimation . setOnFinished ( event -> backgroundIcon . setOpacity ( JFXConstants . TRANSPARENCY_NONE ) ) ; backgroundIconColorFadeAnimation . play ( ) ; } | Apply and play a FadeTransition on the icon in the foregroundIcon . This Transition modifies the opacity of the foregroundIcon from fully transparent to opaque . |
11,669 | public void startBackgroundIconColorFadeAnimation ( final int cycleCount ) { if ( backgroundIcon == null ) { LOGGER . warn ( "Background animation skipped because background icon not set!" ) ; return ; } backgroundIconColorFadeAnimation = Animations . createFadeTransition ( backgroundIcon , JFXConstants . TRANSPARENCY_FULLY , JFXConstants . TRANSPARENCY_NONE , cycleCount , JFXConstants . ANIMATION_DURATION_FADE_SLOW ) ; backgroundIconColorFadeAnimation . setOnFinished ( event -> backgroundIcon . setOpacity ( JFXConstants . TRANSPARENCY_FULLY ) ) ; backgroundIconColorFadeAnimation . play ( ) ; } | Method starts the fade animation of the background icon color . |
11,670 | public void startForegroundIconRotateAnimation ( final double fromAngle , final double toAngle , final int cycleCount , final double duration , final Interpolator interpolator , final boolean autoReverse ) { stopForegroundIconRotateAnimation ( ) ; foregroundRotateAnimation = Animations . createRotateTransition ( foregroundIcon , fromAngle , toAngle , cycleCount , duration , interpolator , autoReverse ) ; foregroundRotateAnimation . setOnFinished ( event -> foregroundIcon . setRotate ( 0 ) ) ; foregroundRotateAnimation . play ( ) ; } | Method starts the rotate animation of the foreground icon . |
11,671 | public void startBackgroundIconRotateAnimation ( final double fromAngle , final double toAngle , final int cycleCount , final double duration , final Interpolator interpolator , final boolean autoReverse ) { stopBackgroundIconRotateAnimation ( ) ; backgroundRotateAnimation = Animations . createRotateTransition ( backgroundIcon , fromAngle , toAngle , cycleCount , duration , interpolator , autoReverse ) ; backgroundRotateAnimation . setOnFinished ( event -> backgroundIcon . setRotate ( 0 ) ) ; backgroundRotateAnimation . play ( ) ; } | Method starts the rotate animation of the background icon . |
11,672 | public void setForegroundIconColorDefault ( ) { stopForegroundIconColorFadeAnimation ( ) ; foregroundIcon . getStyleClass ( ) . clear ( ) ; foregroundIcon . getStyleClass ( ) . add ( JFXConstants . CSS_ICON ) ; foregroundFadeIcon . setFill ( Color . TRANSPARENT ) ; } | Reset the current foreground icon color to default . |
11,673 | public void setBackgroundIconColorDefault ( ) { if ( backgroundIcon == null ) { LOGGER . warn ( "Background modification skipped because background icon not set!" ) ; return ; } stopBackgroundIconColorFadeAnimation ( ) ; backgroundIcon . getStyleClass ( ) . clear ( ) ; backgroundIcon . getStyleClass ( ) . add ( JFXConstants . CSS_ICON ) ; backgroundFadeIcon . setFill ( Color . TRANSPARENT ) ; } | Reset the current background icon color to default . |
11,674 | public synchronized void loadValue ( final ARG_TYPE arg ) { if ( fetchFuture != null ) { fetchFuture . cancel ( false ) ; if ( fetchThread != null ) { fetchThread . interruptAndInformListenersIfNeeded ( ) ; } } fetchThread = new LoadThread < RETURN_TYPE , ARG_TYPE > ( valueGetter , successListener , errorListener , value , arg , dropValueOnFailure ) ; fetchFuture = valueGetterExecutor . submit ( fetchThread ) ; } | Loads value in separate thread . |
11,675 | public static String getValue ( final MetaConfig metaConfig , final String key ) throws NotAvailableException { for ( EntryType . Entry entry : metaConfig . getEntryList ( ) ) { if ( entry . getKey ( ) . equals ( key ) ) { if ( ! entry . getValue ( ) . isEmpty ( ) ) { return entry . getValue ( ) ; } } } throw new NotAvailableException ( "value for Key[" + key + "]" ) ; } | Resolves the key to the value entry of the given meta config . |
11,676 | public void init ( String strDateParam , Date timeTarget , String strLanguage ) { if ( strDateParam != null ) m_strDateParam = strDateParam ; timeNow = new Date ( ) ; if ( timeTarget == null ) timeTarget = timeNow ; selectedTime = timeTarget ; if ( strLanguage != null ) { Locale locale = new Locale ( strLanguage , "" ) ; if ( locale != null ) { calendar = Calendar . getInstance ( locale ) ; timeFormat = DateFormat . getTimeInstance ( DateFormat . SHORT , locale ) ; } } targetTime = new Date ( timeTarget . getTime ( ) ) ; this . layoutCalendar ( targetTime ) ; this . addListSelectionListener ( this ) ; } | Creates new form TimePopup . |
11,677 | public void valueChanged ( ListSelectionEvent e ) { int index = this . getSelectedIndex ( ) ; if ( index != - 1 ) { int hour = index / 2 ; int minute = ( int ) ( ( ( float ) index / 2 - hour ) * 60 ) ; calendar . setTime ( targetTime ) ; calendar . set ( Calendar . HOUR_OF_DAY , hour ) ; calendar . set ( Calendar . MINUTE , minute ) ; Date date = calendar . getTime ( ) ; JPopupMenu popupMenu = this . getJPopupMenu ( ) ; if ( popupMenu != null ) { Component invoker = popupMenu . getInvoker ( ) ; this . getParent ( ) . remove ( this ) ; Container container = popupMenu . getParent ( ) ; popupMenu . setVisible ( false ) ; container . remove ( popupMenu ) ; if ( invoker != null ) if ( transferFocus ) invoker . transferFocus ( ) ; } Date oldTime = selectedTime ; if ( selectedTime == targetTime ) oldTime = null ; this . firePropertyChange ( m_strDateParam , oldTime , date ) ; } } | Called whenever the value of the selection changes . |
11,678 | protected final void initializeAbstractProposition ( String id , UniqueId uniqueId ) { this . uniqueId = uniqueId ; if ( id == null ) { this . id = "" ; } else { this . id = id . intern ( ) ; } } | Assigns fields specified in the constructor . This is pulled into a method so that deserialization can initialize those fields correctly . |
11,679 | public String getDescription ( ) { Object [ ] params = new Object [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { params [ i ] = parameters [ i ] ; } return String . format ( format , params ) ; } | Get a text - based description of this equation |
11,680 | public String toJSONString ( ) { String parms = DoubleStream . of ( parameters ) . mapToObj ( d -> String . format ( "%f" , d ) ) . collect ( Collectors . joining ( ", " , "[" , "]" ) ) ; String desc = String . format ( format , DoubleStream . of ( parameters ) . mapToObj ( Double :: valueOf ) . toArray ( ) ) ; return String . format ( "{name: \"%s\", valid: %s, format: \"%s\", description: \"%s\", parameters: %s, rsquare: %f}" , model . getName ( ) , isValid ( ) ? "true" : "false" , format , desc , parms , rSquared ) ; } | Convert this equation in to a JSON string representing the vital statistics of the equation . |
11,681 | public boolean isValid ( ) { return Math . abs ( parameters [ 0 ] ) >= 0.001 && rSquared != Double . NEGATIVE_INFINITY && ! Double . isNaN ( rSquared ) ; } | Indicate whether this equation is a suitable match against the actual data . |
11,682 | public String serialize ( final Object serviceState ) throws InvalidStateException , CouldNotPerformException { String jsonStringRep ; if ( serviceState instanceof Message ) { try { jsonStringRep = jsonFormat . printToString ( ( Message ) serviceState ) ; } catch ( Exception ex ) { throw new CouldNotPerformException ( "Could not serialize service argument to string!" , ex ) ; } } else { throw new InvalidStateException ( "Service attribute Class[" + serviceState . getClass ( ) . getSimpleName ( ) + "] not a protobuf message!" ) ; } return jsonStringRep ; } | Serialize a serviceState which can be a proto message enumeration or a java primitive to string . If its a primitive toString is called while messages or enumerations will be serialized into JSon |
11,683 | public String getServiceStateClassName ( final Object serviceState ) throws CouldNotPerformException { if ( serviceState . getClass ( ) . getName ( ) . startsWith ( "org.openbase.type" ) ) { return serviceState . getClass ( ) . getName ( ) ; } if ( serviceState . getClass ( ) . isEnum ( ) ) { logger . info ( serviceState . getClass ( ) . getName ( ) ) ; return serviceState . getClass ( ) . getName ( ) ; } logger . debug ( "Simple class name of attribute to upper case [" + serviceState . getClass ( ) . getSimpleName ( ) . toUpperCase ( ) + "]" ) ; JavaTypeToProto javaToProto ; try { javaToProto = JavaTypeToProto . valueOf ( serviceState . getClass ( ) . getSimpleName ( ) . toUpperCase ( ) ) ; } catch ( IllegalArgumentException ex ) { throw new CouldNotPerformException ( "ServiceState is not a supported java primitive nor a supported rst type" , ex ) ; } logger . debug ( "According proto type [" + javaToProto . getProtoType ( ) . name ( ) + "]" ) ; return javaToProto . getProtoType ( ) . name ( ) ; } | Get the string representation for a given serviceState which can be a proto message enumeration or a java primitive . |
11,684 | private boolean hasEntityBeanInterface ( String [ ] interfaces ) { for ( int i = 0 ; i < interfaces . length ; i ++ ) { if ( interfaces [ i ] . equals ( C_ENTITYBEAN ) ) { return true ; } } return false ; } | Return true if this case the EntityBean interface . |
11,685 | protected String getDomainClass ( ) { int posStart = signature . indexOf ( '<' ) ; int posEnd = signature . indexOf ( ';' , posStart + 1 ) ; return signature . substring ( posStart + 2 , posEnd ) ; } | Extract and return the associated entity bean class from the signature . |
11,686 | public AnnotationVisitor visitAnnotation ( String desc , boolean visible ) { classInfo . checkTypeQueryAnnotation ( desc ) ; return super . visitAnnotation ( desc , visible ) ; } | Look for TypeQueryBean annotation . |
11,687 | private MethodVisitor handleAssocBeanConstructor ( int access , String name , String desc , String signature , String [ ] exceptions ) { if ( desc . equals ( ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC ) ) { classInfo . setHasBasicConstructor ( ) ; return new TypeQueryAssocBasicConstructor ( classInfo , cv , desc , signature ) ; } if ( desc . equals ( ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC ) ) { classInfo . setHasMainConstructor ( ) ; return new TypeQueryAssocMainConstructor ( classInfo , cv , desc , signature ) ; } return super . visitMethod ( access , name , desc , signature , exceptions ) ; } | Handle the constructors for assoc type query beans . |
11,688 | private void addMarkerAnnotation ( ) { if ( isLog ( 4 ) ) { log ( "... adding marker annotation" ) ; } AnnotationVisitor av = cv . visitAnnotation ( ANNOTATION_ALREADY_ENHANCED_MARKER , true ) ; if ( av != null ) { av . visitEnd ( ) ; } } | Add the marker annotation so that we don t enhance the type query bean twice . |
11,689 | public static List < SecretShare > split ( BigInteger secret , BigInteger [ ] coefficients , int total , int threshold , BigInteger prime ) { if ( secret . compareTo ( BigInteger . ZERO ) <= 0 ) { throw new IllegalArgumentException ( "secret must be positive integer" ) ; } if ( prime . compareTo ( secret ) <= 0 ) { throw new IllegalArgumentException ( "prime must be greater than secret" ) ; } if ( coefficients . length < threshold ) { throw new IllegalArgumentException ( "not enough coefficients, need " + threshold + ", have " + coefficients . length ) ; } if ( total < threshold ) { throw new IllegalArgumentException ( "total number of shares must be greater than or equal threshold" ) ; } List < SecretShare > shares = new ArrayList < > ( ) ; for ( int i = 1 ; i <= total ; i ++ ) { BigInteger x = BigInteger . valueOf ( i ) ; BigInteger v = coefficients [ 0 ] ; for ( int c = 1 ; c < threshold ; c ++ ) { v = v . add ( x . modPow ( BigInteger . valueOf ( c ) , prime ) . multiply ( coefficients [ c ] ) . mod ( prime ) ) . mod ( prime ) ; } shares . add ( new SecretShare ( i , v , prime ) ) ; } return shares ; } | Split the secret into the specified total number of shares . Specified minimum threshold of shares will need to be present in order to join them back into the secret . |
11,690 | public static BigInteger join ( List < SecretShare > shares ) { if ( ! checkSamePrimes ( shares ) ) { throw new IllegalArgumentException ( "shares not from the same series" ) ; } BigInteger res = BigInteger . ZERO ; for ( int i = 0 ; i < shares . size ( ) ; i ++ ) { BigInteger n = BigInteger . ONE ; BigInteger d = BigInteger . ONE ; BigInteger prime = shares . get ( i ) . getPrime ( ) ; for ( int j = 0 ; j < shares . size ( ) ; j ++ ) { if ( i != j ) { BigInteger sp = BigInteger . valueOf ( shares . get ( i ) . getN ( ) ) ; BigInteger np = BigInteger . valueOf ( shares . get ( j ) . getN ( ) ) ; n = n . multiply ( np . negate ( ) ) . mod ( prime ) ; d = d . multiply ( sp . subtract ( np ) ) . mod ( prime ) ; } } BigInteger v = shares . get ( i ) . getShare ( ) ; res = res . add ( prime ) . add ( v . multiply ( n ) . multiply ( d . modInverse ( prime ) ) ) . mod ( prime ) ; } return res ; } | Join shares back into the secret . |
11,691 | private static boolean checkSamePrimes ( List < SecretShare > shares ) { boolean ret = true ; BigInteger prime = null ; for ( SecretShare share : shares ) { if ( prime == null ) { prime = share . getPrime ( ) ; } else if ( ! prime . equals ( share . getPrime ( ) ) ) { ret = false ; break ; } } return ret ; } | Verify if all shares have the same prime . If they do not then they are not from the same series and cannot possibly be joined . |
11,692 | final void handleKeyId ( String kId ) { String oldKeyId = getKeyId ( ) ; if ( oldKeyId != null && ! oldKeyId . equals ( kId ) ) { createDataStreamingEvent ( oldKeyId , this . props ) ; } this . keyId = kId ; } | For recording the key id of the current record . |
11,693 | public int compare ( TemporalPropositionDefinition a1 , TemporalPropositionDefinition a2 ) { if ( a1 == a2 ) { return 0 ; } else { Integer index1 = rule2Index . get ( a1 . getId ( ) ) ; Integer index2 = rule2Index . get ( a2 . getId ( ) ) ; return index1 . compareTo ( index2 ) ; } } | Compares two temporal proposition definitions topologically according to the inverse of their abstractedFrom or inducedBy relationships . |
11,694 | private void updateModelAccordingToDocker ( ) { try { final ModelHelper modelHelper = new ModelHelper ( context . getNodeName ( ) , docker , factory ) ; final ContainerRoot dockerModel = modelHelper . docker2model ( modelService . getCurrentModel ( ) ) ; modelService . update ( dockerModel , e -> { if ( e == null ) { Log . info ( "Model updated based on the local Docker engine configuration" ) ; } else { Log . warn ( "Failed to update model based on the local Docker engine configuration" , e ) ; } } ) ; } catch ( Exception e ) { Log . warn ( "Failed to update model based on the local Docker engine configuration" , e ) ; } } | Converts the currentModel state of the Docker engine to a Kevoree model . This model is then merged with the currentModel in - use model and deployed . |
11,695 | public List < AdaptationCommand > plan ( ContainerRoot currentModel , ContainerRoot targetModel ) throws KevoreeAdaptationException { final List < AdaptationCommand > commands = super . plan ( currentModel , targetModel ) ; final List < AdaptationCommand > dockerCommands = new ModelHelper ( context . getNodeName ( ) , docker , factory ) . model2docker ( currentModel , targetModel ) ; Log . debug ( "=== Docker commands ===" ) ; dockerCommands . forEach ( ( cmd ) -> Log . debug ( " {} [{}]" , cmd . getElement ( ) . path ( ) , cmd . getType ( ) ) ) ; Log . debug ( "========================" ) ; commands . addAll ( dockerCommands ) ; return commands ; } | This is called when the node has to adapt from currentModel to targetModel . The goal of this method is to return a list of executable adaptation commands according to the delta between currentModel and targetModel . |
11,696 | public static HashMap < String , String > parse ( String args ) { HashMap < String , String > map = new HashMap < > ( ) ; if ( args != null ) { String [ ] split = args . split ( ";" ) ; for ( String nameValuePair : split ) { String [ ] nameValue = nameValuePair . split ( "=" ) ; if ( nameValue . length == 2 ) { map . put ( nameValue [ 0 ] . toLowerCase ( ) , nameValue [ 1 ] ) ; } } } return map ; } | Parse the args returning as name value pairs . |
11,697 | public void setAsText ( final String text ) { if ( BeanUtils . isNull ( text ) ) { setValue ( null ) ; return ; } Object newValue = Boolean . valueOf ( text ) ; setValue ( newValue ) ; } | Map the argument text into Boolean . TRUE or Boolean . FALSE using Boolean . valueOf . |
11,698 | private void decodeSubscription ( ByteBuf in , SubscribeMessage message ) throws UnsupportedEncodingException { String topic = Utils . decodeString ( in ) ; byte qos = ( byte ) ( in . readByte ( ) & 0x03 ) ; message . addSubscription ( new SubscribeMessage . Couple ( qos , topic ) ) ; } | Populate the message with couple of Qos topic |
11,699 | public boolean cancel ( final boolean mayInterruptIfRunning ) { synchronized ( lock ) { if ( isDone ( ) ) { return false ; } throwable = new CancellationException ( ) ; lock . notifyAll ( ) ; return true ; } } | Method cancels the future without delivering any specific reason . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.