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 = ...
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 ) {...
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 ( ) ) ; } ret...
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 ( ) ) ; } retu...
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 ....
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 ...
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 . get...
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...
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 ( te...
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 > ( CollectionUti...
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 [ ] pr...
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 ....
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 . exis...
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 { interfac...
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 ( ( showAc...
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 . setMatchedA...
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 . w...
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 ) ; } de...
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 ....
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 ( Excepti...
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 = su...
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 == ...
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 ( Characte...
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 , endPo...
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 =...
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 ( ) ) ; } retu...
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...
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 ( ) ) ; } retu...
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 . get...
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 ) ) r...
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 ....
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 ...
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 ( reso...
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...
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 instanc...
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 != nu...
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 ) b...
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 ) ) ; ...
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 ) ...
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 ...
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 ...
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 . set...
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 ...
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 = config...
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"...
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 , "preValida...
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" ) Ra...
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