idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
10,900 | 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 . | 27 | 14 |
10,901 | public boolean read ( ) throws IOException { valid = false ; File file = new File ( filename ) ; FileReader reader = new FileReader ( file ) ; if ( file . exists ( ) ) { // Load the file contents contents = getContents ( reader , "\n" ) ; if ( contents != null ) valid = true ; else logger . severe ( "Unable to read fil... | Reads the contents of the file . | 147 | 8 |
10,902 | public boolean read ( InputStream stream ) throws IOException { valid = false ; InputStreamReader reader = new InputStreamReader ( stream ) ; // Load the file contents contents = getContents ( reader , "\n" ) ; if ( contents != null ) valid = true ; else logger . severe ( "Unable to read file contents: " + filename ) ;... | Reads the contents of the given stream . | 101 | 9 |
10,903 | 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 . | 98 | 11 |
10,904 | private void readObject ( ObjectInputStream s ) throws IOException , ClassNotFoundException { s . defaultReadObject ( ) ; type = null ; types = null ; } | Explicitly set all transient fields . | 36 | 8 |
10,905 | 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 . | 486 | 12 |
10,906 | 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 ) ; // the header elements are used to map the bean values to eac... | Takes the output and transforms it into a csv file . | 501 | 13 |
10,907 | public void generateXls ( OutputStream out , List < Map < String , Object > > rows , List < ColumnDef > columns ) { try { Workbook wb = new HSSFWorkbook ( ) ; // or new XSSFWorkbook(); String safeName = WorkbookUtil . createSafeSheetName ( "Report" ) ; // returns " O'Brien's sales " Sheet reportSheet = wb . createSheet... | Takes the output and transforms it into a Excel file . | 394 | 12 |
10,908 | 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 . | 226 | 11 |
10,909 | 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 . | 128 | 26 |
10,910 | 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 | 67 | 20 |
10,911 | 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 | 85 | 24 |
10,912 | 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 . | 65 | 9 |
10,913 | public final Trace alert ( Class < ? > c , String message ) { return _trace . alert ( c , message ) ; } | Reports an error condition . | 27 | 5 |
10,914 | public Iterable < DFactory > queryByBaseUrl ( java . lang . String baseUrl ) { return queryByField ( null , DFactoryMapper . Field . BASEURL . getFieldName ( ) , baseUrl ) ; } | query - by method for field baseUrl | 49 | 8 |
10,915 | public Iterable < DFactory > queryByClientId ( java . lang . String clientId ) { return queryByField ( null , DFactoryMapper . Field . CLIENTID . getFieldName ( ) , clientId ) ; } | query - by method for field clientId | 49 | 8 |
10,916 | public Iterable < DFactory > queryByClientSecret ( java . lang . String clientSecret ) { return queryByField ( null , DFactoryMapper . Field . CLIENTSECRET . getFieldName ( ) , clientSecret ) ; } | query - by method for field clientSecret | 51 | 8 |
10,917 | 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 . | 63 | 23 |
10,918 | 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 . | 164 | 9 |
10,919 | 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 | 101 | 14 |
10,920 | 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 | 63 | 15 |
10,921 | 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 . | 114 | 7 |
10,922 | 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 . | 88 | 10 |
10,923 | 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 . | 74 | 8 |
10,924 | 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 . | 184 | 17 |
10,925 | 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 . | 46 | 11 |
10,926 | 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 . | 65 | 19 |
10,927 | @ Programmatic 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... | This is an idempotent operation . | 240 | 9 |
10,928 | private void scanFraction ( int pos ) { skipIllegalUnderscores ( ) ; if ( ' ' <= reader . ch && reader . ch <= ' ' ) { scanDigits ( pos , 10 ) ; } int sp1 = reader . sp ; if ( reader . ch == ' ' || reader . ch == ' ' ) { reader . putChar ( true ) ; skipIllegalUnderscores ( ) ; if ( reader . ch == ' ' || reader . ch == ... | Read fractional part of floating point number . | 179 | 9 |
10,929 | 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 ) ) { // The first thing after the @ has to be the annotation identifier return false ; } while ( lbp ... | with annotation values . | 439 | 4 |
10,930 | 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 . | 117 | 20 |
10,931 | public boolean isZeroVATAllowed ( @ Nonnull final Locale aCountry , final boolean bUndefinedValue ) { ValueEnforcer . notNull ( aCountry , "Country" ) ; // first get locale specific VAT types final VATCountryData aVATCountryData = getVATCountryData ( aCountry ) ; return aVATCountryData != null ? aVATCountryData . isZer... | Check if zero VAT is allowed for the passed country | 98 | 10 |
10,932 | @ Nullable public VATCountryData getVATCountryData ( @ Nonnull 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 . | 80 | 9 |
10,933 | @ Nullable public IVATItem findVATItem ( @ Nullable final EVATItemType eType , @ Nullable 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 . | 83 | 14 |
10,934 | @ Nullable public IVATItem findFirst ( @ Nonnull final Predicate < ? super IVATItem > aFilter ) { return CollectionHelper . findFirst ( m_aAllVATItems . values ( ) , aFilter ) ; } | Find the first matching VAT item . | 51 | 7 |
10,935 | @ Nonnull @ ReturnsMutableCopy public ICommonsList < IVATItem > findAll ( @ Nonnull 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 . | 89 | 6 |
10,936 | static private String serialize ( Throwable ex , int depth , int level ) { StringBuffer buff = new StringBuffer ( ) ; String str = ex . toString ( ) ; // Split the first line if it's too long int pos = str . indexOf ( ":" ) ; if ( str . length ( ) < 80 || pos == - 1 ) { buff . append ( str ) ; } else { String str1 = st... | Serializes the given exception as a stack trace string . | 333 | 11 |
10,937 | 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 . | 98 | 10 |
10,938 | public static String encode ( String str ) { String ret = str ; try { // Obfuscate the string if ( ret != null ) ret = new String ( Base64 . encodeBase64 ( ret . getBytes ( ) ) ) ; } catch ( NoClassDefFoundError e ) { System . out . println ( "WARNING: unable to encode: " + e . getClass ( ) . getName ( ) + ": " + e . g... | Returns the given string after if it has been encoded . | 104 | 11 |
10,939 | public static String encodeBytes ( byte [ ] bytes ) { String ret = null ; try { // Obfuscate the string 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 ( ) ... | Returns the given byte array after if it has been encoded . | 110 | 12 |
10,940 | public static String decode ( String str ) { String ret = str ; try { // De-obfuscate the string if ( ret != null ) ret = new String ( Base64 . decodeBase64 ( ret . getBytes ( ) ) ) ; } catch ( NoClassDefFoundError e ) { System . out . println ( "WARNING: unable to decode: " + e . getClass ( ) . getName ( ) + ": " + e ... | Returns the given string after if it has been decoded . | 106 | 12 |
10,941 | public static byte [ ] decodeBytes ( String str ) { byte [ ] ret = null ; try { // De-obfuscate the string if ( str != null ) ret = Base64 . decodeBase64 ( str . getBytes ( ) ) ; } catch ( NoClassDefFoundError e ) { ret = str . getBytes ( ) ; System . out . println ( "WARNING: unable to decode: " + e . getClass ( ) . g... | Returns the given byte array after if it has been decoded . | 116 | 13 |
10,942 | 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 . | 85 | 17 |
10,943 | 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 . | 60 | 16 |
10,944 | 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 . | 57 | 14 |
10,945 | 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 . | 99 | 13 |
10,946 | 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 . | 79 | 13 |
10,947 | 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 . | 68 | 14 |
10,948 | 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 . | 75 | 9 |
10,949 | 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 . | 68 | 10 |
10,950 | 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 . | 94 | 10 |
10,951 | 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 . | 47 | 11 |
10,952 | 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 . | 120 | 15 |
10,953 | 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 . | 54 | 10 |
10,954 | public Class < ? > findClass ( String className , String versionRange ) { //if (ClassServiceBootstrap.repositoryAdmin == null) // return null; Class < ? > c = this . getClassFromBundle ( null , className , versionRange ) ; if ( c == null ) { Object resource = this . deployThisResource ( ClassFinderActivator . getPackag... | Find resolve and return this class definition . | 165 | 8 |
10,955 | public URL findResourceURL ( String resourcePath , String versionRange ) { //if (ClassServiceBootstrap.repositoryAdmin == null) // return null; URL url = this . getResourceFromBundle ( null , resourcePath , versionRange ) ; if ( url == null ) { Object resource = this . deployThisResource ( ClassFinderActivator . getPac... | Find resolve and return this resource s URL . | 122 | 9 |
10,956 | public ResourceBundle findResourceBundle ( String resourcePath , Locale locale , String versionRange ) { //if (ClassServiceBootstrap.repositoryAdmin == null) // return null; ResourceBundle resourceBundle = this . getResourceBundleFromBundle ( null , resourcePath , locale , versionRange ) ; if ( resourceBundle == null )... | Find resolve and return this ResourceBundle . | 267 | 9 |
10,957 | 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 . | 374 | 8 |
10,958 | 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 . | 75 | 4 |
10,959 | @ SuppressWarnings ( "unchecked" ) @ Override public Dictionary < String , String > getProperties ( String servicePid ) { Dictionary < String , String > properties = null ; try { if ( servicePid != null ) { ServiceReference caRef = bundleContext . getServiceReference ( ConfigurationAdmin . class . getName ( ) ) ; if ( ... | Get the configuration properties for this Pid . | 151 | 9 |
10,960 | @ Override 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 = ( Configurati... | Set the configuration properties for this Pid . | 132 | 9 |
10,961 | 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 . | 106 | 20 |
10,962 | 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 . | 37 | 11 |
10,963 | 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 . | 55 | 18 |
10,964 | public void setAlertChannels ( Collection < AlertChannel > channels ) { for ( AlertChannel channel : channels ) { // Add the channel to any policies it is associated with List < Long > policyIds = channel . getLinks ( ) . getPolicyIds ( ) ; for ( long policyId : policyIds ) { AlertPolicy policy = policies . get ( polic... | Sets the channels on the policies for the account . | 139 | 11 |
10,965 | 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 . | 55 | 18 |
10,966 | 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 . | 75 | 20 |
10,967 | 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 . | 69 | 20 |
10,968 | 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 . | 69 | 20 |
10,969 | 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 . | 66 | 20 |
10,970 | 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 . | 69 | 19 |
10,971 | 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 | 51 | 6 |
10,972 | 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 . | 80 | 8 |
10,973 | 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 . | 74 | 14 |
10,974 | 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 . | 419 | 9 |
10,975 | 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! | 197 | 17 |
10,976 | 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 . | 162 | 14 |
10,977 | 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 . | 437 | 26 |
10,978 | 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 ) { // various format errors from valueOf() - ig... | Parses a string to produce a validated value of this given data type . | 124 | 16 |
10,979 | public void preValidate ( String text ) throws DataValidationException { // size Trace . g . std . note ( Validator . class , "preValidate: size = " + _size ) ; if ( _size > 0 && text . length ( ) > _size ) { throw new DataValidationException ( "SIZE" , _name , text ) ; } // pattern Trace . g . std . note ( Validator .... | Performs all data validation that is based on the string representation of the value before it is converted . | 149 | 20 |
10,980 | @ 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 | 249 | 14 |
10,981 | public void startRobot ( Robot newRobot ) { newRobot . getData ( ) . setActiveState ( DEFAULT_START_STATE ) ; Thread newThread = new Thread ( robotsThreads , newRobot , "Bot-" + newRobot . getSerialNumber ( ) ) ; newThread . start ( ) ; // jumpstarts the robot } | Starts the thread of a robot in the player s thread group | 78 | 13 |
10,982 | public static List < Player > loadPlayers ( List < String > playersFiles ) throws PlayerException { log . info ( "[loadPlayers] Loading all players" ) ; List < Player > players = new ArrayList <> ( ) ; if ( playersFiles . size ( ) < 1 ) { log . warn ( "[loadPlayers] No players to load" ) ; } for ( String singlePath : p... | Creates a list of players using the paths provided | 112 | 10 |
10,983 | public void add ( Collection < Dashboard > dashboards ) { for ( Dashboard dashboard : dashboards ) this . dashboards . put ( dashboard . getId ( ) , dashboard ) ; } | Adds the dashboard list to the dashboards for the account . | 40 | 12 |
10,984 | @ Override public synchronized void write ( final Event event ) throws IOException { if ( ! acceptsEvents ) { log . warn ( "Writer not ready, discarding event: {}" , event ) ; return ; } delegate . write ( event ) ; uncommittedWriteCount ++ ; commitIfNeeded ( ) ; } | Write an Event via the delegate writer | 66 | 7 |
10,985 | @ Managed ( description = "Commit locally spooled events for flushing" ) @ Override public synchronized void forceCommit ( ) throws IOException { log . debug ( "Performing commit on delegate EventWriter [{}]" , delegate . getClass ( ) ) ; delegate . commit ( ) ; uncommittedWriteCount = 0 ; lastCommitNanos = getNow ( ) ... | Perform a commit via the delegate writer | 84 | 8 |
10,986 | public OptionalFunction < T , R > orElse ( Supplier < R > supplier ) { return new OptionalFunction <> ( function , supplier ) ; } | Creates a new OptionalFunction that will use the given function for null values . | 32 | 16 |
10,987 | public OptionalFunction < T , R > orElseThrow ( Supplier < ? extends RuntimeException > exceptionSupplier ) { return new OptionalFunction <> ( this . function , ( ) -> { throw exceptionSupplier . get ( ) ; } ) ; } | Creates a new OptionalFunction that will throw the exception supplied by the given supplier for null values . | 53 | 20 |
10,988 | public static TimeZone getTimeZone ( String name ) { TimeZone ret = null ; if ( timezones != null ) { for ( int i = 0 ; i < timezones . length && ret == null ; i ++ ) { if ( timezones [ i ] . getName ( ) . equals ( name ) ) ret = timezones [ i ] . getTimeZone ( ) ; } } return ret ; } | Returns the cached timezone with the given name . | 90 | 10 |
10,989 | public static TimeZone getTimeZoneById ( String id ) { TimeZone ret = null ; if ( timezones != null ) { for ( int i = 0 ; i < timezones . length && ret == null ; i ++ ) { if ( timezones [ i ] . getId ( ) . equals ( id ) ) ret = timezones [ i ] . getTimeZone ( ) ; } } return ret ; } | Returns the cached timezone with the given ID . | 91 | 10 |
10,990 | public static TimeZone getTimeZoneByIdIgnoreCase ( String id ) { TimeZone ret = null ; if ( timezones != null ) { id = id . toLowerCase ( ) ; for ( int i = 0 ; i < timezones . length && ret == null ; i ++ ) { if ( timezones [ i ] . getId ( ) . toLowerCase ( ) . equals ( id ) ) ret = timezones [ i ] . getTimeZone ( ) ; ... | Returns the cached timezone with the given ID ignoring case . | 110 | 12 |
10,991 | private String getDisplayName ( ) { long hours = TimeUnit . MILLISECONDS . toHours ( tz . getRawOffset ( ) ) ; long minutes = Math . abs ( TimeUnit . MILLISECONDS . toMinutes ( tz . getRawOffset ( ) ) - TimeUnit . HOURS . toMinutes ( hours ) ) ; return String . format ( "(GMT%+d:%02d) %s" , hours , minutes , tz . getID... | Returns the display name of the timezone . | 110 | 9 |
10,992 | public void report ( DiagnosticPosition pos , String msg , Object ... args ) { JavaFileObject currentSource = log . currentSourceFile ( ) ; if ( verbose ) { if ( sourcesWithReportedWarnings == null ) sourcesWithReportedWarnings = new HashSet < JavaFileObject > ( ) ; if ( log . nwarnings < log . MaxWarnings ) { // gener... | Report a mandatory warning . | 453 | 5 |
10,993 | public static long combineInts ( String high , String low ) throws NumberFormatException { int highInt = Integer . parseInt ( high ) ; int lowInt = Integer . parseInt ( low ) ; /* * Shift the high integer into the upper 32 bits and add the low * integer. However, since this is really a single set of bits split in * hal... | Combine two numbers that represent the high and low bits of a 64 - bit number . | 145 | 18 |
10,994 | public static Pair < String , String > splitLong ( long value ) { return Pair . of ( String . valueOf ( ( int ) ( value >> 32 ) ) , String . valueOf ( ( int ) value ) ) ; } | Split a single 64 bit number into integers representing the high and low 32 bits . | 48 | 16 |
10,995 | public static void sendExpectOk ( SocketManager socketManager , String message ) throws IOException { expectOk ( socketManager . sendAndWait ( message ) ) ; } | Send a message via the given socket manager which should always receive a case insensitive OK as the reply . | 35 | 20 |
10,996 | public static void expectOk ( String response ) throws ProtocolException { if ( ! "OK" . equalsIgnoreCase ( response ) ) { throw new ProtocolException ( response , Direction . RECEIVE ) ; } } | Check the response for an OK message . Throw an exception if response is not expected . | 45 | 17 |
10,997 | public void printError ( SourcePosition pos , String msg ) { if ( diagListener != null ) { report ( DiagnosticType . ERROR , pos , msg ) ; return ; } if ( nerrors < MaxErrors ) { String prefix = ( pos == null ) ? programName : pos . toString ( ) ; errWriter . println ( prefix + ": " + getText ( "javadoc.error" ) + " - ... | Print error message increment error count . Part of DocErrorReporter . | 115 | 14 |
10,998 | public Object unmarshal ( Object map ) throws RpcException { return unmarshal ( getTypeClass ( ) , map , this . s , this . isOptional ) ; } | Converts o from a Map back to the Java Class associated with this Struct . Recursively unmarshals all the members of the map . | 38 | 29 |
10,999 | @ SuppressWarnings ( "unchecked" ) public Object marshal ( Object o ) throws RpcException { if ( o == null ) { return returnNullIfOptional ( ) ; } else if ( o instanceof BStruct ) { return validateMap ( structToMap ( o , this . s ) , this . s ) ; } else if ( o instanceof Map ) { return validateMap ( ( Map ) o , this . ... | Marshals native Java type o to a Map that can be serialized . Recursively marshals all of the Struct fields from o onto the map . | 143 | 31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.