idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
10,900
public static < T > T instantiateClass ( final Class < T > clazz , final Class < ? > [ ] parameterTypes , final Object [ ] parameterValues ) throws BeanInstantiationException { if ( clazz . isInterface ( ) ) { throw new BeanInstantiationException ( clazz , CLASS_IS_INTERFACE ) ; } try { Constructor < T > constructor = clazz . getConstructor ( parameterTypes ) ; T newInstance = constructor . newInstance ( parameterValues ) ; return newInstance ; } catch ( Exception e ) { throw new BeanInstantiationException ( clazz , NO_DEFAULT_CONSTRUCTOR_FOUND , e ) ; } }
Create and initialize a new instance of the given class by given parameterTypes and parameterValues .
10,901
public static boolean isDataObject ( final Object object ) { if ( object == null ) { return true ; } Class < ? > clazz = object . getClass ( ) ; return isDataClass ( clazz ) ; }
Returns true if the given object class is 8 primitive class or their wrapper class or String class or null .
10,902
public static boolean isDataClass ( final Class < ? > clazz ) { if ( clazz == null || clazz . isPrimitive ( ) ) { return true ; } boolean isWrapperClass = contains ( WRAPPER_CLASSES , clazz ) ; if ( isWrapperClass ) { return true ; } boolean isDataClass = contains ( DATA_PRIMITIVE_CLASS , clazz ) ; if ( isDataClass ) { return true ; } return false ; }
Returns true if the given class is 8 primitive class or their wrapper class or String class or null .
10,903
public static String stringFor ( int m ) { switch ( m ) { case CUFFT_R2C : return "CUFFT_R2C" ; case CUFFT_C2R : return "CUFFT_C2R" ; case CUFFT_C2C : return "CUFFT_C2C" ; case CUFFT_D2Z : return "CUFFT_D2Z" ; case CUFFT_Z2D : return "CUFFT_Z2D" ; case CUFFT_Z2Z : return "CUFFT_Z2Z" ; } return "INVALID cufftType: " + m ; }
Returns the String identifying the given cufftType
10,904
public void setContract ( Contract c ) { super . setContract ( c ) ; for ( Field f : fields . values ( ) ) { f . setContract ( c ) ; } }
Sets the Contract associated with this Struct . Propagates to Fields .
10,905
public Map < String , Field > getFieldsPlusParents ( ) { Map < String , Field > tmp = new HashMap < String , Field > ( ) ; tmp . putAll ( fields ) ; if ( extend != null && ! extend . equals ( "" ) ) { Struct parent = contract . getStructs ( ) . get ( extend ) ; tmp . putAll ( parent . getFieldsPlusParents ( ) ) ; } return tmp ; }
Returns a Map of the Fields belonging to this Struct and all its ancestors . Keys are the Field names .
10,906
public List < String > getFieldNamesPlusParents ( ) { List < String > tmp = new ArrayList < String > ( ) ; tmp . addAll ( getFieldNames ( ) ) ; if ( extend != null && ! extend . equals ( "" ) ) { Struct parent = contract . getStructs ( ) . get ( extend ) ; tmp . addAll ( parent . getFieldNamesPlusParents ( ) ) ; } return tmp ; }
Returns a List of the Field names belonging to this Struct and all its ancestors .
10,907
public void add ( Collection < MobileApplication > mobileApplications ) { for ( MobileApplication mobileApplication : mobileApplications ) this . mobileApplications . put ( mobileApplication . getId ( ) , mobileApplication ) ; }
Adds the mobile application list to the mobile applications for the account .
10,908
private FileSystem getFileSystemSafe ( ) throws IOException { try { fs . getFileStatus ( new Path ( "/" ) ) ; return fs ; } catch ( NullPointerException e ) { throw new IOException ( "file system not initialized" ) ; } }
throws an IOException if the current FileSystem isn t working
10,909
public ETriState isValidPostalCode ( final Locale aCountry , final String sPostalCode ) { final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry ( aCountry ) ; if ( aPostalCountry == null ) return ETriState . UNDEFINED ; return ETriState . valueOf ( aPostalCountry . isValidPostalCode ( sPostalCode ) ) ; }
Check if the passed postal code is valid for the passed country .
10,910
public boolean isValidPostalCodeDefaultYes ( final Locale aCountry , final String sPostalCode ) { return isValidPostalCode ( aCountry , sPostalCode ) . getAsBooleanValue ( true ) ; }
Check if the passed postal code is valid for the passed country . If no information for that specific country is defined the postal code is assumed valid!
10,911
public boolean isValidPostalCodeDefaultNo ( final Locale aCountry , final String sPostalCode ) { return isValidPostalCode ( aCountry , sPostalCode ) . getAsBooleanValue ( false ) ; }
Check if the passed postal code is valid for the passed country . If no information for that specific country is defined the postal code is assumed invalid!
10,912
public ICommonsList < String > getPostalCodeExamples ( final Locale aCountry ) { final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry ( aCountry ) ; return aPostalCountry == null ? null : aPostalCountry . getAllExamples ( ) ; }
Get a list of possible postal code examples for the passed country .
10,913
public ServiceRegistration < ? > registerService ( String clazz , Object service , Dictionary < String , ? > properties ) { MockServiceReference < Object > serviceReference = new MockServiceReference < Object > ( getBundle ( ) , properties ) ; if ( serviceRegistrations . get ( clazz ) == null ) { serviceRegistrations . put ( clazz , new ArrayList < ServiceReference < ? > > ( ) ) ; } serviceRegistrations . get ( clazz ) . add ( serviceReference ) ; serviceImplementations . put ( serviceReference , service ) ; notifyListenersAboutNewService ( clazz , serviceReference ) ; return new MockServiceRegistration < Object > ( this , serviceReference ) ; }
Register a service with the bundle context .
10,914
public void addServiceListener ( ServiceListener listener , String filter ) throws InvalidSyntaxException { if ( null == filteredServiceListeners . get ( filter ) ) { filteredServiceListeners . put ( filter , new ArrayList < ServiceListener > ( 1 ) ) ; } filteredServiceListeners . get ( filter ) . add ( listener ) ; }
Register a listener for a service using a filter expression .
10,915
public void removeServiceListener ( ServiceListener listener ) { for ( Entry < String , List < ServiceListener > > filteredList : filteredServiceListeners . entrySet ( ) ) { filteredList . getValue ( ) . remove ( listener ) ; } }
Remove a listener object
10,916
public String [ ] getLoggerList ( ) { try { Enumeration < Logger > currentLoggers = LogManager . getLoggerRepository ( ) . getCurrentLoggers ( ) ; List < String > loggerNames = new ArrayList < String > ( ) ; while ( currentLoggers . hasMoreElements ( ) ) { loggerNames . add ( currentLoggers . nextElement ( ) . getName ( ) ) ; } return loggerNames . toArray ( new String [ 0 ] ) ; } catch ( RuntimeException e ) { logger . warn ( "Exception getting logger names" , e ) ; throw e ; } }
Returns the list of active loggers .
10,917
private void checkHead ( Token token , Optional < Integer > optHead ) { if ( optHead . isPresent ( ) ) { int head = optHead . get ( ) ; Preconditions . checkArgument ( head >= 0 && head <= tokens . size ( ) , String . format ( "Head should refer to token or 0: %s" , token ) ) ; } }
Check that the head is connected .
10,918
public static Long getValue ( final Long value , final Long defaultValue ) { return value == null ? defaultValue : value ; }
Returns defaultValue if given value is null ; else returns it self .
10,919
public boolean read ( ) throws IOException { valid = false ; File file = new File ( filename ) ; FileReader reader = new FileReader ( file ) ; if ( file . exists ( ) ) { contents = getContents ( reader , "\n" ) ; if ( contents != null ) valid = true ; else logger . severe ( "Unable to read file contents: " + file . getAbsolutePath ( ) ) ; } else { logger . severe ( "File does not exist: " + file . getAbsolutePath ( ) ) ; } try { if ( reader != null ) reader . close ( ) ; } catch ( IOException e ) { } return valid ; }
Reads the contents of the file .
10,920
public boolean read ( InputStream stream ) throws IOException { valid = false ; InputStreamReader reader = new InputStreamReader ( stream ) ; contents = getContents ( reader , "\n" ) ; if ( contents != null ) valid = true ; else logger . severe ( "Unable to read file contents: " + filename ) ; try { if ( reader != null ) reader . close ( ) ; } catch ( IOException e ) { } return valid ; }
Reads the contents of the given stream .
10,921
private String getContents ( Reader reader , String terminator ) throws IOException { String line = null ; StringBuffer buff = new StringBuffer ( ) ; BufferedReader in = new BufferedReader ( reader ) ; while ( ( line = in . readLine ( ) ) != null ) { buff . append ( line ) ; if ( terminator != null ) buff . append ( terminator ) ; } reader . close ( ) ; return buff . toString ( ) ; }
Read the contents of the file using the given reader .
10,922
private void readObject ( ObjectInputStream s ) throws IOException , ClassNotFoundException { s . defaultReadObject ( ) ; type = null ; types = null ; }
Explicitly set all transient fields .
10,923
public void generatePdf ( OutputStream out , List < Map < String , Object > > rows , List < ColumnDef > columns ) { try { Document document = new Document ( ) ; PdfWriter . getInstance ( document , out ) ; if ( columns == null ) { if ( rows . size ( ) > 0 ) return ; columns = new ArrayList < ColumnDef > ( CollectionUtils . collect ( rows . get ( 0 ) . keySet ( ) , new Transformer ( ) { public Object transform ( final Object input ) { return new ColumnDef ( ) { { setName ( ( String ) input ) ; } } ; } } ) ) ; } if ( columns . size ( ) > 14 ) document . setPageSize ( PageSize . A1 ) ; else if ( columns . size ( ) > 10 ) document . setPageSize ( PageSize . A2 ) ; else if ( columns . size ( ) > 7 ) document . setPageSize ( PageSize . A3 ) ; else document . setPageSize ( PageSize . A4 ) ; document . open ( ) ; Font font = FontFactory . getFont ( FontFactory . COURIER , 8 , Font . NORMAL , BaseColor . BLACK ) ; Font headerFont = FontFactory . getFont ( FontFactory . COURIER , 8 , Font . BOLD , BaseColor . BLACK ) ; int size = columns . size ( ) ; PdfPTable table = new PdfPTable ( size ) ; for ( ColumnDef column : columns ) { PdfPCell c1 = new PdfPCell ( new Phrase ( column . getName ( ) , headerFont ) ) ; c1 . setHorizontalAlignment ( Element . ALIGN_CENTER ) ; table . addCell ( c1 ) ; } table . setHeaderRows ( 1 ) ; if ( rows != null ) for ( Map < String , Object > row : rows ) { for ( ColumnDef column : columns ) { table . addCell ( new Phrase ( String . valueOf ( row . get ( column . getName ( ) ) ) , font ) ) ; } } document . add ( table ) ; document . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
Takes the output and transforms it into a PDF file .
10,924
public void generateCsv ( OutputStream out , List < Map < String , Object > > rows , List < ColumnDef > columns ) { ICsvMapWriter csvWriter = null ; try { csvWriter = new CsvMapWriter ( new OutputStreamWriter ( out ) , CsvPreference . STANDARD_PREFERENCE ) ; String [ ] header = new String [ ] { } ; CellProcessor [ ] processors = new CellProcessor [ ] { } ; if ( columns != null ) { header = ( String [ ] ) CollectionUtils . collect ( columns , new Transformer ( ) { public Object transform ( Object input ) { ColumnDef column = ( ColumnDef ) input ; return column . getName ( ) ; } } ) . toArray ( new String [ 0 ] ) ; processors = ( CellProcessor [ ] ) CollectionUtils . collect ( columns , new Transformer ( ) { public Object transform ( Object input ) { return new Optional ( ) ; } } ) . toArray ( new CellProcessor [ 0 ] ) ; } else if ( rows . size ( ) > 0 ) { header = new ArrayList < String > ( rows . get ( 0 ) . keySet ( ) ) . toArray ( new String [ 0 ] ) ; processors = ( CellProcessor [ ] ) CollectionUtils . collect ( rows . get ( 0 ) . keySet ( ) , new Transformer ( ) { public Object transform ( Object input ) { return new Optional ( ) ; } } ) . toArray ( new CellProcessor [ 0 ] ) ; } if ( header . length > 0 ) csvWriter . writeHeader ( header ) ; if ( rows != null ) for ( Map < String , Object > row : rows ) { csvWriter . write ( row , header , processors ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { if ( csvWriter != null ) { try { csvWriter . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } }
Takes the output and transforms it into a csv file .
10,925
public void generateXls ( OutputStream out , List < Map < String , Object > > rows , List < ColumnDef > columns ) { try { Workbook wb = new HSSFWorkbook ( ) ; String safeName = WorkbookUtil . createSafeSheetName ( "Report" ) ; Sheet reportSheet = wb . createSheet ( safeName ) ; short rowc = 0 ; Row nrow = reportSheet . createRow ( rowc ++ ) ; short cellc = 0 ; if ( rows == null ) return ; if ( columns == null && rows . size ( ) > 0 ) { columns = new ArrayList < ColumnDef > ( CollectionUtils . collect ( rows . get ( 0 ) . keySet ( ) , new Transformer ( ) { public Object transform ( final Object input ) { return new ColumnDef ( ) { { setName ( ( String ) input ) ; } } ; } } ) ) ; } if ( columns != null ) { for ( ColumnDef column : columns ) { Cell cell = nrow . createCell ( cellc ++ ) ; cell . setCellValue ( column . getName ( ) ) ; } } for ( Map < String , Object > row : rows ) { nrow = reportSheet . createRow ( rowc ++ ) ; cellc = 0 ; for ( ColumnDef column : columns ) { Cell cell = nrow . createCell ( cellc ++ ) ; cell . setCellValue ( String . valueOf ( row . get ( column . getName ( ) ) ) ) ; } } wb . write ( out ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Takes the output and transforms it into a Excel file .
10,926
private void readPackageListFromFile ( String path , DocFile pkgListPath ) throws Fault { DocFile file = pkgListPath . resolve ( DocPaths . PACKAGE_LIST ) ; if ( ! ( file . isAbsolute ( ) || linkoffline ) ) { file = file . resolveAgainst ( DocumentationTool . Location . DOCUMENTATION_OUTPUT ) ; } try { if ( file . exists ( ) && file . canRead ( ) ) { boolean pathIsRelative = ! DocFile . createFileForInput ( configuration , path ) . isAbsolute ( ) && ! isUrl ( path ) ; readPackageList ( file . openInputStream ( ) , path , pathIsRelative ) ; } else { throw new Fault ( configuration . getText ( "doclet.File_error" , file . getPath ( ) ) , null ) ; } } catch ( IOException exc ) { throw new Fault ( configuration . getText ( "doclet.File_error" , file . getPath ( ) ) , exc ) ; } }
Read the package - list file which is available locally .
10,927
private void sort ( List < ClassDoc > list ) { List < ClassDoc > classes = new ArrayList < ClassDoc > ( ) ; List < ClassDoc > interfaces = new ArrayList < ClassDoc > ( ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { ClassDoc cd = list . get ( i ) ; if ( cd . isClass ( ) ) { classes . add ( cd ) ; } else { interfaces . add ( cd ) ; } } list . clear ( ) ; list . addAll ( classes ) ; list . addAll ( interfaces ) ; }
Sort the given mixed list of classes and interfaces to a list of classes followed by interfaces traversed . Don t sort alphabetically .
10,928
public static < T > T runCallableWithCpuCores ( Callable < T > task , int cpuCores ) throws ExecutionException , InterruptedException { ForkJoinPool forkJoinPool = new ForkJoinPool ( cpuCores ) ; return forkJoinPool . submit ( task ) . get ( ) ; }
Creates a custom thread pool that are executed in parallel processes with the given number of the cpu cores
10,929
public static < T > T runAsyncSupplierWithCpuCores ( Supplier < T > supplier , int cpuCores ) throws ExecutionException , InterruptedException { ForkJoinPool forkJoinPool = new ForkJoinPool ( cpuCores ) ; CompletableFuture < T > future = CompletableFuture . supplyAsync ( supplier , forkJoinPool ) ; return future . get ( ) ; }
Creates a custom thread pool that are executed in parallel processes with the will run with the given number of the cpu cores
10,930
public static Thread [ ] resolveRunningThreads ( ) { final Set < Thread > threadSet = Thread . getAllStackTraces ( ) . keySet ( ) ; final Thread [ ] threadArray = threadSet . toArray ( new Thread [ threadSet . size ( ) ] ) ; return threadArray ; }
Finds all threads the are currently running .
10,931
public final Trace alert ( Class < ? > c , String message ) { return _trace . alert ( c , message ) ; }
Reports an error condition .
10,932
public Iterable < DFactory > queryByBaseUrl ( java . lang . String baseUrl ) { return queryByField ( null , DFactoryMapper . Field . BASEURL . getFieldName ( ) , baseUrl ) ; }
query - by method for field baseUrl
10,933
public Iterable < DFactory > queryByClientId ( java . lang . String clientId ) { return queryByField ( null , DFactoryMapper . Field . CLIENTID . getFieldName ( ) , clientId ) ; }
query - by method for field clientId
10,934
public Iterable < DFactory > queryByClientSecret ( java . lang . String clientSecret ) { return queryByField ( null , DFactoryMapper . Field . CLIENTSECRET . getFieldName ( ) , clientSecret ) ; }
query - by method for field clientSecret
10,935
private Sentence constructSentence ( List < Token > tokens ) throws IOException { Sentence sentence ; try { sentence = new SimpleSentence ( tokens , strict ) ; } catch ( IllegalArgumentException e ) { throw new IOException ( e . getMessage ( ) ) ; } return sentence ; }
Construct a sentence . If strictness is used and invariants do not hold convert the exception to an IOException .
10,936
public boolean checkAccess ( AccessFlags flags ) { boolean isPublic = flags . is ( AccessFlags . ACC_PUBLIC ) ; boolean isProtected = flags . is ( AccessFlags . ACC_PROTECTED ) ; boolean isPrivate = flags . is ( AccessFlags . ACC_PRIVATE ) ; boolean isPackage = ! ( isPublic || isProtected || isPrivate ) ; if ( ( showAccess == AccessFlags . ACC_PUBLIC ) && ( isProtected || isPrivate || isPackage ) ) return false ; else if ( ( showAccess == AccessFlags . ACC_PROTECTED ) && ( isPrivate || isPackage ) ) return false ; else if ( ( showAccess == 0 ) && ( isPrivate ) ) return false ; else return true ; }
Checks access of class field or method .
10,937
public static boolean matchProduces ( InternalRoute route , InternalRequest < ? > request ) { if ( nonEmpty ( request . getAccept ( ) ) ) { List < MediaType > matchedAcceptTypes = getAcceptedMediaTypes ( route . getProduces ( ) , request . getAccept ( ) ) ; if ( nonEmpty ( matchedAcceptTypes ) ) { request . setMatchedAccept ( matchedAcceptTypes . get ( 0 ) ) ; return true ; } } return false ; }
Matches route produces configurer and Accept - header in an incoming provider
10,938
public static boolean matchConsumes ( InternalRoute route , InternalRequest < ? > request ) { if ( route . getConsumes ( ) . contains ( WILDCARD ) ) { return true ; } return route . getConsumes ( ) . contains ( request . getContentType ( ) ) ; }
Matches route consumes configurer and Content - Type header in an incoming provider
10,939
public static byte [ ] getBytes ( final InputStream sourceInputStream ) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ BUFFER_SIZE ] ; for ( int len = 0 ; ( len = sourceInputStream . read ( buffer ) ) != - 1 ; ) { byteArrayOutputStream . write ( buffer , 0 , len ) ; } byte [ ] arrayOfByte = byteArrayOutputStream . toByteArray ( ) ; return arrayOfByte ; }
Get bytes from given input stream .
10,940
public static boolean write ( final InputStream sourceInputStream , final OutputStream destinationOutputStream ) throws IOException { byte [ ] buffer = buildBuffer ( BUFFER_SIZE ) ; for ( int len = 0 ; ( len = sourceInputStream . read ( buffer ) ) != - 1 ; ) { destinationOutputStream . write ( buffer , 0 , len ) ; } destinationOutputStream . flush ( ) ; return true ; }
Write source input stream bytes into destination output stream .
10,941
public static boolean write ( final byte [ ] sourceBytes , final OutputStream destinationOutputStream ) throws IOException { BufferedOutputStream bufferedOutputStream = new BufferedOutputStream ( destinationOutputStream ) ; bufferedOutputStream . write ( sourceBytes , 0 , sourceBytes . length ) ; bufferedOutputStream . flush ( ) ; return true ; }
Write source bytes into destination output stream .
10,942
public < T extends DataObject > List < T > asList ( Class < T > type ) throws InstantiationException , IllegalAccessException { Map < String , Field > fields = new HashMap < String , Field > ( ) ; for ( String column : columns ) try { fields . put ( column , Beans . getKnownField ( type , column ) ) ; } catch ( Exception x ) { } List < T > list = new ArrayList < T > ( ) ; for ( Object [ ] row : rows ) { T object = type . newInstance ( ) ; for ( int i = 0 ; i < row . length ; ++ i ) { Field field = fields . get ( columns [ i ] ) ; if ( field != null ) { Beans . setValue ( object , field , row [ i ] ) ; } } list . add ( object ) ; } return list ; }
Retrieves the contents of this result set as a List of DataObjects .
10,943
public CachedResultSet rename ( String ... names ) { for ( int i = 0 ; i < names . length ; ++ i ) { this . columns [ i ] = names [ i ] ; } return this ; }
Renames the columns of a CachedResultSet .
10,944
public Map < String , Integer > buildIndex ( ) { Map < String , Integer > index = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < columns . length ; ++ i ) { index . put ( columns [ i ] , i ) ; } return index ; }
Builds a name - to - column index for quick access to data by columm names .
10,945
public Paperclip attach ( final DocumentAbstract documentAbstract , final String roleName , final Object attachTo ) { Paperclip paperclip = findByDocumentAndAttachedToAndRoleName ( documentAbstract , attachTo , roleName ) ; if ( paperclip != null ) { return paperclip ; } final Class < ? extends Paperclip > subtype = subtypeClassFor ( attachTo ) ; paperclip = repositoryService . instantiate ( subtype ) ; paperclip . setDocument ( documentAbstract ) ; paperclip . setRoleName ( roleName ) ; if ( documentAbstract instanceof Document ) { final Document document = ( Document ) documentAbstract ; paperclip . setDocumentCreatedAt ( document . getCreatedAt ( ) ) ; } if ( ! repositoryService . isPersistent ( attachTo ) ) { transactionService . flushTransaction ( ) ; } final Bookmark bookmark = bookmarkService . bookmarkFor ( attachTo ) ; paperclip . setAttachedTo ( attachTo ) ; paperclip . setAttachedToStr ( bookmark . toString ( ) ) ; repositoryService . persistAndFlush ( paperclip ) ; return paperclip ; }
This is an idempotent operation .
10,946
private void scanFraction ( int pos ) { skipIllegalUnderscores ( ) ; if ( '0' <= reader . ch && reader . ch <= '9' ) { scanDigits ( pos , 10 ) ; } int sp1 = reader . sp ; if ( reader . ch == 'e' || reader . ch == 'E' ) { reader . putChar ( true ) ; skipIllegalUnderscores ( ) ; if ( reader . ch == '+' || reader . ch == '-' ) { reader . putChar ( true ) ; } skipIllegalUnderscores ( ) ; if ( '0' <= reader . ch && reader . ch <= '9' ) { scanDigits ( pos , 10 ) ; return ; } lexError ( pos , "malformed.fp.lit" ) ; reader . sp = sp1 ; } }
Read fractional part of floating point number .
10,947
private boolean isMagicComment ( ) { assert reader . ch == '@' ; int parens = 0 ; boolean stringLit = false ; int lbp = reader . bp ; char lch = reader . buf [ ++ lbp ] ; if ( ! Character . isJavaIdentifierStart ( lch ) ) { return false ; } while ( lbp < reader . buflen ) { lch = reader . buf [ ++ lbp ] ; if ( Character . isWhitespace ( lch ) && ! spacesincomments && parens == 0 ) { return false ; } else if ( lch == '@' && parens == 0 ) { return false ; } else if ( lch == '(' && ! stringLit ) { ++ parens ; } else if ( lch == ')' && ! stringLit ) { -- parens ; } else if ( lch == '"' ) { stringLit = ! stringLit ; } else if ( lch == '*' && ! stringLit && lbp + 1 < reader . buflen && reader . buf [ lbp + 1 ] == '/' ) { return parens == 0 ; } else if ( ! Character . isJavaIdentifierPart ( lch ) && ! Character . isWhitespace ( lch ) && lch != '.' && ! spacesincomments && parens == 0 && ! stringLit ) { return false ; } } return false ; }
with annotation values .
10,948
protected Tokens . Comment processComment ( int pos , int endPos , CommentStyle style ) { if ( scannerDebug ) System . out . println ( "processComment(" + pos + "," + endPos + "," + style + ")=|" + new String ( reader . getRawCharacters ( pos , endPos ) ) + "|" ) ; char [ ] buf = reader . getRawCharacters ( pos , endPos ) ; return new BasicComment < UnicodeReader > ( new UnicodeReader ( fac , buf , buf . length ) , style ) ; }
Called when a complete comment has been scanned . pos and endPos will mark the comment boundary .
10,949
public boolean isZeroVATAllowed ( final Locale aCountry , final boolean bUndefinedValue ) { ValueEnforcer . notNull ( aCountry , "Country" ) ; final VATCountryData aVATCountryData = getVATCountryData ( aCountry ) ; return aVATCountryData != null ? aVATCountryData . isZeroVATAllowed ( ) : bUndefinedValue ; }
Check if zero VAT is allowed for the passed country
10,950
public VATCountryData getVATCountryData ( final Locale aLocale ) { ValueEnforcer . notNull ( aLocale , "Locale" ) ; final Locale aCountry = CountryCache . getInstance ( ) . getCountry ( aLocale ) ; return m_aVATItemsPerCountry . get ( aCountry ) ; }
Get the VAT data of the passed country .
10,951
public IVATItem findVATItem ( final EVATItemType eType , final BigDecimal aPercentage ) { if ( eType == null || aPercentage == null ) return null ; return findFirst ( x -> x . getType ( ) . equals ( eType ) && x . hasPercentage ( aPercentage ) ) ; }
Find a matching VAT item with the passed properties independent of the country .
10,952
public IVATItem findFirst ( final Predicate < ? super IVATItem > aFilter ) { return CollectionHelper . findFirst ( m_aAllVATItems . values ( ) , aFilter ) ; }
Find the first matching VAT item .
10,953
public ICommonsList < IVATItem > findAll ( final Predicate < ? super IVATItem > aFilter ) { final ICommonsList < IVATItem > ret = new CommonsArrayList < > ( ) ; CollectionHelper . findAll ( m_aAllVATItems . values ( ) , aFilter , ret :: add ) ; return ret ; }
Find all matching VAT items .
10,954
static private String serialize ( Throwable ex , int depth , int level ) { StringBuffer buff = new StringBuffer ( ) ; String str = ex . toString ( ) ; int pos = str . indexOf ( ":" ) ; if ( str . length ( ) < 80 || pos == - 1 ) { buff . append ( str ) ; } else { String str1 = str . substring ( 0 , pos ) ; String str2 = str . substring ( pos + 2 ) ; if ( str2 . indexOf ( str1 ) == - 1 ) { buff . append ( str1 ) ; buff . append ( ": \n\t" ) ; } buff . append ( str2 ) ; } if ( depth > 0 ) { StackTraceElement [ ] elements = ex . getStackTrace ( ) ; for ( int i = 0 ; i < elements . length ; i ++ ) { buff . append ( "\n\tat " ) ; buff . append ( elements [ i ] ) ; if ( i == ( depth - 1 ) && elements . length > depth ) { buff . append ( "\n\t... " + ( elements . length - depth ) + " more ..." ) ; i = elements . length ; } } } if ( ex . getCause ( ) != null && level < 3 ) { buff . append ( "\nCaused by: " ) ; buff . append ( serialize ( ex . getCause ( ) , depth , ++ level ) ) ; } return buff . toString ( ) ; }
Serializes the given exception as a stack trace string .
10,955
public static String serialize ( Object [ ] objs ) { StringBuffer buff = new StringBuffer ( ) ; for ( int i = 0 ; i < objs . length ; i ++ ) { if ( objs [ i ] != null ) { buff . append ( objs [ i ] . toString ( ) ) ; if ( i != objs . length - 1 ) buff . append ( "," ) ; } } return buff . toString ( ) ; }
Returns the given array serialized as a string .
10,956
public static String encode ( String str ) { String ret = str ; try { if ( ret != null ) ret = new String ( Base64 . encodeBase64 ( ret . getBytes ( ) ) ) ; } catch ( NoClassDefFoundError e ) { System . out . println ( "WARNING: unable to encode: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } return ret ; }
Returns the given string after if it has been encoded .
10,957
public static String encodeBytes ( byte [ ] bytes ) { String ret = null ; try { if ( bytes != null ) ret = new String ( Base64 . encodeBase64 ( bytes ) ) ; } catch ( NoClassDefFoundError e ) { ret = new String ( bytes ) ; System . out . println ( "WARNING: unable to encode: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } return ret ; }
Returns the given byte array after if it has been encoded .
10,958
public static String decode ( String str ) { String ret = str ; try { if ( ret != null ) ret = new String ( Base64 . decodeBase64 ( ret . getBytes ( ) ) ) ; } catch ( NoClassDefFoundError e ) { System . out . println ( "WARNING: unable to decode: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } return ret ; }
Returns the given string after if it has been decoded .
10,959
public static byte [ ] decodeBytes ( String str ) { byte [ ] ret = null ; try { if ( str != null ) ret = Base64 . decodeBase64 ( str . getBytes ( ) ) ; } catch ( NoClassDefFoundError e ) { ret = str . getBytes ( ) ; System . out . println ( "WARNING: unable to decode: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } return ret ; }
Returns the given byte array after if it has been decoded .
10,960
public static String truncate ( String str , int count ) { if ( count < 0 || str . length ( ) <= count ) return str ; int pos = count ; for ( int i = count ; i >= 0 && ! Character . isWhitespace ( str . charAt ( i ) ) ; i -- , pos -- ) ; return str . substring ( 0 , pos ) + "..." ; }
Returns the given string truncated at a word break before the given number of characters .
10,961
public static int getOccurenceCount ( char c , String s ) { int ret = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == c ) ++ ret ; } return ret ; }
Returns the number of occurences of the given character in the given string .
10,962
public static int getOccurrenceCount ( String expr , String str ) { int ret = 0 ; Pattern p = Pattern . compile ( expr ) ; Matcher m = p . matcher ( str ) ; while ( m . find ( ) ) ++ ret ; return ret ; }
Returns the number of occurrences of the substring in the given string .
10,963
public static boolean endsWith ( StringBuffer buffer , String suffix ) { if ( suffix . length ( ) > buffer . length ( ) ) return false ; int endIndex = suffix . length ( ) - 1 ; int bufferIndex = buffer . length ( ) - 1 ; while ( endIndex >= 0 ) { if ( buffer . charAt ( bufferIndex ) != suffix . charAt ( endIndex ) ) return false ; bufferIndex -- ; endIndex -- ; } return true ; }
Checks that a string buffer ends up with a given string .
10,964
public static String toReadableForm ( String str ) { String ret = str ; if ( str != null && str . length ( ) > 0 && str . indexOf ( "\n" ) != - 1 && str . indexOf ( "\r" ) == - 1 ) { str . replaceAll ( "\n" , "\r\n" ) ; } return ret ; }
Converts the given string with CR and LF character correctly formatted .
10,965
public static String urlEncode ( String str ) { String ret = str ; try { ret = URLEncoder . encode ( str , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { logger . severe ( "Failed to encode value: " + str ) ; } return ret ; }
Encode the special characters in the string to its URL encoded representation .
10,966
public static String stripSpaces ( String s ) { StringBuffer buff = new StringBuffer ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c != ' ' ) buff . append ( c ) ; } return buff . toString ( ) ; }
Returns the given string with all spaces removed .
10,967
public static String removeControlCharacters ( String s , boolean removeCR ) { String ret = s ; if ( ret != null ) { ret = ret . replaceAll ( "_x000D_" , "" ) ; if ( removeCR ) ret = ret . replaceAll ( "\r" , "" ) ; } return ret ; }
Remove any extraneous control characters from text fields .
10,968
public static void printCharacters ( String s ) { if ( s != null ) { logger . info ( "string length=" + s . length ( ) ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; logger . info ( "char[" + i + "]=" + c + " (" + ( int ) c + ")" ) ; } } }
Prints the character codes for the given string .
10,969
public static String stripDoubleQuotes ( String s ) { String ret = s ; if ( hasDoubleQuotes ( s ) ) ret = s . substring ( 1 , s . length ( ) - 1 ) ; return ret ; }
Returns the given string with leading and trailing quotes removed .
10,970
public static String stripClassNames ( String str ) { String ret = str ; if ( ret != null ) { while ( ret . startsWith ( "java.security.PrivilegedActionException:" ) || ret . startsWith ( "com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:" ) || ret . startsWith ( "javax.jms.JMSSecurityException:" ) ) { ret = ret . substring ( ret . indexOf ( ":" ) + 1 ) . trim ( ) ; } } return ret ; }
Strips class name prefixes from the start of the given string .
10,971
public static String stripDomain ( String hostname ) { String ret = hostname ; int pos = hostname . indexOf ( "." ) ; if ( pos != - 1 ) ret = hostname . substring ( 0 , pos ) ; return ret ; }
Returns the given hostname with the domain removed .
10,972
public Class < ? > findClass ( String className , String versionRange ) { Class < ? > c = this . getClassFromBundle ( null , className , versionRange ) ; if ( c == null ) { Object resource = this . deployThisResource ( ClassFinderActivator . getPackageName ( className , false ) , versionRange , false ) ; if ( resource != null ) { c = this . getClassFromBundle ( null , className , versionRange ) ; if ( c == null ) c = this . getClassFromBundle ( resource , className , versionRange ) ; } } return c ; }
Find resolve and return this class definition .
10,973
public URL findResourceURL ( String resourcePath , String versionRange ) { URL url = this . getResourceFromBundle ( null , resourcePath , versionRange ) ; if ( url == null ) { Object resource = this . deployThisResource ( ClassFinderActivator . getPackageName ( resourcePath , true ) , versionRange , false ) ; if ( resource != null ) url = this . getResourceFromBundle ( resource , resourcePath , versionRange ) ; } return url ; }
Find resolve and return this resource s URL .
10,974
public ResourceBundle findResourceBundle ( String resourcePath , Locale locale , String versionRange ) { ResourceBundle resourceBundle = this . getResourceBundleFromBundle ( null , resourcePath , locale , versionRange ) ; if ( resourceBundle == null ) { Object resource = this . deployThisResource ( ClassFinderActivator . getPackageName ( resourcePath , true ) , versionRange , false ) ; if ( resource != null ) { resourceBundle = this . getResourceBundleFromBundle ( resource , resourcePath , locale , versionRange ) ; if ( resourceBundle == null ) { Class < ? > c = this . getClassFromBundle ( resource , resourcePath , versionRange ) ; if ( c != null ) { try { resourceBundle = ( ResourceBundle ) c . newInstance ( ) ; } catch ( InstantiationException e ) { e . printStackTrace ( ) ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } } } return resourceBundle ; }
Find resolve and return this ResourceBundle .
10,975
public boolean shutdownService ( String serviceClass , Object service ) { if ( service == null ) return false ; if ( bundleContext == null ) return false ; String filter = null ; if ( serviceClass == null ) if ( ! ( service instanceof String ) ) serviceClass = service . getClass ( ) . getName ( ) ; if ( service instanceof String ) filter = ClassServiceUtility . addToFilter ( "" , BundleConstants . SERVICE_PID , ( String ) service ) ; ServiceReference [ ] refs ; try { refs = bundleContext . getServiceReferences ( serviceClass , filter ) ; if ( ( refs == null ) || ( refs . length == 0 ) ) return false ; for ( ServiceReference reference : refs ) { if ( ( bundleContext . getService ( reference ) == service ) || ( service instanceof String ) ) { if ( refs . length == 1 ) { String dependentBaseBundleClassName = service . getClass ( ) . getName ( ) ; String packageName = ClassFinderActivator . getPackageName ( dependentBaseBundleClassName , false ) ; if ( service instanceof String ) packageName = ( String ) service ; Bundle bundle = this . findBundle ( null , bundleContext , packageName , null ) ; if ( bundle != null ) if ( ( bundle . getState ( ) & Bundle . ACTIVE ) != 0 ) { try { bundle . stop ( ) ; } catch ( BundleException e ) { e . printStackTrace ( ) ; } } return true ; } } } } catch ( InvalidSyntaxException e1 ) { e1 . printStackTrace ( ) ; } return false ; }
Shutdown the bundle for this service .
10,976
public void startBundle ( Bundle bundle ) { if ( bundle != null ) if ( ( bundle . getState ( ) != Bundle . ACTIVE ) && ( bundle . getState ( ) != Bundle . STARTING ) ) { try { bundle . start ( ) ; } catch ( BundleException e ) { e . printStackTrace ( ) ; } } }
Start this bundle .
10,977
@ SuppressWarnings ( "unchecked" ) public Dictionary < String , String > getProperties ( String servicePid ) { Dictionary < String , String > properties = null ; try { if ( servicePid != null ) { ServiceReference caRef = bundleContext . getServiceReference ( ConfigurationAdmin . class . getName ( ) ) ; if ( caRef != null ) { ConfigurationAdmin configAdmin = ( ConfigurationAdmin ) bundleContext . getService ( caRef ) ; Configuration config = configAdmin . getConfiguration ( servicePid ) ; properties = config . getProperties ( ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } return properties ; }
Get the configuration properties for this Pid .
10,978
public boolean saveProperties ( String servicePid , Dictionary < String , String > properties ) { try { if ( servicePid != null ) { ServiceReference caRef = bundleContext . getServiceReference ( ConfigurationAdmin . class . getName ( ) ) ; if ( caRef != null ) { ConfigurationAdmin configAdmin = ( ConfigurationAdmin ) bundleContext . getService ( caRef ) ; Configuration config = configAdmin . getConfiguration ( servicePid ) ; config . update ( properties ) ; return true ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } return false ; }
Set the configuration properties for this Pid .
10,979
public static byte [ ] read ( InputStream in , boolean closeAfterwards ) throws IOException { byte [ ] buffer = new byte [ 32 * 1024 ] ; ByteArrayOutputStream bas = new ByteArrayOutputStream ( ) ; for ( int length ; ( length = in . read ( buffer , 0 , buffer . length ) ) > - 1 ; bas . write ( buffer , 0 , length ) ) ; if ( closeAfterwards ) in . close ( ) ; return bas . toByteArray ( ) ; }
Reads the whole contents of an input stream into a byte array closing the stream if so requested .
10,980
public void add ( Collection < AlertPolicy > policies ) { for ( AlertPolicy policy : policies ) this . policies . put ( policy . getId ( ) , policy ) ; }
Adds the policy list to the policies for the account .
10,981
public AlertChannelCache alertChannels ( long policyId ) { AlertChannelCache cache = channels . get ( policyId ) ; if ( cache == null ) channels . put ( policyId , cache = new AlertChannelCache ( policyId ) ) ; return cache ; }
Returns the cache of alert channels for the given policy creating one if it doesn t exist .
10,982
public void setAlertChannels ( Collection < AlertChannel > channels ) { for ( AlertChannel channel : channels ) { List < Long > policyIds = channel . getLinks ( ) . getPolicyIds ( ) ; for ( long policyId : policyIds ) { AlertPolicy policy = policies . get ( policyId ) ; if ( policy != null ) alertChannels ( policyId ) . add ( channel ) ; else logger . severe ( String . format ( "Unable to find policy for channel '%s': %d" , channel . getName ( ) , policyId ) ) ; } } }
Sets the channels on the policies for the account .
10,983
public AlertConditionCache alertConditions ( long policyId ) { AlertConditionCache cache = conditions . get ( policyId ) ; if ( cache == null ) conditions . put ( policyId , cache = new AlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of alert conditions for the given policy creating one if it doesn t exist .
10,984
public NrqlAlertConditionCache nrqlAlertConditions ( long policyId ) { NrqlAlertConditionCache cache = nrqlConditions . get ( policyId ) ; if ( cache == null ) nrqlConditions . put ( policyId , cache = new NrqlAlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of NRQL alert conditions for the given policy creating one if it doesn t exist .
10,985
public ExternalServiceAlertConditionCache externalServiceAlertConditions ( long policyId ) { ExternalServiceAlertConditionCache cache = externalServiceConditions . get ( policyId ) ; if ( cache == null ) externalServiceConditions . put ( policyId , cache = new ExternalServiceAlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of external service alert conditions for the given policy creating one if it doesn t exist .
10,986
public SyntheticsAlertConditionCache syntheticsAlertConditions ( long policyId ) { SyntheticsAlertConditionCache cache = syntheticsConditions . get ( policyId ) ; if ( cache == null ) syntheticsConditions . put ( policyId , cache = new SyntheticsAlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of Synthetics alert conditions for the given policy creating one if it doesn t exist .
10,987
public PluginsAlertConditionCache pluginsAlertConditions ( long policyId ) { PluginsAlertConditionCache cache = pluginsConditions . get ( policyId ) ; if ( cache == null ) pluginsConditions . put ( policyId , cache = new PluginsAlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of Plugins alert conditions for the given policy creating one if it doesn t exist .
10,988
public InfraAlertConditionCache infraAlertConditions ( long policyId ) { InfraAlertConditionCache cache = infraConditions . get ( policyId ) ; if ( cache == null ) infraConditions . put ( policyId , cache = new InfraAlertConditionCache ( policyId ) ) ; return cache ; }
Returns the cache of Infrastructure alert conditions for the given policy creating one if it doesn t exist .
10,989
static PrintWriter defaultWriter ( Context context ) { PrintWriter result = context . get ( outKey ) ; if ( result == null ) context . put ( outKey , result = new PrintWriter ( System . err ) ) ; return result ; }
The default writer for diagnostics
10,990
public void initRound ( Log other ) { this . noticeWriter = other . noticeWriter ; this . warnWriter = other . warnWriter ; this . errWriter = other . errWriter ; this . sourceMap = other . sourceMap ; this . recorded = other . recorded ; this . nerrors = other . nerrors ; this . nwarnings = other . nwarnings ; }
Propagate the previous log s information .
10,991
public void setVisibleSources ( Map < String , Source > vs ) { visibleSrcs = new HashSet < URI > ( ) ; for ( String s : vs . keySet ( ) ) { Source src = vs . get ( s ) ; visibleSrcs . add ( src . file ( ) . toURI ( ) ) ; } }
Specify which sources are visible to the compiler through - sourcepath .
10,992
public void save ( ) throws IOException { if ( ! needsSaving ) return ; try ( FileWriter out = new FileWriter ( javacStateFilename ) ) { StringBuilder b = new StringBuilder ( ) ; long millisNow = System . currentTimeMillis ( ) ; Date d = new Date ( millisNow ) ; SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss SSS" ) ; b . append ( "# javac_state ver 0.3 generated " + millisNow + " " + df . format ( d ) + "\n" ) ; b . append ( "# This format might change at any time. Please do not depend on it.\n" ) ; b . append ( "# M module\n" ) ; b . append ( "# P package\n" ) ; b . append ( "# S C source_tobe_compiled timestamp\n" ) ; b . append ( "# S L link_only_source timestamp\n" ) ; b . append ( "# G C generated_source timestamp\n" ) ; b . append ( "# A artifact timestamp\n" ) ; b . append ( "# D dependency\n" ) ; b . append ( "# I pubapi\n" ) ; b . append ( "# R arguments\n" ) ; b . append ( "R " ) . append ( theArgs ) . append ( "\n" ) ; now . copyPackagesExcept ( prev , recompiledPackages , new HashSet < String > ( ) ) ; Module . saveModules ( now . modules ( ) , b ) ; String s = b . toString ( ) ; out . write ( s , 0 , s . length ( ) ) ; } }
Save the javac_state file .
10,993
public boolean performJavaCompilations ( File binDir , String serverSettings , String [ ] args , Set < String > recentlyCompiled , boolean [ ] rcValue ) { Map < String , Transformer > suffixRules = new HashMap < String , Transformer > ( ) ; suffixRules . put ( ".java" , compileJavaPackages ) ; compileJavaPackages . setExtra ( serverSettings ) ; compileJavaPackages . setExtra ( args ) ; rcValue [ 0 ] = perform ( binDir , suffixRules ) ; recentlyCompiled . addAll ( taintedPackages ( ) ) ; clearTaintedPackages ( ) ; boolean again = ! packagesWithChangedPublicApis . isEmpty ( ) ; taintPackagesDependingOnChangedPackages ( packagesWithChangedPublicApis , recentlyCompiled ) ; packagesWithChangedPublicApis = new HashSet < String > ( ) ; return again && rcValue [ 0 ] ; }
Compile all the java sources . Return true if it needs to be called again!
10,994
private void addFileToTransform ( Map < Transformer , Map < String , Set < URI > > > gs , Transformer t , Source s ) { Map < String , Set < URI > > fs = gs . get ( t ) ; if ( fs == null ) { fs = new HashMap < String , Set < URI > > ( ) ; gs . put ( t , fs ) ; } Set < URI > ss = fs . get ( s . pkg ( ) . name ( ) ) ; if ( ss == null ) { ss = new HashSet < URI > ( ) ; fs . put ( s . pkg ( ) . name ( ) , ss ) ; } ss . add ( s . file ( ) . toURI ( ) ) ; }
Store the source into the set of sources belonging to the given transform .
10,995
private void buildDeprecatedAPIInfo ( Configuration configuration ) { PackageDoc [ ] packages = configuration . packages ; PackageDoc pkg ; for ( int c = 0 ; c < packages . length ; c ++ ) { pkg = packages [ c ] ; if ( Util . isDeprecated ( pkg ) ) { getList ( PACKAGE ) . add ( pkg ) ; } } ClassDoc [ ] classes = configuration . root . classes ( ) ; for ( int i = 0 ; i < classes . length ; i ++ ) { ClassDoc cd = classes [ i ] ; if ( Util . isDeprecated ( cd ) ) { if ( cd . isOrdinaryClass ( ) ) { getList ( CLASS ) . add ( cd ) ; } else if ( cd . isInterface ( ) ) { getList ( INTERFACE ) . add ( cd ) ; } else if ( cd . isException ( ) ) { getList ( EXCEPTION ) . add ( cd ) ; } else if ( cd . isEnum ( ) ) { getList ( ENUM ) . add ( cd ) ; } else if ( cd . isError ( ) ) { getList ( ERROR ) . add ( cd ) ; } else if ( cd . isAnnotationType ( ) ) { getList ( ANNOTATION_TYPE ) . add ( cd ) ; } } composeDeprecatedList ( getList ( FIELD ) , cd . fields ( ) ) ; composeDeprecatedList ( getList ( METHOD ) , cd . methods ( ) ) ; composeDeprecatedList ( getList ( CONSTRUCTOR ) , cd . constructors ( ) ) ; if ( cd . isEnum ( ) ) { composeDeprecatedList ( getList ( ENUM_CONSTANT ) , cd . enumConstants ( ) ) ; } if ( cd . isAnnotationType ( ) ) { composeDeprecatedList ( getList ( ANNOTATION_TYPE_MEMBER ) , ( ( AnnotationTypeDoc ) cd ) . elements ( ) ) ; } } sortDeprecatedLists ( ) ; }
Build the sorted list of all the deprecated APIs in this run . Build separate lists for deprecated packages classes constructors methods and fields .
10,996
public Object parse ( String text ) throws DataValidationException { try { preValidate ( text ) ; Object object = _valueOf . invoke ( text ) ; postValidate ( object ) ; return object ; } catch ( DataValidationException x ) { throw x ; } catch ( IllegalArgumentException x ) { throw new DataValidationException ( "FORMAT" , _name , text ) ; } catch ( Throwable t ) { throw new DataValidationException ( "" , _name , text , t ) ; } }
Parses a string to produce a validated value of this given data type .
10,997
public void preValidate ( String text ) throws DataValidationException { Trace . g . std . note ( Validator . class , "preValidate: size = " + _size ) ; if ( _size > 0 && text . length ( ) > _size ) { throw new DataValidationException ( "SIZE" , _name , text ) ; } Trace . g . std . note ( Validator . class , "preValidate: pattern = " + _pattern ) ; if ( _pattern != null && ! _pattern . matcher ( text ) . matches ( ) ) { throw new DataValidationException ( "PATTERN" , _name , text ) ; } }
Performs all data validation that is based on the string representation of the value before it is converted .
10,998
@ SuppressWarnings ( "unchecked" ) public void postValidate ( Object object ) throws DataValidationException { if ( _values != null || _ranges != null ) { if ( _values != null ) for ( Object value : _values ) { if ( value . equals ( object ) ) return ; } if ( _ranges != null ) for ( @ SuppressWarnings ( "rawtypes" ) Range r : _ranges ) { @ SuppressWarnings ( "rawtypes" ) Comparable o = ( Comparable ) object ; if ( r . inclusive ) { if ( ( r . min == null || r . min . compareTo ( o ) <= 0 ) && ( r . max == null || o . compareTo ( r . max ) <= 0 ) ) { return ; } } else { if ( ( r . min == null || r . min . compareTo ( o ) < 0 ) && ( r . max == null || o . compareTo ( r . max ) < 0 ) ) { return ; } } } throw new DataValidationException ( "VALUES/RANGES" , _name , object ) ; } }
Performs all data validation that is appicable to the data value itself
10,999
public void startRobot ( Robot newRobot ) { newRobot . getData ( ) . setActiveState ( DEFAULT_START_STATE ) ; Thread newThread = new Thread ( robotsThreads , newRobot , "Bot-" + newRobot . getSerialNumber ( ) ) ; newThread . start ( ) ; }
Starts the thread of a robot in the player s thread group