idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
10,700
@ Programmatic public List < DocumentTemplate > findByType ( final DocumentType documentType ) { return repositoryService . allMatches ( new QueryDefault <> ( DocumentTemplate . class , "findByType" , "type" , documentType ) ) ; }
Returns all templates for a type ordered by application tenancy and date desc .
55
14
10,701
@ Programmatic public List < DocumentTemplate > findByApplicableToAtPathAndCurrent ( final String atPath ) { final LocalDate now = clockService . now ( ) ; return repositoryService . allMatches ( new QueryDefault <> ( DocumentTemplate . class , "findByApplicableToAtPathAndCurrent" , "atPath" , atPath , "now" , now ) ) ; }
Returns all templates available for a particular application tenancy ordered by most specific tenancy first and then within that the most recent first .
85
24
10,702
@ Programmatic public TranslatableString validateApplicationTenancyAndDate ( final DocumentType proposedType , final String proposedAtPath , final LocalDate proposedDate , final DocumentTemplate ignore ) { final List < DocumentTemplate > existingTemplates = findByTypeAndAtPath ( proposedType , proposedAtPath ) ; for ( DocumentTemplate existingTemplate : existingTemplates ) { if ( existingTemplate == ignore ) { continue ; } if ( java . util . Objects . equals ( existingTemplate . getDate ( ) , proposedDate ) ) { return TranslatableString . tr ( "A template already exists for this date" ) ; } if ( proposedDate == null && existingTemplate . getDate ( ) != null ) { return TranslatableString . tr ( "Must provide a date (there are existing templates that already have a date specified)" ) ; } } return null ; }
region > validate ...
178
4
10,703
public synchronized int numActiveSubTasks ( ) { int c = 0 ; for ( Future < ? > f : subTasks ) { if ( ! f . isDone ( ) && ! f . isCancelled ( ) ) { c ++ ; } } return c ; }
Count the number of active sub tasks .
59
8
10,704
public synchronized void use ( ) { assert ( ! inUse ) ; inUse = true ; compiler = com . sun . tools . javac . api . JavacTool . create ( ) ; fileManager = compiler . getStandardFileManager ( null , null , null ) ; fileManagerBase = ( BaseFileManager ) fileManager ; smartFileManager = new SmartFileManager ( fileManager ) ; context = new Context ( ) ; context . put ( JavaFileManager . class , smartFileManager ) ; ResolveWithDeps . preRegister ( context ) ; JavaCompilerWithDeps . preRegister ( context , this ) ; subTasks = new ArrayList < Future < ? > > ( ) ; }
Prepare the compiler thread for use . It is not yet started . It will be started by the executor service .
149
24
10,705
public synchronized void unuse ( ) { assert ( inUse ) ; inUse = false ; compiler = null ; fileManager = null ; fileManagerBase = null ; smartFileManager = null ; context = null ; subTasks = null ; }
Prepare the compiler thread for idleness .
51
9
10,706
private static boolean expect ( BufferedReader in , String key ) throws IOException { String s = in . readLine ( ) ; if ( s != null && s . equals ( key ) ) { return true ; } return false ; }
Expect this key on the next line read from the reader .
49
13
10,707
public ParametricStatement set ( String sql ) throws IllegalArgumentException { if ( _env != null ) { try { sql = Macro . expand ( sql , _env . call ( ) ) ; } catch ( Exception x ) { throw new IllegalArgumentException ( x . getMessage ( ) , x ) ; } } if ( _params != null ) { int count = 0 ; int qmark = sql . indexOf ( ' ' ) ; while ( qmark > 0 ) { ++ count ; qmark = sql . indexOf ( ' ' , qmark + 1 ) ; } if ( _params . length == count ) { _sql = sql ; } else { throw new IllegalArgumentException ( "Wrong number of parameters in '" + sql + ' ' ) ; } } else { List < Param > params = new ArrayList < Param > ( ) ; _sql = transformer . invoke ( new StringBuilder ( ) , params , sql ) . toString ( ) ; _params = params . toArray ( new Param [ params . size ( ) ] ) ; } return this ; }
Assigns a SQL string to this ParametricStatement .
229
12
10,708
public int executeUpdate ( Connection conn , DataObject object ) throws SQLException { PreparedStatement statement = conn . prepareStatement ( _sql ) ; try { load ( statement , object ) ; return statement . executeUpdate ( ) ; } finally { statement . close ( ) ; } }
Executes an UPDATE or DELETE statement .
60
10
10,709
public int executeUpdate ( Connection conn , DataObject [ ] objects ) throws SQLException { PreparedStatement statement = conn . prepareStatement ( _sql ) ; try { for ( DataObject object : objects ) { load ( statement , object ) ; statement . addBatch ( ) ; } int count = getAffectedRowCount ( statement . executeBatch ( ) ) ; return count ; } finally { statement . close ( ) ; } }
Executes a batch UPDATE or DELETE statement .
94
11
10,710
public long [ ] executeInsert ( Connection conn , DataObject object , boolean generatedKeys ) throws SQLException { PreparedStatement statement = conn . prepareStatement ( _sql , generatedKeys ? Statement . RETURN_GENERATED_KEYS : Statement . NO_GENERATED_KEYS ) ; try { load ( statement , object ) ; long [ ] keys = new long [ statement . executeUpdate ( ) ] ; if ( generatedKeys ) { ResultSet rs = statement . getGeneratedKeys ( ) ; for ( int i = 0 ; rs . next ( ) ; ++ i ) { keys [ i ] = rs . getLong ( 1 ) ; } rs . close ( ) ; } return keys ; } finally { statement . close ( ) ; } }
Executes an INSERT statement .
160
7
10,711
public int executeProcedure ( Connection conn , DataObject object ) throws SQLException { CallableStatement statement = conn . prepareCall ( _sql ) ; try { for ( int i = 0 ; i < _params . length ; ++ i ) { if ( ( _params [ i ] . direction & Param . OUT ) == 0 ) continue ; statement . registerOutParameter ( i + 1 , _params [ i ] . type ) ; } load ( statement , object ) ; statement . execute ( ) ; int result = statement . getUpdateCount ( ) ; if ( object != null ) { Class < ? extends DataObject > type = object . getClass ( ) ; for ( int i = 0 ; i < _params . length ; ++ i ) { if ( ( _params [ i ] . direction & Param . OUT ) == 0 ) continue ; try { Beans . setValue ( object , Beans . getKnownField ( type , _params [ i ] . name ) , statement . getObject ( i + 1 ) ) ; } catch ( NoSuchFieldException x ) { // ignore } catch ( Exception x ) { throw new SQLException ( "Exception in storage of '" + _params [ i ] . name + "' into DataObject (" + type . getName ( ) + ' ' , x ) ; } } } return result ; } finally { statement . close ( ) ; } }
Executes a callable statement that performs updates .
294
10
10,712
public void add ( T closeable , Future < ? > future ) { _pairs . add ( new Pair < T , Future < ? > > ( closeable , future ) ) ; }
Adds an AutoCloseable task and associated Future to this group .
40
13
10,713
public boolean isDone ( ) { int count = 0 ; for ( Pair < T , Future < ? > > pair : _pairs ) { if ( pair . second . isDone ( ) ) ++ count ; } return count == _pairs . size ( ) ; }
Reports whether all futures in this group has completed .
57
10
10,714
@ Override public void close ( ) { // waiting phase int count = 0 , last = 0 ; do { last = count ; try { Thread . sleep ( 500 ) ; } catch ( Exception x ) { } count = 0 ; for ( Pair < T , Future < ? > > pair : _pairs ) { if ( pair . second . isDone ( ) ) ++ count ; } } while ( ( _waiting == null || _waiting . invoke ( count , count - last ) ) && count < _pairs . size ( ) ) ; if ( _waiting != null ) _waiting . invoke ( count , - 1 ) ; // closing phase for ( Pair < T , Future < ? > > pair : _pairs ) { if ( ! pair . second . isDone ( ) ) { try { if ( _closing != null ) _closing . invoke ( pair . first , null ) ; pair . second . cancel ( true ) ; pair . first . close ( ) ; } catch ( Exception x ) { if ( _closing != null ) _closing . invoke ( pair . first , x ) ; } } } }
Closes all Futures . Waits for futures to complete then closes those still running after the waiting phase has ended .
242
24
10,715
public static Contract load ( File idlJson ) throws IOException { FileInputStream fis = new FileInputStream ( idlJson ) ; Contract c = load ( fis ) ; fis . close ( ) ; return c ; }
Loads the IDL JSON file parses it and returns a Contract . Uses the JacksonSerializer .
52
21
10,716
@ SuppressWarnings ( "unchecked" ) public static Contract load ( InputStream idlJson , Serializer ser ) throws IOException { return new Contract ( ser . readList ( idlJson ) ) ; }
Loads the IDL from the given stream using an arbitrary serializer and returns a Contract .
49
19
10,717
public Function getFunction ( String iface , String func ) throws RpcException { Interface i = interfaces . get ( iface ) ; if ( i == null ) { String msg = "Interface '" + iface + "' not found" ; throw RpcException . Error . METHOD_NOT_FOUND . exc ( msg ) ; } Function f = i . getFunction ( func ) ; if ( f == null ) { String msg = "Function '" + iface + "." + func + "' not found" ; throw RpcException . Error . METHOD_NOT_FOUND . exc ( msg ) ; } return f ; }
Returns the Function associated with the given interface and function name .
136
12
10,718
private String getName ( String s1 , String s2 ) { if ( s1 == null || "" . equals ( s1 ) ) return s2 ; else return s1 ; }
If the first String parameter is nonempty return it else return the second string parameter .
39
17
10,719
private void write ( String s ) throws SAXException { try { out . write ( s ) ; out . flush ( ) ; } catch ( IOException ioException ) { throw new SAXParseException ( "I/O error" , documentLocator , ioException ) ; } }
suit handler signature requirements
61
4
10,720
void printSaxException ( String message , SAXException e ) { System . err . println ( ) ; System . err . println ( "*** SAX Exception -- " + message ) ; System . err . println ( " SystemId = \"" + documentLocator . getSystemId ( ) + "\"" ) ; e . printStackTrace ( System . err ) ; }
Utility method to print information about a SAXException .
80
12
10,721
void printSaxParseException ( String message , SAXParseException e ) { System . err . println ( ) ; System . err . println ( "*** SAX Parse Exception -- " + message ) ; System . err . println ( " SystemId = \"" + e . getSystemId ( ) + "\"" ) ; System . err . println ( " PublicId = \"" + e . getPublicId ( ) + "\"" ) ; System . err . println ( " line number " + e . getLineNumber ( ) ) ; e . printStackTrace ( System . err ) ; }
Utility method to print information about a SAXParseException .
130
14
10,722
public void call ( final T request , final Functor < String , RemoteService . Response > process , final Functor < Void , RemoteService . Response > confirm ) { try { String message = process . invoke ( RemoteService . call ( location , endpoint , true , request ) ) ; if ( message != null ) { // clean failure throw new RuntimeException ( message ) ; } } catch ( RuntimeException x ) { if ( confirm == null ) { executor . execute ( new VitalTask < Reporting , Void > ( reporting ) { protected Void execute ( ) throws Exception { if ( getAge ( ) > DEFAULT_RETRY_LIMIT ) { try { process . invoke ( null ) ; } catch ( Exception x ) { } } else { process . invoke ( RemoteService . call ( location , recovery , repacker . invoke ( request ) ) ) ; } return null ; } } ) ; // positive! } else { executor . execute ( new VitalTask < Reporting , Void > ( reporting ) { protected Void execute ( ) throws Exception { if ( getAge ( ) > DEFAULT_RETRY_LIMIT ) { return null ; } else { confirm . invoke ( RemoteService . call ( location , recovery , repacker . invoke ( request ) ) ) ; } return null ; } } ) ; // negative! throw x ; } } }
Starts a critical call and automatically manages uncertain outcomes .
282
11
10,723
public void execute ( ) throws MojoExecutionException , MojoFailureException { if ( preverifyPath == null ) { getLog ( ) . debug ( "skip native preverification" ) ; return ; } getLog ( ) . debug ( "start native preverification" ) ; final File preverifyCmd = getAbsolutePreverifyCommand ( ) ; StreamConsumer stdoutLogger = new LogWriter ( false ) ; StreamConsumer stderrLogger = new LogWriter ( true ) ; String classPath = getClassPath ( getProject ( ) ) ; AbstractConfiguration [ ] configurations = ( AbstractConfiguration [ ] ) getPluginContext ( ) . get ( ConfiguratorMojo . GENERATED_CONFIGURATIONS_KEY ) ; for ( AbstractConfiguration configuration : configurations ) { if ( ! ( configuration instanceof NodeConfiguration ) ) { continue ; } String classifier = configuration . className . substring ( configuration . className . lastIndexOf ( ' ' ) + 1 ) ; File oldJar = checkJarFile ( classifier ) ; if ( keepJars ) { try { FileUtils . copyFile ( oldJar , getJarFile ( classifier + "-before_preverify" ) ) ; } catch ( IOException ioe ) { getLog ( ) . warn ( "could not keep old jar '" + oldJar . getAbsolutePath ( ) + "'" , ioe ) ; } } getLog ( ) . info ( "Preverifying jar: " + FileNameUtil . getAbsolutPath ( oldJar ) ) ; Commandline commandLine = new Commandline ( preverifyCmd . getPath ( ) + " -classpath " + classPath + " -d " + FileNameUtil . getAbsolutPath ( oldJar . getParentFile ( ) ) + " " + FileNameUtil . getAbsolutPath ( oldJar ) ) ; getLog ( ) . debug ( commandLine . toString ( ) ) ; try { if ( CommandLineUtils . executeCommandLine ( commandLine , stdoutLogger , stderrLogger ) != 0 ) { throw new MojoExecutionException ( "Preverification failed. Please read the log for details." ) ; } } catch ( CommandLineException cle ) { throw new MojoExecutionException ( "could not execute preverify command" , cle ) ; } } getLog ( ) . debug ( "finished preverification" ) ; }
The main method of this MoJo
527
7
10,724
public static boolean isDisplayable ( Class < ? > type ) { return Enum . class . isAssignableFrom ( type ) || type == java . net . URL . class || type == java . io . File . class || java . math . BigInteger . class . isAssignableFrom ( type ) || java . math . BigDecimal . class . isAssignableFrom ( type ) || java . util . Date . class . isAssignableFrom ( type ) || java . sql . Date . class . isAssignableFrom ( type ) || java . sql . Time . class . isAssignableFrom ( type ) || java . sql . Timestamp . class . isAssignableFrom ( type ) ; }
Tests whether a non - primitive type is directly displayable .
156
13
10,725
public static Class < ? > classForName ( String name ) throws ClassNotFoundException { if ( "void" . equals ( name ) ) return void . class ; if ( "char" . equals ( name ) ) return char . class ; if ( "boolean" . equals ( name ) ) return boolean . class ; if ( "byte" . equals ( name ) ) return byte . class ; if ( "short" . equals ( name ) ) return short . class ; if ( "int" . equals ( name ) ) return int . class ; if ( "long" . equals ( name ) ) return long . class ; if ( "float" . equals ( name ) ) return float . class ; if ( "double" . equals ( name ) ) return double . class ; return Class . forName ( name , true , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; }
Class lookup by name which also accepts primitive type names .
190
11
10,726
public static Class < ? > toPrimitive ( Class < ? > type ) { if ( type . isPrimitive ( ) ) { return type ; } else if ( type == Boolean . class ) { return Boolean . TYPE ; } else if ( type == Character . class ) { return Character . TYPE ; } else if ( type == Byte . class ) { return Byte . TYPE ; } else if ( type == Short . class ) { return Short . TYPE ; } else if ( type == Integer . class ) { return Integer . TYPE ; } else if ( type == Long . class ) { return Long . TYPE ; } else if ( type == Float . class ) { return Float . TYPE ; } else if ( type == Double . class ) { return Double . TYPE ; } else { return null ; } }
Converts a boxed type to its primitive counterpart .
167
10
10,727
public static Class < ? > [ ] boxPrimitives ( Class < ? > [ ] types ) { for ( int i = 0 ; i < types . length ; ++ i ) { types [ i ] = boxPrimitive ( types [ i ] ) ; } return types ; }
Boxes primitive types .
58
5
10,728
public static Field getKnownField ( Class < ? > type , String name ) throws NoSuchFieldException { NoSuchFieldException last = null ; do { try { Field field = type . getDeclaredField ( name ) ; field . setAccessible ( true ) ; return field ; } catch ( NoSuchFieldException x ) { last = x ; type = type . getSuperclass ( ) ; } } while ( type != null ) ; throw last ; }
Returns a known field by name from the given class disregarding its access control setting looking through all super classes if needed .
96
24
10,729
public static < T extends AccessibleObject > T accessible ( T object ) throws SecurityException { object . setAccessible ( true ) ; return object ; }
Overrides access control of an AccessibleObject facilitating fluent coding style .
32
15
10,730
@ SuppressWarnings ( "unchecked" ) public static void setValue ( Object object , Field field , Object value ) throws IllegalArgumentException , IllegalAccessException { if ( value == null ) { //if (Number.class.isAssignableFrom(field.getType())) { //value = java.math.BigDecimal.ZERO; //} else return; return ; } try { field . setAccessible ( true ) ; field . set ( object , value ) ; } catch ( IllegalArgumentException x ) { if ( value instanceof Number ) { // size of "value" bigger than that of "field"? try { Number number = ( Number ) value ; Class < ? > ftype = field . getType ( ) ; if ( Enum . class . isAssignableFrom ( ftype ) ) { field . set ( object , ftype . getEnumConstants ( ) [ number . intValue ( ) ] ) ; } else if ( BigDecimal . class . isAssignableFrom ( ftype ) ) { field . set ( object , BigDecimal . valueOf ( number . doubleValue ( ) ) ) ; } else if ( BigInteger . class . isAssignableFrom ( ftype ) ) { field . set ( object , BigInteger . valueOf ( number . longValue ( ) ) ) ; } else if ( Double . TYPE == ftype || Double . class . isAssignableFrom ( ftype ) ) { field . set ( object , number . doubleValue ( ) ) ; } else if ( Float . TYPE == ftype || Float . class . isAssignableFrom ( ftype ) ) { field . set ( object , number . floatValue ( ) ) ; } else if ( Long . TYPE == ftype || Long . class . isAssignableFrom ( ftype ) ) { field . set ( object , number . longValue ( ) ) ; } else if ( Integer . TYPE == ftype || Integer . class . isAssignableFrom ( ftype ) ) { field . set ( object , number . intValue ( ) ) ; } else if ( Short . TYPE == ftype || Short . class . isAssignableFrom ( ftype ) ) { field . set ( object , number . shortValue ( ) ) ; } else { field . set ( object , number . byteValue ( ) ) ; } } catch ( Throwable t ) { throw new IllegalArgumentException ( t ) ; } } else if ( value instanceof java . sql . Timestamp ) { try { field . set ( object , new java . sql . Date ( ( ( java . sql . Timestamp ) value ) . getTime ( ) ) ) ; } catch ( Throwable t ) { throw new IllegalArgumentException ( t ) ; } } else if ( value instanceof String ) { field . set ( object , new ValueOf ( field . getType ( ) , field . getAnnotation ( typeinfo . class ) ) . invoke ( ( String ) value ) ) ; } else { throw x ; } } }
Assigns a value to the field in an object converting value type as necessary .
652
17
10,731
public static < T > T fill ( T destination , Object source ) { if ( destination != source ) { Class < ? > stype = source . getClass ( ) ; for ( Field field : destination . getClass ( ) . getFields ( ) ) { try { Object value = field . get ( destination ) ; if ( value == null ) { field . set ( destination , stype . getField ( field . getName ( ) ) . get ( source ) ) ; } } catch ( Exception x ) { } } } return destination ; }
Fills empty identically named public fields with values from another object .
115
14
10,732
public static < T , V > T update ( T object , Class < V > type , String pattern , Bifunctor < V , String , V > updater ) { if ( type . isPrimitive ( ) ) { throw new IllegalArgumentException ( "Primitive type must be boxed" ) ; } Pattern regex = pattern != null ? Pattern . compile ( pattern ) : null ; for ( Field field : object . getClass ( ) . getFields ( ) ) { if ( ( regex == null || regex . matcher ( field . getName ( ) ) . matches ( ) ) && type . isAssignableFrom ( boxPrimitive ( field . getType ( ) ) ) ) { try { field . set ( object , updater . invoke ( field . getName ( ) , type . cast ( field . get ( object ) ) ) ) ; } catch ( Exception x ) { } } } return object ; }
Updates an object by modifying all of its public fields that match a certain name pattern or a super type with a transforming function .
196
26
10,733
public static StringBuilder print ( StringBuilder sb , Object bean , int level ) throws IntrospectionException { return print ( sb , Collections . newSetFromMap ( new IdentityHashMap < Object , Boolean > ( ) ) , bean , level ) ; }
Prints a bean to the StringBuilder .
54
9
10,734
public static < E > E get ( Class < E > type ) { ServiceLoader < E > loader = ServiceLoader . load ( type ) ; Iterator < E > iterator = loader . iterator ( ) ; if ( iterator . hasNext ( ) ) { return iterator . next ( ) ; // only one is expected } try { //loads the default implementation return ( E ) Class . forName ( getDefaultImplementationName ( type ) ) . newInstance ( ) ; } catch ( Exception e ) { throw new TruggerException ( e ) ; } }
Returns the implementation for a given class .
115
8
10,735
@ Nonnull public static IMutablePriceGraduation createSimple ( @ Nonnull final IMutablePrice aPrice ) { final PriceGraduation ret = new PriceGraduation ( aPrice . getCurrency ( ) ) ; ret . addItem ( new PriceGraduationItem ( 1 , aPrice . getNetAmount ( ) . getValue ( ) ) ) ; return ret ; }
Create a simple price graduation that contains one item with the minimum quantity of 1 .
78
16
10,736
@ Override public void contextInitialized ( ServletContextEvent event ) { super . contextInitialized ( event ) ; _dict . addTypeSet ( org . xillium . data . validation . StandardDataTypes . class ) ; _packaged = _context . getResourcePaths ( "/WEB-INF/lib/" ) ; _extended = discover ( System . getProperty ( "xillium.service.ExtensionsRoot" ) ) ; // servlet mappings must be registered before this method returns Functor < Void , ServiceModule > functor = new Functor < Void , ServiceModule > ( ) { public Void invoke ( ServiceModule module ) { _context . getServletRegistration ( "dispatcher" ) . addMapping ( "/" + module . simple + "/*" ) ; return null ; } } ; ServiceModule . scan ( _context , _packaged , functor , _logger ) ; ServiceModule . scan ( _context , _extended , functor , _logger ) ; try { XmlWebApplicationContext wac = new XmlWebApplicationContext ( ) ; wac . setServletContext ( _context ) ; wac . refresh ( ) ; wac . start ( ) ; try { // let the life cycle control take over PlatformControl controlling = wac . getBean ( CONTROLLING , PlatformControl . class ) ; ManagementFactory . getPlatformMBeanServer ( ) . registerMBean ( controlling . bind ( this , wac , Thread . currentThread ( ) . getContextClassLoader ( ) ) , new ObjectName ( controlling . getClass ( ) . getPackage ( ) . getName ( ) , "type" , controlling . getClass ( ) . getSimpleName ( ) ) ) ; if ( controlling . isAutomatic ( ) ) { controlling . reload ( ) ; } } catch ( BeansException x ) { // go ahead with platform realization realize ( wac , null ) ; } catch ( Exception x ) { _logger . warning ( Throwables . getFirstMessage ( x ) ) ; } } catch ( BeanDefinitionStoreException x ) { _logger . warning ( Throwables . getFirstMessage ( x ) ) ; } }
Tries to load an XML web application contenxt upon servlet context initialization . If a PlatformControl is detected in the web application contenxt registers it with the platform MBean server and stop . Otherwise continues to load all module contexts in the application .
468
53
10,737
public void realize ( ApplicationContext wac , ConfigurableApplicationContext child ) { if ( WebApplicationContextUtils . getWebApplicationContext ( _context ) == null ) { _context . setAttribute ( WebApplicationContext . ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE , wac ) ; } else { _logger . warning ( "Already realized" ) ; return ; } if ( child != null ) wac = child ; ServiceModuleInfo info = new ServiceModuleInfo ( ) ; if ( wac . containsBean ( PERSISTENCE ) ) { // persistence may not be there if persistent storage is not required info . persistence . first = info . persistence . second = ( Persistence ) wac . getBean ( PERSISTENCE ) ; _persistences . put ( "-" , info . persistence . first ) ; } _logger . log ( Level . CONFIG , "install packaged modules" ) ; wac = install ( wac , sort ( _context , _packaged ) , info ) ; _logger . log ( Level . CONFIG , "install extension modules" ) ; wac = install ( wac , sort ( _context , _extended ) , info ) ; _logger . log ( Level . CONFIG , "install service augmentations" ) ; for ( ServiceAugmentation fi : info . augmentations ) { fi . install ( _registry ) ; } String hide = System . getProperty ( "xillium.service.HideDescription" ) ; if ( hide == null || hide . length ( ) == 0 ) { _registry . put ( "x!/desc" , new Pair < Service , Persistence > ( new DescService ( info . descriptions ) , info . persistence . first ) ) ; _registry . put ( "x!/list" , new Pair < Service , Persistence > ( new ListService ( _registry ) , info . persistence . first ) ) ; } _registry . put ( "x!/ping" , new Pair < Service , Persistence > ( new PingService ( ) , info . persistence . first ) ) ; if ( System . getProperty ( "xillium.persistence.DisablePrecompilation" ) == null ) { for ( Persistence persistence : _persistences . values ( ) ) { if ( persistence . getTransactionManager ( ) != null ) { persistence . doReadWrite ( null , new Persistence . Task < Void , Void > ( ) { public Void run ( Void facility , Persistence persistence ) throws Exception { _logger . info ( "parametric statements compiled: " + persistence . compile ( ) ) ; return null ; } } ) ; } else { _logger . warning ( "Persistence precompilation is ON (default) but TransactionManager is not configured" ) ; } } } }
Reloads the platform with the given application context at its root .
598
14
10,738
public void destroy ( ) { XmlWebApplicationContext wac = ( XmlWebApplicationContext ) WebApplicationContextUtils . getWebApplicationContext ( _context ) ; if ( wac != null ) { _context . removeAttribute ( WebApplicationContext . ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE ) ; } else { _logger . warning ( "Nothing more to destroy" ) ; return ; } _logger . info ( "<<<< Service Platform(" + _application + ") destruction starting" ) ; MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; while ( ! _manageables . empty ( ) ) { ObjectName on = _manageables . pop ( ) ; _logger . info ( "<<<<<<<< MBean(" + on + ") unregistration starting" ) ; try { mbs . unregisterMBean ( on ) ; } catch ( Exception x ) { _logger . log ( Level . WARNING , on . toString ( ) ) ; } _logger . info ( "<<<<<<<< MBean(" + on + ") unregistration complete" ) ; } while ( ! _plca . empty ( ) ) { List < Pair < String , PlatformAware > > plcas = _plca . pop ( ) ; for ( Pair < String , PlatformAware > plca : plcas ) { _logger . info ( "<<<<<<<< PlatformAware(" + plca . first + ' ' + plca . second . getClass ( ) . getName ( ) + ") termination starting" ) ; plca . second . terminate ( _application , plca . first ) ; _logger . info ( "<<<<<<<< PlatformAware(" + plca . first + ' ' + plca . second . getClass ( ) . getName ( ) + ") termination complete" ) ; } } // finally, deregisters JDBC driver manually to prevent Tomcat 7 from complaining about memory leaks Enumeration < java . sql . Driver > drivers = java . sql . DriverManager . getDrivers ( ) ; while ( drivers . hasMoreElements ( ) ) { java . sql . Driver driver = drivers . nextElement ( ) ; _logger . info ( "<<<<<<<< JDBC Driver(" + driver + ") deregistration starting" ) ; try { java . sql . DriverManager . deregisterDriver ( driver ) ; } catch ( java . sql . SQLException x ) { _logger . log ( Level . WARNING , "Error deregistering driver " + driver , x ) ; } _logger . info ( "<<<<<<<< JDBC Driver(" + driver + ") deregistration complete" ) ; } for ( Iterator < String > it = _registry . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { if ( ! it . next ( ) . startsWith ( "x!/" ) ) it . remove ( ) ; } _registry . remove ( "x!/ping" ) ; _registry . remove ( "x!/list" ) ; _registry . remove ( "x!/desc" ) ; while ( ! _applc . empty ( ) ) { _applc . pop ( ) . close ( ) ; } wac . close ( ) ; _logger . info ( "<<<< Service Platform(" + _application + ") destruction complete" ) ; }
Unloads the platform .
748
5
10,739
private ApplicationContext install ( ApplicationContext wac , ModuleSorter . Sorted sorted , ServiceModuleInfo info ) { // scan special modules, configuring and initializing PlatformAware objects as each module is loaded wac = install ( wac , sorted . specials ( ) , info , true ) ; // scan regular modules, collecting all PlatformAware objects install ( wac , sorted . regulars ( ) , info , false ) ; if ( info . plcas . size ( ) > 0 ) { _logger . info ( "configure PlatformAware objects in regular modules" ) ; for ( Pair < String , PlatformAware > plca : info . plcas ) { _logger . info ( "Configuring REGULAR PlatformAware " + plca . second . getClass ( ) . getName ( ) ) ; plca . second . configure ( _application , plca . first ) ; } _logger . info ( "initialize PlatformAware objects in regular modules" ) ; for ( Pair < String , PlatformAware > plca : info . plcas ) { _logger . info ( "Initalizing REGULAR PlatformAware " + plca . second . getClass ( ) . getName ( ) ) ; plca . second . initialize ( _application , plca . first ) ; } _plca . push ( info . plcas ) ; info . plcas = new ArrayList < Pair < String , PlatformAware > > ( ) ; } else { _logger . info ( "No PlatformAware objects in regular modules" ) ; } return wac ; }
install service modules in the ModuleSorter . Sorted
338
11
10,740
public < T , F > T doReadOnly ( F facility , Task < T , F > task ) { return doTransaction ( facility , task , _readonly ) ; }
Executes a task within a read - only transaction . Any exception rolls back the transaction and gets rethrown as a RuntimeException .
37
27
10,741
public < T , F > T doReadWrite ( F facility , Task < T , F > task ) { return doTransaction ( facility , task , null ) ; }
Executes a task within a read - write transaction . Any exception rolls back the transaction and gets rethrown as a RuntimeException .
35
27
10,742
public ParametricStatement getParametricStatement ( String name ) { ParametricStatement statement = _statements . get ( name ) ; if ( statement != null ) { return statement ; } else { throw new RuntimeException ( "ParametricStatement '" + name + "' not found" ) ; } }
Looks up a ParametricStatement by its name .
62
10
10,743
public < T > T executeSelect ( String name , DataObject object , ResultSetWorker < T > worker ) throws Exception { ParametricQuery statement = ( ParametricQuery ) _statements . get ( name ) ; if ( statement != null ) { return statement . executeSelect ( DataSourceUtils . getConnection ( _dataSource ) , object , worker ) ; } else { throw new RuntimeException ( "ParametricQuery '" + name + "' not found" ) ; } }
Executes a SELECT statement and passes the result set to the ResultSetWorker .
102
17
10,744
public < T extends DataObject > List < T > getResults ( String name , DataObject object ) throws Exception { @ SuppressWarnings ( "unchecked" ) ObjectMappedQuery < T > statement = ( ObjectMappedQuery < T > ) _statements . get ( name ) ; if ( statement != null ) { return statement . getResults ( DataSourceUtils . getConnection ( _dataSource ) , object ) ; } else { throw new RuntimeException ( "ObjectMappedQuery '" + name + "' not found" ) ; } }
Executes a SELECT statement and returns the result set as a list of objects
118
15
10,745
public int compile ( ) throws SQLException { int count = 0 ; for ( Map . Entry < String , ParametricStatement > entry : _statements . entrySet ( ) ) { try { ParametricStatement statement = entry . getValue ( ) ; Connection connection = DataSourceUtils . getConnection ( _dataSource ) ; if ( statement instanceof ParametricQuery ) { connection . prepareStatement ( statement . getSQL ( ) ) ; } else { try { connection . prepareCall ( statement . getSQL ( ) ) ; } catch ( Exception x ) { connection . prepareStatement ( statement . getSQL ( ) ) ; } } ++ count ; } catch ( SQLException x ) { throw new SQLException ( entry . getKey ( ) , x ) ; } } return count ; }
Compile all ParametricStatement registered with this Persistence .
169
12
10,746
public void addPackageDeprecationInfo ( Content li , PackageDoc pkg ) { Tag [ ] deprs ; if ( Util . isDeprecated ( pkg ) ) { deprs = pkg . tags ( "deprecated" ) ; HtmlTree deprDiv = new HtmlTree ( HtmlTag . DIV ) ; deprDiv . addStyle ( HtmlStyle . deprecatedContent ) ; Content deprPhrase = HtmlTree . SPAN ( HtmlStyle . deprecatedLabel , deprecatedPhrase ) ; deprDiv . addContent ( deprPhrase ) ; if ( deprs . length > 0 ) { Tag [ ] commentTags = deprs [ 0 ] . inlineTags ( ) ; if ( commentTags . length > 0 ) { addInlineDeprecatedComment ( pkg , deprs [ 0 ] , deprDiv ) ; } } li . addContent ( deprDiv ) ; } }
Add the profile package deprecation information to the documentation tree .
202
13
10,747
public Content getNavLinkPrevious ( ) { Content li ; if ( prevProfile == null ) { li = HtmlTree . LI ( prevprofileLabel ) ; } else { li = HtmlTree . LI ( getHyperLink ( pathToRoot . resolve ( DocPaths . profileSummary ( prevProfile . name ) ) , prevprofileLabel , "" , "" ) ) ; } return li ; }
Get PREV PROFILE link in the navigation bar .
83
11
10,748
public Content getNavLinkNext ( ) { Content li ; if ( nextProfile == null ) { li = HtmlTree . LI ( nextprofileLabel ) ; } else { li = HtmlTree . LI ( getHyperLink ( pathToRoot . resolve ( DocPaths . profileSummary ( nextProfile . name ) ) , nextprofileLabel , "" , "" ) ) ; } return li ; }
Get NEXT PROFILE link in the navigation bar .
83
10
10,749
public ProgramElementDoc owner ( ) { Symbol osym = type . tsym . owner ; if ( ( osym . kind & Kinds . TYP ) != 0 ) { return env . getClassDoc ( ( ClassSymbol ) osym ) ; } Names names = osym . name . table . names ; if ( osym . name == names . init ) { return env . getConstructorDoc ( ( MethodSymbol ) osym ) ; } else { return env . getMethodDoc ( ( MethodSymbol ) osym ) ; } }
Return the class interface method or constructor within which this type variable is declared .
116
15
10,750
protected void activate ( final ComponentContext context ) throws InvalidSyntaxException { log . info ( "activate" ) ; bundleContext = context . getBundleContext ( ) ; sl = new ServiceListener ( ) { public void serviceChanged ( ServiceEvent event ) { if ( event . getType ( ) == ServiceEvent . UNREGISTERING ) { cache . unregisterComponentBindingsProvider ( event . getServiceReference ( ) ) ; } else if ( event . getType ( ) == ServiceEvent . REGISTERED ) { cache . registerComponentBindingsProvider ( event . getServiceReference ( ) ) ; } } } ; bundleContext . addServiceListener ( sl , "(" + Constants . OBJECTCLASS + "=" + ComponentBindingsProvider . class . getName ( ) + ")" ) ; reloadCache ( ) ; log . info ( "Activation successful" ) ; }
Executed when the service is activated .
188
8
10,751
protected void deactivate ( ComponentContext context ) { log . info ( "deactivate" ) ; bundleContext = context . getBundleContext ( ) ; bundleContext . removeServiceListener ( sl ) ; log . info ( "Deactivate successful" ) ; }
Executed when the service is deactivated .
54
9
10,752
protected void reloadCache ( ) { log . info ( "reloadCache" ) ; cache . clear ( ) ; try { ServiceReference [ ] references = bundleContext . getAllServiceReferences ( ComponentBindingsProvider . class . getCanonicalName ( ) , null ) ; if ( references != null ) { for ( ServiceReference reference : references ) { cache . registerComponentBindingsProvider ( reference ) ; } } } catch ( Exception e ) { log . error ( "Exception reloading cache of component binding providers" , e ) ; } }
Reloads the cache of Component Binding Providers
114
10
10,753
private boolean htmlSentenceTerminatorFound ( String str , int index ) { for ( int i = 0 ; i < sentenceTerminators . length ; i ++ ) { String terminator = sentenceTerminators [ i ] ; if ( str . regionMatches ( true , index , terminator , 0 , terminator . length ( ) ) ) { return true ; } } return false ; }
Find out if there is any HTML tag in the given string . If found return true else return false .
81
21
10,754
public TypeMirror getOriginalType ( javax . lang . model . type . ErrorType errorType ) { if ( errorType instanceof com . sun . tools . javac . code . Type . ErrorType ) { return ( ( com . sun . tools . javac . code . Type . ErrorType ) errorType ) . getOriginalType ( ) ; } return com . sun . tools . javac . code . Type . noType ; }
Gets the original type from the ErrorType object .
98
11
10,755
private static MimeBodyPart createBodyPart ( byte [ ] data , String type , String filename ) throws MessagingException { final MimeBodyPart attachmentPart = new MimeBodyPart ( ) ; attachmentPart . setFileName ( filename ) ; ByteArrayDataSource source = new ByteArrayDataSource ( data , type ) ; attachmentPart . setDataHandler ( new DataHandler ( source ) ) ; attachmentPart . setHeader ( "Content-ID" , createContentID ( filename ) ) ; attachmentPart . setDisposition ( MimeBodyPart . INLINE ) ; return attachmentPart ; }
Build attachment part
125
3
10,756
public T getObject ( Connection conn , DataObject object ) throws Exception { return executeSelect ( conn , object , new ResultSetMapper < SingleObjectCollector < T > > ( new SingleObjectCollector < T > ( ) ) ) . value ; }
Executes the query and returns the first row of the results as a single object .
54
17
10,757
public Collector < T > getResults ( Connection conn , DataObject object , Collector < T > collector ) throws Exception { return executeSelect ( conn , object , new ResultSetMapper < Collector < T > > ( collector ) ) ; }
Executes the query and passes the results to a Collector .
49
12
10,758
public static void preRegister ( Context context ) { context . put ( FSInfo . class , new Context . Factory < FSInfo > ( ) { public FSInfo make ( Context c ) { FSInfo instance = new CacheFSInfo ( ) ; c . put ( FSInfo . class , instance ) ; return instance ; } } ) ; }
Register a Context . Factory to create a CacheFSInfo .
70
12
10,759
public MediaType getContentType ( ) { if ( isNull ( this . contentType ) ) { contentType = getHeader ( HeaderName . CONTENT_TYPE ) . map ( MediaType :: of ) . orElse ( WILDCARD ) ; } return contentType ; }
Returns a content - type header value
59
7
10,760
public List < MediaType > getAccept ( ) { if ( isNull ( accept ) ) { List < MediaType > accepts = getHeader ( HeaderName . ACCEPT ) . map ( MediaType :: list ) . get ( ) ; this . accept = nonEmpty ( accepts ) ? accepts : singletonList ( WILDCARD ) ; } return accept ; }
Returns a accept header value
77
5
10,761
public int verify ( Request request , Response response ) { String authValue = request . getHeaders ( ) . getValues ( "Authorization" ) ; log . debug ( "Auth header value is: " + authValue ) ; if ( authValue == null ) { return Verifier . RESULT_MISSING ; } String [ ] tokenValues = authValue . split ( " " ) ; if ( tokenValues . length < 2 ) { return Verifier . RESULT_MISSING ; } if ( ! "Bearer" . equals ( tokenValues [ 0 ] ) ) { return Verifier . RESULT_INVALID ; } String token = tokenValues [ 1 ] ; log . debug ( "Token: " + token ) ; return checkToken ( token ) ; }
Verifies that the token passed is valid .
164
9
10,762
public void organizeTypeAnnotationsSignatures ( final Env < AttrContext > env , final JCClassDecl tree ) { annotate . afterRepeated ( new Worker ( ) { @ Override public void run ( ) { JavaFileObject oldSource = log . useSource ( env . toplevel . sourcefile ) ; try { new TypeAnnotationPositions ( true ) . scan ( tree ) ; } finally { log . useSource ( oldSource ) ; } } } ) ; }
Separate type annotations from declaration annotations and determine the correct positions for type annotations . This version only visits types in signatures and should be called from MemberEnter . The method takes the Annotate object as parameter and adds an Annotate . Worker to the correct Annotate queue for later processing .
103
60
10,763
public static Class < ? > classForNameWithException ( final String name , final ClassLoader cl ) throws ClassNotFoundException { if ( cl != null ) { try { return Class . forName ( name , false , cl ) ; } catch ( final ClassNotFoundException | NoClassDefFoundError e ) { // fall through and try with default classloader } } return Class . forName ( name ) ; }
Get the Class from the class name .
87
8
10,764
public static ClassLoader getContextClassLoader ( ) { return AccessController . doPrivileged ( new PrivilegedAction < ClassLoader > ( ) { @ Override public ClassLoader run ( ) { ClassLoader cl = null ; try { cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; } catch ( final SecurityException ex ) { // fall through } return cl ; } } ) ; }
Get the context class loader .
85
6
10,765
@ Override public void sendMessage ( String subject , String message ) { first . sendMessage ( subject , message ) ; second . sendMessage ( subject , message ) ; }
Sends a message that consists of a subject and a message body .
36
14
10,766
private short getCellType ( String value ) { short ret = STRING_TYPE ; if ( value . equals ( "number" ) ) ret = NUMBER_TYPE ; else if ( value . equals ( "datetime" ) ) ret = DATETIME_TYPE ; else if ( value . equals ( "boolean" ) ) ret = BOOLEAN_TYPE ; return ret ; }
Returns the cell type for the given value .
84
9
10,767
private short getDataType ( String value ) { short ret = STRING_TYPE ; if ( value . equals ( "number" ) ) ret = NUMBER_TYPE ; else if ( value . equals ( "integer" ) ) ret = INTEGER_TYPE ; else if ( value . equals ( "decimal" ) ) ret = DECIMAL_TYPE ; else if ( value . equals ( "seconds" ) ) ret = SECONDS_TYPE ; else if ( value . equals ( "datetime" ) ) ret = DATETIME_TYPE ; else if ( value . equals ( "boolean" ) ) ret = BOOLEAN_TYPE ; return ret ; }
Returns the data type for the given value .
145
9
10,768
private short getAlignment ( String value ) { short ret = ALIGN_LEFT ; if ( value . equals ( "centre" ) ) ret = ALIGN_CENTRE ; else if ( value . equals ( "left" ) ) ret = ALIGN_LEFT ; else if ( value . equals ( "right" ) ) ret = ALIGN_RIGHT ; else if ( value . equals ( "justify" ) ) ret = ALIGN_JUSTIFY ; else if ( value . equals ( "fill" ) ) ret = ALIGN_FILL ; return ret ; }
Returns the alignment for the given value .
125
8
10,769
public WritableCellFormat getCellFormat ( boolean create ) { WritableCellFormat ret = null ; if ( cellFormat != null ) ret = cellFormat ; else if ( create ) ret = new WritableCellFormat ( NumberFormats . TEXT ) ; return ret ; }
Returns the format object for this column .
57
8
10,770
private String convert ( String str , String dateFormat ) { String ret = str ; // Carry out the required string conversion long longValue = 0L ; double doubleValue = 0.0d ; // Convert the input value to a number if ( str . length ( ) > 0 ) { if ( inputType == INTEGER_TYPE || inputType == NUMBER_TYPE ) longValue = Long . parseLong ( str ) ; else if ( inputType == DECIMAL_TYPE || inputType == SECONDS_TYPE ) doubleValue = Double . parseDouble ( str ) ; else if ( inputType == DATETIME_TYPE && inputFormat . length ( ) > 0 ) longValue = parseDateTime ( str , inputFormat ) ; } // Convert seconds to milliseconds if ( inputType == SECONDS_TYPE ) doubleValue *= 1000.0d ; // Allow for cross type conversions // eg. decimal->datetime, seconds->datetime if ( inputType == DECIMAL_TYPE || inputType == SECONDS_TYPE ) longValue = ( long ) doubleValue ; else doubleValue = ( double ) longValue ; // Convert the number to the output format if ( outputType == INTEGER_TYPE ) ret = Long . toString ( longValue ) ; else if ( outputType == DECIMAL_TYPE || outputType == SECONDS_TYPE ) ret = convertDecimal ( doubleValue , outputFormat ) ; else if ( outputType == DATETIME_TYPE ) ret = convertDateTime ( longValue , outputFormat . length ( ) > 0 ? outputFormat : dateFormat ) ; else if ( outputType == STRING_TYPE ) ret = convertString ( str , outputFormat , regex ) ; return ret ; }
Convert the given string using the defined input and output formats and types .
369
15
10,771
private long parseDateTime ( String str , String format ) { return FormatUtilities . getDateTime ( str , format , false , true ) ; }
Parses the given date string in the given format to a milliseconds vale .
32
17
10,772
private String convertDateTime ( long dt , String format ) { if ( format . length ( ) == 0 ) format = Formats . DATETIME_FORMAT ; return FormatUtilities . getFormattedDateTime ( dt , format , false , 0L ) ; }
Converts the given milliseconds date value to the output date format .
60
13
10,773
private String convertDecimal ( double d , String format ) { String ret = "" ; if ( format . length ( ) > 0 ) { DecimalFormat f = new DecimalFormat ( format ) ; ret = f . format ( d ) ; } else { ret = Double . toString ( d ) ; } return ret ; }
Converts the given numeric value to the output date format .
69
12
10,774
private String convertString ( String str , String format , String expr ) { String ret = str ; String [ ] params = null ; if ( format . length ( ) > 0 ) { ret = "" ; if ( expr . length ( ) > 0 ) // Indicates a format using regex { Pattern pattern = getPattern ( expr ) ; Matcher m = pattern . matcher ( str ) ; if ( m . find ( ) ) { params = new String [ m . groupCount ( ) ] ; for ( int i = 0 ; i < m . groupCount ( ) ; i ++ ) params [ i ] = m . group ( i + 1 ) ; } } else if ( str != null ) { params = new String [ ] { str } ; } if ( params != null ) ret = String . format ( format , params ) ; } return ret ; }
Converts the given string value to the output string format .
179
12
10,775
private Pattern getPattern ( String expr ) { Pattern pattern = patterns . get ( expr ) ; if ( pattern == null ) { pattern = Pattern . compile ( expr ) ; patterns . put ( expr , pattern ) ; } return pattern ; }
Returns the pattern for the given regular expression .
49
9
10,776
public LanguageVersion languageVersion ( ) { try { Object retVal ; String methodName = "languageVersion" ; Class < ? > [ ] paramTypes = new Class < ? > [ 0 ] ; Object [ ] params = new Object [ 0 ] ; try { retVal = invoke ( methodName , JAVA_1_1 , paramTypes , params ) ; } catch ( DocletInvokeException exc ) { return JAVA_1_1 ; } if ( retVal instanceof LanguageVersion ) { return ( LanguageVersion ) retVal ; } else { messager . error ( Messager . NOPOS , "main.must_return_languageversion" , docletClassName , methodName ) ; return JAVA_1_1 ; } } catch ( NoClassDefFoundError ex ) { // for boostrapping, no Enum class. return null ; } }
Return the language version supported by this doclet . If the method does not exist in the doclet assume version 1 . 1 .
187
26
10,777
private Object invoke ( String methodName , Object returnValueIfNonExistent , Class < ? > [ ] paramTypes , Object [ ] params ) throws DocletInvokeException { Method meth ; try { meth = docletClass . getMethod ( methodName , paramTypes ) ; } catch ( NoSuchMethodException exc ) { if ( returnValueIfNonExistent == null ) { messager . error ( Messager . NOPOS , "main.doclet_method_not_found" , docletClassName , methodName ) ; throw new DocletInvokeException ( ) ; } else { return returnValueIfNonExistent ; } } catch ( SecurityException exc ) { messager . error ( Messager . NOPOS , "main.doclet_method_not_accessible" , docletClassName , methodName ) ; throw new DocletInvokeException ( ) ; } if ( ! Modifier . isStatic ( meth . getModifiers ( ) ) ) { messager . error ( Messager . NOPOS , "main.doclet_method_must_be_static" , docletClassName , methodName ) ; throw new DocletInvokeException ( ) ; } ClassLoader savedCCL = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { if ( appClassLoader != null ) // will be null if doclet class provided via API Thread . currentThread ( ) . setContextClassLoader ( appClassLoader ) ; return meth . invoke ( null , params ) ; } catch ( IllegalArgumentException exc ) { messager . error ( Messager . NOPOS , "main.internal_error_exception_thrown" , docletClassName , methodName , exc . toString ( ) ) ; throw new DocletInvokeException ( ) ; } catch ( IllegalAccessException exc ) { messager . error ( Messager . NOPOS , "main.doclet_method_not_accessible" , docletClassName , methodName ) ; throw new DocletInvokeException ( ) ; } catch ( NullPointerException exc ) { messager . error ( Messager . NOPOS , "main.internal_error_exception_thrown" , docletClassName , methodName , exc . toString ( ) ) ; throw new DocletInvokeException ( ) ; } catch ( InvocationTargetException exc ) { Throwable err = exc . getTargetException ( ) ; if ( apiMode ) throw new ClientCodeException ( err ) ; if ( err instanceof java . lang . OutOfMemoryError ) { messager . error ( Messager . NOPOS , "main.out.of.memory" ) ; } else { messager . error ( Messager . NOPOS , "main.exception_thrown" , docletClassName , methodName , exc . toString ( ) ) ; exc . getTargetException ( ) . printStackTrace ( ) ; } throw new DocletInvokeException ( ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( savedCCL ) ; } }
Utility method for calling doclet functionality
663
8
10,778
public synchronized List < ZipFileIndex > getZipFileIndexes ( boolean openedOnly ) { List < ZipFileIndex > zipFileIndexes = new ArrayList < ZipFileIndex > ( ) ; zipFileIndexes . addAll ( map . values ( ) ) ; if ( openedOnly ) { for ( ZipFileIndex elem : zipFileIndexes ) { if ( ! elem . isOpen ( ) ) { zipFileIndexes . remove ( elem ) ; } } } return zipFileIndexes ; }
Returns a list of all ZipFileIndex entries
109
9
10,779
public synchronized void setOpenedIndexes ( List < ZipFileIndex > indexes ) throws IllegalStateException { if ( map . isEmpty ( ) ) { String msg = "Setting opened indexes should be called only when the ZipFileCache is empty. " + "Call JavacFileManager.flush() before calling this method." ; throw new IllegalStateException ( msg ) ; } for ( ZipFileIndex zfi : indexes ) { map . put ( zfi . zipFile , zfi ) ; } }
Sets already opened list of ZipFileIndexes from an outside client of the compiler . This functionality should be used in a non - batch clients of the compiler .
105
33
10,780
public void close ( ) throws IOException , QdbException { this . compoundRegistry . close ( ) ; this . propertyRegistry . close ( ) ; this . descriptorRegistry . close ( ) ; this . modelRegistry . close ( ) ; this . predictionRegistry . close ( ) ; try { this . storage . close ( ) ; } finally { this . storage = null ; } try { if ( this . tempDir != null ) { FileUtil . deleteTempDirectory ( this . tempDir ) ; } } finally { this . tempDir = null ; } }
Frees resources .
122
4
10,781
public static ExceptionThrower instance ( Class < ? extends RuntimeException > classType ) { iae . throwIfNull ( classType , "The parameter of exception type can not be null." ) ; if ( classType . equals ( IllegalArgumentException . class ) ) { return iae ; } else { iae . throwIfTrue ( true , "Not fond ExceptionThrower Utils for :" , classType . getClass ( ) . toString ( ) ) ; return null ; } }
Return specify exception type singleton exceptionThrower .
104
10
10,782
@ SuppressWarnings ( "unchecked" ) public static < T > T cleanse ( T list , T element ) { if ( list == null || list == element ) { return null ; } else if ( list instanceof Pair ) { Pair < T , T > pair = ( Pair < T , T > ) list ; if ( pair . first == element ) { return pair . second ; } else if ( pair . second == element ) { return pair . first ; } else if ( pair . second instanceof Pair ) { pair . second = cleanse ( pair . second , element ) ; } } return list ; }
Cleanses an isomorphic list of a particular element . Only one thread should be updating the list at a time .
132
24
10,783
@ SuppressWarnings ( "unchecked" ) public static < T > boolean includes ( T list , T element ) { if ( list == null ) { return false ; } else if ( list == element ) { return true ; } else if ( list instanceof Pair ) { Pair < T , T > pair = ( Pair < T , T > ) list ; if ( pair . first == element || pair . second == element ) { return true ; } else if ( pair . second instanceof Pair ) { return includes ( pair . second , element ) ; } else { return false ; } } else { return false ; } }
Tests whether an isomorphic list includes a particular element .
132
12
10,784
@ SuppressWarnings ( "unchecked" ) public static < T > int count ( T list ) { if ( list == null ) { return 0 ; } else if ( list instanceof Pair ) { return 1 + count ( ( ( Pair < T , T > ) list ) . second ) ; } else { return 1 ; } }
Counts the number of elements in an isomorphic list .
72
12
10,785
@ SuppressWarnings ( "unchecked" ) public static < T > int traverse ( T list , Functor < ? , T > func ) { if ( list == null ) { return 0 ; } else if ( list instanceof Pair ) { Pair < T , T > pair = ( Pair < T , T > ) list ; func . invoke ( pair . first ) ; return 1 + traverse ( pair . second , func ) ; } else { func . invoke ( list ) ; return 1 ; } }
Traverses an isomorphic list using a Functor . The return values from the functor are discarded .
107
22
10,786
public JSONBuilder quote ( String value ) { _sb . append ( ' ' ) ; for ( int i = 0 ; i < value . length ( ) ; ++ i ) { char c = value . charAt ( i ) ; switch ( c ) { case ' ' : _sb . append ( "\\\"" ) ; break ; case ' ' : _sb . append ( "\\\\" ) ; break ; default : if ( c < 0x20 ) { _sb . append ( CTRLCHARS [ c ] ) ; } else { _sb . append ( c ) ; } break ; } } _sb . append ( ' ' ) ; return this ; }
Quotes properly a string and appends it to the JSON stream .
139
13
10,787
public JSONBuilder serialize ( Object value ) { if ( value == null ) { _sb . append ( "null" ) ; } else { Class < ? > t = value . getClass ( ) ; if ( t . isArray ( ) ) { _sb . append ( ' ' ) ; boolean hasElements = false ; for ( int i = 0 , ii = Array . getLength ( value ) ; i < ii ; ++ i ) { serialize ( Array . get ( value , i ) ) ; _sb . append ( ' ' ) ; hasElements = true ; } if ( hasElements ) { _sb . setCharAt ( _sb . length ( ) - 1 , ' ' ) ; } else { _sb . append ( ' ' ) ; } } else if ( Iterable . class . isAssignableFrom ( t ) ) { _sb . append ( ' ' ) ; boolean hasElements = false ; for ( Object object : ( Iterable < ? > ) value ) { serialize ( object ) ; _sb . append ( ' ' ) ; hasElements = true ; } if ( hasElements ) { _sb . setCharAt ( _sb . length ( ) - 1 , ' ' ) ; } else { _sb . append ( ' ' ) ; } } else if ( Number . class . isAssignableFrom ( t ) || Boolean . class . isAssignableFrom ( t ) ) { _sb . append ( value . toString ( ) ) ; } else if ( String . class == t ) { quote ( ( String ) value ) ; } else { quote ( value . toString ( ) ) ; } } return this ; }
Serializes an object and appends it to the stream .
357
12
10,788
protected String createExceptionMessage ( final String message , final Object ... messageParameters ) { if ( ArrayUtils . isEmpty ( messageParameters ) ) { return message ; } else { return String . format ( message , messageParameters ) ; } }
Create a string message by string format .
50
8
10,789
public static ApruveResponse < PaymentRequest > get ( String paymentRequestId ) { return ApruveClient . getInstance ( ) . get ( PAYMENT_REQUESTS_PATH + paymentRequestId , PaymentRequest . class ) ; }
Fetches the PaymentRequest with the given ID from Apruve .
52
15
10,790
public String toSecureHash ( ) { String apiKey = ApruveClient . getInstance ( ) . getApiKey ( ) ; String shaInput = apiKey + toValueString ( ) ; return ShaUtil . getDigest ( shaInput ) ; }
For use by merchants and depends on proper initialization of ApruveClient . Returns the secure hash for a PaymentRequest suitable for use with the property of apruve . js JavaScript library on a merchant checkout page . Use this to populate the value of apruve . secureHash .
58
57
10,791
public AnnotationValue defaultValue ( ) { return ( sym . defaultValue == null ) ? null : new AnnotationValueImpl ( env , sym . defaultValue ) ; }
Returns the default value of this element . Returns null if this element has no default .
36
17
10,792
public void sessionReady ( boolean isReady ) { if ( isReady ) { speedSlider . setValue ( session . getClockPeriod ( ) ) ; } startAction . setEnabled ( isReady ) ; speedSlider . setEnabled ( isReady ) ; stepAction . setEnabled ( isReady ) ; reloadAction . setEnabled ( isReady ) ; }
Changes the UI depending on whether the session is ready or not
76
12
10,793
@ Override public synchronized void mark ( final int limit ) { try { in . mark ( limit ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe . getMessage ( ) ) ; } }
Marks the read limit of the StringReader .
47
10
10,794
@ Override public synchronized void reset ( ) throws IOException { if ( in == null ) { throw new IOException ( "Stream Closed" ) ; } slack = null ; in . reset ( ) ; }
Resets the StringReader .
43
6
10,795
@ Override public synchronized void close ( ) throws IOException { if ( in != null ) in . close ( ) ; slack = null ; in = null ; }
Closes the Stringreader .
34
6
10,796
public Collection < String > getValues ( String property ) { Multimap < Optional < String > , String > values = properties . get ( property ) ; if ( values == null ) { return Collections . emptyList ( ) ; } return values . values ( ) ; }
Get all literal values for the property passed by parameter
56
10
10,797
public String getValue ( String property , String language ) { Multimap < Optional < String > , String > values = properties . get ( property ) ; if ( values == null ) { return null ; } Iterator < String > it = values . get ( Optional . of ( language ) ) . iterator ( ) ; return it . hasNext ( ) ? it . next ( ) : null ; }
Get a literal value for a property and language passed by parameters
83
12
10,798
public String getFirstPropertyValue ( String property ) { Iterator < String > it = getValues ( property ) . iterator ( ) ; return it . hasNext ( ) ? it . next ( ) : null ; }
Return the first value associated to the property passed by parameter
45
11
10,799
public DConnection findByAccessToken ( java . lang . String accessToken ) { return queryUniqueByField ( null , DConnectionMapper . Field . ACCESSTOKEN . getFieldName ( ) , accessToken ) ; }
find - by method for unique field accessToken
49
9