idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
9,900 | private final void setColor ( ColorSet colorSet ) { int [ ] rgb = ColorSet . getRGB ( colorSet ) ; this . red = rgb [ 0 ] / 255.0 ; this . green = rgb [ 1 ] / 255.0 ; this . blue = rgb [ 2 ] / 255.0 ; } | Returns the colorset s RGB values . | 67 | 8 |
9,901 | public static void shutDown ( ) { if ( Quartz . QUARTZ != null && Quartz . QUARTZ . scheduler != null ) { try { Quartz . QUARTZ . scheduler . shutdown ( ) ; } catch ( final SchedulerException e ) { Quartz . LOG . error ( "Problems on shutdown of QuartsSheduler" , e ) ; } } } | ShutDown Quartz . | 80 | 4 |
9,902 | public static GenClassCompiler compile ( TypeElement superClass , ProcessingEnvironment env ) throws IOException { GenClassCompiler compiler ; GrammarDef grammarDef = superClass . getAnnotation ( GrammarDef . class ) ; if ( grammarDef != null ) { compiler = new ParserCompiler ( superClass ) ; } else { DFAMap mapDef = superClass . getAnnotation ( DFAMap . class ) ; if ( mapDef != null ) { compiler = new MapCompiler ( superClass ) ; } else { compiler = new GenClassCompiler ( superClass ) ; } } compiler . setProcessingEnvironment ( env ) ; compiler . compile ( ) ; if ( env == null ) { System . err . println ( "warning! classes directory not set" ) ; } else { compiler . saveClass ( ) ; } return compiler ; } | Compiles a subclass for annotated superClass | 180 | 9 |
9,903 | private synchronized boolean refreshAuthToken ( final AuthHandler handler , final boolean forceRefresh ) { if ( handler == null ) { return false ; } AuthToken token = authToken . get ( ) ; if ( ! forceRefresh && token != null && token . isValid ( ) ) { logger . fine ( "Auth token is already valid" ) ; return true ; } try { handler . setForceRefresh ( forceRefresh ) ; token = handler . call ( ) ; authToken . set ( token ) ; if ( token != null ) { if ( token instanceof UserBearerAuthToken ) { final UserBearerAuthToken bt = ( UserBearerAuthToken ) token ; logger . info ( "Acquired auth token. Expires: " + bt . getExpires ( ) + " token=" + bt . getToken ( ) ) ; } else if ( token instanceof ProjectBearerAuthToken ) { ProjectBearerAuthToken pt = ( ProjectBearerAuthToken ) token ; logger . info ( "Acquired proj token. Expires: " + pt . getExpires ( ) + " token=" + pt . getToken ( ) ) ; } else { logger . info ( "Acquired auth token. Token valid=" + token . isValid ( ) ) ; } } } catch ( ExecutionException e ) { final Throwable cause = e . getCause ( ) ; if ( cause != null ) { logger . warning ( "Authentication failed: " + cause . getMessage ( ) ) ; } else { logger . warning ( "Authentication failed: " + e . getMessage ( ) ) ; } } catch ( Exception e ) { logger . warning ( "Authentication failed: " + e . getMessage ( ) ) ; } finally { handler . setForceRefresh ( false ) ; } return true ; } | Return true if caller should retry false if give up | 390 | 11 |
9,904 | public PropertyDescriptor getPropertyDescriptor ( String propertyName ) { final PropertyDescriptor propertyDescriptor = findPropertyDescriptor ( propertyName ) ; if ( propertyDescriptor == null ) { throw new PropertyNotFoundException ( beanClass , propertyName ) ; } return propertyDescriptor ; } | Get the property descriptor for the named property . Throws an exception if the property does not exist . | 68 | 20 |
9,905 | public PropertyDescriptor findPropertyDescriptor ( String propertyName ) { for ( PropertyDescriptor property : propertyDescriptors ) { if ( property . getName ( ) . equals ( propertyName ) ) { return property ; } } return null ; } | Attempt to get the property descriptor for the named property . | 55 | 11 |
9,906 | public boolean isAssigendTo ( final Company _company ) throws CacheReloadException { final boolean ret ; if ( isRoot ( ) ) { ret = this . companies . isEmpty ( ) ? true : this . companies . contains ( _company ) ; } else { ret = getParentClassification ( ) . isAssigendTo ( _company ) ; } return ret ; } | Check if the root classification of this classification is assigned to the given company . | 81 | 15 |
9,907 | private void overrideAbstractMethods ( ) throws IOException { for ( final ExecutableElement method : El . getEffectiveMethods ( superClass ) ) { if ( method . getModifiers ( ) . contains ( Modifier . ABSTRACT ) ) { if ( method . getAnnotation ( Terminal . class ) != null || method . getAnnotation ( Rule . class ) != null || method . getAnnotation ( Rules . class ) != null ) { implementedAbstractMethods . add ( method ) ; MethodCompiler mc = new MethodCompiler ( ) { @ Override protected void implement ( ) throws IOException { TypeMirror returnType = method . getReturnType ( ) ; List < ? extends VariableElement > params = method . getParameters ( ) ; if ( returnType . getKind ( ) != TypeKind . VOID && params . size ( ) == 1 ) { nameArgument ( ARG , 1 ) ; try { convert ( ARG , returnType ) ; } catch ( IllegalConversionException ex ) { throw new IOException ( "bad conversion with " + method , ex ) ; } treturn ( ) ; } else { if ( returnType . getKind ( ) == TypeKind . VOID && params . size ( ) == 0 ) { treturn ( ) ; } else { throw new IllegalArgumentException ( "cannot implement abstract method " + method ) ; } } } } ; subClass . overrideMethod ( mc , method , Modifier . PROTECTED ) ; } } } } | Implement abstract method which have either one parameter and returning something or void type not returning anything . | 315 | 19 |
9,908 | private void init ( ) { this . container = InfinispanCache . findCacheContainer ( ) ; if ( this . container == null ) { try { this . container = new DefaultCacheManager ( this . getClass ( ) . getResourceAsStream ( "/org/efaps/util/cache/infinispan-config.xml" ) ) ; if ( this . container instanceof EmbeddedCacheManager ) { this . container . addListener ( new CacheLogListener ( InfinispanCache . LOG ) ) ; } InfinispanCache . bindCacheContainer ( this . container ) ; final Cache < String , Integer > cache = this . container . < String , Integer > getCache ( InfinispanCache . COUNTERCACHE ) ; cache . put ( InfinispanCache . COUNTERCACHE , 1 ) ; } catch ( final FactoryConfigurationError e ) { InfinispanCache . LOG . error ( "FactoryConfigurationError" , e ) ; } catch ( final IOException e ) { InfinispanCache . LOG . error ( "IOException" , e ) ; } } else { final Cache < String , Integer > cache = this . container . < String , Integer > getCache ( InfinispanCache . COUNTERCACHE ) ; Integer count = cache . get ( InfinispanCache . COUNTERCACHE ) ; if ( count == null ) { count = 1 ; } else { count = count + 1 ; } cache . put ( InfinispanCache . COUNTERCACHE , count ) ; } } | init this instance . | 325 | 4 |
9,909 | private void terminate ( ) { if ( this . container != null ) { final Cache < String , Integer > cache = this . container . < String , Integer > getCache ( InfinispanCache . COUNTERCACHE ) ; Integer count = cache . get ( InfinispanCache . COUNTERCACHE ) ; if ( count == null || count < 2 ) { this . container . stop ( ) ; } else { count = count - 1 ; cache . put ( InfinispanCache . COUNTERCACHE , count ) ; } } } | Terminate the manager . | 116 | 5 |
9,910 | public < K , V > AdvancedCache < K , V > getIgnReCache ( final String _cacheName ) { return this . container . < K , V > getCache ( _cacheName , true ) . getAdvancedCache ( ) . withFlags ( Flag . IGNORE_RETURN_VALUES , Flag . SKIP_REMOTE_LOOKUP , Flag . SKIP_CACHE_LOAD ) ; } | An advanced cache that does not return the value of the previous value in case of replacement . | 90 | 18 |
9,911 | public < K , V > Cache < K , V > initCache ( final String _cacheName ) { if ( ! exists ( _cacheName ) && ( ( EmbeddedCacheManager ) getContainer ( ) ) . getCacheConfiguration ( _cacheName ) == null ) { ( ( EmbeddedCacheManager ) getContainer ( ) ) . defineConfiguration ( _cacheName , "eFaps-Default" , new ConfigurationBuilder ( ) . build ( ) ) ; } return this . container . getCache ( _cacheName , true ) ; } | Method to init a Cache using the default definitions . | 113 | 10 |
9,912 | public static FacetsConfig getFacetsConfig ( ) { final FacetsConfig ret = new FacetsConfig ( ) ; ret . setHierarchical ( Indexer . Dimension . DIMCREATED . name ( ) , true ) ; return ret ; } | Gets the facets config . | 54 | 6 |
9,913 | public static Analyzer getAnalyzer ( ) throws EFapsException { IAnalyzerProvider provider = null ; if ( EFapsSystemConfiguration . get ( ) . containsAttributeValue ( KernelSettings . INDEXANALYZERPROVCLASS ) ) { final String clazzname = EFapsSystemConfiguration . get ( ) . getAttributeValue ( KernelSettings . INDEXANALYZERPROVCLASS ) ; try { final Class < ? > clazz = Class . forName ( clazzname , false , EFapsClassLoader . getInstance ( ) ) ; provider = ( IAnalyzerProvider ) clazz . newInstance ( ) ; } catch ( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) { throw new EFapsException ( Index . class , "Could not instanciate IAnalyzerProvider" , e ) ; } } else { provider = new IAnalyzerProvider ( ) { @ Override public Analyzer getAnalyzer ( ) { return new StandardAnalyzer ( SpanishAnalyzer . getDefaultStopSet ( ) ) ; } } ; } return provider . getAnalyzer ( ) ; } | Gets the analyzer . | 236 | 6 |
9,914 | @ CallMethod ( pattern = "install/version/script" ) public void addScript ( @ CallParam ( pattern = "install/version/script" ) final String _code , @ CallParam ( pattern = "install/version/script" , attributeName = "type" ) final String _type , @ CallParam ( pattern = "install/version/script" , attributeName = "name" ) final String _name , @ CallParam ( pattern = "install/version/script" , attributeName = "function" ) final String _function ) { AbstractScript script = null ; if ( "rhino" . equalsIgnoreCase ( _type ) ) { script = new RhinoScript ( _code , _name , _function ) ; } else if ( "groovy" . equalsIgnoreCase ( _type ) ) { script = new GroovyScript ( _code , _name , _function ) ; } if ( script != null ) { this . scripts . add ( script ) ; } } | Adds a new Script to this version . | 211 | 8 |
9,915 | @ CallMethod ( pattern = "install/version/description" ) public void appendDescription ( @ CallParam ( pattern = "install/version/description" ) final String _desc ) { if ( _desc != null ) { this . description . append ( _desc . trim ( ) ) . append ( "\n" ) ; } } | Append a description for this version . | 70 | 8 |
9,916 | @ CallMethod ( pattern = "install/version/lifecyle/ignore" ) public void addIgnoredStep ( @ CallParam ( pattern = "install/version/lifecyle/ignore" , attributeName = "step" ) final String _step ) { this . ignoredSteps . add ( UpdateLifecycle . valueOf ( _step . toUpperCase ( ) ) ) ; } | Appends a step which is ignored within the installation of this version . | 85 | 14 |
9,917 | @ Override protected void freeResource ( ) throws EFapsException { try { if ( ! getConnection ( ) . isClosed ( ) ) { getConnection ( ) . close ( ) ; } } catch ( final SQLException e ) { throw new EFapsException ( "Could not close" , e ) ; } } | Frees the resource and gives this connection resource back to the context object . | 69 | 15 |
9,918 | public static < K , V > Configuration newMutable ( TimeUnit expiryTimeUnit , long expiryDurationAmount ) { return new MutableConfiguration < K , V > ( ) . setExpiryPolicyFactory ( factoryOf ( new Duration ( expiryTimeUnit , expiryDurationAmount ) ) ) ; } | Build a new mutable javax . cache . configuration . Configuration with an expiry policy | 66 | 19 |
9,919 | public boolean next ( ) throws EFapsException { initialize ( false ) ; boolean stepForward = true ; boolean ret = true ; while ( stepForward && ret ) { ret = step ( this . selection . getAllSelects ( ) ) ; stepForward = ! this . access . hasAccess ( inst ( ) ) ; } return ret ; } | Move the evaluator to the next value . Skips values the User does not have access to . | 71 | 21 |
9,920 | private boolean step ( final Collection < Select > _selects ) { boolean ret = ! CollectionUtils . isEmpty ( _selects ) ; for ( final Select select : _selects ) { ret = ret && select . next ( ) ; } return ret ; } | Move the selects to the next value . | 56 | 8 |
9,921 | private void evalAccess ( ) throws EFapsException { final List < Instance > instances = new ArrayList <> ( ) ; while ( step ( this . selection . getInstSelects ( ) . values ( ) ) ) { for ( final Entry < String , Select > entry : this . selection . getInstSelects ( ) . entrySet ( ) ) { final Object object = entry . getValue ( ) . getCurrent ( ) ; if ( object != null ) { if ( object instanceof List ) { ( ( List < ? > ) object ) . stream ( ) . filter ( Objects :: nonNull ) . forEach ( e -> instances . add ( ( Instance ) e ) ) ; } else { instances . add ( ( Instance ) object ) ; } } } } for ( final Entry < String , Select > entry : this . selection . getInstSelects ( ) . entrySet ( ) ) { entry . getValue ( ) . reset ( ) ; } this . access = Access . get ( AccessTypeEnums . READ . getAccessType ( ) , instances ) ; } | Evaluate the access for the instances . | 229 | 9 |
9,922 | public DataList getDataList ( ) throws EFapsException { final DataList ret = new DataList ( ) ; while ( next ( ) ) { final ObjectData data = new ObjectData ( ) ; int idx = 1 ; for ( final Select select : this . selection . getSelects ( ) ) { final String key = select . getAlias ( ) == null ? String . valueOf ( idx ) : select . getAlias ( ) ; data . getValues ( ) . add ( JSONData . getValue ( key , get ( select ) ) ) ; idx ++ ; } ret . add ( data ) ; } return ret ; } | Gets the data list . | 135 | 6 |
9,923 | protected String makeInfo ( ) { final StringBuilder str = new StringBuilder ( ) ; if ( this . className != null ) { str . append ( "Thrown within class " ) . append ( this . className . getName ( ) ) . append ( ' ' ) ; } if ( this . id != null ) { str . append ( "Id of Exception is " ) . append ( this . id ) . append ( ' ' ) ; } if ( this . args != null && this . args . length > 0 ) { str . append ( "Arguments are:\n" ) ; for ( Integer index = 0 ; index < this . args . length ; index ++ ) { final String arg = this . args [ index ] == null ? "null" : this . args [ index ] . toString ( ) ; str . append ( "\targs[" ) . append ( index . toString ( ) ) . append ( "] = '" ) . append ( arg ) . append ( "'\n" ) ; } } return str . toString ( ) ; } | Prepares a string of all information of this EFapsException . The returned string includes information about the class which throws this exception the exception id and all arguments . | 226 | 32 |
9,924 | private static String getValueFromDB ( final String _key , final String _language ) { String ret = null ; try { boolean closeContext = false ; if ( ! Context . isThreadActive ( ) ) { Context . begin ( ) ; closeContext = true ; } final Connection con = Context . getConnection ( ) ; final PreparedStatement stmt = con . prepareStatement ( DBProperties . SQLSELECT ) ; stmt . setString ( 1 , _key ) ; stmt . setString ( 2 , _language ) ; final ResultSet resultset = stmt . executeQuery ( ) ; if ( resultset . next ( ) ) { final String defaultValue = resultset . getString ( 1 ) ; final String value = resultset . getString ( 2 ) ; if ( value != null ) { ret = value . trim ( ) ; } else if ( defaultValue != null ) { ret = defaultValue . trim ( ) ; } } else { final PreparedStatement stmt2 = con . prepareStatement ( DBProperties . SQLSELECTDEF ) ; stmt2 . setString ( 1 , _key ) ; final ResultSet resultset2 = stmt2 . executeQuery ( ) ; if ( resultset2 . next ( ) ) { final String defaultValue = resultset2 . getString ( 1 ) ; if ( defaultValue != null ) { ret = defaultValue . trim ( ) ; } } resultset2 . close ( ) ; stmt2 . close ( ) ; } resultset . close ( ) ; stmt . close ( ) ; con . commit ( ) ; con . close ( ) ; if ( closeContext ) { Context . rollback ( ) ; } } catch ( final EFapsException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } catch ( final SQLException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } return ret ; } | This method is initializing the cache . | 415 | 8 |
9,925 | private static void cacheOnStart ( ) { try { boolean closeContext = false ; if ( ! Context . isThreadActive ( ) ) { Context . begin ( ) ; closeContext = true ; } Context . getThreadContext ( ) ; final Connection con = Context . getConnection ( ) ; final PreparedStatement stmtLang = con . prepareStatement ( DBProperties . SQLLANG ) ; final ResultSet rsLang = stmtLang . executeQuery ( ) ; final Set < String > languages = new HashSet <> ( ) ; while ( rsLang . next ( ) ) { languages . add ( rsLang . getString ( 1 ) . trim ( ) ) ; } rsLang . close ( ) ; stmtLang . close ( ) ; final Cache < String , String > cache = InfinispanCache . get ( ) . < String , String > getCache ( DBProperties . CACHENAME ) ; final PreparedStatement stmt = con . prepareStatement ( DBProperties . SQLSELECTONSTART ) ; final ResultSet resultset = stmt . executeQuery ( ) ; while ( resultset . next ( ) ) { final String propKey = resultset . getString ( 1 ) . trim ( ) ; final String defaultValue = resultset . getString ( 2 ) ; if ( defaultValue != null ) { final String value = defaultValue . trim ( ) ; for ( final String lang : languages ) { final String cachKey = lang + ":" + propKey ; if ( ! cache . containsKey ( cachKey ) ) { cache . put ( cachKey , value ) ; } } } final String value = resultset . getString ( 3 ) ; final String lang = resultset . getString ( 4 ) ; if ( value != null ) { final String cachKey = lang . trim ( ) + ":" + propKey ; cache . put ( cachKey , value . trim ( ) ) ; } } resultset . close ( ) ; stmt . close ( ) ; con . commit ( ) ; con . close ( ) ; if ( closeContext ) { Context . rollback ( ) ; } } catch ( final EFapsException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } catch ( final SQLException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } } | Load the properties that must be cached on start . | 515 | 10 |
9,926 | public static void initialize ( ) { if ( InfinispanCache . get ( ) . exists ( DBProperties . CACHENAME ) ) { InfinispanCache . get ( ) . < String , String > getCache ( DBProperties . CACHENAME ) . clear ( ) ; } else { InfinispanCache . get ( ) . < String , String > getCache ( DBProperties . CACHENAME ) . addListener ( new CacheLogListener ( DBProperties . LOG ) ) ; } DBProperties . cacheOnStart ( ) ; } | Initialize the Cache be calling it . Used from runtime level . | 120 | 13 |
9,927 | public static int getReadCount ( final Long _userId ) { int ret = 0 ; if ( MessageStatusHolder . CACHE . userID2Read . containsKey ( _userId ) ) { ret = MessageStatusHolder . CACHE . userID2Read . get ( _userId ) ; } return ret ; } | Count of read messages . | 72 | 5 |
9,928 | public static int getUnReadCount ( final Long _userId ) { int ret = 0 ; if ( MessageStatusHolder . CACHE . userID2UnRead . containsKey ( _userId ) ) { ret = MessageStatusHolder . CACHE . userID2UnRead . get ( _userId ) ; } return ret ; } | Count of unread messages . | 75 | 6 |
9,929 | public void setNode ( int number , Vector3D v ) { setNode ( number , v . getX ( ) , v . getY ( ) , v . getZ ( ) ) ; } | Sets coordinate of nodes of this Bezier . | 42 | 11 |
9,930 | public void setAnchorColor ( int index , Color color ) { if ( index <= 0 ) { if ( startColor == null ) { startColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . startColor = color ; } else if ( index >= 1 ) { if ( endColor == null ) { endColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . endColor = color ; } } | Sets the color of the anchor point for gradation . | 121 | 12 |
9,931 | public final double getWidth ( int line ) { if ( strArray . length == 0 ) return 0.0 ; try { return textRenderer . getBounds ( strArray [ line ] ) . getWidth ( ) ; } catch ( GLException e ) { reset = true ; } return 0.0 ; } | Returns letter s width of the current font at its current size and line . | 69 | 15 |
9,932 | public final void setFont ( Font font ) { this . font = font ; textRenderer = new TextRenderer ( font . getAWTFont ( ) , true , true ) ; } | Sets the Font of this Text . | 42 | 8 |
9,933 | public static PermissionSet getPermissionSet ( final Instance _instance ) throws EFapsException { Evaluation . LOG . debug ( "Evaluation PermissionSet for {}" , _instance ) ; final Key accessKey = Key . get4Instance ( _instance ) ; final PermissionSet ret = AccessCache . getPermissionCache ( ) . get ( accessKey ) ; Evaluation . LOG . debug ( "Evaluated PermissionSet {}" , ret ) ; return ret ; } | Gets the permissions . | 102 | 5 |
9,934 | public static PermissionSet getPermissionSet ( final Instance _instance , final boolean _evaluate ) throws EFapsException { Evaluation . LOG . debug ( "Retrieving PermissionSet for {}" , _instance ) ; final Key accessKey = Key . get4Instance ( _instance ) ; final PermissionSet ret ; if ( AccessCache . getPermissionCache ( ) . containsKey ( accessKey ) ) { ret = AccessCache . getPermissionCache ( ) . get ( accessKey ) ; } else if ( _evaluate ) { ret = new PermissionSet ( ) . setPersonId ( accessKey . getPersonId ( ) ) . setCompanyId ( accessKey . getCompanyId ( ) ) . setTypeId ( accessKey . getTypeId ( ) ) ; Evaluation . eval ( ret ) ; AccessCache . getPermissionCache ( ) . put ( accessKey , ret ) ; } else { ret = null ; } Evaluation . LOG . debug ( "Retrieved PermissionSet {}" , ret ) ; return ret ; } | Gets the PermissionSet . | 219 | 7 |
9,935 | public static Status getStatus ( final Instance _instance ) throws EFapsException { Evaluation . LOG . debug ( "Retrieving Status for {}" , _instance ) ; long statusId = 0 ; if ( _instance . getType ( ) . isCheckStatus ( ) ) { final Cache < String , Long > cache = AccessCache . getStatusCache ( ) ; if ( cache . containsKey ( _instance . getKey ( ) ) ) { statusId = cache . get ( _instance . getKey ( ) ) ; } else { final PrintQuery print = new PrintQuery ( _instance ) ; print . addAttribute ( _instance . getType ( ) . getStatusAttribute ( ) ) ; print . executeWithoutAccessCheck ( ) ; final Long statusIdTmp = print . getAttribute ( _instance . getType ( ) . getStatusAttribute ( ) ) ; statusId = statusIdTmp == null ? 0 : statusIdTmp ; cache . put ( _instance . getKey ( ) , statusId ) ; } } final Status ret = statusId > 0 ? Status . get ( statusId ) : null ; Evaluation . LOG . debug ( "Retrieve Status: {}" , ret ) ; return ret ; } | Gets the status . | 256 | 5 |
9,936 | public static void evalStatus ( final Collection < Instance > _instances ) throws EFapsException { Evaluation . LOG . debug ( "Evaluating Status for {}" , _instances ) ; if ( CollectionUtils . isNotEmpty ( _instances ) ) { final Cache < String , Long > cache = AccessCache . getStatusCache ( ) ; final List < Instance > instances = _instances . stream ( ) . filter ( inst -> ! cache . containsKey ( inst . getKey ( ) ) ) . collect ( Collectors . toList ( ) ) ; if ( ! instances . isEmpty ( ) ) { final Attribute attr = instances . get ( 0 ) . getType ( ) . getStatusAttribute ( ) ; final MultiPrintQuery multi = new MultiPrintQuery ( instances ) ; multi . addAttribute ( attr ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { final Long statusId = multi . getAttribute ( attr ) ; cache . put ( multi . getCurrentInstance ( ) . getKey ( ) , statusId == null ? 0 : statusId ) ; } } } } | Eval status . | 243 | 4 |
9,937 | public static String addZerosBefore ( String orderNo , int count ) { if ( orderNo == null ) { return "" ; // orderNo = ""; } if ( orderNo . length ( ) > count ) { orderNo = "?" + orderNo . substring ( orderNo . length ( ) - count - 1 , orderNo . length ( ) - 1 ) ; } else { int le = orderNo . length ( ) ; for ( int i = 0 ; i < count - le ; i ++ ) { orderNo = "0" + orderNo ; } } return orderNo ; } | Method addZerosBefore . | 126 | 6 |
9,938 | public Map < String , Set < DataPoint > > getSeries ( ) { return new HashMap < String , Set < DataPoint > > ( store ) ; } | Gets a mapping from series to an unordered set of DataPoints . | 34 | 15 |
9,939 | public void addDataPoint ( String series , DataPoint dataPoint ) { DataSet set = store . get ( series ) ; if ( set == null ) { set = new DataSet ( ) ; store . put ( series , set ) ; } set . add ( dataPoint ) ; } | Adds a new data point to a particular series . | 60 | 10 |
9,940 | public void addDataPointSet ( String series , Set < DataPoint > dataPoints ) { DataSet set = store . get ( series ) ; if ( set == null ) { set = new DataSet ( dataPoints ) ; store . put ( series , set ) ; } else { set . addAll ( dataPoints ) ; } } | Adds a set of DataPoint s to a series . | 70 | 11 |
9,941 | public JSONObject serialize ( Map < String , Object > out ) { JSONObject json = new JSONObject ( ) ; json . put ( "device_id" , deviceId ) ; json . put ( "project_id" , projectId ) ; out . put ( "device_id" , deviceId ) ; out . put ( "project_id" , projectId ) ; JSONArray sourcesArr = new JSONArray ( ) ; List < String > sourceNames = new ArrayList < String > ( store . keySet ( ) ) ; Collections . sort ( sourceNames ) ; for ( String k : sourceNames ) { JSONObject temp = new JSONObject ( ) ; temp . put ( "name" , k ) ; JSONArray dataArr = new JSONArray ( ) ; for ( DataPoint d : store . get ( k ) ) { dataArr . put ( d . toJson ( ) ) ; } temp . put ( "data" , dataArr ) ; sourcesArr . put ( temp ) ; } json . put ( "sources" , sourcesArr ) ; out . put ( "sources" , sourcesArr ) ; return json ; } | Custom serialization method for this object to JSON . | 250 | 10 |
9,942 | public Vector3D getVertex ( int index ) { tmpV . setX ( cornerX . get ( index ) ) ; tmpV . setY ( cornerY . get ( index ) ) ; tmpV . setZ ( cornerZ . get ( index ) ) ; calcG ( ) ; return tmpV ; } | Gets the corner of Polygon . | 67 | 8 |
9,943 | public void removeVertex ( int index ) { this . cornerX . remove ( index ) ; this . cornerY . remove ( index ) ; this . cornerZ . remove ( index ) ; if ( isGradation ( ) == true ) this . cornerColor . remove ( index ) ; setNumberOfCorner ( this . cornerX . size ( ) ) ; calcG ( ) ; } | Removes the corner of Polygon . | 82 | 8 |
9,944 | public void setVertex ( int i , double x , double y , double z ) { this . cornerX . set ( i , x ) ; this . cornerY . set ( i , y ) ; this . cornerZ . set ( i , z ) ; calcG ( ) ; } | Sets the coordinates of the corner . | 61 | 8 |
9,945 | public void setCornerColor ( int index , Color color ) { if ( cornerColor == null ) { for ( int i = 0 ; i < cornerX . size ( ) ; i ++ ) { cornerColor . add ( new RGBColor ( this . fillColor . getRed ( ) , this . fillColor . getGreen ( ) , this . fillColor . getBlue ( ) , this . fillColor . getAlpha ( ) ) ) ; } setGradation ( true ) ; } if ( cornerColor . size ( ) < cornerX . size ( ) ) { while ( cornerColor . size ( ) != cornerX . size ( ) ) { cornerColor . add ( new RGBColor ( this . fillColor . getRed ( ) , this . fillColor . getGreen ( ) , this . fillColor . getBlue ( ) , this . fillColor . getAlpha ( ) ) ) ; } } cornerColor . set ( index , color ) ; } | Sets the color of a corner . | 202 | 8 |
9,946 | public static List < DataPoint > parse ( int [ ] values , long ts ) { List < DataPoint > ret = new ArrayList < DataPoint > ( values . length ) ; for ( int v : values ) { ret . add ( new DataPoint ( ts , v ) ) ; } return ret ; } | Takes an array of values and converts it into a list of DataPoint s with the same timestamp . | 65 | 21 |
9,947 | @ SuppressWarnings ( "unchecked" ) @ SafeVarargs public static < G , ERR > Or < G , Every < ERR > > when ( Or < ? extends G , ? extends Every < ? extends ERR > > or , Function < ? super G , ? extends Validation < ERR > > ... validations ) { return when ( or , Stream . of ( validations ) ) ; } | Enables further validation on an existing accumulating Or by passing validation functions . | 89 | 14 |
9,948 | public static < A , B , ERR , RESULT > Or < RESULT , Every < ERR > > withGood ( Or < ? extends A , ? extends Every < ? extends ERR > > a , Or < ? extends B , ? extends Every < ? extends ERR > > b , BiFunction < ? super A , ? super B , ? extends RESULT > function ) { if ( allGood ( a , b ) ) return Good . of ( function . apply ( a . get ( ) , b . get ( ) ) ) ; else { return getBads ( a , b ) ; } } | Combines two accumulating Or into a single one using the given function . The resulting Or will be a Good if both Ors are Goods otherwise it will be a Bad containing every error in the Bads . | 129 | 41 |
9,949 | public Vector3D getVertex ( int i ) { tmpV . setX ( x . get ( i ) ) ; tmpV . setY ( y . get ( i ) ) ; tmpV . setZ ( z . get ( i ) ) ; calcG ( ) ; return tmpV ; } | Gets the coordinates of the point . | 64 | 8 |
9,950 | public void removeVertex ( int i ) { this . x . remove ( i ) ; this . y . remove ( i ) ; this . z . remove ( i ) ; this . colors . remove ( i ) ; calcG ( ) ; } | Removes the point from Lines . | 52 | 7 |
9,951 | public void setVertex ( int i , double x , double y ) { this . x . set ( i , x ) ; this . y . set ( i , y ) ; this . z . set ( i , 0d ) ; calcG ( ) ; } | Sets the coordinates of the point . | 56 | 8 |
9,952 | public void setStartCornerColor ( Color color ) { if ( startColor == null ) { startColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . startColor = color ; } | Sets the start point s color for gradation . | 57 | 11 |
9,953 | public void setEndCornerColor ( Color color ) { if ( endColor == null ) { endColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . endColor = color ; } | Sets the end point s color for gradation . | 57 | 11 |
9,954 | public void setCornerColor ( int index , Color color ) { if ( ! cornerGradation ) { cornerGradation = true ; } colors . set ( index , color ) ; } | Sets the point s color for gradation . | 39 | 10 |
9,955 | public boolean hasTransitionTo ( CharRange condition , NFAState < T > state ) { Set < Transition < NFAState < T >>> set = transitions . get ( condition ) ; if ( set != null ) { for ( Transition < NFAState < T > > tr : set ) { if ( state . equals ( tr . getTo ( ) ) ) { return true ; } } } return false ; } | Returns true if transition with condition to state exists | 87 | 9 |
9,956 | public RangeSet getConditionsTo ( NFAState < T > state ) { RangeSet rs = new RangeSet ( ) ; for ( CharRange range : transitions . keySet ( ) ) { if ( range != null ) { Set < Transition < NFAState < T >>> set2 = transitions . get ( range ) ; for ( Transition < NFAState < T > > tr : set2 ) { if ( state . equals ( tr . getTo ( ) ) ) { rs . add ( range ) ; } } } } return rs ; } | Returns non epsilon confitions to transit to given state | 115 | 12 |
9,957 | public static boolean isSingleEpsilonOnly ( Set < Transition < NFAState > > set ) { if ( set . size ( ) != 1 ) { return false ; } for ( Transition < NFAState > tr : set ) { if ( tr . isEpsilon ( ) ) { return true ; } } return false ; } | Returns true if set only has one epsilon transition . | 71 | 12 |
9,958 | boolean isDeadEnd ( Set < NFAState < T > > nfaSet ) { for ( Set < Transition < NFAState < T > > > set : transitions . values ( ) ) { for ( Transition < NFAState < T > > t : set ) { if ( ! nfaSet . contains ( t . getTo ( ) ) ) { return false ; } } } return true ; } | Returns true if this state is not accepting and doesn t have any outbound transitions . | 87 | 17 |
9,959 | public DFAState < T > constructDFA ( Scope < DFAState < T > > dfaScope ) { Map < Set < NFAState < T > > , DFAState < T > > all = new HashMap <> ( ) ; Deque < DFAState < T > > unmarked = new ArrayDeque <> ( ) ; Set < NFAState < T > > startSet = epsilonClosure ( dfaScope ) ; DFAState < T > startDfa = new DFAState <> ( dfaScope , startSet ) ; all . put ( startSet , startDfa ) ; unmarked . add ( startDfa ) ; while ( ! unmarked . isEmpty ( ) ) { DFAState < T > dfa = unmarked . pop ( ) ; for ( CharRange c : dfa . possibleMoves ( ) ) { Set < NFAState < T >> moveSet = dfa . nfaTransitsFor ( c ) ; if ( ! moveSet . isEmpty ( ) ) { Set < NFAState < T >> newSet = epsilonClosure ( dfaScope , moveSet ) ; DFAState < T > ndfa = all . get ( newSet ) ; if ( ndfa == null ) { ndfa = new DFAState <> ( dfaScope , newSet ) ; all . put ( newSet , ndfa ) ; unmarked . add ( ndfa ) ; } dfa . addTransition ( c , ndfa ) ; } } } // optimize for ( DFAState < T > dfa : all . values ( ) ) { dfa . removeTransitionsFromAcceptImmediatelyStates ( ) ; } for ( DFAState < T > dfa : all . values ( ) ) { dfa . removeDeadEndTransitions ( ) ; } for ( DFAState < T > dfa : startDfa ) { dfa . optimizeTransitions ( ) ; } return startDfa ; } | Construct a dfa by using this state as starting state . | 426 | 12 |
9,960 | RangeSet getConditions ( ) { RangeSet is = new RangeSet ( ) ; for ( CharRange ic : transitions . keySet ( ) ) { if ( ic != null ) { is . add ( ic ) ; } } return is ; } | Returns all ranges from all transitions | 52 | 6 |
9,961 | private Set < NFAState < T > > epsilonTransitions ( StateVisitSet < NFAState < T > > marked ) { marked . add ( this ) ; Set < NFAState < T > > set = new HashSet <> ( ) ; for ( NFAState < T > nfa : epsilonTransit ( ) ) { if ( ! marked . contains ( nfa ) ) { set . add ( nfa ) ; set . addAll ( nfa . epsilonTransitions ( marked ) ) ; } } return set ; } | Returns a set of states that can be reached by epsilon transitions . | 120 | 15 |
9,962 | public Set < NFAState < T > > epsilonClosure ( Scope < DFAState < T > > scope ) { Set < NFAState < T >> set = new HashSet <> ( ) ; set . add ( this ) ; return epsilonClosure ( scope , set ) ; } | Creates a dfa state from all nfa states that can be reached from this state with epsilon move . | 64 | 24 |
9,963 | public void addTransition ( RangeSet rs , NFAState < T > to ) { for ( CharRange c : rs ) { addTransition ( c , to ) ; } edges . add ( to ) ; to . inStates . add ( this ) ; } | Adds a set of transitions | 56 | 5 |
9,964 | public Transition < NFAState < T > > addTransition ( CharRange condition , NFAState < T > to ) { Transition < NFAState < T >> t = new Transition <> ( condition , this , to ) ; Set < Transition < NFAState < T > > > set = transitions . get ( t . getCondition ( ) ) ; if ( set == null ) { set = new HashSet <> ( ) ; transitions . put ( t . getCondition ( ) , set ) ; } set . add ( t ) ; edges . add ( to ) ; to . inStates . add ( this ) ; return t ; } | Adds a transition | 135 | 3 |
9,965 | public void addEpsilon ( NFAState < T > to ) { Transition < NFAState < T >> t = new Transition <> ( this , to ) ; Set < Transition < NFAState < T > > > set = transitions . get ( null ) ; if ( set == null ) { set = new HashSet <> ( ) ; transitions . put ( null , set ) ; } set . add ( t ) ; edges . add ( to ) ; to . inStates . add ( this ) ; } | Adds a epsilon transition | 109 | 6 |
9,966 | public void addChildValueSelect ( final AbstractValueSelect _valueSelect ) throws EFapsException { if ( this . child == null ) { this . child = _valueSelect ; _valueSelect . setParentValueSelect ( this ) ; } else { this . child . addChildValueSelect ( _valueSelect ) ; } } | Method adds an AbstractValueSelect as a child of this chain of AbstractValueSelect . | 68 | 17 |
9,967 | public Object getValue ( final List < Object > _objectList ) throws EFapsException { final List < Object > ret = new ArrayList < Object > ( ) ; for ( final Object object : _objectList ) { ret . add ( getValue ( object ) ) ; } return _objectList . size ( ) > 0 ? ( ret . size ( ) > 1 ? ret : ret . get ( 0 ) ) : null ; } | Method to get the value for a list of object . | 91 | 11 |
9,968 | private void preparePrint ( final AbstractPrint _print ) throws EFapsException { for ( final Select select : _print . getSelection ( ) . getAllSelects ( ) ) { for ( final AbstractElement < ? > element : select . getElements ( ) ) { if ( element instanceof AbstractDataElement ) { ( ( AbstractDataElement < ? > ) element ) . append2SQLSelect ( sqlSelect ) ; } } } if ( sqlSelect . getColumns ( ) . size ( ) > 0 ) { for ( final Select select : _print . getSelection ( ) . getAllSelects ( ) ) { for ( final AbstractElement < ? > element : select . getElements ( ) ) { if ( element instanceof AbstractDataElement ) { ( ( AbstractDataElement < ? > ) element ) . append2SQLWhere ( sqlSelect . getWhere ( ) ) ; } } } if ( _print instanceof ObjectPrint ) { addWhere4ObjectPrint ( ( ObjectPrint ) _print ) ; } else if ( _print instanceof ListPrint ) { addWhere4ListPrint ( ( ListPrint ) _print ) ; } else { addTypeCriteria ( ( QueryPrint ) _print ) ; addWhere4QueryPrint ( ( QueryPrint ) _print ) ; } addCompanyCriteria ( _print ) ; } } | Prepare print . | 283 | 4 |
9,969 | private void addTypeCriteria ( final QueryPrint _print ) { final MultiValuedMap < TableIdx , TypeCriteria > typeCriterias = MultiMapUtils . newListValuedHashMap ( ) ; final List < Type > types = _print . getTypes ( ) . stream ( ) . sorted ( ( type1 , type2 ) -> Long . compare ( type1 . getId ( ) , type2 . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ; for ( final Type type : types ) { final String tableName = type . getMainTable ( ) . getSqlTable ( ) ; final TableIdx tableIdx = sqlSelect . getIndexer ( ) . getTableIdx ( tableName ) ; if ( tableIdx . isCreated ( ) ) { sqlSelect . from ( tableIdx . getTable ( ) , tableIdx . getIdx ( ) ) ; } if ( type . getMainTable ( ) . getSqlColType ( ) != null ) { typeCriterias . put ( tableIdx , new TypeCriteria ( type . getMainTable ( ) . getSqlColType ( ) , type . getId ( ) ) ) ; } } if ( ! typeCriterias . isEmpty ( ) ) { final SQLWhere where = sqlSelect . getWhere ( ) ; for ( final TableIdx tableIdx : typeCriterias . keySet ( ) ) { final Collection < TypeCriteria > criterias = typeCriterias . get ( tableIdx ) ; final Iterator < TypeCriteria > iter = criterias . iterator ( ) ; final TypeCriteria typeCriteria = iter . next ( ) ; final Criteria criteria = where . addCriteria ( tableIdx . getIdx ( ) , typeCriteria . sqlColType , iter . hasNext ( ) ? Comparison . IN : Comparison . EQUAL , String . valueOf ( typeCriteria . id ) , Connection . AND ) ; while ( iter . hasNext ( ) ) { criteria . value ( String . valueOf ( iter . next ( ) . id ) ) ; } } } } | Adds the type criteria . | 464 | 5 |
9,970 | private void executeUpdates ( ) throws EFapsException { ConnectionResource con = null ; try { con = Context . getThreadContext ( ) . getConnectionResource ( ) ; for ( final Entry < SQLTable , AbstractSQLInsertUpdate < ? > > entry : updatemap . entrySet ( ) ) { ( ( SQLUpdate ) entry . getValue ( ) ) . execute ( con ) ; } } catch ( final SQLException e ) { throw new EFapsException ( SQLRunner . class , "executeOneCompleteStmt" , e ) ; } } | Execute the update . | 118 | 5 |
9,971 | @ SuppressWarnings ( "unchecked" ) protected boolean executeSQLStmt ( final ISelectionProvider _sqlProvider , final String _complStmt ) throws EFapsException { SQLRunner . LOG . debug ( "SQL-Statement: {}" , _complStmt ) ; boolean ret = false ; List < Object [ ] > rows = new ArrayList <> ( ) ; boolean cached = false ; if ( runnable . has ( StmtFlag . REQCACHED ) ) { final QueryKey querykey = QueryKey . get ( Context . getThreadContext ( ) . getRequestId ( ) , _complStmt ) ; final Cache < QueryKey , Object > cache = QueryCache . getSqlCache ( ) ; if ( cache . containsKey ( querykey ) ) { final Object object = cache . get ( querykey ) ; if ( object instanceof List ) { rows = ( List < Object [ ] > ) object ; } cached = true ; } } if ( ! cached ) { ConnectionResource con = null ; try { con = Context . getThreadContext ( ) . getConnectionResource ( ) ; final Statement stmt = con . createStatement ( ) ; final ResultSet rs = stmt . executeQuery ( _complStmt ) ; final ArrayListHandler handler = new ArrayListHandler ( Context . getDbType ( ) . getRowProcessor ( ) ) ; rows = handler . handle ( rs ) ; rs . close ( ) ; stmt . close ( ) ; } catch ( final SQLException e ) { throw new EFapsException ( SQLRunner . class , "executeOneCompleteStmt" , e ) ; } if ( runnable . has ( StmtFlag . REQCACHED ) ) { final ICacheDefinition cacheDefinition = new ICacheDefinition ( ) { @ Override public long getLifespan ( ) { return 5 ; } @ Override public TimeUnit getLifespanUnit ( ) { return TimeUnit . MINUTES ; } } ; QueryCache . put ( cacheDefinition , QueryKey . get ( Context . getThreadContext ( ) . getRequestId ( ) , _complStmt ) , rows ) ; } } for ( final Object [ ] row : rows ) { for ( final Select select : _sqlProvider . getSelection ( ) . getAllSelects ( ) ) { select . addObject ( row ) ; } ret = true ; } return ret ; } | Execute SQL stmt . | 518 | 6 |
9,972 | void processTedQueue ( ) { int totalProcessing = context . taskManager . calcWaitingTaskCountInAllChannels ( ) ; if ( totalProcessing >= TaskManager . LIMIT_TOTAL_WAIT_TASKS ) { logger . warn ( "Total size of waiting tasks ({}) already exceeded limit ({}), skip this iteration (2)" , totalProcessing , TaskManager . LIMIT_TOTAL_WAIT_TASKS ) ; return ; } Channel channel = context . registry . getChannelOrMain ( Model . CHANNEL_QUEUE ) ; int maxTask = context . taskManager . calcChannelBufferFree ( channel ) ; maxTask = Math . min ( maxTask , 50 ) ; Map < String , Integer > channelSizes = new HashMap < String , Integer > ( ) ; channelSizes . put ( Model . CHANNEL_QUEUE , maxTask ) ; List < TaskRec > heads = tedDao . reserveTaskPortion ( channelSizes ) ; if ( heads . isEmpty ( ) ) return ; for ( final TaskRec head : heads ) { logger . debug ( "exec eventQueue for '{}', headTaskId={}" , head . key1 , head . taskId ) ; channel . workers . execute ( new TedRunnable ( head ) { @ Override public void run ( ) { processEventQueue ( head ) ; } } ) ; } } | heads uniqueness by key1 should be guaranteed by unique index . | 304 | 12 |
9,973 | private void processEventQueue ( final TaskRec head ) { final TedResult headResult = processEvent ( head ) ; TaskConfig tc = context . registry . getTaskConfig ( head . name ) ; if ( tc == null ) { context . taskManager . handleUnknownTasks ( asList ( head ) ) ; return ; } TaskRec lastUnsavedEvent = null ; TedResult lastUnsavedResult = null ; // try to execute next events, while head is reserved. some events may be created while executing current if ( headResult . status == TedStatus . DONE ) { outer : for ( int i = 0 ; i < 10 ; i ++ ) { List < TaskRec > events = tedDaoExt . eventQueueGetTail ( head . key1 ) ; if ( events . isEmpty ( ) ) break outer ; for ( TaskRec event : events ) { TaskConfig tc2 = context . registry . getTaskConfig ( event . name ) ; if ( tc2 == null ) break outer ; // unknown task, leave it for later TedResult result = processEvent ( event ) ; // DONE - final status, on which can continue with next event if ( result . status == TedStatus . DONE ) { saveResult ( event , result ) ; } else { lastUnsavedEvent = event ; lastUnsavedResult = result ; break outer ; } } } } // first save head, otherwise unique index will fail final TedResult finalLastUnsavedResult = lastUnsavedResult ; final TaskRec finalLastUnsavedEvent = lastUnsavedEvent ; tedDaoExt . runInTx ( new Runnable ( ) { @ Override public void run ( ) { try { saveResult ( head , headResult ) ; if ( finalLastUnsavedResult != null ) { saveResult ( finalLastUnsavedEvent , finalLastUnsavedResult ) ; } } catch ( Exception e ) { logger . error ( "Error while finishing events queue execution" , e ) ; } } } ) ; } | process events from queue each after other until ERROR or RETRY will happen | 429 | 14 |
9,974 | static public String [ ] getAllProperties ( ) { java . util . Properties prop = System . getProperties ( ) ; java . util . ArrayList < String > list = new java . util . ArrayList < String > ( ) ; java . util . Enumeration < ? > enumeration = prop . propertyNames ( ) ; while ( enumeration . hasMoreElements ( ) ) { list . add ( ( String ) enumeration . nextElement ( ) ) ; } return list . toArray ( new String [ 0 ] ) ; } | Get all property names . | 115 | 5 |
9,975 | public void set ( double fov , double aspect , double zNear , double zFar ) { this . fov = fov ; this . aspect = aspect ; this . zNear = zNear ; this . zFar = zFar ; } | Sets a perspective projection applying foreshortening making distant objects appear smaller than closer ones . | 51 | 18 |
9,976 | public static List < CharRange > removeOverlap ( CharRange r1 , CharRange r2 ) { assert r1 . intersect ( r2 ) ; List < CharRange > list = new ArrayList < CharRange > ( ) ; Set < Integer > set = new TreeSet < Integer > ( ) ; set . add ( r1 . getFrom ( ) ) ; set . add ( r1 . getTo ( ) ) ; set . add ( r2 . getFrom ( ) ) ; set . add ( r2 . getTo ( ) ) ; int p = 0 ; for ( int r : set ) { if ( p != 0 ) { list . add ( new CharRange ( p , r ) ) ; } p = r ; } return list ; } | Returns a list of ranges that together gather the same characters as r1 and r2 . None of the resulting ranges doesn t intersect each other . | 160 | 29 |
9,977 | public String getHrefResolved ( ) { if ( Atom10Parser . isAbsoluteURI ( href ) ) { return href ; } else if ( baseURI != null && collectionElement != null ) { final int lastslash = baseURI . lastIndexOf ( "/" ) ; return Atom10Parser . resolveURI ( baseURI . substring ( 0 , lastslash ) , collectionElement , href ) ; } return null ; } | Get resolved URI of the collection or null if impossible to determine | 92 | 12 |
9,978 | public String getHrefResolved ( final String relativeUri ) { if ( Atom10Parser . isAbsoluteURI ( relativeUri ) ) { return relativeUri ; } else if ( baseURI != null && collectionElement != null ) { final int lastslash = baseURI . lastIndexOf ( "/" ) ; return Atom10Parser . resolveURI ( baseURI . substring ( 0 , lastslash ) , collectionElement , relativeUri ) ; } return null ; } | Get resolved URI using collection s baseURI or null if impossible to determine | 103 | 14 |
9,979 | public boolean accepts ( final String ct ) { for ( final Object element : accepts ) { final String accept = ( String ) element ; if ( accept != null && accept . trim ( ) . equals ( "*/*" ) ) { return true ; } final String entryType = "application/atom+xml" ; final boolean entry = entryType . equals ( ct ) ; if ( entry && null == accept ) { return true ; } else if ( entry && "entry" . equals ( accept ) ) { return true ; } else if ( entry && entryType . equals ( accept ) ) { return true ; } else { final String [ ] rules = accepts . toArray ( new String [ accepts . size ( ) ] ) ; for ( final String rule2 : rules ) { String rule = rule2 . trim ( ) ; if ( rule . equals ( ct ) ) { return true ; } final int slashstar = rule . indexOf ( "/*" ) ; if ( slashstar > 0 ) { rule = rule . substring ( 0 , slashstar + 1 ) ; if ( ct . startsWith ( rule ) ) { return true ; } } } } } return false ; } | Returns true if contentType is accepted by collection . | 250 | 10 |
9,980 | public Element collectionToElement ( ) { final Collection collection = this ; final Element element = new Element ( "collection" , AtomService . ATOM_PROTOCOL ) ; element . setAttribute ( "href" , collection . getHref ( ) ) ; final Element titleElem = new Element ( "title" , AtomService . ATOM_FORMAT ) ; titleElem . setText ( collection . getTitle ( ) ) ; if ( collection . getTitleType ( ) != null && ! collection . getTitleType ( ) . equals ( "TEXT" ) ) { titleElem . setAttribute ( "type" , collection . getTitleType ( ) , AtomService . ATOM_FORMAT ) ; } element . addContent ( titleElem ) ; // Loop to create <app:categories> elements for ( final Object element2 : collection . getCategories ( ) ) { final Categories cats = ( Categories ) element2 ; element . addContent ( cats . categoriesToElement ( ) ) ; } for ( final Object element2 : collection . getAccepts ( ) ) { final String range = ( String ) element2 ; final Element acceptElem = new Element ( "accept" , AtomService . ATOM_PROTOCOL ) ; acceptElem . setText ( range ) ; element . addContent ( acceptElem ) ; } return element ; } | Serialize an AtomService . Collection into an XML element | 290 | 11 |
9,981 | public void rotate ( double angle ) { double s = Math . sin ( angle ) ; double c = Math . cos ( angle ) ; double temp1 = m00 ; double temp2 = m01 ; m00 = c * temp1 + s * temp2 ; m01 = - s * temp1 + c * temp2 ; temp1 = m10 ; temp2 = m11 ; m10 = c * temp1 + s * temp2 ; m11 = - s * temp1 + c * temp2 ; } | Implementation roughly based on AffineTransform . | 109 | 9 |
9,982 | public Vector3D mult ( Vector3D source ) { Vector3D result = new Vector3D ( ) ; result . setX ( m00 * source . getX ( ) + m01 * source . getY ( ) + m02 ) ; result . setY ( m10 * source . getX ( ) + m11 * source . getY ( ) + m12 ) ; return result ; } | Multiply the x and y coordinates of a Vertex against this matrix . | 86 | 16 |
9,983 | public boolean invert ( ) { double determinant = determinant ( ) ; if ( Math . abs ( determinant ) <= Double . MIN_VALUE ) { return false ; } double t00 = m00 ; double t01 = m01 ; double t02 = m02 ; double t10 = m10 ; double t11 = m11 ; double t12 = m12 ; m00 = t11 / determinant ; m10 = - t10 / determinant ; m01 = - t01 / determinant ; m11 = t00 / determinant ; m02 = ( t01 * t12 - t11 * t02 ) / determinant ; m12 = ( t10 * t02 - t00 * t12 ) / determinant ; return true ; } | Invert this matrix . Implementation stolen from OpenJDK . | 161 | 12 |
9,984 | @ JsonAnySetter public void setAdditionalField ( final String key , final Object value ) { this . additionalFields . put ( key , value ) ; } | Add additional field | 35 | 3 |
9,985 | public static Object getGenInstance ( Class < ? > cls , Object ... args ) throws ParserException { Class < ? > parserClass = getGenClass ( cls ) ; try { if ( args . length == 0 ) { return parserClass . newInstance ( ) ; } else { for ( Constructor constructor : parserClass . getConstructors ( ) ) { Class [ ] parameterTypes = constructor . getParameterTypes ( ) ; if ( parameterTypes . length == args . length ) { boolean match = true ; int index = 0 ; for ( Class c : parameterTypes ) { if ( ! c . isAssignableFrom ( args [ index ++ ] . getClass ( ) ) ) { match = false ; break ; } } if ( match ) { return constructor . newInstance ( args ) ; } } } throw new IllegalArgumentException ( "no required constructor for " + cls ) ; } } catch ( InstantiationException | IllegalAccessException | SecurityException | IllegalArgumentException | InvocationTargetException ex ) { throw new ParserException ( ex ) ; } } | Creates generated class instance either by using ClassLoader or by compiling it dynamically | 227 | 15 |
9,986 | public static Class < ? > getGenClass ( Class < ? > cls ) throws ParserException { GenClassname genClassname = cls . getAnnotation ( GenClassname . class ) ; if ( genClassname == null ) { throw new IllegalArgumentException ( "@GenClassname not set in " + cls ) ; } try { return loadGenClass ( cls ) ; } catch ( ClassNotFoundException ex ) { throw new ParserException ( cls + " classes implementation class not compiled.\n" + "Possible problem with annotation processor.\n" + "Try building the whole project and check that implementation class " + genClassname . value ( ) + " exist!" ) ; /* try { GenClassCompiler pc = GenClassCompiler.compile(El.getTypeElement(cls.getCanonicalName()), null); return pc.loadDynamic(); } catch (IOException ex1) { throw new ParserException(ex1); } */ } } | Creates generated class either by using ClassLoader | 215 | 9 |
9,987 | public static Object createDynamicInstance ( Class < ? > cls ) throws IOException { GenClassCompiler pc = GenClassCompiler . compile ( El . getTypeElement ( cls . getCanonicalName ( ) ) , null ) ; return pc . loadDynamic ( ) ; } | Creates instance of implementation class and loads it dynamic . This method is used in testing . | 61 | 18 |
9,988 | public static Class < ? > loadGenClass ( Class < ? > cls ) throws ClassNotFoundException { Class < ? > parserClass = map . get ( cls ) ; if ( parserClass == null ) { GenClassname genClassname = cls . getAnnotation ( GenClassname . class ) ; if ( genClassname == null ) { throw new IllegalArgumentException ( "@GenClassname not set in " + cls ) ; } parserClass = Class . forName ( genClassname . value ( ) ) ; map . put ( cls , parserClass ) ; } return parserClass ; } | Creates generated class by using ClassLoader . Return null if unable to load class | 131 | 16 |
9,989 | private String getObtainRequestPath ( String requestID , Boolean byResourceID , Boolean byDocID , Boolean idsOnly , String resumptionToken ) { String path = obtainPath ; if ( resumptionToken != null ) { path += "?" + resumptionTokenParam + "=" + resumptionToken ; return path ; } if ( requestID != null ) { path += "?" + requestIDParam + "=" + requestID ; } else { // error return null ; } if ( byResourceID ) { path += "&" + byResourceIDParam + "=" + booleanTrueString ; } else { path += "&" + byResourceIDParam + "=" + booleanFalseString ; } if ( byDocID ) { path += "&" + byDocIDParam + "=" + booleanTrueString ; } else { path += "&" + byDocIDParam + "=" + booleanFalseString ; } if ( idsOnly ) { path += "&" + idsOnlyParam + "=" + booleanTrueString ; } else { path += "&" + idsOnlyParam + "=" + booleanFalseString ; } return path ; } | Obtain the path used for an obtain request | 246 | 9 |
9,990 | private String getHarvestRequestPath ( String requestID , Boolean byResourceID , Boolean byDocID ) { String path = harvestPath ; if ( requestID != null ) { path += "?" + requestIDParam + "=" + requestID ; } else { // error return null ; } if ( byResourceID ) { path += "&" + byResourceIDParam + "=" + booleanTrueString ; } else { path += "&" + byResourceIDParam + "=" + booleanFalseString ; } if ( byDocID ) { path += "&" + byDocIDParam + "=" + booleanTrueString ; } else { path += "&" + byDocIDParam + "=" + booleanFalseString ; } return path ; } | Obtain the path used for a harvest request | 159 | 9 |
9,991 | private LRResult getObtainJSONData ( String requestID , Boolean byResourceID , Boolean byDocID , Boolean idsOnly , String resumptionToken ) throws LRException { String path = getObtainRequestPath ( requestID , byResourceID , byDocID , idsOnly , resumptionToken ) ; JSONObject json = getJSONFromPath ( path ) ; return new LRResult ( json ) ; } | Get a result from an obtain request If the resumption token is not null it will override the other parameters for ths request | 89 | 25 |
9,992 | public LRResult getHarvestJSONData ( String requestID , Boolean byResourceID , Boolean byDocID ) throws LRException { String path = getHarvestRequestPath ( requestID , byResourceID , byDocID ) ; JSONObject json = getJSONFromPath ( path ) ; return new LRResult ( json ) ; } | Get a result from a harvest request | 71 | 7 |
9,993 | private String getExtractRequestPath ( String dataServiceName , String viewName , Date from , Date until , Boolean idsOnly , String mainValue , Boolean partial , String mainName ) { String path = extractPath ; if ( viewName != null ) { path += "/" + viewName ; } else { return null ; } if ( dataServiceName != null ) { path += "/" + dataServiceName ; } else { return null ; } if ( mainValue != null && mainName != null ) { path += "?" + mainName ; if ( partial ) { path += startsWithParam ; } path += "=" + mainValue ; } else { return null ; } if ( from != null ) { path += "&" + fromParam + "=" + ISO8601 . format ( from ) ; } if ( until != null ) { path += "&" + untilParam + "=" + ISO8601 . format ( until ) ; } if ( idsOnly ) { path += "&" + idsOnlyParam + "=" + booleanTrueString ; } return path ; } | Get an extract request path | 230 | 5 |
9,994 | private JSONObject getJSONFromPath ( String path ) throws LRException { JSONObject json = null ; String jsonTxt = null ; try { jsonTxt = LRClient . executeJsonGet ( importProtocol + "://" + nodeHost + path ) ; } catch ( Exception e ) { throw new LRException ( LRException . IMPORT_FAILED ) ; //e.printStackTrace(); } try { json = new JSONObject ( jsonTxt ) ; } catch ( JSONException e ) { throw new LRException ( LRException . JSON_IMPORT_FAILED ) ; //e.printStackTrace(); } return json ; } | Get the data from the specified path as a JSONObject | 150 | 11 |
9,995 | private static int fontStyleToInt ( FontStyle style ) { switch ( style ) { case PLAIN : return java . awt . Font . PLAIN ; case BOLD : return java . awt . Font . BOLD ; case ITALIC : return java . awt . Font . ITALIC ; default : return java . awt . Font . PLAIN ; } } | Return a java . awt . Font style constant from FontStyle . | 80 | 14 |
9,996 | private static FontStyle intToFontStyle ( int style ) { switch ( style ) { case java . awt . Font . PLAIN : return FontStyle . PLAIN ; case java . awt . Font . BOLD : return FontStyle . BOLD ; case java . awt . Font . ITALIC : return FontStyle . ITALIC ; case java . awt . Font . BOLD + java . awt . Font . ITALIC : return FontStyle . BOLD_ITALIC ; default : return FontStyle . PLAIN ; } } | Return FontStyle enum value from java . awt . Font style constant . | 117 | 15 |
9,997 | private static FontStyle stringToFontStyle ( String style ) { if ( style . compareToIgnoreCase ( "plain" ) == 0 ) { return FontStyle . PLAIN ; } else if ( style . compareToIgnoreCase ( "bold" ) == 0 ) { return FontStyle . BOLD ; } else if ( style . compareToIgnoreCase ( "italic" ) == 0 ) { return FontStyle . ITALIC ; } else { throw new IllegalArgumentException ( ) ; } } | Return FontStyle enum value from a font style name . | 108 | 11 |
9,998 | public void onReload ( final Container _container ) { final Set < Class < ? > > classesToRemove = new HashSet <> ( ) ; final Set < Class < ? > > classesToAdd = new HashSet <> ( ) ; for ( final Class < ? > c : getClasses ( ) ) { if ( ! this . cachedClasses . contains ( c ) ) { classesToAdd . add ( c ) ; } } for ( final Class < ? > c : this . cachedClasses ) { if ( ! getClasses ( ) . contains ( c ) ) { classesToRemove . add ( c ) ; } } getClasses ( ) . clear ( ) ; init ( ) ; getClasses ( ) . addAll ( classesToAdd ) ; getClasses ( ) . removeAll ( classesToRemove ) ; } | Perform a new search for resource classes and provider classes . | 179 | 12 |
9,999 | private void addInstSelect ( final Select _select , final AbstractDataElement < ? > _element , final Object _attrOrClass , final Type _currentType ) throws CacheReloadException { if ( StringUtils . isNotEmpty ( _element . getPath ( ) ) && ! this . instSelects . containsKey ( _element . getPath ( ) ) ) { final Select instSelect = Select . get ( ) ; for ( final AbstractElement < ? > selectTmp : _select . getElements ( ) ) { if ( ! selectTmp . equals ( _element ) ) { if ( selectTmp instanceof LinktoElement ) { instSelect . addElement ( new LinktoElement ( ) . setAttribute ( ( ( LinktoElement ) selectTmp ) . getAttribute ( ) ) ) ; } else if ( selectTmp instanceof LinkfromElement ) { instSelect . addElement ( new LinkfromElement ( ) . setAttribute ( ( ( LinkfromElement ) selectTmp ) . getAttribute ( ) ) . setStartType ( ( ( LinkfromElement ) selectTmp ) . getStartType ( ) ) ) ; } else if ( selectTmp instanceof ClassElement ) { instSelect . addElement ( new ClassElement ( ) . setClassification ( ( ( ClassElement ) selectTmp ) . getClassification ( ) ) . setType ( ( ( ClassElement ) selectTmp ) . getType ( ) ) ) ; } else if ( selectTmp instanceof AttributeSetElement ) { instSelect . addElement ( new AttributeSetElement ( ) . setAttributeSet ( ( ( AttributeSetElement ) selectTmp ) . getAttributeSet ( ) ) . setType ( ( ( ClassElement ) selectTmp ) . getType ( ) ) ) ; } } } if ( _element instanceof LinkfromElement ) { instSelect . addElement ( new LinkfromElement ( ) . setAttribute ( ( Attribute ) _attrOrClass ) . setStartType ( _currentType ) ) ; instSelect . addElement ( new InstanceElement ( ( ( Attribute ) _attrOrClass ) . getParent ( ) ) ) ; } else if ( _element instanceof LinktoElement ) { instSelect . addElement ( new LinktoElement ( ) . setAttribute ( ( Attribute ) _attrOrClass ) ) ; instSelect . addElement ( new InstanceElement ( _currentType ) ) ; } else if ( _element instanceof ClassElement ) { instSelect . addElement ( new ClassElement ( ) . setClassification ( ( Classification ) _attrOrClass ) . setType ( _currentType ) ) ; instSelect . addElement ( new InstanceElement ( ( Type ) _attrOrClass ) ) ; } else if ( _element instanceof AttributeSetElement ) { instSelect . addElement ( new AttributeSetElement ( ) . setAttributeSet ( ( AttributeSet ) _attrOrClass ) . setType ( _currentType ) ) ; instSelect . addElement ( new InstanceElement ( ( Type ) _attrOrClass ) ) ; } this . instSelects . put ( _element . getPath ( ) , instSelect ) ; } } | Adds the inst select . | 679 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.