idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
12,800 | public static < K , T > IKeyedObjectPool . Single < K , T > createPool ( IPoolObjectFactory < K , T > factory ) { return new KeyedSingleObjectPool < K , T > ( factory ) ; } | Creates a new Single Key to Object Pool |
12,801 | public int compare ( MajorMinorVersion otherVersion ) { int result = this . major - otherVersion . major ; if ( result == 0 ) { result = this . minor - otherVersion . minor ; } return result ; } | Compares two versions by major then minor number . |
12,802 | public static MemcachedManagerBuilder memcacheAddOn ( ) { final String memcacheServers = System . getenv ( "MEMCACHE_SERVERS" ) ; return memcachedConfig ( ) . username ( System . getenv ( "MEMCACHE_USERNAME" ) ) . password ( System . getenv ( "MEMCACHE_PASSWORD" ) ) . url ( memcacheServers == null ? DEFAULT_URL : memcacheServers ) ; } | Configuration based on system properties set by the memcacheAddOn |
12,803 | public static MemcachedManagerBuilder memcachierAddOn ( ) { final String memcachierServers = System . getenv ( "MEMCACHIER_SERVERS" ) ; return memcachedConfig ( ) . username ( System . getenv ( "MEMCACHIER_USERNAME" ) ) . password ( System . getenv ( "MEMCACHIER_PASSWORD" ) ) . url ( memcachierServers == null ? DEFAULT_URL : memcachierServers ) ; } | Configuration based on system properties set by the memcachierAddOn |
12,804 | public void setWikipedia ( String wikipedia ) { if ( wikipedia != null ) { wikipedia = wikipedia . trim ( ) ; } this . wikipedia = wikipedia ; } | Set link to the Wikipedia page for the detected language . |
12,805 | public CroquetWicketBuilder < T > addHealthCheck ( final String path , final Class < ? extends IResource > resource ) { settings . addResourceMount ( path , resource ) ; return this ; } | Adds a health check resource to a particular mount . |
12,806 | public void start ( ) { System . out . println ( "Starting hub" ) ; try { Class . forName ( "org.apache.derby.jdbc.EmbeddedDriver" ) ; EmbeddedDataSource ds = new EmbeddedDataSource ( ) ; ds . setConnectionAttributes ( "create=true" ) ; ds . setDatabaseName ( "classes" ) ; JobHub . prepareDataSource ( ds ) ; logger . info ( "Initializing service" ) ; jobHub = new JobHub ( ds ) ; AuthenticationServer authServer = new AuthenticationServer ( jobHub , JdcpUtil . DEFAULT_PORT ) ; logger . info ( "Binding service" ) ; Registry registry = getRegistry ( ) ; registry . bind ( "AuthenticationService" , authServer ) ; logger . info ( "Hub ready" ) ; System . out . println ( "Hub started" ) ; } catch ( Exception e ) { System . err . println ( "Failed to start hub" ) ; logger . error ( "Failed to start hub" , e ) ; } } | Starts the hub . |
12,807 | public void stop ( ) { try { jobHub . shutdown ( ) ; jobHub = null ; Registry registry = getRegistry ( ) ; registry . unbind ( "AuthenticationService" ) ; System . out . println ( "Hub stopped" ) ; } catch ( Exception e ) { logger . error ( "An error occurred while stopping the hub" , e ) ; System . err . println ( "Hub did not shut down cleanly, see log for details." ) ; } } | Stops the hub . |
12,808 | public void stat ( ) { if ( this . jobHub == null ) { System . err . println ( "Hub not running" ) ; return ; } System . out . println ( "Hub running" ) ; } | Prints the status of the hub . |
12,809 | public static Web3j configureInstance ( String address , Long timeout ) { web3jInstance = EthereumUtils . generateClient ( address , timeout ) ; return web3jInstance ; } | Get instance with parameters . |
12,810 | private JSONObject getKeyword ( final JSONArray keywords , final int index ) { JSONObject object = new JSONObject ( ) ; try { object = ( JSONObject ) keywords . get ( index ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return object ; } | Return a json object from the provided array . Return an empty object if there is any problems fetching the keyword data . |
12,811 | private SentimentAlchemyEntity getSentiment ( final JSONObject jsonKeyword ) { SentimentAlchemyEntity sentiment = null ; final JSONObject sentimentObject = getJSONObject ( JSONConstants . SENTIMENT_KEY , jsonKeyword ) ; if ( sentimentObject == null ) { return sentiment ; } final String type = getString ( JSONConstants . SENTIMENT_TYPE_KEY , sentimentObject ) ; final Double score = getDouble ( JSONConstants . SENTIMENT_SCORE_KEY , sentimentObject ) ; final Integer mixed = getInteger ( JSONConstants . SENTIMENT_MIXED_KEY , sentimentObject ) ; if ( isValidSentiment ( type , score , mixed ) ) { sentiment = new SentimentAlchemyEntity ( ) ; if ( ! StringUtils . isBlank ( type ) ) { sentiment . setType ( type ) ; } if ( score != null ) { sentiment . setScore ( score ) ; } if ( mixed != null ) { sentiment . setIsMixed ( mixed ) ; } } return sentiment ; } | Return a sentiment object populated by the values in the json object . Return null if there are no sentiment data . |
12,812 | protected StoredClassCatalog createClassCatalog ( Environment env ) throws IllegalArgumentException , DatabaseException { DatabaseConfig dbConfig = new DatabaseConfig ( ) ; dbConfig . setTemporary ( false ) ; dbConfig . setAllowCreate ( true ) ; Database catalogDb = env . openDatabase ( null , CLASS_CATALOG , dbConfig ) ; return new StoredClassCatalog ( catalogDb ) ; } | Creates a persistent class catalog . |
12,813 | protected EnvironmentConfig createEnvConfig ( ) { EnvironmentConfig envConf = new EnvironmentConfig ( ) ; envConf . setAllowCreate ( true ) ; envConf . setTransactional ( true ) ; LOGGER . log ( Level . FINE , "Calculating cache size" ) ; MemoryMXBean memoryMXBean = ManagementFactory . getMemoryMXBean ( ) ; MemoryUsage memoryUsage = memoryMXBean . getHeapMemoryUsage ( ) ; long max = memoryUsage . getMax ( ) ; long used = memoryUsage . getUsed ( ) ; long available = max - used ; long cacheSize = Math . round ( available / 6.0 ) ; envConf . setCacheSize ( cacheSize ) ; LOGGER . log ( Level . FINE , "Cache size set to {0}" , cacheSize ) ; return envConf ; } | Creates an environment config that allows object creation and supports transactions . In addition it automatically calculates a cache size based on available memory . |
12,814 | protected DatabaseConfig createDatabaseConfig ( ) { DatabaseConfig dbConfig = new DatabaseConfig ( ) ; dbConfig . setAllowCreate ( true ) ; dbConfig . setTemporary ( false ) ; return dbConfig ; } | Creates a database config for creating persistent databases . |
12,815 | public static Selection forName ( Class cl , String name ) { java . lang . reflect . Method [ ] all ; int i ; List < Function > lst ; Function fn ; all = cl . getDeclaredMethods ( ) ; lst = new ArrayList < Function > ( ) ; for ( i = 0 ; i < all . length ; i ++ ) { if ( name . equals ( all [ i ] . getName ( ) ) ) { fn = create ( all [ i ] ) ; if ( fn != null ) { lst . add ( fn ) ; } } } return new Selection ( lst ) ; } | Gets all valid Methods from the specified class with the specified name . |
12,816 | public Object invoke ( Object [ ] vals ) throws InvocationTargetException { Object [ ] tmp ; int i ; try { if ( isStatic ( ) ) { return meth . invoke ( null , vals ) ; } else { if ( vals . length == 0 ) { throw new IllegalArgumentException ( "invalid arguments" ) ; } tmp = new Object [ vals . length - 1 ] ; for ( i = 1 ; i < vals . length ; i ++ ) { tmp [ i - 1 ] = vals [ i ] ; } return meth . invoke ( vals [ 0 ] , tmp ) ; } } catch ( InvocationTargetException | IllegalArgumentException e ) { throw e ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "can't access method" ) ; } } | Invokes the wrapped Java Method . Throws Exceptions raised in the Java Method . |
12,817 | public static void write ( ObjectOutput out , java . lang . reflect . Method meth ) throws IOException { Class cl ; if ( meth == null ) { ClassRef . write ( out , null ) ; } else { cl = meth . getDeclaringClass ( ) ; ClassRef . write ( out , cl ) ; out . writeUTF ( meth . getName ( ) ) ; ClassRef . writeClasses ( out , meth . getParameterTypes ( ) ) ; } } | Writes a Java Method object . |
12,818 | public static java . lang . reflect . Method read ( ObjectInput in ) throws ClassNotFoundException , NoSuchMethodException , IOException { Class cl ; Class [ ] types ; String name ; cl = ClassRef . read ( in ) ; if ( cl == null ) { return null ; } else { name = ( String ) in . readUTF ( ) ; types = ClassRef . readClasses ( in ) ; return cl . getMethod ( name , types ) ; } } | Reads a Java Method object . |
12,819 | public static Type getTargetType ( MethodParameter methodParam ) { Preconditions . checkNotNull ( methodParam , "MethodParameter must not be null" ) ; if ( methodParam . getConstructor ( ) != null ) { return methodParam . getConstructor ( ) . getGenericParameterTypes ( ) [ methodParam . getParameterIndex ( ) ] ; } else { if ( methodParam . getParameterIndex ( ) >= 0 ) { return methodParam . getMethod ( ) . getGenericParameterTypes ( ) [ methodParam . getParameterIndex ( ) ] ; } else { return methodParam . getMethod ( ) . getGenericReturnType ( ) ; } } } | Determine the target type for the given parameter specification . |
12,820 | public static Class < ? > resolveParameterType ( MethodParameter methodParam , Class clazz ) { Type genericType = getTargetType ( methodParam ) ; Preconditions . checkNotNull ( clazz , "Class must not be null" ) ; Map < TypeVariable , Type > typeVariableMap = getTypeVariableMap ( clazz ) ; Type rawType = getRawType ( genericType , typeVariableMap ) ; Class result = ( rawType instanceof Class ? ( Class ) rawType : methodParam . getParameterType ( ) ) ; methodParam . setParameterType ( result ) ; methodParam . typeVariableMap = typeVariableMap ; return result ; } | Determine the target type for the given generic parameter type . |
12,821 | public static Class < ? > resolveReturnType ( Method method , Class clazz ) { Preconditions . checkNotNull ( method , "Method must not be null" ) ; Type genericType = method . getGenericReturnType ( ) ; Preconditions . checkNotNull ( clazz , "Class must not be null" ) ; Map < TypeVariable , Type > typeVariableMap = getTypeVariableMap ( clazz ) ; Type rawType = getRawType ( genericType , typeVariableMap ) ; return ( rawType instanceof Class ? ( Class ) rawType : method . getReturnType ( ) ) ; } | Determine the target type for the generic return type of the given method . |
12,822 | public void addShift ( int state , int sym , int nextState ) { int idx ; idx = state * symbolCount + sym ; if ( values [ idx ] != NOT_SET ) { throw new IllegalStateException ( ) ; } values [ idx ] = createValue ( Parser . SHIFT , nextState ) ; } | Cannot have conflicts . |
12,823 | public String [ ] packValue ( StringBuilder difs , StringBuilder vals ) { List < String > lst ; String [ ] array ; if ( difs . length ( ) != vals . length ( ) ) { throw new IllegalArgumentException ( ) ; } lst = new ArrayList < String > ( ) ; split ( difs , MAX_UTF8_LENGTH , lst ) ; split ( vals , MAX_UTF8_LENGTH , lst ) ; array = new String [ lst . size ( ) ] ; lst . toArray ( array ) ; return array ; } | 3 max size of utf8 encoded char |
12,824 | public Instruction read ( int opcode , Input src , int ofs ) throws IOException { switch ( opcode ) { case WIDE : return readWide ( src , ofs ) ; case TABLESWITCH : return readTableSwitch ( src , ofs ) ; case LOOKUPSWITCH : return readLookupSwitch ( src , ofs ) ; default : return readNormal ( src , ofs ) ; } } | all opcodes except for tableswitch lookupswitch and wide are considered normal |
12,825 | private String prepareXmlForParsing ( String xml ) throws TheDavidBoxClientException { xml = xml . replaceAll ( "&" , "&" ) ; String xmlReady ; try { xmlReady = new String ( xml . getBytes ( ) , CHARSET_ENCODING ) ; } catch ( UnsupportedEncodingException e ) { throw new TheDavidBoxClientException ( e ) ; } return xmlReady ; } | It prepares the xml string for parsing . |
12,826 | public void setLematized ( String lematized ) { if ( lematized != null ) { lematized = lematized . trim ( ) ; } this . lematized = lematized ; } | Set the lemmatized base form of the detected action . |
12,827 | public < T > void validate ( T entity ) { Set < ConstraintViolation < T > > constraintViolations = validator . validate ( entity ) ; if ( constraintViolations == null || constraintViolations . size ( ) == 0 ) return ; ConstraintViolation < T > first = constraintViolations . iterator ( ) . next ( ) ; ConstraintDescriptor < ? > constraintDescriptor = first . getConstraintDescriptor ( ) ; String entityName = first . getRootBeanClass ( ) . getSimpleName ( ) ; String propertyName = first . getPropertyPath ( ) . toString ( ) ; String message = first . getMessage ( ) ; String [ ] parameters = buildAnnotationConstraintParameters ( constraintDescriptor . getAnnotation ( ) ) ; throw new InvalidEntityInstanceStateException ( entityName , propertyName , message , parameters ) ; } | Methode permettant de valider un onjet |
12,828 | protected String [ ] buildAnnotationConstraintParameters ( Annotation annotation ) { if ( annotation == null ) return null ; if ( annotation instanceof AuthorizedValues ) return new String [ ] { Arrays . toString ( ( ( AuthorizedValues ) annotation ) . values ( ) ) } ; if ( annotation instanceof Interval ) return new String [ ] { Double . toString ( ( ( Interval ) annotation ) . min ( ) ) , Double . toString ( ( ( Interval ) annotation ) . max ( ) ) } ; if ( annotation instanceof Length ) return new String [ ] { Integer . toString ( ( ( Length ) annotation ) . min ( ) ) , Integer . toString ( ( ( Length ) annotation ) . max ( ) ) } ; return null ; } | Methode permettant d obtenir la liste des parametres d une annotation de validation de contraintes |
12,829 | public String execute ( Connection < ? > connection ) { String localUserId = UUID . randomUUID ( ) . toString ( ) ; logger . debug ( "Local User ID is: {}" , localUserId ) ; return localUserId ; } | here use random generated id to act as localUserId localUserId will be the key to save connection & sign |
12,830 | public static String escapeDelimitedColumn ( String str , char delimiter ) { if ( str == null || ( containsNone ( str , SEARCH_CHARS ) && str . indexOf ( delimiter ) < 0 ) ) { return str ; } else { StringBuilder writer = new StringBuilder ( ) ; writer . append ( QUOTE ) ; for ( int j = 0 , n = str . length ( ) ; j < n ; j ++ ) { char c = str . charAt ( j ) ; if ( c == QUOTE ) { writer . append ( QUOTE ) ; } writer . append ( c ) ; } writer . append ( QUOTE ) ; return writer . toString ( ) ; } } | Escapes a column in a delimited file . |
12,831 | public void add ( String str ) { String [ ] tmp ; if ( size == data . length ) { tmp = new String [ data . length + GROW ] ; System . arraycopy ( data , 0 , tmp , 0 , data . length ) ; data = tmp ; } data [ size ] = str ; size ++ ; } | Adds a new element to the end of the List . |
12,832 | public void addAll ( StringArrayList vec ) { int i ; int max ; max = vec . size ( ) ; for ( i = 0 ; i < max ; i ++ ) { add ( vec . get ( i ) ) ; } } | Adds a whole List of elements . |
12,833 | public int indexOf ( String str ) { int i ; for ( i = 0 ; i < size ; i ++ ) { if ( data [ i ] . equals ( str ) ) { return i ; } } return - 1 ; } | Lookup an element . |
12,834 | private static Label combineLabel ( FA fa , IntBitSet states ) { int si ; Label tmp ; Label result ; result = null ; for ( si = states . first ( ) ; si != - 1 ; si = states . next ( si ) ) { tmp = ( Label ) fa . get ( si ) . getLabel ( ) ; if ( tmp != null ) { if ( result == null ) { result = new Label ( ) ; } result . symbols . addAll ( tmp . symbols ) ; } } return result ; } | might return null |
12,835 | public ObjectNode toJson ( ) { ObjectMapper mapper = new ObjectMapper ( ) ; ObjectNode node = mapper . createObjectNode ( ) ; ObjectNode unitIntervalNode = mapper . createObjectNode ( ) ; node . put ( intervalUnit . getUnitNodeName ( ) , unitIntervalNode ) ; unitIntervalNode . put ( "interval" , buildIntervalNode ( ) ) ; unitIntervalNode . put ( "aggregationType" , intervalUnit . name ( ) ) ; return node ; } | Returns a JSON representation of this interval to send to the server . Used by the SDK internally . |
12,836 | static int readInt ( JsonNode node , String field ) throws NumberFormatException { String stringValue = node . get ( field ) . asText ( ) ; return ( int ) Float . parseFloat ( stringValue ) ; } | Reads a whole number from the given field of the node . Accepts numbers numerical strings and fractions . |
12,837 | public CssResourceReference [ ] getCssResourceReferences ( ) { final List < CssResourceReference > resources = new ArrayList < CssResourceReference > ( ) ; for ( final String resource : cssResources ) { if ( ! resource . startsWith ( "//" ) && resource . startsWith ( "http" ) ) { resources . add ( new CssResourceReference ( getResourcesRootClass ( ) , resource ) ) ; } } return resources . toArray ( new CssResourceReference [ resources . size ( ) ] ) ; } | Get a list of CSS resources to include on the default page . |
12,838 | public JavaScriptResourceReference [ ] getJavaScriptResourceReferences ( ) { final List < JavaScriptResourceReference > resources = new ArrayList < JavaScriptResourceReference > ( ) ; for ( final String resource : jsResources ) { if ( ! resource . startsWith ( "//" ) && resource . startsWith ( "http" ) ) { resources . add ( new JavaScriptResourceReference ( getResourcesRootClass ( ) , resource ) ) ; } } return resources . toArray ( new JavaScriptResourceReference [ resources . size ( ) ] ) ; } | Get a list of JavaScript resources to include on the default page . |
12,839 | public Boolean getMinifyResources ( ) { if ( getDevelopment ( ) ) { return minifyResources != null ? minifyResources : false ; } else { return minifyResources != null ? minifyResources : true ; } } | Should Croquet minify CSS and JavaScript resources? Defaults to follow dev vs deploy . |
12,840 | public boolean getStripWicketTags ( ) { if ( getDevelopment ( ) ) { return stripWicketTags != null ? stripWicketTags : false ; } else { return stripWicketTags != null ? stripWicketTags : true ; } } | Determine if tags should be removed from the final markup . Defaults to follow dev vs deploy . |
12,841 | public Boolean getStatelessChecker ( ) { if ( getDevelopment ( ) ) { return statelessChecker != null ? statelessChecker : true ; } else { return statelessChecker != null ? statelessChecker : false ; } } | Should Croquet enable the stateless checker? Defaults to follow dev vs deploy . |
12,842 | public Boolean getWicketDebugToolbar ( ) { if ( getDevelopment ( ) ) { return wicketDebugToolbar != null ? wicketDebugToolbar : true ; } else { return wicketDebugToolbar != null ? wicketDebugToolbar : false ; } } | Should Croquet enable the wicket debug toolbar? Defaults to follow dev vs deploy . |
12,843 | public void addPoint ( double x , double y ) { numItems ++ ; double xMinusMeanX = x - meanx ; double yMinusMeanY = y - meany ; sumsq += xMinusMeanX * yMinusMeanY * ( numItems - 1 ) / numItems ; meanx += xMinusMeanX / numItems ; meany += yMinusMeanY / numItems ; } | Update the covariance with another point . |
12,844 | public static void write ( OutputStream dest , byte [ ] data , int ofs , int len ) throws IOException { dest . write ( data , ofs , len ) ; } | no added functionality just for symmetry reasons |
12,845 | private synchronized void doAddRoot ( final WatchedDirectory pWatchedDirectory ) { final Object key = requireNonNull ( pWatchedDirectory . getKey ( ) , KEY_IS_NULL ) ; final Path directory = requireNonNull ( pWatchedDirectory . getDirectory ( ) , DIRECTORY_IS_NULL ) ; if ( ! isDirectory ( directory ) ) { throw new IllegalArgumentException ( format ( "[%s]: %s is not a directory!" , key , directory ) ) ; } if ( watchedDirectories . containsKey ( key ) ) { throw new IllegalArgumentException ( format ( "Key %s already used by %s" , key , watchedDirectories . get ( key ) ) ) ; } watchedDirectories . put ( key , pWatchedDirectory ) ; try { children . computeIfAbsent ( directory . getFileSystem ( ) , this :: newDedicatedFileSystem ) . registerRootDirectory ( pWatchedDirectory ) ; pWatchedDirectory . addObserver ( this ) ; LOG . info ( "Added [{}:{}]" , key , directory ) ; } catch ( final IOException | UncheckedIOException e ) { LOG . warn ( e . getMessage ( ) , e ) ; } } | registered before another WatchedDirectory is being registered . |
12,846 | public synchronized void removeRoot ( final WatchedDirectory pWatchedDirectory ) { requireNonNull ( pWatchedDirectory , WATCHED_DIRECTORY_IS_NULL ) ; final Object key = requireNonNull ( pWatchedDirectory . getKey ( ) , KEY_IS_NULL ) ; final Path directory = requireNonNull ( pWatchedDirectory . getDirectory ( ) , DIRECTORY_IS_NULL ) ; final DedicatedFileSystem fs = children . get ( directory . getFileSystem ( ) ) ; if ( fs == null ) { LOG . warn ( format ( "No dedicated file system registered! Path: %s" , directory ) ) ; } else { fs . unregisterRootDirectory ( pWatchedDirectory . getDirectory ( ) , pWatchedDirectory ) ; watchedDirectories . remove ( key ) ; pWatchedDirectory . removeObserver ( this ) ; LOG . info ( "Removed [{}:{}]" , key , directory ) ; } } | discarded before another WatchedDirectory is being unregistered . |
12,847 | public Oag createSemantics ( List < Attribute > firstAttrs ) throws GenericException { Layout layout ; int [ ] [ ] internalAttrs ; Visits [ ] visits ; layout = createLayout ( firstAttrs ) ; internalAttrs = createInternalAttributes ( layout ) ; visits = OagBuilder . run ( this , layout , null ) ; return new Oag ( visits , internalAttrs ) ; } | them in a certain order |
12,848 | public void getAttributes ( int symbol , Set < Attribute > internal , Set < Attribute > synthesized , Set < Attribute > inherited ) { int i ; int max ; Attribute a ; for ( AttributionBuffer ab : attributions ) { a = ab . result . attr ; if ( a . symbol == symbol ) { if ( ab . result . ofs == - 1 ) { synthesized . add ( a ) ; } else { inherited . add ( a ) ; } } } max = internals . size ( ) ; for ( i = 0 ; i < max ; i += 2 ) { a = ( Attribute ) internals . get ( i ) ; if ( a . symbol == symbol ) { internal . add ( a ) ; } } } | Besides the classic synthesized and inherited attributes I have internal attributes . Internal attributes are computed when creating the node a better name might be initial . |
12,849 | final void closeAndRemoveDatabaseHandle ( Database databaseHandle ) { try { databaseHandle . close ( ) ; } catch ( EnvironmentFailureException | IllegalStateException ex ) { try { LOGGER . log ( Level . SEVERE , "Error closing database {0}" , databaseHandle . getDatabaseName ( ) ) ; } catch ( EnvironmentFailureException | IllegalStateException ex2 ) { ex . addSuppressed ( ex2 ) ; } throw ex ; } finally { this . databaseHandles . remove ( databaseHandle ) ; } } | Closes a database that was previously created by this factory instance . |
12,850 | final void closeAndRemoveAllDatabaseHandles ( ) { for ( Database databaseHandle : this . databaseHandles ) { try { databaseHandle . close ( ) ; } catch ( EnvironmentFailureException | IllegalStateException ex ) { LOGGER . log ( Level . SEVERE , "Error closing databases" , ex ) ; } } this . databaseHandles . clear ( ) ; } | Closes all databases that this factory instance previously created . |
12,851 | private Environment createEnvironment ( ) { EnvironmentConfig envConf = createEnvConfig ( ) ; if ( ! envFile . exists ( ) ) { envFile . mkdirs ( ) ; } LOGGER . log ( Level . INFO , "Initialized BerkeleyDB cache environment at {0}" , envFile . getAbsolutePath ( ) ) ; return new Environment ( this . envFile , envConf ) ; } | Creates a Berkeley DB database environment from the provided environment configuration . |
12,852 | public static JCGLFramebufferBlitFilter framebufferBlitFilterFromGL ( final int filter ) { switch ( filter ) { case GL11 . GL_LINEAR : { return JCGLFramebufferBlitFilter . FRAMEBUFFER_BLIT_FILTER_LINEAR ; } case GL11 . GL_NEAREST : { return JCGLFramebufferBlitFilter . FRAMEBUFFER_BLIT_FILTER_NEAREST ; } default : throw new UnreachableCodeException ( ) ; } } | Convert framebuffer blit filter from GL constants . |
12,853 | public static int faceSelectionToGL ( final JCGLFaceSelection faces ) { switch ( faces ) { case FACE_BACK : return GL11 . GL_BACK ; case FACE_FRONT : return GL11 . GL_FRONT ; case FACE_FRONT_AND_BACK : return GL11 . GL_FRONT_AND_BACK ; } throw new UnreachableCodeException ( ) ; } | Convert faces to GL constants . |
12,854 | public static int faceWindingOrderToGL ( final JCGLFaceWindingOrder f ) { switch ( f ) { case FRONT_FACE_CLOCKWISE : return GL11 . GL_CW ; case FRONT_FACE_COUNTER_CLOCKWISE : return GL11 . GL_CCW ; } throw new UnreachableCodeException ( ) ; } | Convert face winding orders to GL constants . |
12,855 | protected String [ ] getRoles ( Principal inPrincipal , ServletRequest inRequest ) { UserEntity user = this . userDao . getByPrincipal ( inPrincipal ) ; if ( user != null ) { return user . getRoleNames ( ) ; } else { return null ; } } | The getRoles method will now return Null if UserObject not found EMPTY_ARRAY if the user found and don t have any associated roles and String Array if the user found and have associated roles . |
12,856 | public long performClockSkewDetection ( Calendar clientTime ) throws IfmapErrorResult , IfmapException { publishTime ( clientTime ) ; Element time = searchTime ( ) ; deleteTimes ( ) ; mClockSkew = calculateTimeDiff ( time ) ; mLastTimeSynchronization = Calendar . getInstance ( TimeZone . getTimeZone ( "UTC" ) ) ; return mClockSkew ; } | Send a client - time publish request with the current time followed by a search request in order to synchronize time to MAPS . |
12,857 | public Calendar getClockOfServer ( ) { Calendar retCal = Calendar . getInstance ( TimeZone . getTimeZone ( "UTC" ) ) ; retCal . add ( Calendar . MILLISECOND , mClockSkew . intValue ( ) ) ; return retCal ; } | The corrected server time |
12,858 | public ArrayList < String > getGenerators ( ) { ArrayList < String > genList = new ArrayList < String > ( ) ; for ( ArrayList < HashMap < String , String > > genGroup : genGroups ) { if ( ! genGroup . isEmpty ( ) ) { HashMap < String , String > genRule = genGroup . get ( genGroup . size ( ) - 1 ) ; if ( ! genRule . isEmpty ( ) ) { genList . add ( genRule . get ( "cmd" ) + "," + genRule . get ( "variable" ) + "," + genRule . get ( "args" ) ) ; } } } return genList ; } | Get the list of loaded generator rules |
12,859 | public void addPatternFromFile ( String file ) throws IOException { File f = new File ( file ) ; addPatternFromReader ( new FileReader ( f ) ) ; } | Add patterns from a file |
12,860 | public void addPatternFromReader ( Reader r ) throws IOException { BufferedReader br = new BufferedReader ( r ) ; String line ; Pattern MY_PATTERN = Pattern . compile ( "^([A-z0-9_]+)([~]?)\\s+(.*)$" ) ; while ( ( line = br . readLine ( ) ) != null ) { Matcher m = MY_PATTERN . matcher ( line ) ; if ( m . matches ( ) ) { if ( m . group ( 2 ) . length ( ) > 0 ) { this . addPattern ( m . group ( 1 ) , simpleTemplateToRegEx ( m . group ( 3 ) ) ) ; } else { this . addPattern ( m . group ( 1 ) , m . group ( 3 ) ) ; } } } br . close ( ) ; } | Add patterns from a reader |
12,861 | public void compile ( String pattern ) { this . expandedPattern = expand ( pattern ) ; if ( ! expandedPattern . isEmpty ( ) ) { regexp = Pattern . compile ( expandedPattern ) ; } else { throw new IllegalArgumentException ( "Pattern is not found '" + pattern + "'" ) ; } } | Transform Jorka regex into a compiled regex |
12,862 | public static void prepareDataSource ( DataSource ds ) throws SQLException { Connection con = null ; String sql ; try { con = ds . getConnection ( ) ; con . setAutoCommit ( false ) ; DatabaseMetaData meta = con . getMetaData ( ) ; ResultSet rs = meta . getTables ( null , null , null , new String [ ] { "TABLE" } ) ; int tableNameColumn = rs . findColumn ( "TABLE_NAME" ) ; int count = 0 ; while ( rs . next ( ) ) { String tableName = rs . getString ( tableNameColumn ) ; if ( tableName . equalsIgnoreCase ( "CachedClasses" ) ) { count ++ ; } } if ( count == 0 ) { String blobType = DbUtil . getTypeName ( Types . BLOB , con ) ; String nameType = DbUtil . getTypeName ( Types . VARCHAR , 1024 , con ) ; String md5Type = DbUtil . getTypeName ( Types . BINARY , 16 , con ) ; sql = "CREATE TABLE CachedClasses ( \n" + " Name " + nameType + " NOT NULL, \n" + " MD5 " + md5Type + " NOT NULL, \n" + " Definition " + blobType + " NOT NULL, \n" + " PRIMARY KEY (Name, MD5) \n" + ")" ; DbUtil . update ( ds , sql ) ; con . commit ( ) ; } con . setAutoCommit ( true ) ; } catch ( SQLException e ) { DbUtil . rollback ( con ) ; throw e ; } finally { DbUtil . close ( con ) ; } } | Prepares the data source to store cached class definitions . |
12,863 | public int decompress ( final short [ ] source , int size , final Decompressed decomp ) { this . source = source ; globalError = false ; readPtr = 0 ; if ( ! isCompressed ( source , size ) ) { return 0 ; } readPtr += ( size - 4 ) ; int lastDword = readBEdword ( source , readPtr ) ; int outputLen = lastDword >> 8 ; dest = new short [ outputLen ] ; writePtr = outputLen ; bits = 32 - ( lastDword & 0xFF ) ; bytesTOdword ( ) ; if ( bits != 32 ) current >>= ( 32 - bits ) ; do { if ( readBits ( 1 ) == 0 ) bytes ( ) ; if ( writePtr > 0 ) sequence ( ) ; if ( globalError ) { outputLen = 0 ; break ; } } while ( writePtr > 0 ) ; if ( outputLen > 0 ) { decomp . destBufRef = new short [ dest . length ] ; System . arraycopy ( dest , 0 , decomp . destBufRef , 0 , dest . length ) ; } return outputLen ; } | If successful allocates a new buffer containing the uncompresse data and returns the uncompressed length . Else returns 0 . |
12,864 | int readBEdword ( final short [ ] ptr , int pos ) { return ( ( ( ( ( short ) ptr [ pos + 0 ] ) << 24 ) + ( ( ( short ) ptr [ pos + 1 ] ) << 16 ) + ( ( ( short ) ptr [ pos + 2 ] ) << 8 ) + ( ( short ) ptr [ pos + 3 ] ) ) << 0 ) ; } | Read a big - endian 32 - bit word from four bytes in memory . No endian - specific optimizations applied . |
12,865 | void readResidual ( BitInputStream is , int predictorOrder , int partitionOrder , Header header , int [ ] residual ) throws IOException { int sample = 0 ; int partitions = 1 << partitionOrder ; int partitionSamples = partitionOrder > 0 ? header . blockSize >> partitionOrder : header . blockSize - predictorOrder ; contents . ensureSize ( Math . max ( 6 , partitionOrder ) ) ; contents . parameters = new int [ partitions ] ; for ( int partition = 0 ; partition < partitions ; partition ++ ) { int riceParameter = is . readRawUInt ( ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN ) ; contents . parameters [ partition ] = riceParameter ; if ( riceParameter < ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER ) { int u = ( partitionOrder == 0 || partition > 0 ) ? partitionSamples : partitionSamples - predictorOrder ; is . readRiceSignedBlock ( residual , sample , u , riceParameter ) ; sample += u ; } else { riceParameter = is . readRawUInt ( ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN ) ; contents . rawBits [ partition ] = riceParameter ; for ( int u = ( partitionOrder == 0 || partition > 0 ) ? 0 : predictorOrder ; u < partitionSamples ; u ++ , sample ++ ) { residual [ sample ] = is . readRawInt ( riceParameter ) ; } } } } | Read compressed signal residual data . |
12,866 | public int calcLength ( ) { int bits = STREAMINFO_MIN_BLOCK_SIZE_LEN + STREAMINFO_MAX_BLOCK_SIZE_LEN + STREAMINFO_MIN_FRAME_SIZE_LEN + STREAMINFO_MAX_FRAME_SIZE_LEN + STREAMINFO_SAMPLE_RATE_LEN + STREAMINFO_CHANNELS_LEN + STREAMINFO_BITS_PER_SAMPLE_LEN + STREAMINFO_TOTAL_SAMPLES_LEN + ( md5sum . length * 8 ) ; return ( ( bits + 7 ) / 8 ) ; } | Calculate the metadata block size . |
12,867 | public boolean compatiable ( StreamInfo info ) { if ( sampleRate != info . sampleRate ) return false ; if ( channels != info . channels ) return false ; if ( bitsPerSample != info . bitsPerSample ) return false ; return true ; } | Check for compatiable StreamInfo . Checks if sampleRate channels and bitsPerSample are equal |
12,868 | public void readFile ( String filename ) throws ConverterException { try { content = "" ; final InputStream input = ResourceManager . getInputStream ( filename ) ; while ( input . available ( ) > 0 ) { content = content + ( char ) input . read ( ) ; } input . close ( ) ; } catch ( Exception e ) { throw new ConverterException ( e ) ; } } | Reads the content of the converter file |
12,869 | public byte [ ] asByteArray ( ) { Objects . requireNonNull ( data ) ; byte [ ] ret = Arrays . copyOf ( data , data . length ) ; Arrays . fill ( data , ( byte ) 0 ) ; data = null ; return ret ; } | Return un - obfuscated data as byte array . |
12,870 | public IO . Readable getResourceFrom ( ClassLoader cl , String path , byte priority ) { IOProvider . Readable provider = new IOProviderFromPathUsingClassloader ( cl ) . get ( path ) ; if ( provider == null ) return null ; try { return provider . provideIOReadable ( priority ) ; } catch ( IOException e ) { return null ; } } | Open a resource from the given class loader . |
12,871 | public void exitIdentifier ( VersionParser . IdentifierContext ctx ) { String postfix = ctx . getText ( ) ; Matcher m = numericHasLeadingZeroes . matcher ( postfix ) ; while ( m . find ( ) ) { postfix = m . replaceAll ( "" ) ; } while ( ! postfix . isEmpty ( ) && ! startsWithDigitLetterOrHyphen . matcher ( postfix ) . find ( ) ) { postfix = postfix . substring ( 1 ) ; } stack . push ( postfix ) ; } | Normalize the postfix to something that semantic version can handle |
12,872 | public void exitNamed_version ( VersionParser . Named_versionContext ctx ) { IVersion version = null ; try { version = new NamedVersion ( ctx . getText ( ) ) ; } catch ( InvalidRangeException e ) { throw new InvalidRangeRuntimeException ( e . getMessage ( ) , e ) ; } stack . push ( version ) ; } | Get a named version . |
12,873 | public void exitRange ( VersionParser . RangeContext ctx ) { Object o = stack . pop ( ) ; if ( o instanceof IVersion ) { range = new VersionSet ( ( IVersion ) o ) ; } else if ( o instanceof IVersionRange ) { range = ( IVersionRange ) o ; } } | Get whatever is on the stack and make a version range out of it |
12,874 | public void exitSemantic_range ( VersionParser . Semantic_rangeContext ctx ) { String operator = ctx . getChild ( 0 ) . getText ( ) ; Object o = stack . pop ( ) ; if ( o instanceof SemanticVersion ) { switch ( operator ) { case "^" : SemanticVersion sv = ( SemanticVersion ) o ; VersionRange from = new VersionRange ( ">=" , sv ) ; VersionRange to = new VersionRange ( "<" , sv . getNextCaretVersion ( ) ) ; range = new AndRange ( from , to ) ; break ; } stack . push ( range ) ; } else { throw new InvalidRangeRuntimeException ( "Expected a semantic version, got a " + o . getClass ( ) . getSimpleName ( ) ) ; } } | Special semantic version type ranges |
12,875 | public void exitSimple_range ( VersionParser . Simple_rangeContext ctx ) { String operator = ctx . getChild ( 0 ) . getText ( ) ; Object o = stack . pop ( ) ; if ( o instanceof SemanticVersion ) { switch ( operator ) { case "~>" : SemanticVersion sv = ( SemanticVersion ) o ; VersionRange from = new VersionRange ( ">=" , sv ) ; VersionRange to = new VersionRange ( "<" , sv . getNextParentVersion ( ) ) ; range = new AndRange ( from , to ) ; break ; default : range = new VersionRange ( operator , ( SemanticVersion ) o ) ; break ; } stack . push ( range ) ; } else { throw new InvalidRangeRuntimeException ( "Expected a semantic version, got a " + o . getClass ( ) . getSimpleName ( ) ) ; } } | A simple range . |
12,876 | public void exitVersion_set ( VersionParser . Version_setContext ctx ) { Object o1 = stack . pop ( ) ; if ( strict && ( o1 instanceof NamedVersion ) ) { String name = o1 . toString ( ) ; switch ( name . trim ( ) ) { case "-" : case "_" : throw new InvalidRangeRuntimeException ( "Invalid named version: " + o1 ) ; default : break ; } } if ( stack . isEmpty ( ) ) { VersionSet set = new VersionSet ( ( IVersion ) o1 ) ; stack . push ( set ) ; } else { VersionSet set = ( VersionSet ) stack . peek ( ) ; set . add ( ( IVersion ) o1 ) ; } } | Set of versions |
12,877 | public boolean isValidNamedVersion ( final String s ) { if ( SEMANTIC_RANGE_SPECIAL_CHARS . matcher ( s ) . find ( ) || SET_RANGE_SPECIAL_CHARS . matcher ( s ) . find ( ) || INVALID_VERSION_CHARS . matcher ( s ) . find ( ) ) { return false ; } return true ; } | People use all sorts of whack characters in version . We are just excluding the smallest set that we can . |
12,878 | public JdbcDatabaseDescriptor dbByName ( final String dbName ) { Collection < H2DatabaseWorking > select = CollectionUtils . select ( dbsw , new Predicate < H2DatabaseWorking > ( ) { public boolean evaluate ( H2DatabaseWorking db ) { return dbName . equals ( db . getName ( ) ) ; } } ) ; if ( CollectionUtils . size ( select ) == 0 ) { throw new IllegalArgumentException ( "There are no databases called '" + dbName + "'" ) ; } if ( CollectionUtils . size ( select ) >= 2 ) { throw new IllegalArgumentException ( "More than one database is called '" + dbName + "'" ) ; } return CollectionUtils . extractSingleton ( select ) ; } | Get a database by its name . |
12,879 | private WalkingAction walk ( N tree , TreeVisitor < N > walkerClient ) { WalkingAction action = walkerClient . visit ( tree ) ; if ( action == WalkingAction . ABORT ) { return WalkingAction . ABORT ; } else if ( action == WalkingAction . LEAVE_BRANCH ) { return WalkingAction . PROCEED ; } for ( N child : tree . getChildren ( ) ) { if ( walk ( child , walkerClient ) == WalkingAction . ABORT ) { return WalkingAction . ABORT ; } } return WalkingAction . PROCEED ; } | This is the recursive part of the walk method . |
12,880 | public ActiveMQQueueJmxStats addCounts ( ActiveMQQueueJmxStats other , String resultBrokerName ) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats ( resultBrokerName , this . queueName ) ; result . setCursorPercentUsage ( this . getCursorPercentUsage ( ) ) ; result . setDequeueCount ( this . getDequeueCount ( ) + other . getDequeueCount ( ) ) ; result . setEnqueueCount ( this . getEnqueueCount ( ) + other . getEnqueueCount ( ) ) ; result . setMemoryPercentUsage ( this . getMemoryPercentUsage ( ) ) ; result . setNumConsumers ( this . getNumConsumers ( ) + other . getNumConsumers ( ) ) ; result . setNumProducers ( this . getNumProducers ( ) + other . getNumProducers ( ) ) ; result . setQueueSize ( this . getQueueSize ( ) + other . getQueueSize ( ) ) ; result . setInflightCount ( this . getInflightCount ( ) + other . getInflightCount ( ) ) ; return result ; } | Return a new queue stats structure with the total of the stats from this structure and the one given . Returning a new structure keeps all three structures unchanged in the manner of immutability to make it easier to have safe usage under concurrency . Note that non - count values are copied out from this instance ; those values from the given other stats are ignored . |
12,881 | public ActiveMQQueueJmxStats dup ( String brokerName ) { ActiveMQQueueJmxStats result = new ActiveMQQueueJmxStats ( brokerName , this . queueName ) ; this . copyOut ( result ) ; return result ; } | Return a duplicate of this queue stats structure . |
12,882 | public void copyOut ( ActiveMQQueueJmxStats other ) { other . setCursorPercentUsage ( this . getCursorPercentUsage ( ) ) ; other . setDequeueCount ( this . getDequeueCount ( ) ) ; other . setEnqueueCount ( this . getEnqueueCount ( ) ) ; other . setMemoryPercentUsage ( this . getMemoryPercentUsage ( ) ) ; other . setNumConsumers ( this . getNumConsumers ( ) ) ; other . setNumProducers ( this . getNumProducers ( ) ) ; other . setQueueSize ( this . getQueueSize ( ) ) ; other . setInflightCount ( this . getInflightCount ( ) ) ; } | Copy out the values to the given destination . |
12,883 | void init ( int n ) { bitrev = new int [ n / 4 ] ; trig = new float [ n + n / 4 ] ; log2n = ( int ) Math . rint ( Math . log ( n ) / Math . log ( 2 ) ) ; this . n = n ; int AE = 0 ; int AO = 1 ; int BE = AE + n / 2 ; int BO = BE + 1 ; int CE = BE + n / 2 ; int CO = CE + 1 ; for ( int i = 0 ; i < n / 4 ; i ++ ) { trig [ AE + i * 2 ] = ( float ) Math . cos ( ( Math . PI / n ) * ( 4 * i ) ) ; trig [ AO + i * 2 ] = ( float ) - Math . sin ( ( Math . PI / n ) * ( 4 * i ) ) ; trig [ BE + i * 2 ] = ( float ) Math . cos ( ( Math . PI / ( 2 * n ) ) * ( 2 * i + 1 ) ) ; trig [ BO + i * 2 ] = ( float ) Math . sin ( ( Math . PI / ( 2 * n ) ) * ( 2 * i + 1 ) ) ; } for ( int i = 0 ; i < n / 8 ; i ++ ) { trig [ CE + i * 2 ] = ( float ) Math . cos ( ( Math . PI / n ) * ( 4 * i + 2 ) ) ; trig [ CO + i * 2 ] = ( float ) - Math . sin ( ( Math . PI / n ) * ( 4 * i + 2 ) ) ; } { int mask = ( 1 << ( log2n - 1 ) ) - 1 ; int msb = 1 << ( log2n - 2 ) ; for ( int i = 0 ; i < n / 8 ; i ++ ) { int acc = 0 ; for ( int j = 0 ; msb >>> j != 0 ; j ++ ) if ( ( ( msb >>> j ) & i ) != 0 ) acc |= 1 << j ; bitrev [ i * 2 ] = ( ( ~ acc ) & mask ) ; bitrev [ i * 2 + 1 ] = acc ; } } } | float scale ; |
12,884 | public Converter getConverterForOperation ( String operId ) { if ( getConverters ( ) != null ) { for ( Converter converter : getConverters ( ) ) { if ( check ( converter , converter . getOperations ( ) , operId ) ) { return converter ; } } } if ( getExternalConverters ( ) != null ) { for ( ExternalConverter ecs : getExternalConverters ( ) ) { final Converter c = PresentationManager . getPm ( ) . findExternalConverter ( ecs . getId ( ) ) ; if ( c != null && check ( c , ( ecs . getOperations ( ) == null ) ? c . getOperations ( ) : ecs . getOperations ( ) , operId ) ) { return c ; } } } return null ; } | Looks for an aproppiate converter for the given operation id . |
12,885 | synchronized static int _01inverse ( Block vb , Object vl , float [ ] [ ] in , int ch , int decodepart ) { int i , j , k , l , s ; LookResidue0 look = ( LookResidue0 ) vl ; InfoResidue0 info = look . info ; int samples_per_partition = info . grouping ; int partitions_per_word = look . phrasebook . dim ; int n = info . end - info . begin ; int partvals = n / samples_per_partition ; int partwords = ( partvals + partitions_per_word - 1 ) / partitions_per_word ; if ( _01inverse_partword . length < ch ) { _01inverse_partword = new int [ ch ] [ ] [ ] ; } for ( j = 0 ; j < ch ; j ++ ) { if ( _01inverse_partword [ j ] == null || _01inverse_partword [ j ] . length < partwords ) { _01inverse_partword [ j ] = new int [ partwords ] [ ] ; } } for ( s = 0 ; s < look . stages ; s ++ ) { for ( i = 0 , l = 0 ; i < partvals ; l ++ ) { if ( s == 0 ) { for ( j = 0 ; j < ch ; j ++ ) { int temp = look . phrasebook . decode ( vb . opb ) ; if ( temp == - 1 ) { return ( 0 ) ; } _01inverse_partword [ j ] [ l ] = look . decodemap [ temp ] ; if ( _01inverse_partword [ j ] [ l ] == null ) { return ( 0 ) ; } } } for ( k = 0 ; k < partitions_per_word && i < partvals ; k ++ , i ++ ) for ( j = 0 ; j < ch ; j ++ ) { int offset = info . begin + i * samples_per_partition ; int index = _01inverse_partword [ j ] [ l ] [ k ] ; if ( ( info . secondstages [ index ] & ( 1 << s ) ) != 0 ) { CodeBook stagebook = look . fullbooks [ look . partbooks [ index ] [ s ] ] ; if ( stagebook != null ) { if ( decodepart == 0 ) { if ( stagebook . decodevs_add ( in [ j ] , offset , vb . opb , samples_per_partition ) == - 1 ) { return ( 0 ) ; } } else if ( decodepart == 1 ) { if ( stagebook . decodev_add ( in [ j ] , offset , vb . opb , samples_per_partition ) == - 1 ) { return ( 0 ) ; } } } } } } } return ( 0 ) ; } | re - using partword |
12,886 | public void gotoEnd ( ) { currentNode = tree ; while ( currentNode . hasChildren ( ) ) { currentNode = currentNode . getChildren ( ) . get ( currentNode . getChildren ( ) . size ( ) - 1 ) ; } } | This method sets the iterator onto the last tree element . |
12,887 | public boolean goForward ( ) { if ( currentNode . hasChildren ( ) ) { currentNode = currentNode . getChildren ( ) . get ( 0 ) ; return true ; } else if ( currentNode . getParent ( ) == null ) { return false ; } while ( true ) { N parent = currentNode . getParent ( ) ; if ( ( parent == null ) || ( currentNode == tree ) ) { return false ; } int index = parent . getChildren ( ) . indexOf ( currentNode ) ; if ( parent . getChildren ( ) . size ( ) > index + 1 ) { currentNode = parent . getChildren ( ) . get ( index + 1 ) ; return true ; } else { currentNode = parent ; } } } | This method walks forward one node . |
12,888 | private static HashMap < String , Module > getFileExtensionMap ( ) { if ( fileExtensionMap == null ) fileExtensionMap = new HashMap < String , Module > ( ) ; return fileExtensionMap ; } | Lazy instantiation access method |
12,889 | private static Module getModuleFromStreamByID ( ModfileInputStream input ) { Iterator < Module > iter = getModulesArray ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Module mod = iter . next ( ) ; try { if ( mod . checkLoadingPossible ( input ) ) return mod ; } catch ( IOException ex ) { } } return null ; } | Finds the appropriate loader through the IDs |
12,890 | private static Module getModuleFromStream ( ModfileInputStream input ) { Iterator < Module > iter = getModulesArray ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Module mod = iter . next ( ) ; try { Module result = mod . loadModFile ( input ) ; input . seek ( 0 ) ; return result ; } catch ( Throwable ex ) { } } return null ; } | Finds the appropriate loader through simply loading it! |
12,891 | public static Module getInstance ( URL url ) throws IOException { ModfileInputStream inputStream = null ; try { inputStream = new ModfileInputStream ( url ) ; Module mod = getModuleFromStreamByID ( inputStream ) ; if ( mod != null ) return mod . loadModFile ( inputStream ) ; else { mod = getModuleFromStream ( inputStream ) ; if ( mod != null ) return mod ; else throw new IOException ( "Unsupported MOD-Type: " + inputStream . getFileName ( ) ) ; } } catch ( Exception ex ) { Log . error ( "[ModuleFactory] Failed with loading " + url . toString ( ) , ex ) ; return null ; } finally { if ( inputStream != null ) try { inputStream . close ( ) ; } catch ( IOException ex ) { Log . error ( "IGNORED" , ex ) ; } } } | Uses the File - Extension to find a suitable loader . |
12,892 | public final static Map < String , Set < String > > loadChunks ( ) { return new HashMap < String , Set < String > > ( ) { private static final long serialVersionUID = 1L ; { put ( "max" , new HashSet < String > ( ) { private static final long serialVersionUID = 1L ; { add ( "name" ) ; add ( "number" ) ; add ( "type" ) ; } } ) ; } } ; } | Returns a map set with all expected template names and their expected arguments . |
12,893 | public static Message5WH createInfoMessage ( String what , Object ... obj ) { return new Message5WH_Builder ( ) . addWhat ( FormattingTupleWrapper . create ( what , obj ) ) . setType ( E_MessageType . INFO ) . build ( ) ; } | Creates a new information message . |
12,894 | public static Message5WH createWarningMessage ( String what , Object ... obj ) { return new Message5WH_Builder ( ) . addWhat ( FormattingTupleWrapper . create ( what , obj ) ) . setType ( E_MessageType . WARNING ) . build ( ) ; } | Creates a new warning message . |
12,895 | public static Message5WH createErrorMessage ( String what , Object ... obj ) { return new Message5WH_Builder ( ) . addWhat ( FormattingTupleWrapper . create ( what , obj ) ) . setType ( E_MessageType . ERROR ) . build ( ) ; } | Creates a new error message . |
12,896 | public boolean hasErrors ( ) { if ( this . messageHandlers . containsKey ( E_MessageType . ERROR ) ) { return ( this . messageHandlers . get ( E_MessageType . ERROR ) . getCount ( ) == 0 ) ? false : true ; } return false ; } | Returns true if the manager has errors reported false otherwise |
12,897 | public boolean hasWarnings ( ) { if ( this . messageHandlers . containsKey ( E_MessageType . WARNING ) ) { return ( this . messageHandlers . get ( E_MessageType . WARNING ) . getCount ( ) == 0 ) ? false : true ; } return false ; } | Returns true if the manager has warnings reported false otherwise |
12,898 | public boolean hasInfos ( ) { if ( this . messageHandlers . containsKey ( E_MessageType . INFO ) ) { return ( this . messageHandlers . get ( E_MessageType . INFO ) . getCount ( ) == 0 ) ? false : true ; } return false ; } | Returns true if the manager has infos reported false otherwise |
12,899 | public int getMessageCount ( E_MessageType type ) { if ( this . messageHandlers . containsKey ( type ) ) { return this . messageHandlers . get ( type ) . getCount ( ) ; } return - 1 ; } | Returns the current count for the given message type since its last initialization or reset . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.