idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
10,100
public final void loadTexture ( ) { texture = null ; texture = AWTTextureIO . newTexture ( GLProfile . get ( GLProfile . GL2 ) , img , true ) ; if ( texture == null ) { throw new CasmiRuntimeException ( "Cannot load texture" ) ; } }
Loads a texture using image data .
64
8
10,101
public final Color getColor ( int x , int y ) { int [ ] pixels = ( ( DataBufferInt ) img . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; int idx = x + y * width ; return new RGBColor ( ( pixels [ idx ] >> 16 & 0x000000ff ) / 255.0 , ( pixels [ idx ] >> 8 & 0x000000ff ) / 255.0 , ( pixels [ idx ] & 0x000000ff ) / 255.0 , ( pixels [ idx ] >> 24 ) / 255.0 ) ; }
Returns the pixel color of this Image .
131
8
10,102
public final double getRed ( int x , int y ) { int [ ] pixels = ( ( DataBufferInt ) img . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; int idx = x + y * width ; return ( pixels [ idx ] >> 16 & 0x000000ff ) ; }
Returns the red color value of the pixel data in this Image .
71
13
10,103
public final void setColor ( Color color , int x , int y ) { int [ ] pixels = ( ( DataBufferInt ) img . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; int red = ( int ) ( color . getRed ( ) * 255.0 ) ; int green = ( int ) ( color . getGreen ( ) * 255.0 ) ; int blue = ( int ) ( color . getBlue ( ) * 255.0 ) ; int alpha = ( int ) ( color . getAlpha ( ) * 255.0 ) ; pixels [ x + y * width ] = alpha << 24 | red << 16 | green << 8 | blue ; }
Sets the color value of the pixel data in this Image .
147
13
10,104
public final void setA ( double alpha , int x , int y ) { int [ ] pixels = ( ( DataBufferInt ) img . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; int idx = x + y * width ; int tmpR = pixels [ idx ] >> 16 & 0x000000ff ; int tmpG = pixels [ idx ] >> 8 & 0x000000ff ; int tmpB = pixels [ idx ] & 0x000000ff ; pixels [ idx ] = ( int ) alpha << 24 | tmpR << 16 | tmpG << 8 | tmpB ; }
Sets the alpha value of the pixel data in this Image .
133
13
10,105
public final void setColors ( Color [ ] colors ) { int [ ] pixels = ( ( DataBufferInt ) img . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; for ( int y = 0 ; y < height ; ++ y ) { for ( int x = 0 ; x < width ; ++ x ) { int idx = x + y * width ; if ( colors . length <= idx ) break ; int red = ( int ) ( colors [ idx ] . getRed ( ) * 255.0 ) ; int green = ( int ) ( colors [ idx ] . getGreen ( ) * 255.0 ) ; int blue = ( int ) ( colors [ idx ] . getBlue ( ) * 255.0 ) ; int alpha = ( int ) ( colors [ idx ] . getAlpha ( ) * 255.0 ) ; pixels [ idx ] = alpha << 24 | red << 16 | green << 8 | blue ; } } }
Sets the color values to this Image .
210
9
10,106
public static AbstractCI < ? > getCI ( final ICIPrintStmt _stmt ) throws CacheReloadException { AbstractCI < ? > ret = null ; switch ( _stmt . getCINature ( ) ) { case TYPE : final Type type ; if ( UUIDUtil . isUUID ( _stmt . getCI ( ) ) ) { type = Type . get ( UUID . fromString ( _stmt . getCI ( ) ) ) ; } else { type = Type . get ( _stmt . getCI ( ) ) ; } if ( type != null ) { final org . efaps . json . ci . Type jsonType = new org . efaps . json . ci . Type ( ) . setName ( type . getName ( ) ) . setUUID ( type . getUUID ( ) ) . setId ( type . getId ( ) ) ; for ( final Attribute attr : type . getAttributes ( ) . values ( ) ) { final AttributeType attrType = new AttributeType ( ) . setName ( attr . getAttributeType ( ) . getName ( ) ) ; switch ( DMAttributeType . fromValue ( attr . getAttributeType ( ) . getName ( ) ) ) { case LINK : case LINK_WITH_RANGES : case STATUS : if ( attr . hasLink ( ) ) { attrType . setInfo ( attr . getLink ( ) . getName ( ) + ", " + attr . getLink ( ) . getUUID ( ) ) ; } break ; default : break ; } jsonType . addAttribute ( new org . efaps . json . ci . Attribute ( ) . setName ( attr . getName ( ) ) . setType ( attrType ) ) ; } ret = jsonType ; } break ; default : break ; } return ret ; }
Gets the ci .
411
6
10,107
public void addUniqueKeyColumn ( final String _ukName , final int _colIndex , final String _colName ) { final String ukName = _ukName . toUpperCase ( ) ; final UniqueKeyInformation uki ; if ( ! this . ukMap . containsKey ( ukName ) ) { uki = new UniqueKeyInformation ( _ukName ) ; this . ukMap . put ( ukName , uki ) ; } else { uki = this . ukMap . get ( ukName ) ; } uki . appendColumnName ( _colIndex , _colName ) ; // this.ukColMap.put(uki.getColumnNames(), uki); }
Adds an unique key information to this table information .
152
10
10,108
public void addForeignKey ( final String _fkName , final String _colName , final String _refTableName , final String _refColName , final boolean _cascade ) { this . fkMap . put ( _fkName . toUpperCase ( ) , new ForeignKeyInformation ( _fkName , _colName , _refTableName , _refColName , _cascade ) ) ; }
Fetches all foreign keys for this table .
91
10
10,109
@ SuppressWarnings ( "unchecked" ) private List < ListenerRegistration > addListenerToRegistry ( ) { List < ListenerRegistration > registrationsBuilder = newArrayList ( ) ; for ( Pair < IdMatcher , Watcher > guiceWatcherRegistration : getRegisteredWatchers ( ) ) { Watcher watcher = guiceWatcherRegistration . right ( ) ; IdMatcher idMatcher = guiceWatcherRegistration . left ( ) ; Registration registration = registry . addWatcher ( idMatcher , watcher ) ; ListenerRegistration listenerRegistration = new ListenerRegistration ( registration , idMatcher , watcher ) ; registrationsBuilder . add ( listenerRegistration ) ; } return registrationsBuilder ; }
enforce creation of all watcher before register it
153
10
10,110
private void initConfig ( ) { SystemConfiguration config = null ; try { config = EFapsSystemConfiguration . get ( ) ; if ( config != null ) { final Properties confProps = config . getAttributeValueAsProperties ( KernelSettings . PWDSTORE ) ; this . digesterConfig . setAlgorithm ( confProps . getProperty ( PasswordStore . ALGORITHM , this . digesterConfig . getAlgorithm ( ) ) ) ; this . digesterConfig . setIterations ( confProps . getProperty ( PasswordStore . ITERATIONS , this . digesterConfig . getIterations ( ) . toString ( ) ) ) ; this . digesterConfig . setSaltSizeBytes ( confProps . getProperty ( PasswordStore . SALTSIZE , this . digesterConfig . getSaltSizeBytes ( ) . toString ( ) ) ) ; this . threshold = config . getAttributeValueAsInteger ( KernelSettings . PWDTH ) ; } } catch ( final EFapsException e ) { PasswordStore . LOG . error ( "Error on reading SystemConfiguration for PasswordStore" , e ) ; } }
Initialize the digester configuration by reading values from the kernel SystemConfiguration .
239
15
10,111
public void read ( final String _readValue ) throws EFapsException { if ( _readValue != null ) { try { this . props . load ( new StringReader ( _readValue ) ) ; } catch ( final IOException e ) { throw new EFapsException ( PasswordStore . class . getName ( ) , e ) ; } } }
Read a PasswordStore from a String .
73
8
10,112
private boolean check ( final String _plainPassword , final int _pos ) { boolean ret = false ; if ( this . props . containsKey ( PasswordStore . DIGEST + _pos ) ) { final ConfigurablePasswordEncryptor passwordEncryptor = new ConfigurablePasswordEncryptor ( ) ; this . digesterConfig . setAlgorithm ( this . props . getProperty ( PasswordStore . ALGORITHM + _pos ) ) ; this . digesterConfig . setIterations ( this . props . getProperty ( PasswordStore . ITERATIONS + _pos ) ) ; this . digesterConfig . setSaltSizeBytes ( this . props . getProperty ( PasswordStore . SALTSIZE + _pos ) ) ; passwordEncryptor . setConfig ( this . digesterConfig ) ; ret = passwordEncryptor . checkPassword ( _plainPassword , this . props . getProperty ( PasswordStore . DIGEST + _pos ) ) ; } return ret ; }
Check the given Plain Text Password for equal on the Hash by applying the algorithm salt etc .
207
18
10,113
public boolean isRepeated ( final String _plainPassword ) { boolean ret = false ; for ( int i = 1 ; i < this . threshold + 1 ; i ++ ) { ret = check ( _plainPassword , i ) ; if ( ret ) { break ; } } return ret ; }
Is the given plain password repeated . It is checked against the existing previous passwords .
61
16
10,114
public void setNew ( final String _plainPassword , final String _currentValue ) throws EFapsException { initConfig ( ) ; read ( _currentValue ) ; final ConfigurablePasswordEncryptor passwordEncryptor = new ConfigurablePasswordEncryptor ( ) ; passwordEncryptor . setConfig ( this . digesterConfig ) ; final String encrypted = passwordEncryptor . encryptPassword ( _plainPassword ) ; shiftAll ( ) ; this . props . setProperty ( PasswordStore . DIGEST + 0 , encrypted ) ; this . props . setProperty ( PasswordStore . ALGORITHM + 0 , this . digesterConfig . getAlgorithm ( ) ) ; this . props . setProperty ( PasswordStore . ITERATIONS + 0 , this . digesterConfig . getIterations ( ) . toString ( ) ) ; this . props . setProperty ( PasswordStore . SALTSIZE + 0 , this . digesterConfig . getSaltSizeBytes ( ) . toString ( ) ) ; }
Set the given given Plain Password as the new current Password by encrypting it .
213
16
10,115
private void shiftAll ( ) { shift ( PasswordStore . DIGEST ) ; shift ( PasswordStore . ALGORITHM ) ; shift ( PasswordStore . ITERATIONS ) ; shift ( PasswordStore . SALTSIZE ) ; }
Shift all Properties .
50
4
10,116
private void shift ( final String _key ) { for ( int i = this . threshold ; i > 0 ; i -- ) { this . props . setProperty ( _key + i , this . props . getProperty ( _key + ( i - 1 ) , "" ) . trim ( ) ) ; } int i = this . threshold + 1 ; while ( this . props . contains ( _key + i ) ) { this . props . remove ( _key + i ) ; i ++ ; } }
Shift a property .
105
4
10,117
public Long createBatch ( String batchTaskName , String data , String key1 , String key2 , List < TedTask > tedTasks ) { if ( tedTasks == null || tedTasks . isEmpty ( ) ) return null ; if ( batchTaskName == null ) { throw new IllegalStateException ( "batchTaskName is required!" ) ; } TaskConfig batchTC = context . registry . getTaskConfig ( batchTaskName ) ; if ( batchTC == null ) throw new IllegalArgumentException ( "Batch task '" + batchTaskName + "' is not known for TED" ) ; Long batchId = context . tedDao . createTaskPostponed ( batchTC . taskName , Model . CHANNEL_BATCH , data , key1 , key2 , 30 * 60 ) ; createTasksBulk ( tedTasks , batchId ) ; context . tedDao . setStatusPostponed ( batchId , TedStatus . NEW , Model . BATCH_MSG , new Date ( ) ) ; return batchId ; }
if batchTaskName is null - will take from taskConfiguration
226
12
10,118
public int maxDepth ( ) { Map < DFAState < T > , Integer > indexOf = new NumMap <> ( ) ; Map < DFAState < T > , Long > depth = new NumMap <> ( ) ; Deque < DFAState < T > > stack = new ArrayDeque <> ( ) ; maxDepth ( root , indexOf , stack , depth ) ; long d = depth . get ( root ) ; assert d >= 0 ; if ( d >= Integer . MAX_VALUE ) { return Integer . MAX_VALUE ; } else { return ( int ) d ; } }
Calculates the maximum length of accepted string . Returns Integer . MAX_VALUE if length is infinite . For if|while returns 5 . For a + returns Integer . MAX_VALUE .
128
38
10,119
public void calculateMaxFindSkip ( ) { Map < DFAState < T > , Integer > indexOf = new NumMap <> ( ) ; Map < DFAState < T > , Integer > skip = new NumMap <> ( ) ; Deque < DFAState < T > > stack = new ArrayDeque <> ( ) ; findSkip ( root , indexOf , stack , new LinkedList ( ) ) ; root . setAcceptStartLength ( 1 ) ; }
Calculates how many characters we can skip after failed find operation
102
13
10,120
public void register ( ) { logger . debug ( "[register] uri = {}" , getManagementUri ( ) ) ; JsonNode jsonNode ; ObjectMapper objectMapper = jsonObjectMapper . getObjectMapperBinary ( ) ; ObjectNode objectNode = objectMapper . createObjectNode ( ) ; objectNode . put ( CommandParameters . METHOD , "register" ) ; try { jsonNode = objectMapper . readTree ( managementConnection . sendWithResult ( objectMapper . writeValueAsBytes ( objectNode ) ) ) ; } catch ( Exception e ) { logger . error ( "[register] could not register at server" ) ; return ; } id = jsonNode . get ( "id" ) . asText ( ) ; setMaster ( jsonNode . get ( "isMaster" ) . asBoolean ( ) ) ; managementConnection . setServerId ( id ) ; logger . debug ( "[register] id = {}, isMaster = {}, uri = {}" , getId ( ) , isMaster ( ) , getManagementUri ( ) ) ; }
Registers with the Neo4j server and saves some Neo4j server information with this object .
233
20
10,121
public DataConnection getConnection ( ) { DataConnection connection ; for ( connection = availableConnections . poll ( ) ; connection != null && ! connection . isUsable ( ) ; connection = availableConnections . poll ( ) ) { if ( ! connection . isUsable ( ) ) { connection . close ( ) ; } } if ( connection == null ) { connection = new DataConnection ( getDataUri ( ) ) ; try { connection . connect ( ) ; } catch ( Exception e ) { logger . error ( "[getConnection] could not connect to database" , e ) ; return null ; } } connection . setLocale ( threadLocale . getLocale ( ) ) ; return connection ; }
Gets a connection from the pool of available and free data connections to this server .
148
17
10,122
public void returnConnection ( DataConnection connection ) { if ( connection . isUsable ( ) ) { connection . setLastUsage ( new Date ( ) ) ; availableConnections . add ( connection ) ; } else { connection . close ( ) ; } usedConnections . remove ( connection ) ; }
Returns a connection to the pool of available and free data connections to this server .
62
16
10,123
public void connect ( ) throws Exception { logger . debug ( "[connect] initializing new connection" ) ; if ( timer != null ) { timer . cancel ( ) ; } if ( isConnected ( ) ) { return ; } synchronized ( webSocketHandler . getNotifyConnectionObject ( ) ) { webSocketConnectionManager . start ( ) ; try { webSocketHandler . getNotifyConnectionObject ( ) . wait ( TimeUnit . SECONDS . toMillis ( WEBSOCKET_TIMEOUT ) ) ; } catch ( InterruptedException e ) { onConnectionClosed ( ) ; logger . debug ( "[connect] not open" ) ; throw new Exception ( "websocket connection not open" ) ; } if ( ! isConnected ( ) ) { onConnectionClosed ( ) ; logger . debug ( "[connect] timeout" ) ; throw new Exception ( "websocket connection timeout" ) ; } } }
Connects to the Neo4j server identified by URI and ID of this connection .
196
17
10,124
public void onConnectionClosed ( ) { logger . debug ( "[onConnectionClosed] '{}', isConnected = {}" , uri , isConnected ( ) ) ; webSocketConnectionManager . stop ( ) ; timer = new Timer ( ) ; timer . schedule ( new TimerTask ( ) { @ Override public void run ( ) { logger . debug ( "[onConnectionClosed:run]" ) ; synchronized ( webSocketHandler . getNotifyConnectionObject ( ) ) { webSocketConnectionManager . start ( ) ; try { webSocketHandler . getNotifyConnectionObject ( ) . wait ( TimeUnit . SECONDS . toMillis ( WEBSOCKET_RECONNECT_TIMEOUT ) ) ; } catch ( InterruptedException e ) { logger . debug ( "[onConnectionClose]" , e ) ; } if ( isConnected ( ) ) { logger . debug ( "[onConnectionClosed:run] connected" ) ; clusterListener . onServerReconnected ( getServerId ( ) , uri ) ; this . cancel ( ) ; } else { logger . debug ( "[onConnectionClosed:run] NOT connected" ) ; webSocketConnectionManager . stop ( ) ; } } } } , TimeUnit . SECONDS . toMillis ( WEBSOCKET_TIMEOUT ) , TimeUnit . SECONDS . toMillis ( WEBSOCKET_RECONNECT_TIMEOUT ) ) ; }
Is being called when the websocket connection was closed and tries to reconnect .
310
15
10,125
public byte [ ] sendWithResult ( final byte [ ] message ) { synchronized ( webSocketHandler . getNotifyResultObject ( ) ) { webSocketHandler . sendMessage ( message ) ; try { webSocketHandler . getNotifyResultObject ( ) . wait ( TimeUnit . SECONDS . toMillis ( ANSWER_TIMEOUT ) ) ; } catch ( InterruptedException e ) { return null ; } return webSocketHandler . getResultBytes ( ) ; } }
Sends a message through it s websocket connection to the server and waits for the reply .
102
19
10,126
public Object getObject ( ) { Object ret = null ; try { ret = this . proxy . getValue ( this . object ) ; } catch ( final EFapsException e ) { LOG . error ( "Catched" , e ) ; } return ret ; }
Gets the object .
55
5
10,127
public void setCenterColor ( Color color ) { if ( centerColor == null ) { centerColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . centerColor = color ; }
Sets the color of this Ellipse s center .
55
12
10,128
protected Attribute copy ( final long _parentId ) { final Attribute ret = new Attribute ( getId ( ) , _parentId , getName ( ) , this . sqlTable , this . attributeType , this . defaultValue , this . dimensionUUID , this . required , this . size , this . scale ) ; ret . getSqlColNames ( ) . addAll ( getSqlColNames ( ) ) ; ret . setLink ( this . link ) ; ret . setClassName ( getClassName ( ) ) ; ret . getProperties ( ) . putAll ( getProperties ( ) ) ; return ret ; }
The method makes a clone of the current attribute instance .
136
11
10,129
public Dimension getDimension ( ) { Dimension ret = null ; try { ret = Dimension . get ( UUID . fromString ( this . dimensionUUID ) ) ; } catch ( final CacheReloadException e ) { Attribute . LOG . error ( "Catched CacheReloadException" , e ) ; } return ret ; }
Method to get the dimension related to this attribute .
70
10
10,130
public static void initialize ( final Class < ? > _class ) throws CacheReloadException { if ( InfinispanCache . get ( ) . exists ( Attribute . NAMECACHE ) ) { InfinispanCache . get ( ) . < String , Attribute > getCache ( Attribute . NAMECACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < String , Attribute > getCache ( Attribute . NAMECACHE ) . addListener ( new CacheLogListener ( Attribute . LOG ) ) ; } if ( InfinispanCache . get ( ) . exists ( Attribute . IDCACHE ) ) { InfinispanCache . get ( ) . < Long , Attribute > getCache ( Attribute . IDCACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < Long , Attribute > getCache ( Attribute . IDCACHE ) . addListener ( new CacheLogListener ( Attribute . LOG ) ) ; } }
Method to initialize this Cache .
223
6
10,131
public String toHtml ( ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( "<p>" ) . append ( objectNode . get ( TYPE ) . asText ( ) ) . append ( ": " ) . append ( objectNode . get ( MESSAGE ) . asText ( ) ) . append ( " -> " ) . append ( objectNode . get ( DETAILS ) . toString ( ) ) . append ( "</p>" ) ; return stringBuilder . toString ( ) ; }
Get the error as a string in html format
114
9
10,132
LifecycleListener createLifecycleListener ( final WeakReference < ComapiChatClient > ref ) { return new LifecycleListener ( ) { /** * App foregrounded. * * @param context Application context */ public void onForegrounded ( Context context ) { ComapiChatClient client = ref . get ( ) ; if ( client != null ) { client . service ( ) . messaging ( ) . synchroniseStore ( null ) ; } } /** * App backgrounded. * * @param context Application context */ public void onBackgrounded ( Context context ) { } } ; }
Creates listener for Application visibility .
121
7
10,133
public void addListener ( final ParticipantsListener participantsListener ) { if ( participantsListener != null ) { MessagingListener messagingListener = new MessagingListener ( ) { @ Override public void onParticipantAdded ( ParticipantAddedEvent event ) { participantsListener . onParticipantAdded ( event ) ; } @ Override public void onParticipantUpdated ( ParticipantUpdatedEvent event ) { participantsListener . onParticipantUpdated ( event ) ; } @ Override public void onParticipantRemoved ( ParticipantRemovedEvent event ) { participantsListener . onParticipantRemoved ( event ) ; } } ; participantsListeners . put ( participantsListener , messagingListener ) ; client . addListener ( messagingListener ) ; } }
Registers listener for changes in participant list in conversations . Delivers participant added updated and removed events .
143
20
10,134
public void removeListener ( final ParticipantsListener participantsListener ) { MessagingListener messagingListener = participantsListeners . get ( participantsListener ) ; if ( messagingListener != null ) { client . removeListener ( messagingListener ) ; participantsListeners . remove ( participantsListener ) ; } }
Removes listener for changes in participant list in conversations .
57
11
10,135
public void addListener ( final ProfileListener profileListener ) { if ( profileListener != null ) { com . comapi . ProfileListener foundationListener = new com . comapi . ProfileListener ( ) { @ Override public void onProfileUpdate ( ProfileUpdateEvent event ) { profileListener . onProfileUpdate ( event ) ; } } ; profileListeners . put ( profileListener , foundationListener ) ; client . addListener ( foundationListener ) ; } }
Registers listener for changes in profile details .
93
9
10,136
public void removeListener ( final ProfileListener profileListener ) { com . comapi . ProfileListener foundationListener = profileListeners . get ( profileListener ) ; if ( foundationListener != null ) { client . removeListener ( foundationListener ) ; profileListeners . remove ( profileListener ) ; } }
Removes listener for changes in profile details .
61
9
10,137
public static void initialize ( ) throws CacheReloadException { if ( InfinispanCache . get ( ) . exists ( JAASSystem . IDCACHE ) ) { InfinispanCache . get ( ) . < Long , JAASSystem > getCache ( JAASSystem . IDCACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < Long , JAASSystem > getCache ( JAASSystem . IDCACHE ) . addListener ( new CacheLogListener ( JAASSystem . LOG ) ) ; } if ( InfinispanCache . get ( ) . exists ( JAASSystem . NAMECACHE ) ) { InfinispanCache . get ( ) . < String , JAASSystem > getCache ( JAASSystem . NAMECACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < String , JAASSystem > getCache ( JAASSystem . NAMECACHE ) . addListener ( new CacheLogListener ( JAASSystem . LOG ) ) ; } JAASSystem . getJAASSystemFromDB ( JAASSystem . SQL_SELECT , null ) ; }
Method to initialize the cache of JAAS systems .
250
10
10,138
public static Set < JAASSystem > getAllJAASSystems ( ) { final Set < JAASSystem > ret = new HashSet <> ( ) ; final Cache < Long , JAASSystem > cache = InfinispanCache . get ( ) . < Long , JAASSystem > getCache ( JAASSystem . IDCACHE ) ; for ( final Map . Entry < Long , JAASSystem > entry : cache . entrySet ( ) ) { ret . add ( entry . getValue ( ) ) ; } return ret ; }
Returns all cached JAAS system in a set .
114
10
10,139
void reset ( boolean deleteFile ) { String path = this . path ; this . path = null ; this . projectId = - 1 ; this . projectToken = null ; this . deviceId = null ; this . client = null ; synchronized ( dataStoreLock ) { dataStore = null ; dataBatches . clear ( ) ; } if ( deleteFile ) { File f = new File ( path , DEVICE_FILENAME ) ; if ( f . exists ( ) ) { f . delete ( ) ; } } }
Resets the iobeam client to uninitialized state including removing any added data .
110
17
10,140
public void registerDeviceAsync ( String deviceId , RegisterCallback callback ) { final Device d = new Device . Builder ( projectId ) . id ( deviceId ) . build ( ) ; registerDeviceAsync ( d , callback ) ; }
Registers a device asynchronously with the provided device ID .
48
13
10,141
@ Deprecated public void registerDeviceWithIdAsync ( String deviceId , String deviceName , RegisterCallback callback ) { final Device d = new Device . Builder ( projectId ) . id ( deviceId ) . name ( deviceName ) . build ( ) ; registerDeviceAsync ( d , callback ) ; }
Registers a device asynchronously with the provided device ID and name .
63
15
10,142
public void setDeviceId ( String deviceId ) throws CouldNotPersistException { this . deviceId = deviceId ; if ( deviceId != null && path != null ) { persistDeviceId ( ) ; } }
Sets the current device id that the iobeam client is associated with .
45
16
10,143
public DataStore getDataStore ( final Collection < String > columns ) { for ( DataStore ds : dataBatches ) { if ( ds . hasColumns ( columns ) ) { return ds ; } } return null ; }
Get the DataStore associated with a collection of column names .
50
12
10,144
public DataStore getOrAddDataStore ( final Collection < String > columns ) { DataStore ret = getDataStore ( columns ) ; if ( ret == null ) { ret = this . createDataStore ( columns ) ; } return ret ; }
Get the DataStore associated with a collection of column names adding a new one if necessary .
51
18
10,145
@ Deprecated public void addData ( String seriesName , DataPoint dataPoint ) { synchronized ( dataStoreLock ) { _addDataWithoutLock ( seriesName , dataPoint ) ; } }
Adds a data value to a particular series in the data store .
40
13
10,146
@ Deprecated public boolean addDataMapToSeries ( String [ ] seriesNames , DataPoint [ ] points ) { if ( seriesNames == null || points == null || points . length != seriesNames . length ) { return false ; } synchronized ( dataStoreLock ) { for ( int i = 0 ; i < seriesNames . length ; i ++ ) { _addDataWithoutLock ( seriesNames [ i ] , points [ i ] ) ; } } return true ; }
Adds a list of data points to a list of series in the data store . This is essentially a zip operation on the points and series names where the first point is put in the first series the second point in the second series etc . Both lists MUST be the same size .
98
55
10,147
public DataStore createDataStore ( Collection < String > columns ) { DataStore b = new DataStore ( columns ) ; trackDataStore ( b ) ; return b ; }
Creates a DataStore with a given set of columns and tracks it so that any data added will be sent on a subsequent send calls .
36
28
10,148
public long getDataSize ( ) { long size = 0 ; synchronized ( dataStoreLock ) { for ( DataStore b : dataBatches ) { size += b . getDataSize ( ) ; } } return size ; }
Returns the size of all of the data in all the series .
47
13
10,149
private int getSeriesSize ( String series ) { synchronized ( dataStoreLock ) { if ( dataStore == null ) { return 0 ; } if ( seriesToBatch . containsKey ( series ) ) { return ( int ) seriesToBatch . get ( series ) . getDataSize ( ) ; } else { return 0 ; } } }
Returns the size of the data set in a particular series .
72
12
10,150
public void reload ( ) { InfinispanCache . get ( ) . < UUID , SystemConfiguration > getCache ( SystemConfiguration . UUIDCACHE ) . remove ( uuid ) ; InfinispanCache . get ( ) . < Long , SystemConfiguration > getCache ( SystemConfiguration . IDCACHE ) . remove ( id ) ; InfinispanCache . get ( ) . < String , SystemConfiguration > getCache ( SystemConfiguration . NAMECACHE ) . remove ( name ) ; }
Reload the current SystemConfiguration by removing it from the Cache .
107
13
10,151
private void readConfig ( ) throws CacheReloadException { Connection con = null ; try { boolean closeContext = false ; if ( ! Context . isThreadActive ( ) ) { Context . begin ( ) ; closeContext = true ; } final List < Object [ ] > dbValues = new ArrayList <> ( ) ; con = Context . getConnection ( ) ; PreparedStatement stmt = null ; try { stmt = con . prepareStatement ( SystemConfiguration . SQL_CONFIG ) ; stmt . setObject ( 1 , getId ( ) ) ; final ResultSet rs = stmt . executeQuery ( ) ; while ( rs . next ( ) ) { dbValues . add ( new Object [ ] { rs . getLong ( 1 ) , rs . getString ( 2 ) , rs . getString ( 3 ) , rs . getLong ( 4 ) , rs . getString ( 5 ) } ) ; } rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; if ( closeContext ) { Context . rollback ( ) ; } for ( final Object [ ] row : dbValues ) { final Long typeId = ( Long ) row [ 0 ] ; final String key = ( String ) row [ 1 ] ; final String value = ( String ) row [ 2 ] ; final Long companyId = ( Long ) row [ 3 ] ; final String appkey = ( String ) row [ 4 ] ; final Type type = Type . get ( typeId ) ; final ConfType confType ; if ( type . equals ( CIAdminCommon . SystemConfigurationLink . getType ( ) ) ) { confType = ConfType . LINK ; } else if ( type . equals ( CIAdminCommon . SystemConfigurationObjectAttribute . getType ( ) ) ) { confType = ConfType . OBJATTR ; } else { confType = ConfType . ATTRIBUTE ; } values . add ( new Value ( confType , key , value , companyId , appkey ) ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read SystemConfiguration attributes" , e ) ; } catch ( final EFapsException e ) { throw new CacheReloadException ( "could not read SystemConfiguration attributes" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } }
Read the config .
555
4
10,152
@ PUT @ Consumes ( MediaType . APPLICATION_JSON ) public Response put ( @ PathParam ( "cacheName" ) String cacheName , Cache cache ) { if ( ! cacheService . isPresent ( cacheName ) ) { return Response . status ( Response . Status . NOT_FOUND ) . build ( ) ; } cacheService . update ( cacheName , cache ) ; return Response . ok ( ) . build ( ) ; }
Modify state of a single cache
93
7
10,153
protected void addAttributes ( final boolean _inherited , final Attribute ... _attributes ) throws CacheReloadException { for ( final Attribute attribute : _attributes ) { if ( ! this . attributes . containsKey ( attribute . getName ( ) ) ) { Type . LOG . trace ( "adding Attribute:'{}' to type: '{}'" , attribute . getName ( ) , getName ( ) ) ; // evaluate for type attribute if ( attribute . getAttributeType ( ) . getClassRepr ( ) . equals ( TypeType . class ) ) { this . typeAttributeName = attribute . getName ( ) ; } else if ( attribute . getAttributeType ( ) . getClassRepr ( ) . equals ( StatusType . class ) && ! _inherited ) { // evaluate for status, an inherited attribute will not // overwrite the original attribute this . statusAttributeName = attribute . getName ( ) ; } else if ( attribute . getAttributeType ( ) . getClassRepr ( ) . equals ( CompanyLinkType . class ) || attribute . getAttributeType ( ) . getClassRepr ( ) . equals ( ConsortiumLinkType . class ) ) { // evaluate for company this . companyAttributeName = attribute . getName ( ) ; } else if ( attribute . getAttributeType ( ) . getClassRepr ( ) . equals ( GroupLinkType . class ) ) { // evaluate for group this . groupAttributeName = attribute . getName ( ) ; } this . attributes . put ( attribute . getName ( ) , attribute ) ; if ( attribute . getTable ( ) != null ) { this . tables . add ( attribute . getTable ( ) ) ; attribute . getTable ( ) . addType ( getId ( ) ) ; if ( getMainTable ( ) == null ) { setMainTable ( attribute . getTable ( ) ) ; } } setDirty ( ) ; } } }
Add attributes to this type and all child types of this type . Recursive method .
407
17
10,154
protected void inheritAttributes ( ) throws CacheReloadException { Type parent = getParentType ( ) ; final List < Attribute > attributesTmp = new ArrayList <> ( ) ; while ( parent != null ) { for ( final Attribute attribute : getParentType ( ) . getAttributes ( ) . values ( ) ) { attributesTmp . add ( attribute . copy ( getId ( ) ) ) ; } parent = parent . getParentType ( ) ; } addAttributes ( true , attributesTmp . toArray ( new Attribute [ attributesTmp . size ( ) ] ) ) ; }
Inherit Attributes are child types .
126
8
10,155
public Attribute getTypeAttribute ( ) { final Attribute ret ; if ( this . typeAttributeName == null && getParentType ( ) != null ) { ret = getParentType ( ) . getTypeAttribute ( ) ; } else { ret = this . attributes . get ( this . typeAttributeName ) ; } return ret ; }
Get the attribute containing the type information .
70
8
10,156
@ SuppressWarnings ( "unchecked" ) public Map < Instance , Boolean > checkAccess ( final Collection < Instance > _instances , final AccessType _accessType ) throws EFapsException { Map < Instance , Boolean > ret = new HashMap <> ( ) ; if ( _instances != null && ! _instances . isEmpty ( ) && _instances . size ( ) == 1 ) { final Instance instance = _instances . iterator ( ) . next ( ) ; ret . put ( instance , hasAccess ( instance , _accessType ) ) ; } else { final List < EventDefinition > events = super . getEvents ( EventType . ACCESSCHECK ) ; if ( events != null ) { final Parameter parameter = new Parameter ( ) ; parameter . put ( ParameterValues . OTHERS , _instances ) ; parameter . put ( ParameterValues . ACCESSTYPE , _accessType ) ; parameter . put ( ParameterValues . CLASS , this ) ; for ( final EventDefinition event : events ) { final Return retrn = event . execute ( parameter ) ; ret = ( Map < Instance , Boolean > ) retrn . get ( ReturnValues . VALUES ) ; } } else { for ( final Instance instance : _instances ) { ret . put ( instance , true ) ; } } } return ret ; }
Method to check the access right for a list of instances .
293
12
10,157
protected void addClassifiedByType ( final Classification _classification ) { this . checked4classifiedBy = true ; this . classifiedByTypes . add ( _classification . getId ( ) ) ; setDirty ( ) ; }
Add a root Classification to this type .
49
8
10,158
protected static void cacheTypesByHierachy ( final Type _type ) throws CacheReloadException { final Cache < UUID , Type > cache4UUID = InfinispanCache . get ( ) . < UUID , Type > getIgnReCache ( Type . UUIDCACHE ) ; if ( cache4UUID . getCacheConfiguration ( ) . clustering ( ) != null && ! cache4UUID . getCacheConfiguration ( ) . clustering ( ) . cacheMode ( ) . equals ( CacheMode . LOCAL ) ) { Type type = _type ; while ( type . getParentTypeId ( ) != null ) { final Cache < Long , Type > cache = InfinispanCache . get ( ) . < Long , Type > getIgnReCache ( Type . IDCACHE ) ; if ( cache . containsKey ( type . getParentTypeId ( ) ) ) { type = cache . get ( type . getParentTypeId ( ) ) ; } else { type = type . getParentType ( ) ; } } type . recacheChildren ( ) ; } }
In case of a cluster the types must be cached after the final loading again to be sure that the last instance including all the changes like attribute links etc are up to date .
230
35
10,159
private void recacheChildren ( ) throws CacheReloadException { if ( isDirty ( ) ) { Type . cacheType ( this ) ; } for ( final Type child : getChildTypes ( ) ) { child . recacheChildren ( ) ; } }
Recache the children in dropdown . Used for Caching in cluster .
54
15
10,160
@ Override public void transpose ( ) { double temp ; temp = m01 ; m01 = m10 ; m10 = temp ; temp = m02 ; m02 = m20 ; m20 = temp ; temp = m03 ; m03 = m30 ; m30 = temp ; temp = m12 ; m12 = m21 ; m21 = temp ; temp = m13 ; m13 = m31 ; m31 = temp ; temp = m23 ; m23 = m32 ; m32 = temp ; }
Transpose this matrix .
110
5
10,161
private double determinant3x3 ( double t00 , double t01 , double t02 , double t10 , double t11 , double t12 , double t20 , double t21 , double t22 ) { return ( t00 * ( t11 * t22 - t12 * t21 ) + t01 * ( t12 * t20 - t10 * t22 ) + t02 * ( t10 * t21 - t11 * t20 ) ) ; }
Calculate the determinant of a 3x3 matrix .
100
13
10,162
ThreadPoolExecutor createChannelExecutor ( String channel , final String threadPrefix , final int workerCount , int queueSize ) { ThreadFactory threadFactory = new ThreadFactory ( ) { private int counter = 0 ; @ Override public Thread newThread ( Runnable runnable ) { return new Thread ( runnable , threadPrefix + "-" + ++ counter ) ; } } ; ThreadPoolExecutor executor = new ChannelThreadPoolExecutor ( channel , workerCount , new LinkedBlockingQueue < Runnable > ( queueSize ) , threadFactory ) ; return executor ; }
create ThreadPoolExecutor for channel
127
7
10,163
ThreadPoolExecutor createExecutor ( final String threadPrefix , final int workerCount , int queueSize ) { ThreadFactory threadFactory = new ThreadFactory ( ) { private int counter = 0 ; @ Override public Thread newThread ( Runnable runnable ) { return new Thread ( runnable , threadPrefix + "-" + ++ counter ) ; } } ; ThreadPoolExecutor executor = new ThreadPoolExecutor ( workerCount , workerCount , 0 , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( queueSize ) , threadFactory ) ; return executor ; }
create general purpose ThreadPoolExecutor
132
7
10,164
ScheduledExecutorService createSchedulerExecutor ( final String prefix ) { ThreadFactory threadFactory = new ThreadFactory ( ) { private int counter = 0 ; @ Override public Thread newThread ( Runnable runnable ) { return new Thread ( runnable , prefix + ++ counter ) ; } } ; ScheduledExecutorService executor = java . util . concurrent . Executors . newSingleThreadScheduledExecutor ( threadFactory ) ; return executor ; }
create scheduler ThreadPoolExecutor
104
7
10,165
protected void open ( ) throws EFapsException { AbstractResource . LOG . debug ( "open resource:{}" , this ) ; if ( this . opened ) { AbstractResource . LOG . error ( "resource already opened" ) ; throw new EFapsException ( AbstractResource . class , "open.AlreadyOpened" ) ; } try { final Context context = Context . getThreadContext ( ) ; context . getTransaction ( ) . enlistResource ( this ) ; } catch ( final RollbackException e ) { AbstractResource . LOG . error ( "exception occurs while delisting in transaction, " + "commit not possible" , e ) ; throw new EFapsException ( AbstractResource . class , "open.RollbackException" , e ) ; } catch ( final SystemException e ) { AbstractResource . LOG . error ( "exception occurs while delisting in transaction, " + "commit not possible" , e ) ; throw new EFapsException ( AbstractResource . class , "open.SystemException" , e ) ; } this . opened = true ; }
Opens this connection resource and enlisted this resource in the transaction .
221
13
10,166
@ Override public void end ( final Xid _xid , final int _flags ) { AbstractResource . LOG . trace ( "end resource {}, flags {}" + _flags , _xid , _flags ) ; }
The method ends the work performed on behalf of a transaction branch . Normally nothing must be done because an instance of a resource is only defined for one transaction .
48
31
10,167
private List < UpdateLifecycle > getUpdateLifecycles ( ) { final List < UpdateLifecycle > ret = new ArrayList <> ( ) ; for ( final UpdateLifecycle cycle : UpdateLifecycle . values ( ) ) { ret . add ( cycle ) ; } Collections . sort ( ret , ( _cycle1 , _cycle2 ) -> _cycle1 . getOrder ( ) . compareTo ( _cycle2 . getOrder ( ) ) ) ; return ret ; }
Method to get all UpdateLifecycle in an ordered List .
106
13
10,168
protected void initialise ( ) throws InstallationException { if ( ! this . initialised ) { this . initialised = true ; this . cache . clear ( ) ; AppDependency . initialise ( ) ; for ( final FileType fileType : FileType . values ( ) ) { if ( fileType == FileType . XML ) { for ( final InstallFile file : this . files ) { if ( file . getType ( ) == fileType ) { final SaxHandler handler = new SaxHandler ( ) ; try { final IUpdate elem = handler . parse ( file ) ; final List < IUpdate > list ; if ( this . cache . containsKey ( elem . getIdentifier ( ) ) ) { list = this . cache . get ( elem . getIdentifier ( ) ) ; } else { list = new ArrayList <> ( ) ; this . cache . put ( elem . getIdentifier ( ) , list ) ; } list . add ( handler . getUpdate ( ) ) ; } catch ( final SAXException e ) { throw new InstallationException ( "initialise()" , e ) ; } catch ( final IOException e ) { throw new InstallationException ( "initialise()" , e ) ; } } } } else { for ( final Class < ? extends IUpdate > updateClass : fileType . getClazzes ( ) ) { Method method = null ; try { method = updateClass . getMethod ( "readFile" , InstallFile . class ) ; } catch ( final SecurityException e ) { throw new InstallationException ( "initialise()" , e ) ; } catch ( final NoSuchMethodException e ) { throw new InstallationException ( "initialise()" , e ) ; } for ( final InstallFile file : this . files ) { if ( file . getType ( ) == fileType ) { Object obj = null ; try { obj = method . invoke ( null , file ) ; } catch ( final IllegalArgumentException e ) { throw new InstallationException ( "initialise()" , e ) ; } catch ( final IllegalAccessException e ) { throw new InstallationException ( "initialise()" , e ) ; } catch ( final InvocationTargetException e ) { throw new InstallationException ( "initialise()" , e ) ; } if ( obj != null && obj instanceof IUpdate ) { final IUpdate iUpdate = ( IUpdate ) obj ; final List < IUpdate > list ; if ( this . cache . containsKey ( iUpdate . getIdentifier ( ) ) ) { list = this . cache . get ( iUpdate . getIdentifier ( ) ) ; } else { list = new ArrayList <> ( ) ; this . cache . put ( iUpdate . getIdentifier ( ) , list ) ; } list . add ( iUpdate ) ; } } } } } } } }
Reads all XML update files and parses them .
601
11
10,169
public void set ( boolean index , double x , double y ) { this . MODE = LINES ; if ( index == true ) { this . x1 = x ; this . y1 = y ; } else { this . x2 = x ; this . y2 = y ; } calcG ( ) ; dx [ 0 ] = x1 - this . x ; dx [ 1 ] = x2 - this . x ; dy [ 0 ] = y1 - this . y ; dy [ 1 ] = y2 - this . y ; dz [ 0 ] = z1 - 0 ; dz [ 1 ] = z2 - 0 ; if ( dashed ) calcDashedLine ( ) ; }
Sets the coordinates for the first or second point .
148
11
10,170
public void setDashedLinePram ( double length , double interval ) { this . dashedLineLength = length ; this . dashedLineInterval = interval ; this . dashed = true ; calcDashedLine ( ) ; }
Sets the parameter for the dashed line .
47
9
10,171
public Vector3D getCorner ( int index ) { Vector3D v = new Vector3D ( ) ; if ( index <= 0 ) v . set ( x1 , y1 , z1 ) ; else v . set ( x2 , y2 , z2 ) ; return v ; }
Gets coordinates of the point .
63
7
10,172
public String getValueList ( ) { final StringBuffer buf = new StringBuffer ( ) ; for ( final Token token : this . tokens ) { switch ( token . type ) { case EXPRESSION : buf . append ( "$<" ) . append ( token . value ) . append ( ">" ) ; break ; case TEXT : buf . append ( token . value ) ; break ; default : break ; } } return buf . toString ( ) ; }
Get the ValueList .
95
5
10,173
public void addExpression ( final String _expression ) { this . tokens . add ( new Token ( ValueList . TokenType . EXPRESSION , _expression ) ) ; getExpressions ( ) . add ( _expression ) ; }
Add an Expression to this ValueList .
49
8
10,174
public void addText ( final String _text ) { this . tokens . add ( new Token ( ValueList . TokenType . TEXT , _text ) ) ; }
Add Text to the Tokens .
34
6
10,175
public void makeSelect ( final AbstractPrintQuery _print ) throws EFapsException { for ( final String expression : getExpressions ( ) ) { // TODO remove, only selects allowed if ( _print . getMainType ( ) . getAttributes ( ) . containsKey ( expression ) ) { _print . addAttribute ( expression ) ; ValueList . LOG . warn ( "The arguments for ValueList must only contain selects. Invalid: '{}' for ValueList: {}" , expression , getValueList ( ) ) ; } else if ( expression . contains ( "[" ) || expression . equals ( expression . toLowerCase ( ) ) ) { _print . addSelect ( expression ) ; } else { ValueList . LOG . warn ( "The arguments for ValueList must only contain selects. Invalid: '{}' for ValueList: {}" , expression , getValueList ( ) ) ; } } }
This method adds the expressions of this ValueList to the given query .
191
14
10,176
public String makeString ( final Instance _callInstance , final AbstractPrintQuery _print , final TargetMode _mode ) throws EFapsException { final StringBuilder buf = new StringBuilder ( ) ; for ( final Token token : this . tokens ) { switch ( token . type ) { case EXPRESSION : Attribute attr = null ; Object value = null ; if ( _print . getMainType ( ) . getAttributes ( ) . containsKey ( token . value ) ) { attr = _print . getAttribute4Attribute ( token . value ) ; value = _print . getAttribute ( token . value ) ; } else { attr = _print . getAttribute4Select ( token . value ) ; value = _print . getSelect ( token . value ) ; } if ( attr != null ) { buf . append ( attr . getAttributeType ( ) . getUIProvider ( ) . getStringValue ( UIValue . get ( null , attr , value ) ) ) ; } else if ( value != null ) { buf . append ( value ) ; } break ; case TEXT : buf . append ( token . value ) ; break ; default : break ; } } return buf . toString ( ) ; }
This method retrieves the Values from the given PrintQuery and combines them with the Text partes .
259
20
10,177
public static void moveFile ( File src , File dest ) throws IOException { copyFile ( src , dest ) ; if ( ! delete ( src ) ) { throw new IOException ( "Failed to delete the src file '" + src + "' after copying." ) ; } }
Moves a file from src to dest . This method is equals to copy - > delete .
59
19
10,178
public static void copyFile ( File src , File dest ) throws IOException { if ( src == null ) throw new NullPointerException ( "Source must not be null" ) ; if ( dest == null ) throw new NullPointerException ( "Destination must not be null" ) ; if ( ! src . exists ( ) ) throw new FileNotFoundException ( "Source '" + src + "' does not exist" ) ; if ( ! src . isFile ( ) ) throw new IOException ( "Source '" + src + "' is not a file" ) ; if ( dest . exists ( ) ) throw new IOException ( "Destination '" + dest + "' is already exists" ) ; FileChannel in = null , out = null ; try { in = new FileInputStream ( src ) . getChannel ( ) ; out = new FileOutputStream ( dest ) . getChannel ( ) ; in . transferTo ( 0 , in . size ( ) , out ) ; } finally { try { in . close ( ) ; out . close ( ) ; } catch ( IOException e ) { // Ignore. } } if ( src . length ( ) != dest . length ( ) ) { throw new IOException ( "Failed to copy full contents from '" + src + "' to '" + dest + "'" ) ; } dest . setLastModified ( src . lastModified ( ) ) ; }
Copies a file to a new location preserving the file date .
299
13
10,179
public static boolean delete ( File file ) { if ( file == null ) { return false ; } else if ( ! file . isFile ( ) ) { return false ; } return file . delete ( ) ; }
Deletes a file .
44
5
10,180
public static boolean exist ( String filePath ) { File f = new File ( filePath ) ; if ( ! f . isFile ( ) ) { return false ; } return true ; }
Check file existence
39
3
10,181
public static String getSuffix ( File file ) { String filename = file . getName ( ) ; int index = filename . lastIndexOf ( "." ) ; if ( index != - 1 ) { return filename . substring ( index + 1 ) ; } return filename ; }
Returns a suffix string from a File .
59
8
10,182
public static String searchFilePath ( String fileName ) { java . io . File dir = new java . io . File ( System . getProperty ( "user.dir" ) ) ; return recursiveSearch ( dir , fileName ) ; }
Search an absolute file path from current working directory recursively .
50
13
10,183
private static String recursiveSearch ( java . io . File dir , String fileName ) { for ( String name : dir . list ( ) ) { java . io . File file = new java . io . File ( dir . getAbsolutePath ( ) + "/" + name ) ; if ( name . compareTo ( fileName ) == 0 ) return file . getAbsolutePath ( ) ; if ( file . isDirectory ( ) ) { String filePath = recursiveSearch ( file , fileName ) ; if ( filePath != null ) return filePath ; } } return null ; }
Recursive method for searching file path .
122
8
10,184
public static void touch ( File file ) throws FileNotFoundException { if ( ! file . exists ( ) ) { OutputStream out = new FileOutputStream ( file ) ; try { out . close ( ) ; } catch ( IOException e ) { // Ignore. } } file . setLastModified ( System . currentTimeMillis ( ) ) ; }
Implements the same behavior as the touch utility on Unix . It creates a new file with size 0 byte or if the file exists already it is opened and closed without modifying it but updating the file date and time .
75
44
10,185
public boolean isType ( final org . efaps . admin . datamodel . Type _type ) { return getType ( ) . equals ( _type ) ; }
Tests if this type the type in the parameter .
37
11
10,186
public void rotation ( TextureRotationMode mode ) { float [ ] [ ] tmp = corner . clone ( ) ; switch ( mode ) { case HALF : corner [ 0 ] = tmp [ 2 ] ; corner [ 1 ] = tmp [ 3 ] ; corner [ 2 ] = tmp [ 0 ] ; corner [ 3 ] = tmp [ 1 ] ; break ; case CLOCKWIZE : corner [ 0 ] = tmp [ 3 ] ; corner [ 1 ] = tmp [ 0 ] ; corner [ 2 ] = tmp [ 1 ] ; corner [ 3 ] = tmp [ 2 ] ; break ; case COUNTERCLOCKWIZE : corner [ 0 ] = tmp [ 1 ] ; corner [ 1 ] = tmp [ 2 ] ; corner [ 2 ] = tmp [ 3 ] ; corner [ 3 ] = tmp [ 0 ] ; break ; default : break ; } }
Rotates the way of mapping the texture .
179
9
10,187
public void flip ( TextureFlipMode mode ) { float [ ] [ ] tmp = corner . clone ( ) ; switch ( mode ) { case VERTICAL : corner [ 0 ] = tmp [ 1 ] ; corner [ 1 ] = tmp [ 0 ] ; corner [ 2 ] = tmp [ 3 ] ; corner [ 3 ] = tmp [ 2 ] ; break ; case HORIZONTAL : corner [ 0 ] = tmp [ 3 ] ; corner [ 1 ] = tmp [ 2 ] ; corner [ 2 ] = tmp [ 1 ] ; corner [ 3 ] = tmp [ 0 ] ; break ; default : break ; } }
Flips the way of mapping the texture .
130
9
10,188
public void addObject ( final Object [ ] _row ) throws EFapsException { this . objects . add ( this . elements . get ( 0 ) . getObject ( _row ) ) ; }
Adds the object .
41
4
10,189
public void resolve ( ) throws InstallationException { final IvySettings ivySettings = new IvySettings ( ) ; try { ivySettings . load ( this . getClass ( ) . getResource ( "/org/efaps/update/version/ivy.xml" ) ) ; } catch ( final IOException e ) { throw new InstallationException ( "IVY setting file could not be read" , e ) ; } catch ( final ParseException e ) { throw new InstallationException ( "IVY setting file could not be parsed" , e ) ; } final Ivy ivy = Ivy . newInstance ( ivySettings ) ; ivy . getLoggerEngine ( ) . pushLogger ( new IvyOverSLF4JLogger ( ) ) ; final Map < String , String > attr = new HashMap < String , String > ( ) ; attr . put ( "changing" , "true" ) ; final ModuleRevisionId modRevId = ModuleRevisionId . newInstance ( this . groupId , this . artifactId , this . version , attr ) ; final ResolveOptions options = new ResolveOptions ( ) ; options . setConfs ( new String [ ] { "runtime" } ) ; final ResolvedModuleRevision resModRev = ivy . findModule ( modRevId ) ; Artifact dw = null ; for ( final Artifact artifact : resModRev . getDescriptor ( ) . getAllArtifacts ( ) ) { if ( "jar" . equals ( artifact . getType ( ) ) ) { dw = artifact ; break ; } } final DownloadOptions dwOptions = new DownloadOptions ( ) ; final ArtifactOrigin ao = resModRev . getArtifactResolver ( ) . locate ( dw ) ; resModRev . getArtifactResolver ( ) . getRepositoryCacheManager ( ) . clean ( ) ; final ArtifactDownloadReport adw = resModRev . getArtifactResolver ( ) . download ( ao , dwOptions ) ; this . jarFile = adw . getLocalFile ( ) ; }
Resolves this dependency .
436
5
10,190
private void compileJasperReport ( final Instance _instSource , final Instance _instCompiled ) throws EFapsException { // make the classPath final String sep = System . getProperty ( "os.name" ) . startsWith ( "Windows" ) ? ";" : ":" ; final StringBuilder classPath = new StringBuilder ( ) ; for ( final String classPathElement : this . classPathElements ) { classPath . append ( classPathElement ) . append ( sep ) ; } final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext . getInstance ( ) ; reportContext . setProperty ( JRCompiler . COMPILER_CLASSPATH , classPath . toString ( ) ) ; reportContext . setProperty ( "net.sf.jasperreports.compiler.groovy" , JasperGroovyCompiler . class . getName ( ) ) ; reportContext . setProperty ( "net.sf.jasperreports.query.executer.factory.eFaps" , FakeQueryExecuterFactory . class . getName ( ) ) ; try { final JasperDesign jasperDesign = JasperUtil . getJasperDesign ( _instSource ) ; // the fault value for the language is no information but the used compiler needs a value, // therefore it must be set explicitly if ( jasperDesign . getLanguage ( ) == null ) { jasperDesign . setLanguage ( JRReport . LANGUAGE_JAVA ) ; } final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; JasperCompileManager . compileReportToStream ( jasperDesign , out ) ; final ByteArrayInputStream in = new ByteArrayInputStream ( out . toByteArray ( ) ) ; final Checkin checkin = new Checkin ( _instCompiled ) ; checkin . executeWithoutAccessCheck ( jasperDesign . getName ( ) + ".jasper" , in , in . available ( ) ) ; out . close ( ) ; in . close ( ) ; } catch ( final JRException e ) { throw new EFapsException ( JasperReportCompiler . class , "JRException" , e ) ; } catch ( final IOException e ) { throw new EFapsException ( JasperReportCompiler . class , "IOException" , e ) ; } }
Method to compile one JasperReport .
494
7
10,191
protected void registerEQLStmt ( final String _origin , final String _stmt ) throws EFapsException { // Common_HistoryEQL final Insert insert = new Insert ( UUID . fromString ( "c96c63b5-2d4c-4bf9-9627-f335fd9c7a84" ) ) ; insert . add ( "Origin" , "REST: " + ( _origin == null ? "" : _origin ) ) ; insert . add ( "EQLStatement" , _stmt ) ; insert . execute ( ) ; }
Register eql stmt .
124
6
10,192
@ Override public Object getValue ( final Object _object ) throws EFapsException { final Instance inst = ( Instance ) super . getValue ( _object ) ; if ( this . esjp == null ) { try { final Class < ? > clazz = Class . forName ( this . className , false , EFapsClassLoader . getInstance ( ) ) ; this . esjp = ( IEsjpSelect ) clazz . newInstance ( ) ; final List < Instance > instances = new ArrayList <> ( ) ; for ( final Object obj : getOneSelect ( ) . getObjectList ( ) ) { instances . add ( ( Instance ) super . getValue ( obj ) ) ; } if ( this . parameters . isEmpty ( ) ) { this . esjp . initialize ( instances ) ; } else { this . esjp . initialize ( instances , this . parameters . toArray ( new String [ this . parameters . size ( ) ] ) ) ; } } catch ( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) { LOG . error ( "Catched error" , e ) ; } } return this . esjp . getValue ( inst ) ; }
Method to get the value for the current object .
254
10
10,193
@ Override protected String evalApplication ( ) { String ret = null ; final Pattern revisionPattern = Pattern . compile ( "@eFapsApplication[\\s].*" ) ; final Matcher revisionMatcher = revisionPattern . matcher ( getCode ( ) ) ; if ( revisionMatcher . find ( ) ) { ret = revisionMatcher . group ( ) . replaceFirst ( "^@eFapsApplication" , "" ) ; } return ret == null ? null : ret . trim ( ) ; }
This Method extracts the Revision from the program .
107
9
10,194
@ Override protected UUID evalUUID ( ) { UUID uuid = null ; final Pattern uuidPattern = Pattern . compile ( "@eFapsUUID[\\s]*[0-9a-z\\-]*" ) ; final Matcher uuidMatcher = uuidPattern . matcher ( getCode ( ) ) ; if ( uuidMatcher . find ( ) ) { final String uuidStr = uuidMatcher . group ( ) . replaceFirst ( "^@eFapsUUID" , "" ) ; uuid = UUID . fromString ( uuidStr . trim ( ) ) ; } return uuid ; }
This Method extracts the UUID from the source .
142
10
10,195
protected String evalExtends ( ) { String ret = null ; // regular expression for the package name final Pattern exPattern = Pattern . compile ( "@eFapsExtends[\\s]*[a-zA-Z\\._-]*\\b" ) ; final Matcher exMatcher = exPattern . matcher ( getCode ( ) ) ; if ( exMatcher . find ( ) ) { ret = exMatcher . group ( ) . replaceFirst ( "^@eFapsExtends" , "" ) ; } return ret == null ? null : ret . trim ( ) ; }
This Method extracts the extend from the source .
128
9
10,196
public void setBackground ( float x , float y , float z , float a ) { gl . glClearColor ( x / 255 , y / 255 , z / 255 , a / 255 ) ; }
Sets the background to a RGB and alpha value .
42
11
10,197
public void setBackgroud ( Color color ) { gl . glClearColor ( ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) ( color . getAlpha ( ) * getAlpha ( ) ) ) ; }
Sets the background to a RGB or HSB and alpha value .
66
14
10,198
public void matrixMode ( MatrixMode mode ) { switch ( mode ) { case PROJECTION : gl . glMatrixMode ( GL2 . GL_PROJECTION ) ; break ; case MODELVIEW : gl . glMatrixMode ( GL2 . GL_MODELVIEW ) ; break ; default : break ; } }
Sets the MatrixMode .
67
6
10,199
public void setAmbientLight ( float r , float g , float b ) { float ambient [ ] = { r , g , b , 255 } ; normalize ( ambient ) ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_AMBIENT , ambient , 0 ) ; }
Sets the RGB value of the ambientLight
99
9