idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,900
public static < G , B > Bad < G , B > of ( B value ) { return new Bad < > ( value ) ; }
Creates a Bad of type B .
9,901
public LREnvelope sign ( LREnvelope envelope ) throws LRException { String bencodedMessage = bencode ( envelope . getSignableData ( ) ) ; String clearSignedMessage = signEnvelopeData ( bencodedMessage ) ; envelope . addSigningData ( signingMethod , publicKeyLocation , clearSignedMessage ) ; return envelope ; }
Sign the specified envelope with this signer
9,902
private List < Object > normalizeList ( List < Object > list ) { List < Object > result = new ArrayList < Object > ( ) ; for ( Object o : list ) { if ( o == null ) { result . add ( nullLiteral ) ; } else if ( o instanceof Boolean ) { result . add ( ( ( Boolean ) o ) . toString ( ) ) ; } else if ( o instanceof List < ? > ) { result . add ( normalizeList ( ( List < Object > ) o ) ) ; } else if ( o instanceof Map < ? , ? > ) { result . add ( normalizeMap ( ( Map < String , Object > ) o ) ) ; } else if ( ! ( o instanceof Number ) ) { result . add ( o ) ; } } return result ; }
Helper for map normalization ; inspects list and returns a replacement list that has been normalized .
9,903
private String signEnvelopeData ( String message ) throws LRException { if ( passPhrase == null || publicKeyLocation == null || privateKey == null ) { throw new LRException ( LRException . NULL_FIELD ) ; } InputStream privateKeyStream = getPrivateKeyStream ( privateKey ) ; ByteArrayOutputStream result = new ByteArrayOutputStream ( ) ; ArmoredOutputStream aOut = new ArmoredOutputStream ( result ) ; char [ ] privateKeyPassword = passPhrase . toCharArray ( ) ; try { PGPSecretKey sk = readSecretKey ( privateKeyStream ) ; PGPPrivateKey pk = sk . extractPrivateKey ( new JcePBESecretKeyDecryptorBuilder ( ) . setProvider ( "BC" ) . build ( privateKeyPassword ) ) ; PGPSignatureGenerator sGen = new PGPSignatureGenerator ( new JcaPGPContentSignerBuilder ( sk . getPublicKey ( ) . getAlgorithm ( ) , PGPUtil . SHA256 ) . setProvider ( "BC" ) ) ; PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator ( ) ; java . util . Iterator it = sk . getPublicKey ( ) . getUserIDs ( ) ; if ( it . hasNext ( ) ) { spGen . setSignerUserID ( false , ( String ) it . next ( ) ) ; sGen . setHashedSubpackets ( spGen . generate ( ) ) ; } aOut . beginClearText ( PGPUtil . SHA256 ) ; sGen . init ( PGPSignature . CANONICAL_TEXT_DOCUMENT , pk ) ; byte [ ] msg = message . getBytes ( ) ; sGen . update ( msg , 0 , msg . length ) ; aOut . write ( msg , 0 , msg . length ) ; BCPGOutputStream bOut = new BCPGOutputStream ( aOut ) ; aOut . endClearText ( ) ; sGen . generate ( ) . encode ( bOut ) ; aOut . close ( ) ; String strResult = result . toString ( "utf8" ) ; strResult = strResult . replaceAll ( "([a-z0-9])-----BEGIN PGP SIGNATURE-----" , "$1\n-----BEGIN PGP SIGNATURE-----" ) ; return strResult ; } catch ( Exception e ) { throw new LRException ( LRException . SIGNING_FAILED ) ; } finally { try { if ( privateKeyStream != null ) { privateKeyStream . close ( ) ; } result . close ( ) ; } catch ( IOException e ) { } } }
Encodes the provided message with the private key and pass phrase set in configuration
9,904
private PGPSecretKey readSecretKey ( InputStream input ) throws LRException { PGPSecretKeyRingCollection pgpSec ; try { pgpSec = new PGPSecretKeyRingCollection ( PGPUtil . getDecoderStream ( input ) ) ; } catch ( Exception e ) { throw new LRException ( LRException . NO_KEY ) ; } java . util . Iterator keyRingIter = pgpSec . getKeyRings ( ) ; while ( keyRingIter . hasNext ( ) ) { PGPSecretKeyRing keyRing = ( PGPSecretKeyRing ) keyRingIter . next ( ) ; java . util . Iterator keyIter = keyRing . getSecretKeys ( ) ; while ( keyIter . hasNext ( ) ) { PGPSecretKey key = ( PGPSecretKey ) keyIter . next ( ) ; if ( key . isSigningKey ( ) ) { return key ; } } } throw new LRException ( LRException . NO_KEY ) ; }
Reads private key from the provided InputStream
9,905
private InputStream getPrivateKeyStream ( String privateKey ) throws LRException { try { if ( privateKey . matches ( pgpRegex ) ) { return new ByteArrayInputStream ( privateKey . getBytes ( ) ) ; } else { return new FileInputStream ( new File ( privateKey ) ) ; } } catch ( IOException e ) { throw new LRException ( LRException . NO_KEY_STREAM ) ; } }
Converts the local location or text of a private key into an input stream
9,906
public void include ( Readable in , String source ) throws IOException { if ( cursor != end ) { release ( ) ; } if ( includeStack == null ) { includeStack = new ArrayDeque < > ( ) ; } includeStack . push ( includeLevel ) ; includeLevel = new IncludeLevel ( in , source ) ; }
Include Readable at current input . Readable is read as part of input . When Readable ends input continues using current input .
9,907
private static Set < Type > getChildTypes ( final Type _type ) throws CacheReloadException { final Set < Type > ret = new HashSet < Type > ( ) ; ret . add ( _type ) ; for ( final Type child : _type . getChildTypes ( ) ) { ret . addAll ( getChildTypes ( child ) ) ; } return ret ; }
Gets the type list .
9,908
public Criteria addCriteria ( final int _idx , final List < String > _sqlColNames , final Comparison _comparison , final Set < String > _values , final boolean _escape , final Connection _connection ) { final Criteria criteria = new Criteria ( ) . tableIndex ( _idx ) . colNames ( _sqlColNames ) . comparison ( _comparison ) . values ( _values ) . escape ( _escape ) . connection ( _connection ) ; sections . add ( criteria ) ; return criteria ; }
Adds the criteria .
9,909
protected void appendSQL ( final String _tablePrefix , final StringBuilder _cmd ) { if ( sections . size ( ) > 0 ) { if ( isStarted ( ) ) { new SQLSelectPart ( SQLPart . AND ) . appendSQL ( _cmd ) ; new SQLSelectPart ( SQLPart . SPACE ) . appendSQL ( _cmd ) ; } else { new SQLSelectPart ( SQLPart . WHERE ) . appendSQL ( _cmd ) ; new SQLSelectPart ( SQLPart . SPACE ) . appendSQL ( _cmd ) ; } addSectionsSQL ( _tablePrefix , _cmd , sections ) ; } }
Append SQL .
9,910
public static InetAddress getInetAddress ( Config config , String path ) { try { return InetAddress . getByName ( config . getString ( path ) ) ; } catch ( UnknownHostException e ) { throw badValue ( e , config , path ) ; } }
Get an IP address . The configuration value can either be a hostname or a literal IP address .
9,911
public static NetworkInterface getNetworkInterface ( Config config , String path ) { NetworkInterface value = getNetworkInterfaceByName ( config , path ) ; if ( value == null ) value = getNetworkInterfaceByInetAddress ( config , path ) ; if ( value == null ) throw badValue ( "No network interface for value '" + config . getString ( path ) + "'" , config , path ) ; return value ; }
Get a network interface . The network interface can be identified by its name or its IP address .
9,912
public static int getPort ( Config config , String path ) { try { return new InetSocketAddress ( config . getInt ( path ) ) . getPort ( ) ; } catch ( IllegalArgumentException e ) { throw badValue ( e , config , path ) ; } }
Get a port number .
9,913
public List < ChatMessageStatus > adaptEvents ( List < DbOrphanedEvent > dbOrphanedEvents ) { List < ChatMessageStatus > statuses = new ArrayList < > ( ) ; Parser parser = new Parser ( ) ; for ( DbOrphanedEvent event : dbOrphanedEvents ) { OrphanedEvent orphanedEvent = parser . parse ( event . event ( ) , OrphanedEvent . class ) ; statuses . add ( ChatMessageStatus . builder ( ) . populate ( orphanedEvent . getConversationId ( ) , orphanedEvent . getMessageId ( ) , orphanedEvent . getProfileId ( ) , orphanedEvent . isEventTypeRead ( ) ? LocalMessageStatus . read : LocalMessageStatus . delivered , DateHelper . getUTCMilliseconds ( orphanedEvent . getTimestamp ( ) ) , ( long ) orphanedEvent . getConversationEventId ( ) ) . build ( ) ) ; } return statuses ; }
Translates Orphaned events to message statuses .
9,914
public List < ChatMessage > adaptMessages ( List < MessageReceived > messagesReceived ) { List < ChatMessage > chatMessages = new ArrayList < > ( ) ; if ( messagesReceived != null ) { for ( MessageReceived msg : messagesReceived ) { ChatMessage adaptedMessage = ChatMessage . builder ( ) . populate ( msg ) . build ( ) ; List < ChatMessageStatus > adaptedStatuses = adaptStatuses ( msg . getConversationId ( ) , msg . getMessageId ( ) , msg . getStatusUpdate ( ) ) ; for ( ChatMessageStatus s : adaptedStatuses ) { adaptedMessage . addStatusUpdate ( s ) ; } chatMessages . add ( adaptedMessage ) ; } } return chatMessages ; }
Translates received messages through message query to chat SDK model .
9,915
public List < ChatMessageStatus > adaptStatuses ( String conversationId , String messageId , Map < String , MessageReceived . Status > statuses ) { List < ChatMessageStatus > adapted = new ArrayList < > ( ) ; for ( String key : statuses . keySet ( ) ) { MessageReceived . Status status = statuses . get ( key ) ; adapted . add ( ChatMessageStatus . builder ( ) . populate ( conversationId , messageId , key , status . getStatus ( ) . compareTo ( MessageStatus . delivered ) == 0 ? LocalMessageStatus . delivered : LocalMessageStatus . read , DateHelper . getUTCMilliseconds ( status . getTimestamp ( ) ) , null ) . build ( ) ) ; } return adapted ; }
Translates received message statuses through message query to chat SDK model .
9,916
public List < ChatParticipant > adapt ( List < Participant > participants ) { List < ChatParticipant > result = new ArrayList < > ( ) ; if ( participants != null && ! participants . isEmpty ( ) ) { for ( Participant p : participants ) { result . add ( ChatParticipant . builder ( ) . populate ( p ) . build ( ) ) ; } } return result ; }
Translates Foundation conversation participants to Chat SDK conversation participants .
9,917
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 .
9,918
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 .
9,919
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
9,920
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
9,921
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 .
9,922
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 .
9,923
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 .
9,924
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 ( ) { 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 .
9,925
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 .
9,926
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 .
9,927
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 .
9,928
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 .
9,929
public static FacetsConfig getFacetsConfig ( ) { final FacetsConfig ret = new FacetsConfig ( ) ; ret . setHierarchical ( Indexer . Dimension . DIMCREATED . name ( ) , true ) ; return ret ; }
Gets the facets config .
9,930
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 ( ) { public Analyzer getAnalyzer ( ) { return new StandardAnalyzer ( SpanishAnalyzer . getDefaultStopSet ( ) ) ; } } ; } return provider . getAnalyzer ( ) ; }
Gets the analyzer .
9,931
@ 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 .
9,932
@ 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 .
9,933
@ 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 .
9,934
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 .
9,935
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
9,936
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 .
9,937
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 .
9,938
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 .
9,939
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 .
9,940
protected String makeInfo ( ) { final StringBuilder str = new StringBuilder ( ) ; if ( this . className != null ) { str . append ( "Thrown within class " ) . append ( this . className . getName ( ) ) . append ( '\n' ) ; } if ( this . id != null ) { str . append ( "Id of Exception is " ) . append ( this . id ) . append ( '\n' ) ; } 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 .
9,941
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 .
9,942
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 .
9,943
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 .
9,944
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 .
9,945
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 .
9,946
public void setNode ( int number , Vector3D v ) { setNode ( number , v . getX ( ) , v . getY ( ) , v . getZ ( ) ) ; }
Sets coordinate of nodes of this Bezier .
9,947
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 .
9,948
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 .
9,949
public final void setFont ( Font font ) { this . font = font ; textRenderer = new TextRenderer ( font . getAWTFont ( ) , true , true ) ; }
Sets the Font of this Text .
9,950
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 .
9,951
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 .
9,952
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 .
9,953
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 .
9,954
public static String addZerosBefore ( String orderNo , int count ) { if ( orderNo == null ) { return "" ; } 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 .
9,955
public Map < String , Set < DataPoint > > getSeries ( ) { return new HashMap < String , Set < DataPoint > > ( store ) ; }
Gets a mapping from series to an unordered set of DataPoints .
9,956
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 .
9,957
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 .
9,958
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 .
9,959
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 .
9,960
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 .
9,961
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 .
9,962
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 .
9,963
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 .
9,964
@ SuppressWarnings ( "unchecked" ) 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 .
9,965
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 .
9,966
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 .
9,967
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 .
9,968
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 .
9,969
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 .
9,970
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 .
9,971
public void setCornerColor ( int index , Color color ) { if ( ! cornerGradation ) { cornerGradation = true ; } colors . set ( index , color ) ; }
Sets the point s color for gradation .
9,972
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
9,973
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
9,974
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 .
9,975
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 .
9,976
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 ) ; } } } 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 .
9,977
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
9,978
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 .
9,979
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 .
9,980
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
9,981
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
9,982
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
9,983
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 .
9,984
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 .
9,985
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 .
9,986
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 .
9,987
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 .
9,988
@ 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 ( ) { public long getLifespan ( ) { return 5 ; } 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 .
9,989
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 ) { public void run ( ) { processEventQueue ( head ) ; } } ) ; } }
heads uniqueness by key1 should be guaranteed by unique index .
9,990
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 ; 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 ; TedResult result = processEvent ( event ) ; if ( result . status == TedStatus . DONE ) { saveResult ( event , result ) ; } else { lastUnsavedEvent = event ; lastUnsavedResult = result ; break outer ; } } } } final TedResult finalLastUnsavedResult = lastUnsavedResult ; final TaskRec finalLastUnsavedEvent = lastUnsavedEvent ; tedDaoExt . runInTx ( new Runnable ( ) { 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
9,991
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 .
9,992
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 .
9,993
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 .
9,994
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
9,995
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
9,996
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 .
9,997
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 ) ; 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
9,998
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 .
9,999
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 .