idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
36,700 | public void loadField ( String fieldName , TypeDesc type ) { getfield ( 0 , Opcode . GETFIELD , constantField ( fieldName , type ) , type ) ; } | load - field - to - stack style instructions |
36,701 | public void storeField ( String fieldName , TypeDesc type ) { putfield ( - 1 , Opcode . PUTFIELD , constantField ( fieldName , type ) , type ) ; } | store - to - field - from - stack style instructions |
36,702 | public static ClassFile buildClassFile ( String className , Class < ? > [ ] classes , String [ ] prefixes , int observerMode ) throws IllegalArgumentException { return buildClassFile ( className , classes , prefixes , null , observerMode ) ; } | Just create the bytecode for the merged class but don t load it . Since no ClassInjector is provided to resolve name conflicts the class name must be manually provided . An optional implementation of the MethodInvocationEventObserver interface may be supplied . |
36,703 | private static synchronized Class < ? > getMergedClass ( ClassInjector injector , ClassEntry [ ] classEntries , Class < ? > [ ] interfaces , int observerMode ) throws IllegalArgumentException { Map < MultiKey , String > classListMap = cMergedMap . get ( injector ) ; if ( classListMap == null ) { classListMap = new HashMap < MultiKey , String > ( 7 ) ; cMergedMap . put ( injector , classListMap ) ; } MultiKey key = generateKey ( classEntries ) ; String mergedName = classListMap . get ( key ) ; if ( mergedName != null ) { try { return injector . loadClass ( mergedName ) ; } catch ( ClassNotFoundException e ) { } } ClassFile cf ; try { cf = buildClassFile ( injector , null , classEntries , interfaces , observerMode ) ; } catch ( IllegalArgumentException e ) { e . fillInStackTrace ( ) ; throw e ; } try { OutputStream stream = injector . getStream ( cf . getClassName ( ) ) ; cf . writeTo ( stream ) ; stream . close ( ) ; } catch ( Throwable e ) { String output = outputClassToFile ( cf ) ; throw new RuntimeException ( "Error generating merged class, contents saved to: " + output , e ) ; } if ( DEBUG ) { String output = outputClassToFile ( cf ) ; System . out . println ( "Saved merged class to: " + output ) ; } Class < ? > merged ; try { merged = injector . loadClass ( cf . getClassName ( ) ) ; } catch ( ClassNotFoundException e ) { throw new InternalError ( e . toString ( ) ) ; } classListMap . put ( key , merged . getName ( ) ) ; return merged ; } | Creates a class with a public constructor whose parameter types match the given source classes . Another constructor is also created that accepts an InstanceFactory . |
36,704 | public String getExceptionStackTrace ( ) { Throwable t = getException ( ) ; if ( t == null ) { return null ; } StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; t . printStackTrace ( pw ) ; return sw . toString ( ) ; } | Returns null if there is no exception logged . |
36,705 | public String getThreadName ( ) { if ( mThreadName == null ) { Thread t = getThread ( ) ; if ( t != null ) { mThreadName = t . getName ( ) ; } } return mThreadName ; } | Returns the name of the thread that created this event . |
36,706 | public boolean deleteFile ( String filePath ) throws IOException { boolean result = false ; String path = ( String ) Utils . intern ( filePath ) ; synchronized ( path ) { File file = null ; try { file = new File ( path ) ; if ( file . exists ( ) ) { if ( file . canWrite ( ) ) { result = file . delete ( ) ; } else { String msg = "Can not delete write locked file (" + filePath + ")" ; mLog . warn ( msg ) ; throw new IOException ( msg ) ; } } else { String msg = "Cannot delete non-existant file (" + filePath + ")" ; mLog . warn ( msg ) ; throw new IOException ( msg ) ; } } catch ( IOException e ) { mLog . error ( "Error deleting: " + filePath ) ; mLog . error ( e ) ; throw e ; } } return result ; } | Delete the file at the given path . |
36,707 | public File [ ] listFiles ( String directoryPath ) { File [ ] result = null ; File directory = null ; directory = new File ( directoryPath ) ; if ( directory . isDirectory ( ) ) { result = directory . listFiles ( ) ; } return result ; } | Get the list of files within the given directory . This only returns the files in the immediate directory and is not recursive . |
36,708 | public String readFileAsString ( String filePath ) throws IOException { String result = null ; Reader reader = new BufferedReader ( new FileReader ( filePath ) ) ; StringBuilder stringBuffer = new StringBuilder ( 4096 ) ; int charRead = - 1 ; while ( ( charRead = reader . read ( ) ) >= 0 ) { stringBuffer . append ( ( char ) charRead ) ; } reader . close ( ) ; result = stringBuffer . toString ( ) ; return result ; } | Read the contents of the given file and return the value as a string . |
36,709 | public void writeToFile ( String filePath , String fileData ) throws IOException { writeToFile ( filePath , fileData , false ) ; } | Write the contents of the given file data to the file at the given path . This will replace any existing data . |
36,710 | public byte [ ] getFileBytes ( String filePath ) throws IOException { byte [ ] out = null ; String path = ( String ) Utils . intern ( filePath ) ; RandomAccessFile raf = null ; synchronized ( path ) { File file = null ; try { file = new File ( path ) ; boolean exists = file . exists ( ) ; if ( exists ) { byte [ ] fileBytes = new byte [ ( int ) file . length ( ) ] ; raf = new RandomAccessFile ( file , "r" ) ; raf . readFully ( fileBytes ) ; out = fileBytes ; } else { String msg = "File does not exist. (" + filePath + ")" ; mLog . error ( msg ) ; throw new IOException ( msg ) ; } } catch ( IOException e ) { mLog . error ( "Error writing: " + filePath ) ; mLog . error ( e ) ; throw e ; } finally { if ( raf != null ) { raf . close ( ) ; } } } return out ; } | Read the contents of the file at the given path and return the associated byte array . |
36,711 | public Integer getInteger ( String key , Integer def ) { String value = getString ( key ) ; if ( value == null ) { return def ; } else { try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { } return def ; } } | Returns the default value if the given key isn t in this PropertyMap or it isn t a valid integer . |
36,712 | public Number getNumber ( String key ) throws NumberFormatException { String value = getString ( key ) ; if ( value == null ) { return null ; } else { try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { } try { return Long . valueOf ( value ) ; } catch ( NumberFormatException e ) { } return Double . valueOf ( value ) ; } } | Returns null if the given key isn t in this PropertyMap . |
36,713 | public boolean getBoolean ( String key , boolean def ) { String value = getString ( key ) ; if ( value == null ) { return def ; } else { return "true" . equalsIgnoreCase ( value ) ; } } | Returns the default value if the given key isn t in this PropertyMap or if the the value isn t equal to true ignoring case . |
36,714 | public void putDefaults ( Map map ) { Iterator it = map . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) it . next ( ) ; Object key = entry . getKey ( ) ; if ( ! containsKey ( key ) ) { put ( key , entry . getValue ( ) ) ; } } } | Copies the entries of the given map into this one only for keys that aren t contained in this map . Is equivalent to putAll if this map is empty . |
36,715 | public synchronized void startAutoRollover ( ) { if ( mRolloverThread == null ) { mRolloverThread = new Thread ( new AutoRollover ( this ) , nextName ( ) ) ; mRolloverThread . setDaemon ( true ) ; mRolloverThread . start ( ) ; } } | Starts up a thread that automatically rolls the underlying OutputStream at the beginning of the interval even if no output is written . |
36,716 | public static SortedSet reduce ( SortedSet locations ) { SortedSet newSet = new TreeSet ( ) ; Iterator it = locations . iterator ( ) ; while ( it . hasNext ( ) ) { LocationRange next = ( LocationRange ) it . next ( ) ; if ( newSet . size ( ) == 0 ) { newSet . add ( next ) ; continue ; } if ( next . getStartLocation ( ) . compareTo ( next . getEndLocation ( ) ) >= 0 ) { continue ; } LocationRange last = ( LocationRange ) newSet . last ( ) ; if ( next . getStartLocation ( ) . compareTo ( last . getEndLocation ( ) ) <= 0 ) { if ( last . getEndLocation ( ) . compareTo ( next . getEndLocation ( ) ) <= 0 ) { newSet . remove ( last ) ; newSet . add ( new LocationRangeImpl ( last , next ) ) ; } continue ; } newSet . add ( next ) ; } return newSet ; } | Reduces a set of LocationRange objects . |
36,717 | public PropertyDescription [ ] createPropertyDescriptions ( PropertyDescriptor [ ] pds ) { if ( pds == null ) { return null ; } PropertyDescription [ ] descriptions = new PropertyDescription [ pds . length ] ; for ( int i = 0 ; i < pds . length ; i ++ ) { descriptions [ i ] = new PropertyDescription ( pds [ i ] , this ) ; } return descriptions ; } | Returns an array of PropertyDescriptions to wrap and describe the specified PropertyDescriptors . |
36,718 | public MethodDescription [ ] createMethodDescriptions ( MethodDescriptor [ ] mds ) { if ( mds == null ) { return null ; } MethodDescription [ ] descriptions = new MethodDescription [ mds . length ] ; for ( int i = 0 ; i < mds . length ; i ++ ) { descriptions [ i ] = new MethodDescription ( mds [ i ] , this ) ; } return descriptions ; } | Returns an array of MethodDescriptions to wrap and describe the specified MethodDescriptors . |
36,719 | public ParameterDescription [ ] createParameterDescriptions ( MethodDescriptor md ) { if ( md == null ) { return null ; } Method method = md . getMethod ( ) ; Class < ? > [ ] paramClasses = method . getParameterTypes ( ) ; int descriptionCount = paramClasses . length ; if ( acceptsSubstitution ( md ) ) { descriptionCount -- ; } ParameterDescriptor [ ] pds = md . getParameterDescriptors ( ) ; ParameterDescription [ ] descriptions = new ParameterDescription [ descriptionCount ] ; for ( int i = 0 ; i < descriptions . length ; i ++ ) { TypeDescription type = createTypeDescription ( paramClasses [ i ] ) ; ParameterDescriptor pd = null ; if ( pds != null && i < pds . length ) { pd = pds [ i ] ; } descriptions [ i ] = new ParameterDescription ( type , pd , this ) ; } return descriptions ; } | Returns an array of ParameterDescriptions to wrap and describe the parameters of the specified MethodDescriptor . |
36,720 | public String getFullClassName ( String fullClassName ) { String [ ] parts = parseClassName ( fullClassName ) ; String className = getInnerClassName ( parts [ 1 ] ) ; if ( parts [ 0 ] != null ) { return parts [ 0 ] + '.' + className ; } else { return className ; } } | Returns the full class name of the specified class . This method provides special formatting for inner classes . |
36,721 | public String getArrayClassName ( Class < ? > clazz ) { if ( clazz . isArray ( ) ) { return getArrayClassName ( clazz . getComponentType ( ) ) + "[]" ; } return clazz . getName ( ) ; } | Formats the class name with trailing square brackets . |
36,722 | public Class < ? > getArrayType ( Class < ? > clazz ) { if ( clazz . isArray ( ) ) { return getArrayType ( clazz . getComponentType ( ) ) ; } return clazz ; } | Returns the array type . Returns the specified class if it is not an array . |
36,723 | public BeanInfo getBeanInfo ( Class < ? > beanClass , Class < ? > stopClass ) throws IntrospectionException { return Introspector . getBeanInfo ( beanClass , stopClass ) ; } | Introspects a Java bean to learn all about its properties exposed methods below a given stop point . |
36,724 | public Object getAttributeValue ( FeatureDescriptor feature , String attributeName ) { if ( feature == null || attributeName == null ) { return null ; } return feature . getValue ( attributeName ) ; } | Retrieves the value of the named FeatureDescriptor attribute . |
36,725 | public String createPatternString ( String pattern , int length ) { if ( pattern == null ) { return null ; } int totalLength = pattern . length ( ) * length ; StringBuffer sb = new StringBuffer ( totalLength ) ; for ( int i = 0 ; i < length ; i ++ ) { sb . append ( pattern ) ; } return sb . toString ( ) ; } | Creates a String with the specified pattern repeated length times . |
36,726 | public String getDescription ( FeatureDescriptor feature ) { String description = feature . getShortDescription ( ) ; if ( description == null || description . equals ( feature . getDisplayName ( ) ) ) { description = "" ; } return description ; } | Returns the FeatureDescriptor s shortDescription or if the shortDescription is the same as the displayName . |
36,727 | public FeatureDescriptor [ ] sortDescriptors ( FeatureDescriptor [ ] fds ) { FeatureDescriptor [ ] dolly = fds . clone ( ) ; Arrays . sort ( dolly , DESCRIPTOR_COMPARATOR ) ; return dolly ; } | Sorts an array of FeatureDescriptors based on the method name and if these descriptors are MethodDescriptors by param count as well . To prevent damage to the original array a clone is made sorted and returned from this method . |
36,728 | public Object [ ] loadContextClasses ( ClassLoader loader , ContextClassEntry [ ] contextClasses ) throws Exception { if ( loader == null ) { throw new IllegalArgumentException ( "ClassLoader is null" ) ; } if ( contextClasses == null || contextClasses . length == 0 ) { throw new IllegalArgumentException ( "No Context Classes" ) ; } Vector < Class < ? > > classVector = new Vector < Class < ? > > ( contextClasses . length ) ; String [ ] prefixNames = new String [ contextClasses . length ] ; String className = null ; for ( int i = 0 ; i < contextClasses . length ; i ++ ) { className = contextClasses [ i ] . getContextClassName ( ) ; Class < ? > contextClass = loader . loadClass ( className ) ; classVector . addElement ( contextClass ) ; String prefixName = contextClasses [ i ] . getPrefixName ( ) ; if ( prefixName != null ) { prefixNames [ i ] = prefixName + "$" ; } else { prefixNames [ i ] = null ; } } Class < ? > [ ] classes = new Class < ? > [ classVector . size ( ) ] ; classVector . copyInto ( classes ) ; return new Object [ ] { classes , prefixNames } ; } | Loads and returns the runtime context classes specified by the ContextClassEntry array . |
36,729 | public boolean isLikelyContextClass ( Class < ? > clazz ) { return ( OutputReceiver . class . isAssignableFrom ( clazz ) || getClassName ( clazz ) . toLowerCase ( ) . endsWith ( "context" ) ) ; } | Returns true if it is likely that the specified class serves as a Tea runtime context class . |
36,730 | public MethodDescriptor [ ] getTeaContextMethodDescriptors ( Class < ? > contextClass , boolean specifiedClassOnly ) { Vector < MethodDescriptor > v = new Vector < MethodDescriptor > ( ) ; MethodDescriptor [ ] methodDescriptors = null ; try { BeanInfo beanInfo = getBeanInfo ( contextClass ) ; methodDescriptors = beanInfo . getMethodDescriptors ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } if ( methodDescriptors != null ) { Method [ ] methods = contextClass . getMethods ( ) ; if ( methods . length > methodDescriptors . length ) { methodDescriptors = addMissingContextMethodDescriptors ( methods , methodDescriptors ) ; } for ( int i = 0 ; i < methodDescriptors . length ; i ++ ) { MethodDescriptor md = methodDescriptors [ i ] ; Class < ? > declaringClass = md . getMethod ( ) . getDeclaringClass ( ) ; if ( declaringClass != Object . class && ! md . isHidden ( ) && ( ! specifiedClassOnly || declaringClass == contextClass ) ) { v . addElement ( md ) ; } } } methodDescriptors = new MethodDescriptor [ v . size ( ) ] ; v . copyInto ( methodDescriptors ) ; sortMethodDescriptors ( methodDescriptors ) ; return methodDescriptors ; } | Gets the MethodDescriptors of the specified context class |
36,731 | public MethodDescriptor [ ] getTeaContextMethodDescriptors ( Class < ? > [ ] contextClasses ) { Vector < MethodDescriptor > v = new Vector < MethodDescriptor > ( ) ; Hashtable < Method , Method > methods = new Hashtable < Method , Method > ( ) ; if ( contextClasses != null ) { for ( int i = 0 ; i < contextClasses . length ; i ++ ) { Class < ? > c = contextClasses [ i ] ; if ( c == null ) { continue ; } MethodDescriptor [ ] mds = getTeaContextMethodDescriptors ( c , false ) ; for ( int j = 0 ; j < mds . length ; j ++ ) { MethodDescriptor md = mds [ j ] ; Method m = md . getMethod ( ) ; if ( methods . get ( m ) == null ) { methods . put ( m , m ) ; v . addElement ( md ) ; } } } } MethodDescriptor [ ] methodDescriptors = new MethodDescriptor [ v . size ( ) ] ; v . copyInto ( methodDescriptors ) ; sortMethodDescriptors ( methodDescriptors ) ; return methodDescriptors ; } | Gets the complete combined set of MethodDescriptors for the specified context classes . |
36,732 | public String getTeaFullClassName ( Class < ? > clazz ) { if ( isImplicitTeaImport ( clazz ) ) { return getClassName ( clazz ) ; } return getFullClassName ( clazz ) ; } | Returns the full class name of the specified class . This method provides special formatting for array and inner classes . If the specified class is implicitly imported by Tea then its package is omitted in the returned name . |
36,733 | public boolean isImplicitTeaImport ( String classOrPackageName ) { if ( classOrPackageName == null ) { return false ; } if ( cPrimativeClasses . get ( classOrPackageName ) != null ) { return true ; } for ( int i = 0 ; i < IMPLICIT_TEA_IMPORTS . length ; i ++ ) { String prefix = IMPLICIT_TEA_IMPORTS [ i ] ; if ( classOrPackageName . startsWith ( prefix ) ) { return true ; } } return false ; } | Returns true if the specified class or package is implicitly imported by Tea . |
36,734 | public boolean compareFileExtension ( String fileName , String extension ) { if ( fileName == null || extension == null ) { return false ; } fileName = fileName . toLowerCase ( ) . trim ( ) ; extension = extension . toLowerCase ( ) ; return ( fileName . endsWith ( extension ) ) ; } | Returns true if the specified fileName ends with the specified file extension . |
36,735 | protected MethodDescriptor [ ] addMissingContextMethodDescriptors ( Method [ ] methods , MethodDescriptor [ ] methodDescriptors ) { List < Method > methodNames = new ArrayList < Method > ( methodDescriptors . length ) ; Vector < MethodDescriptor > mds = new Vector < MethodDescriptor > ( methods . length ) ; for ( int i = 0 ; i < methodDescriptors . length ; i ++ ) { methodNames . add ( methodDescriptors [ i ] . getMethod ( ) ) ; mds . add ( methodDescriptors [ i ] ) ; } for ( int i = 0 ; i < methods . length ; i ++ ) { if ( ! methodNames . contains ( methods [ i ] ) ) { mds . add ( new MethodDescriptor ( methods [ i ] ) ) ; } } methodDescriptors = new MethodDescriptor [ mds . size ( ) ] ; mds . copyInto ( methodDescriptors ) ; return methodDescriptors ; } | Works around a bug in java . beans . Introspector where sub - interfaces do not return their parent s methods in the method descriptor array . |
36,736 | public TypeDescription getType ( ) { if ( mType == null ) { mType = getTeaToolsUtils ( ) . createTypeDescription ( getPropertyDescriptor ( ) . getPropertyType ( ) ) ; } return mType ; } | Returns the property s type |
36,737 | public boolean isDeprecated ( ) { Method method = getPropertyDescriptor ( ) . getReadMethod ( ) ; return ( method == null ? false : getTeaToolsUtils ( ) . isDeprecated ( method ) ) ; } | Returns whether the given property is deprecated based on whether any of its read methods are deprecated . |
36,738 | public static ClassInjector getInstance ( ClassLoader loader ) { ClassInjector injector = null ; synchronized ( cShared ) { Reference ref = ( Reference ) cShared . get ( loader ) ; if ( ref != null ) { injector = ( ClassInjector ) ref . get ( ) ; } if ( injector == null ) { injector = new ClassInjector ( loader ) ; cShared . put ( loader , new WeakReference ( injector ) ) ; } return injector ; } } | Returns a shared ClassInjector instance for the given ClassLoader . |
36,739 | private static long getScaledValue ( FileBuffer buffer , int scale , long position ) throws IOException { return getScaledValue ( new byte [ 8 ] , buffer , scale , position ) ; } | temporary byte array . |
36,740 | private static void putScaledValue ( FileBuffer buffer , int scale , long position , long value ) throws IOException { putScaledValue ( new byte [ 8 ] , buffer , scale , position , value ) ; } | temorary byte array . |
36,741 | public void deleteFile ( long id ) throws IOException { if ( id >= getFileCount ( ) ) { return ; } Long key = new Long ( id ) ; InternalFile file = openInternal ( key ) ; try { file . lock ( ) . acquireWriteLock ( ) ; try { mFileTableLock . acquireWriteLock ( ) ; file . delete ( ) ; mOpenFiles . remove ( key ) ; } finally { mFileTableLock . releaseLock ( ) ; } } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } finally { file . lock ( ) . releaseLock ( ) ; } } | Deletes the specified file . Opening it up again re - creates it . |
36,742 | public void truncateFileCount ( long count ) throws IOException { if ( count < 0 ) { throw new IllegalArgumentException ( "count < 0: " + count ) ; } try { mFileTableLock . acquireUpgradableLock ( ) ; long oldCount = getFileCount ( ) ; if ( count >= oldCount ) { return ; } mFileTableLock . acquireWriteLock ( ) ; try { for ( long id = oldCount ; -- id >= count ; ) { deleteFile ( id ) ; } mFileTable . truncate ( count * mFileTableEntrySize ) ; } finally { mFileTableLock . releaseLock ( ) ; } } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } finally { mFileTableLock . releaseLock ( ) ; } } | Truncating the file count deletes any files with ids at or above the new count . |
36,743 | final int calcLevels ( long length ) { int index = Arrays . binarySearch ( mLevelMaxSizes , length ) ; return ( index < 0 ) ? ~ index : index ; } | Calculates the level of indirection needed to access a block in a file of the given length . If the level is zero the file table points directly to a data block . If the level is one the file table points to file table block . A file table block contains block ids which map to data blocks or more file table blocks . |
36,744 | final void freeBlock ( long blockId ) throws IOException { if ( blockId == 0 ) { } else { try { mFreeBlocksBitlist . lock ( ) . acquireWriteLock ( ) ; mFreeBlocksBitlist . set ( blockId ) ; if ( mFirstFreeBlock == 0 || blockId < mFirstFreeBlock ) { setFirstFreeBlock ( blockId ) ; } } catch ( InterruptedException e ) { throw new InterruptedIOException ( ) ; } finally { mFreeBlocksBitlist . lock ( ) . releaseLock ( ) ; } } } | Attempting to free block 0 or a block that is already free has no effect . |
36,745 | final long getBlockId ( long refBlockId , int index ) throws IOException { if ( refBlockId == 0 ) { return 0 ; } return getBlockId ( mBackingFile , refBlockId * mBlockSize + index ) ; } | Returns 0 if referring block is 0 . |
36,746 | public void doGet ( HttpServletRequest req , HttpServletResponse res ) { getTemplateData ( req , res , req . getPathInfo ( ) ) ; } | Retrieves all the templates that are newer that the timestamp specified by the client . The pathInfo from the request specifies which templates are desired . QueryString parameters timeStamp and ??? provide |
36,747 | public final synchronized Template getTemplate ( String name ) throws ClassNotFoundException , NoSuchMethodException , LinkageError { Template template = mTemplates . get ( name ) ; if ( template == null ) { template = loadTemplate ( name ) ; mTemplates . put ( name , template ) ; } return template ; } | Get or load a template by its full name . The full name of a template has . characters to separate name parts and it does not include a Java package prefix . |
36,748 | private Class < ? > getTemplateClass ( ) { String fqName = getTargetPackage ( ) + "." + getName ( ) ; try { mTemplateClass = getCompiler ( ) . loadClass ( fqName ) ; } catch ( ClassNotFoundException nx ) { try { mTemplateClass = getCompiler ( ) . loadClass ( getName ( ) ) ; } catch ( ClassNotFoundException nx2 ) { return null ; } } return mTemplateClass ; } | Load the template . |
36,749 | public static boolean exists ( Compiler c , String name , CompilationUnit from ) { String fqName = getFullyQualifiedName ( resolveName ( name , from ) ) ; try { c . loadClass ( fqName ) ; return true ; } catch ( ClassNotFoundException nx ) { try { c . loadClass ( resolveName ( name , from ) ) ; return true ; } catch ( ClassNotFoundException nx2 ) { return false ; } } } | Test to see of the template can be loaded before CompiledTemplate can be constructed . |
36,750 | public Template getParseTree ( ) { getTemplateClass ( ) ; if ( findExecuteMethod ( ) == null ) throw new IllegalArgumentException ( "Cannot locate compiled template entry point." ) ; reflectParameters ( ) ; mTree = new Template ( mCallerInfo , new Name ( mCallerInfo , getName ( ) ) , mParameters , mSubParam , null , null ) ; mTree . setReturnType ( new Type ( mExecuteMethod . getReturnType ( ) , mExecuteMethod . getGenericReturnType ( ) ) ) ; return mTree ; } | This method is called by JavaClassGenerator during the compile phase . It overrides the method in CompilationUnit and returns just the reflected template signature . |
36,751 | public String getTargetPackage ( ) { return mCaller != null && mCaller . getTargetPackage ( ) != null ? mCaller . getTargetPackage ( ) : TEMPLATE_PACKAGE ; } | Return the package name that this CompilationUnit should be compiled into . |
36,752 | public synchronized boolean enqueue ( Transaction transaction ) { mTotalEnqueueAttempts ++ ; if ( transaction == null || mThreadPool . isClosed ( ) ) { return false ; } int queueSize ; if ( ( queueSize = mQueue . size ( ) ) >= mMaxSize ) { if ( mListeners . size ( ) > 0 ) { TransactionQueueEvent event = new TransactionQueueEvent ( this , transaction ) ; Iterator it = mListeners . iterator ( ) ; while ( it . hasNext ( ) ) { ( ( TransactionQueueListener ) it . next ( ) ) . transactionQueueFull ( event ) ; } } return false ; } if ( ! mSuspended ) { if ( ! ensureWaitingThread ( ) ) { return false ; } } mTotalEnqueued ++ ; TransactionQueueEvent event = new TransactionQueueEvent ( this , transaction ) ; mQueue . addLast ( event ) ; if ( ++ queueSize > mPeakQueueSize ) { mPeakQueueSize = queueSize ; } notify ( ) ; if ( mListeners . size ( ) > 0 ) { Iterator it = mListeners . iterator ( ) ; while ( it . hasNext ( ) ) { ( ( TransactionQueueListener ) it . next ( ) ) . transactionEnqueued ( event ) ; } } return true ; } | Enqueues a transaction that will be serviced when a worker is available . If the queue is full or cannot accept new transactions the transaction is not enqueued and false is returned . |
36,753 | public synchronized TransactionQueueData getStatistics ( ) { return new TransactionQueueData ( this , mTimeLapseStart , System . currentTimeMillis ( ) , mQueue . size ( ) , mThreadCount , mServicingCount , mPeakQueueSize , mPeakThreadCount , mPeakServicingCount , mTotalEnqueueAttempts , mTotalEnqueued , mTotalServiced , mTotalExpired , mTotalServiceExceptions , mTotalUncaughtExceptions , mTotalQueueDuration , mTotalServiceDuration ) ; } | Returns a snapshot of the statistics on this TransactionQueue . |
36,754 | public synchronized void resetStatistics ( ) { mPeakQueueSize = 0 ; mPeakThreadCount = 0 ; mPeakServicingCount = 0 ; mTotalEnqueueAttempts = 0 ; mTotalEnqueued = 0 ; mTotalServiced = 0 ; mTotalExpired = 0 ; mTotalServiceExceptions = 0 ; mTotalUncaughtExceptions = 0 ; mTotalQueueDuration = 0 ; mTotalServiceDuration = 0 ; mTimeLapseStart = System . currentTimeMillis ( ) ; } | Resets all time lapse statistics . |
36,755 | public synchronized void applyProperties ( PropertyMap properties ) { if ( properties . containsKey ( "max.size" ) ) { setMaximumSize ( properties . getInt ( "max.size" ) ) ; } if ( properties . containsKey ( "max.threads" ) ) { setMaximumThreads ( properties . getInt ( "max.threads" ) ) ; } if ( properties . containsKey ( "timeout.idle" ) ) { setIdleTimeout ( properties . getNumber ( "timeout.idle" ) . longValue ( ) ) ; } if ( properties . containsKey ( "timeout.transaction" ) ) { setTransactionTimeout ( properties . getNumber ( "timeout.transaction" ) . longValue ( ) ) ; } if ( "true" . equalsIgnoreCase ( properties . getString ( "tune.size" ) ) ) { addTransactionQueueListener ( new TransactionQueueSizeTuner ( ) ) ; } if ( "true" . equalsIgnoreCase ( properties . getString ( "tune.threads" ) ) ) { addTransactionQueueListener ( new TransactionQueueThreadTuner ( ) ) ; } } | Understands and applies the following integer properties . |
36,756 | synchronized TransactionQueueEvent nextTransactionEvent ( ) throws InterruptedException { if ( mQueue . isEmpty ( ) ) { if ( mIdleTimeout != 0 ) { if ( mIdleTimeout < 0 ) { wait ( ) ; } else { wait ( mIdleTimeout ) ; } } } if ( mQueue . isEmpty ( ) ) { return null ; } return ( TransactionQueueEvent ) mQueue . removeFirst ( ) ; } | Returns null when the TransactionQueue should go idle . |
36,757 | public int compareTo ( NameValuePair < T > other ) { String otherName = other . mName ; if ( mName == null ) { return otherName == null ? 0 : 1 ; } if ( otherName == null ) { return - 1 ; } return mName . compareToIgnoreCase ( otherName ) ; } | Comparison is based on case - insensitive ordering of name . |
36,758 | public String getDetailedMessage ( ) { String prepend = getSourceInfoMessage ( ) ; if ( prepend == null || prepend . length ( ) == 0 ) { return mMessage ; } else { return prepend + ": " + mMessage ; } } | Returns the detailed message by prepending the standard message with source file information . |
36,759 | public String getSourceInfoMessage ( ) { String msg ; if ( mUnit == null ) { if ( mInfo == null ) { msg = "" ; } else { msg = String . valueOf ( mInfo . getLine ( ) ) ; } } else { if ( mInfo == null ) { msg = mUnit . getName ( ) ; } else { msg = mUnit . getName ( ) + ':' + mInfo . getLine ( ) ; } } return msg ; } | Get the source file information associated with this event . The source file information includes the name of the associated template and potential line number . |
36,760 | public static InetAddressResolver listenFor ( String host , InetAddressListener listener ) { synchronized ( cResolvers ) { InetAddressResolver resolver = ( InetAddressResolver ) cResolvers . get ( host ) ; if ( resolver == null ) { resolver = new InetAddressResolver ( host ) ; cResolvers . put ( host , resolver ) ; } resolver . addListener ( listener ) ; return resolver ; } } | Resolve the host name into InetAddresses and listen for changes . The caller must save a reference to the resolver to prevent it from being reclaimed by the garbage collector . |
36,761 | private synchronized boolean resolveAddresses ( ) { boolean changed ; try { InetAddress [ ] addresses = InetAddress . getAllByName ( mHost ) ; if ( mResolutionResults instanceof UnknownHostException ) { changed = true ; } else { Arrays . sort ( addresses , new Comparator ( ) { public int compare ( Object a , Object b ) { return ( ( InetAddress ) a ) . getHostAddress ( ) . compareTo ( ( ( InetAddress ) b ) . getHostAddress ( ) ) ; } } ) ; changed = ! Arrays . equals ( addresses , ( InetAddress [ ] ) mResolutionResults ) ; } mResolutionResults = addresses ; } catch ( UnknownHostException e ) { changed = ! ( mResolutionResults instanceof UnknownHostException ) ; mResolutionResults = e ; } if ( changed ) { int size = mListeners . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { notifyListener ( ( InetAddressListener ) mListeners . get ( i ) ) ; } } return changed ; } | Returns true if anything changed from the last time this was invoked . |
36,762 | private static final String trimFirstWord ( String s ) { s = s . trim ( ) ; char [ ] chars = s . toCharArray ( ) ; int firstSpace = - 1 ; for ( int i = 0 ; i < chars . length ; i ++ ) { char c = chars [ i ] ; if ( Character . isWhitespace ( c ) ) { firstSpace = i ; break ; } } if ( firstSpace == - 1 ) { return s ; } s = s . substring ( firstSpace ) . trim ( ) ; s = capitalize ( s ) ; return s ; } | Trims off the first word of the specified string and capitalizes the new first word |
36,763 | public String getTagValue ( String tagName ) { String value = null ; if ( mReadMethod != null ) { value = mReadMethod . getTagValue ( tagName ) ; } if ( value == null && mWriteMethod != null ) { value = mWriteMethod . getTagValue ( tagName ) ; } return value ; } | Overridden to check both the read and write MethodDocs for the tag |
36,764 | private String getMethodCommentText ( ) { String text = null ; if ( mReadMethod != null ) { text = mReadMethod . getCommentText ( ) ; } if ( text == null && mWriteMethod != null ) { text = mWriteMethod . getCommentText ( ) ; } if ( text == null || text . trim ( ) . length ( ) == 0 ) { text = getTagValue ( "return" ) ; } return text ; } | Checks both the read and write MethodDocs for a comment |
36,765 | String createTemplateServerRequest ( String servletPath , String templateName ) { String pathInfo = servletPath . substring ( servletPath . indexOf ( "/" , TEMPLATE_LOAD_PROTOCOL . length ( ) ) ) ; if ( templateName != null ) { pathInfo = pathInfo + templateName ; } return pathInfo ; } | turns a template name and a servlet path into a |
36,766 | private Map < String , TemplateSourceInfo > retrieveTemplateMap ( ) { Map < String , TemplateSourceInfo > templateMap = new TreeMap < String , TemplateSourceInfo > ( ) ; String remoteSource = mRemoteSourceDir ; if ( ! remoteSource . endsWith ( "/" ) ) { remoteSource = remoteSource + "/" ; } try { HttpClient tsClient = getTemplateServerClient ( remoteSource ) ; HttpClient . Response response = tsClient . setURI ( createTemplateServerRequest ( remoteSource , null ) ) . setPersistent ( true ) . getResponse ( ) ; if ( response != null && response . getStatusCode ( ) == 200 ) { Reader rin = new InputStreamReader ( new BufferedInputStream ( response . getInputStream ( ) ) ) ; StreamTokenizer st = new StreamTokenizer ( rin ) ; st . resetSyntax ( ) ; st . wordChars ( '!' , '{' ) ; st . wordChars ( '}' , '}' ) ; st . whitespaceChars ( 0 , ' ' ) ; st . parseNumbers ( ) ; st . quoteChar ( '|' ) ; st . eolIsSignificant ( true ) ; String templateName = null ; int tokenID = 0 ; while ( ( tokenID = st . nextToken ( ) ) != StreamTokenizer . TT_EOF ) { if ( tokenID == '|' || tokenID == StreamTokenizer . TT_WORD ) { templateName = st . sval ; } else if ( tokenID == StreamTokenizer . TT_NUMBER && templateName != null ) { templateName = templateName . substring ( 1 ) ; templateMap . put ( templateName . replace ( '/' , '.' ) , new TemplateSourceInfo ( templateName , remoteSource , ( long ) st . nval ) ) ; templateName = null ; } } } } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } return templateMap ; } | creates a map relating the templates found on the template server to the timestamp on the sourcecode |
36,767 | public synchronized static TypeDesc forClass ( Class < ? > clazz ) { if ( clazz == null ) { return null ; } TypeDesc type = cClassesToInstances . get ( clazz ) ; if ( type != null ) { return type ; } if ( clazz . isArray ( ) ) { type = forClass ( clazz . getComponentType ( ) ) . toArrayType ( ) ; } else if ( clazz . isPrimitive ( ) ) { if ( clazz == int . class ) { type = INT ; } if ( clazz == boolean . class ) { type = BOOLEAN ; } if ( clazz == char . class ) { type = CHAR ; } if ( clazz == byte . class ) { type = BYTE ; } if ( clazz == long . class ) { type = LONG ; } if ( clazz == float . class ) { type = FLOAT ; } if ( clazz == double . class ) { type = DOUBLE ; } if ( clazz == short . class ) { type = SHORT ; } if ( clazz == void . class ) { type = VOID ; } } else { String name = clazz . getName ( ) ; type = intern ( new ObjectType ( generateDescriptor ( name ) , name ) ) ; } cClassesToInstances . put ( clazz , type ) ; return type ; } | Acquire a TypeDesc from any class including primitives and arrays . |
36,768 | public static TypeDesc forDescriptor ( String desc ) throws IllegalArgumentException { TypeDesc td ; int cursor = 0 ; int dim = 0 ; try { char c ; while ( ( c = desc . charAt ( cursor ++ ) ) == '[' ) { dim ++ ; } switch ( c ) { case 'V' : td = VOID ; break ; case 'Z' : td = BOOLEAN ; break ; case 'C' : td = CHAR ; break ; case 'B' : td = BYTE ; break ; case 'S' : td = SHORT ; break ; case 'I' : td = INT ; break ; case 'J' : td = LONG ; break ; case 'F' : td = FLOAT ; break ; case 'D' : td = DOUBLE ; break ; case 'L' : if ( dim > 0 ) { desc = desc . substring ( dim ) ; cursor = 1 ; } StringBuffer name = new StringBuffer ( desc . length ( ) - 2 ) ; while ( ( c = desc . charAt ( cursor ++ ) ) != ';' ) { if ( c == '/' ) { c = '.' ; } name . append ( c ) ; } td = intern ( new ObjectType ( desc , name . toString ( ) ) ) ; break ; default : throw invalidDescriptor ( desc ) ; } } catch ( NullPointerException e ) { throw invalidDescriptor ( desc ) ; } catch ( IndexOutOfBoundsException e ) { throw invalidDescriptor ( desc ) ; } if ( cursor != desc . length ( ) ) { throw invalidDescriptor ( desc ) ; } while ( -- dim >= 0 ) { td = td . toArrayType ( ) ; } return td ; } | Acquire a TypeDesc from a type descriptor . This syntax is described in section 4 . 3 . 2 Field Descriptors . |
36,769 | public String getMessage ( ) { Throwable rock = getUndeclaredThrowable ( ) ; if ( rock != null ) { return rock . getMessage ( ) ; } else { return super . getMessage ( ) ; } } | overridden Throwable methods |
36,770 | static ConstantClassInfo make ( ConstantPool cp , String className , int dim ) { ConstantInfo ci = new ConstantClassInfo ( cp , className , dim ) ; return ( ConstantClassInfo ) cp . addConstant ( ci ) ; } | Used to describe an array class . |
36,771 | public void addReadUrl ( String url ) { if ( readUrlLoggingEnabled == false ) { return ; } int paramIndex = url . indexOf ( '?' ) ; String filteredUrl = url ; if ( paramIndex != - 1 ) { filteredUrl = url . substring ( 0 , paramIndex ) ; } AtomicLong count = ( AtomicLong ) __UrlMap . get ( filteredUrl ) ; if ( count == null ) { count = new AtomicLong ( 1 ) ; __UrlMap . put ( filteredUrl , count ) ; } else { count . incrementAndGet ( ) ; } } | Adds the URL to the list if it doesn t already exist . Or increment the hit count otherwise . |
36,772 | public Scope [ ] getChildren ( ) { if ( mChildren == null ) { return new Scope [ 0 ] ; } else { return mChildren . toArray ( new Scope [ mChildren . size ( ) ] ) ; } } | Returns an empty array if this scope has no children . |
36,773 | public Variable declareVariable ( Variable var , boolean isPrivate ) { if ( mVariables . containsKey ( var ) ) { var = mVariables . get ( var ) ; } else { mVariables . put ( var , var ) ; } mDeclared . put ( var . getName ( ) , var ) ; if ( isPrivate ) { if ( mPrivateVars == null ) { mPrivateVars = new HashSet < Variable > ( 7 ) ; } mPrivateVars . add ( var ) ; } else { if ( mPrivateVars != null ) { mPrivateVars . remove ( var ) ; } } return var ; } | Declare a variable for use in this scope . If no variable of this name and type has been defined it is added to the shared set of pooled variables . Returns the actual Variable object that should be used instead . |
36,774 | public void declareVariables ( Variable [ ] vars ) { for ( int i = 0 ; i < vars . length ; i ++ ) { vars [ i ] = declareVariable ( vars [ i ] ) ; } } | Declare new variables in this scope . Entries in the array are replaced with actual Variable objects that should be used instead . |
36,775 | public Variable getDeclaredVariable ( String name , boolean publicOnly ) { Variable var = mDeclared . get ( name ) ; if ( var != null ) { if ( ! publicOnly || mPrivateVars == null || ! mPrivateVars . contains ( var ) ) { return var ; } } if ( mParent != null ) { return mParent . getDeclaredVariable ( name ) ; } return null ; } | Returns a declared variable by name . Search begins in this scope and moves up into parent scopes . If not found null is returned . A public - only variable can be requested . |
36,776 | private Variable [ ] getLocallyDeclaredVariables ( ) { Collection < Variable > vars = mDeclared . values ( ) ; return vars . toArray ( new Variable [ vars . size ( ) ] ) ; } | Returns all the variables declared in this scope . |
36,777 | public boolean bindToVariable ( VariableRef ref ) { String name = ref . getName ( ) ; Variable var = getDeclaredVariable ( name ) ; if ( var != null ) { ref . setType ( null ) ; ref . setVariable ( var ) ; mVariableRefs . add ( ref ) ; return true ; } else { return false ; } } | Attempt to bind variable reference to a variable in this scope or a parent scope . If the variable to bind to isn t available or doesn t exist false is returned . |
36,778 | public VariableRef [ ] getVariableRefs ( ) { Collection < VariableRef > allRefs = new ArrayList < VariableRef > ( ) ; fillVariableRefs ( allRefs , this ) ; return allRefs . toArray ( new VariableRef [ allRefs . size ( ) ] ) ; } | Returns all the variable references made from this scope and all child scopes . |
36,779 | public VariableRef [ ] getLocalVariableRefs ( ) { VariableRef [ ] refs = new VariableRef [ mVariableRefs . size ( ) ] ; return mVariableRefs . toArray ( refs ) ; } | Returns all the references made from this scope to variables declared in this scope or in a parent . |
36,780 | public VariableRef [ ] getOutOfScopeVariableRefs ( ) { Scope parent ; if ( ( parent = getParent ( ) ) == null ) { return new VariableRef [ 0 ] ; } Collection < VariableRef > allRefs = new ArrayList < VariableRef > ( ) ; fillVariableRefs ( allRefs , this ) ; Collection < VariableRef > refs = new ArrayList < VariableRef > ( allRefs . size ( ) ) ; Iterator < VariableRef > it = allRefs . iterator ( ) ; while ( it . hasNext ( ) ) { VariableRef ref = it . next ( ) ; Variable var = ref . getVariable ( ) ; if ( var != null && parent . getDeclaredVariable ( var . getName ( ) ) == var ) { refs . add ( ref ) ; } } VariableRef [ ] refsArray = new VariableRef [ refs . size ( ) ] ; return refs . toArray ( refsArray ) ; } | Returns all the references made from this scope and all child scopes to variables declared outside of this scope . |
36,781 | public boolean isEnclosing ( Scope scope ) { for ( ; scope != null ; scope = scope . getParent ( ) ) { if ( this == scope ) { return true ; } } return false ; } | Returns true if this scope is the same as or a parent of the one given . |
36,782 | public Scope getEnclosingScope ( Scope scope ) { for ( Scope s = this ; s != null ; s = s . getParent ( ) ) { if ( s . isEnclosing ( scope ) ) { return s ; } } return null ; } | Returns the innermost enclosing scope of this and the one given . If no enclosing scope exists null is returned . |
36,783 | public boolean hasPrimitivePeer ( ) { if ( mObjectClass == Integer . class || mObjectClass == Boolean . class || mObjectClass == Byte . class || mObjectClass == Character . class || mObjectClass == Short . class || mObjectClass == Long . class || mObjectClass == Float . class || mObjectClass == Double . class || mObjectClass == Void . class ) { return true ; } return false ; } | Returns true if this type is not primitive but it has a primitive type peer . |
36,784 | public Type toPrimitive ( ) { if ( mPrimitive ) { return this ; } else { Class < ? > primitive = convertToPrimitive ( mObjectClass ) ; if ( primitive . isPrimitive ( ) ) { return new Type ( primitive ) ; } else { return new Type ( mGenericType , primitive ) ; } } } | Returns a new type from this one that represents a primitive type . If this type cannot be represented by a primitive then this is returned . |
36,785 | public Type toNonNull ( ) { if ( isNonNull ( ) ) { return this ; } else { return new Type ( this ) { private static final long serialVersionUID = 1L ; public boolean isNonNull ( ) { return true ; } public boolean isNullable ( ) { return false ; } public Type toNullable ( ) { return Type . this ; } } ; } } | Returns this type converted such that it cannot reference null . |
36,786 | public Type [ ] getArrayIndexTypes ( ) throws IntrospectionException { if ( ! mCheckedForArrayLookup ) { checkForArrayLookup ( ) ; } return mArrayIndexTypes == null ? null : ( Type [ ] ) mArrayIndexTypes . clone ( ) ; } | If this Type supports array lookup then return the index type . Because the index type may be overloaded an array is returned . Null is returned if this Type doesn t support array lookup . |
36,787 | public Method [ ] getArrayAccessMethods ( ) throws IntrospectionException { if ( ! mCheckedForArrayLookup ) { checkForArrayLookup ( ) ; } return mArrayAccessMethods == null ? null : ( Method [ ] ) mArrayAccessMethods . clone ( ) ; } | If this Type supports array lookup then return all of the methods that can be called to access the array . If there are no methods then an empty array is returned . Null is returned only if this Type doesn t support array lookup . |
36,788 | public Type getIterationElementType ( ) throws IntrospectionException { if ( ! mCheckedForIteration ) { mCheckedForIteration = true ; if ( mIterationElementType != null ) return mIterationElementType ; if ( mNaturalClass . isArray ( ) ) { mIterationElementType = getArrayElementType ( ) ; } else if ( Collection . class . isAssignableFrom ( mNaturalClass ) || Map . class . isAssignableFrom ( mNaturalClass ) ) { mIterationElementType = getIterationType ( mGenericType ) ; if ( mIterationElementType == null || mIterationElementType == OBJECT_TYPE ) { try { Field field = mNaturalClass . getField ( BeanAnalyzer . ELEMENT_TYPE_FIELD_NAME ) ; if ( field . getType ( ) == Class . class && Modifier . isStatic ( field . getModifiers ( ) ) ) { mIterationElementType = new Type ( ( Class < ? > ) field . get ( null ) ) ; } } catch ( NoSuchFieldException e ) { } catch ( IllegalAccessException e ) { } } } if ( mIterationElementType == null ) { mIterationElementType = Type . OBJECT_TYPE ; } } return mIterationElementType ; } | If this type supports iteration then the element type is returned . Otherwise null is returned . |
36,789 | public boolean isReverseIterationSupported ( ) { return mNaturalClass . isArray ( ) || List . class . isAssignableFrom ( mNaturalClass ) || Set . class . isAssignableFrom ( mNaturalClass ) || Map . class . isAssignableFrom ( mNaturalClass ) ; } | Returns true if this type supports iteration in the reverse direction . |
36,790 | public Type setArrayElementType ( Type elementType ) throws IntrospectionException { Type type = new Type ( mGenericType , mNaturalClass ) ; type . checkForArrayLookup ( ) ; type . mArrayElementType = elementType ; return type ; } | Accessed by the TypeChecker to override the default . |
36,791 | public Type getCompatibleType ( Type other ) { if ( other == null ) { return null ; } if ( equals ( other ) ) { if ( this == NULL_TYPE ) { return other ; } else { return this ; } } Class < ? > classA = mObjectClass ; Class < ? > classB = other . mObjectClass ; Type compat ; if ( classA == Void . class ) { if ( classB == Void . class ) { compat = this ; } else { return null ; } } else if ( classB == Void . class ) { return null ; } else if ( other == NULL_TYPE ) { compat = this . toNullable ( ) ; } else if ( this == NULL_TYPE ) { compat = other . toNullable ( ) ; } else if ( Number . class . isAssignableFrom ( classA ) && Number . class . isAssignableFrom ( classB ) ) { Class < ? > clazz = compatibleNumber ( classA , classB ) ; if ( isPrimitive ( ) && other . isPrimitive ( ) ) { compat = new Type ( clazz , convertToPrimitive ( clazz ) ) ; } else { compat = new Type ( clazz ) ; } } else { compat = new Type ( findCommonBaseClass ( classA , classB ) ) ; } if ( isNonNull ( ) && other . isNonNull ( ) ) { compat = compat . toNonNull ( ) ; } return compat ; } | Returns a type that is compatible with this type and the one passed in . The type returned is selected using a best - fit algorithm . |
36,792 | public static Type preserveType ( Type currentType , Type newType ) { Type result = newType ; if ( newType != null && currentType != null && currentType . getObjectClass ( ) == newType . getObjectClass ( ) ) { if ( newType . getGenericType ( ) . getGenericType ( ) instanceof Class && ! ( currentType . getGenericType ( ) . getGenericType ( ) instanceof Class ) ) { if ( newType . isNonNull ( ) && ! currentType . isNonNull ( ) ) { result = currentType . toNonNull ( ) ; } else if ( ! newType . isNonNull ( ) && currentType . isNonNull ( ) ) { result = currentType . toNullable ( ) ; } } } return result ; } | Preserve the current type s generic information with the specified new type if they have the same class . |
36,793 | public static Class < ? > findCommonBaseClass ( Class < ? > a , Class < ? > b ) { Class < ? > clazz = findCommonBaseClass0 ( a , b ) ; if ( clazz != null && clazz . isInterface ( ) ) { if ( clazz . getMethods ( ) . length <= 0 ) { } } return clazz ; } | Returns the most specific common superclass or interface that can be used to represent both of the specified classes . Null is only returned if either class refers to a primitive type and isn t the same as the other class . |
36,794 | private static Class < ? > convertToObject ( Class < ? > type ) { if ( type == int . class ) { return Integer . class ; } else if ( type == boolean . class ) { return Boolean . class ; } else if ( type == byte . class ) { return Byte . class ; } else if ( type == char . class ) { return Character . class ; } else if ( type == short . class ) { return Short . class ; } else if ( type == long . class ) { return Long . class ; } else if ( type == float . class ) { return Float . class ; } else if ( type == double . class ) { return Double . class ; } else if ( type == void . class ) { return Void . class ; } else { return type ; } } | If class passed in represents a primitive type its object peer is returned . Otherwise it is returned unchanged . |
36,795 | public int convertableFrom ( Type other , boolean vararg ) { int cost = convertableFrom ( other ) ; if ( cost < 0 ) { return cost ; } return ( vararg ? cost + 40 : cost ) ; } | Check if a type is convertable including support for varargs . If varargs is true then this will add 40 to the total cost such that non - varargs will always take precedence . |
36,796 | static ConstantIntegerInfo make ( ConstantPool cp , int value ) { ConstantInfo ci = new ConstantIntegerInfo ( value ) ; return ( ConstantIntegerInfo ) cp . addConstant ( ci ) ; } | Will return either a new ConstantIntegerInfo object or one already in the constant pool . If it is a new ConstantIntegerInfo it will be inserted into the pool . |
36,797 | public List < CompileEvent > getErrors ( ) { List < CompileEvent > errors = new ArrayList < CompileEvent > ( ) ; for ( CompileEvent event : mIssues ) { if ( event . isError ( ) ) { errors . add ( event ) ; } } return errors ; } | Retrieves the set of errors that were reported via the compileError method . |
36,798 | public List < CompileEvent > getWarnings ( ) { List < CompileEvent > warnings = new ArrayList < CompileEvent > ( ) ; for ( CompileEvent event : mIssues ) { if ( event . isWarning ( ) ) { warnings . add ( event ) ; } } return warnings ; } | Retrieves the set of warnings that were reported via the compileWarning method . |
36,799 | public String [ ] getPagination ( String text , int maxChars , String splitValue , String [ ] HTMLBalanceTags ) { int count ; int lastSplitCount ; String tempHolder = " " ; List < String > list = new ArrayList < String > ( ) ; boolean secondRunThrough = false ; if ( ( getCharCount ( text ) <= maxChars ) ) { list . add ( text ) ; return list . toArray ( new String [ list . size ( ) ] ) ; } String [ ] splits = split ( text , splitValue , HTMLBalanceTags ) ; int len = splits . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( i == len - 2 ) { lastSplitCount = getCharCount ( splits [ i + 1 ] ) ; if ( lastSplitCount <= maxChars / 2 ) { splits [ i ] = splits [ i ] + " " + splits [ i + 1 ] ; list . add ( tempHolder + splits [ i ] ) ; return list . toArray ( new String [ list . size ( ) ] ) ; } } if ( secondRunThrough ) { count = getCharCount ( tempHolder + splits [ i ] ) ; } else { count = getCharCount ( splits [ i ] ) ; } if ( count >= maxChars || i + 1 == len ) { list . add ( tempHolder + splits [ i ] ) ; secondRunThrough = false ; tempHolder = " " ; } else { tempHolder = tempHolder + splits [ i ] ; secondRunThrough = true ; } } return list . toArray ( new String [ list . size ( ) ] ) ; } | Paginate the given text input so that each page contains no more than the given maximum number of characters . The length of each page is based on the text only ignoring any HTML tags . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.