signature
stringlengths
43
39.1k
implementation
stringlengths
0
450k
public class IoTProvisioningManager { /** * As the given provisioning server is the given JID is a friend . * @ param provisioningServer the provisioning server to ask . * @ param friendInQuestion the JID to ask about . * @ return < code > true < / code > if the JID is a friend , < code > false < / code > otherwise . * @ throws NoResponseException * @ throws XMPPErrorException * @ throws NotConnectedException * @ throws InterruptedException */ public boolean isFriend ( Jid provisioningServer , BareJid friendInQuestion ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { } }
LruCache < BareJid , Void > cache = negativeFriendshipRequestCache . lookup ( provisioningServer ) ; if ( cache != null && cache . containsKey ( friendInQuestion ) ) { // We hit a cached negative isFriend response for this provisioning server . return false ; } IoTIsFriend iotIsFriend = new IoTIsFriend ( friendInQuestion ) ; iotIsFriend . setTo ( provisioningServer ) ; IoTIsFriendResponse response = connection ( ) . createStanzaCollectorAndSend ( iotIsFriend ) . nextResultOrThrow ( ) ; assert ( response . getJid ( ) . equals ( friendInQuestion ) ) ; boolean isFriend = response . getIsFriendResult ( ) ; if ( ! isFriend ) { // Cache the negative is friend response . if ( cache == null ) { cache = new LruCache < > ( 1024 ) ; negativeFriendshipRequestCache . put ( provisioningServer , cache ) ; } cache . put ( friendInQuestion , null ) ; } return isFriend ;
public class StringUtil { /** * Turns a string value into a java . lang . Number . * If the string starts with { @ code 0x } or { @ code - 0x } ( lower or upper case ) * or { @ code # } or { @ code - # } , it will be interpreted as a hexadecimal * Integer - or Long , if the number of digits after the prefix is more than * 8 - or BigInteger if there are more than 16 digits . * Then , the value is examined for a type qualifier on the end , i . e . one of * < code > ' f ' , ' F ' , ' d ' , ' D ' , ' l ' , ' L ' < / code > . If it is found , it starts trying to * create successively larger types from the type specified until one is * found that can represent the value . * If a type specifier is not found , it will check for a decimal point and * then try successively larger types from < code > Integer < / code > to * < code > BigInteger < / code > and from < code > double < / code > to * < code > BigDecimal < / code > . * Integral values with a leading { @ code 0 } will be interpreted as octal ; * the returned number will be Integer , Long or BigDecimal as appropriate . * Returns an empty { @ code Optional } if the string is { @ code null } or can ' t be parsed as { @ code Number } . * @ param str a String containing a number , may be null * @ return */ @ SuppressWarnings ( { } }
"unchecked" , "rawtypes" } ) public static Optional < Number > createNumber ( final String str ) { if ( N . isNullOrEmptyOrBlank ( str ) ) { return Optional . empty ( ) ; } // Need to deal with all possible hex prefixes here final String [ ] hex_prefixes = { "0x" , "0X" , "-0x" , "-0X" , "#" , "-#" } ; int pfxLen = 0 ; for ( final String pfx : hex_prefixes ) { if ( str . startsWith ( pfx ) ) { pfxLen += pfx . length ( ) ; break ; } } if ( pfxLen > 0 ) { // we have a hex number char firstSigDigit = 0 ; // strip leading zeroes for ( int i = pfxLen ; i < str . length ( ) ; i ++ ) { firstSigDigit = str . charAt ( i ) ; if ( firstSigDigit == '0' ) { // count leading zeroes pfxLen ++ ; } else { break ; } } final int hexDigits = str . length ( ) - pfxLen ; if ( hexDigits > 16 || hexDigits == 16 && firstSigDigit > '7' ) { // too many for Long return ( Optional ) createBigInteger ( str ) ; } else if ( hexDigits > 8 || hexDigits == 8 && firstSigDigit > '7' ) { // too many for an int return ( Optional ) createLong ( str ) . boxed ( ) ; } else { return ( Optional ) createInteger ( str ) . boxed ( ) ; } } final char lastChar = str . charAt ( str . length ( ) - 1 ) ; String mant ; String dec ; String exp ; final int decPos = str . indexOf ( '.' ) ; final int expPos = str . indexOf ( 'e' ) + str . indexOf ( 'E' ) + 1 ; // assumes both not present // if both e and E are present , this is caught by the checks on expPos ( which prevent IOOBE ) // and the parsing which will detect if e or E appear in a number due to using the wrong offset Optional < ? extends Number > op = null ; if ( decPos > - 1 ) { // there is a decimal point if ( expPos > - 1 ) { // there is an exponent if ( expPos < decPos || expPos > str . length ( ) ) { // prevents double exponent causing IOOBE return Optional . empty ( ) ; } dec = str . substring ( decPos + 1 , expPos ) ; } else { dec = str . substring ( decPos + 1 ) ; } mant = getMantissa ( str , decPos ) ; } else { if ( expPos > - 1 ) { if ( expPos > str . length ( ) ) { // prevents double exponent causing IOOBE return Optional . empty ( ) ; } mant = getMantissa ( str , expPos ) ; } else { mant = getMantissa ( str ) ; } dec = null ; } if ( ! Character . isDigit ( lastChar ) && lastChar != '.' ) { if ( expPos > - 1 && expPos < str . length ( ) - 1 ) { exp = str . substring ( expPos + 1 , str . length ( ) - 1 ) ; } else { exp = null ; } // Requesting a specific type . . final String numeric = str . substring ( 0 , str . length ( ) - 1 ) ; final boolean allZeros = isAllZeros ( mant ) && isAllZeros ( exp ) ; switch ( lastChar ) { case 'l' : case 'L' : if ( dec == null && exp == null && ( numeric . charAt ( 0 ) == '-' && StringUtil . isNumeric ( numeric . substring ( 1 ) ) || StringUtil . isNumeric ( numeric ) ) ) { op = createLong ( numeric ) . boxed ( ) ; if ( op . isPresent ( ) ) { return ( Optional ) op ; } else { return ( Optional ) createBigInteger ( numeric ) ; } } return Optional . empty ( ) ; case 'f' : case 'F' : try { final Float f = Float . valueOf ( str ) ; if ( ! ( f . isInfinite ( ) || f . floatValue ( ) == 0.0F && ! allZeros ) ) { // If it ' s too big for a float or the float value = 0 and the string // has non - zeros in it , then float does not have the precision we want return ( Optional ) Optional . of ( f ) ; } } catch ( final NumberFormatException nfe ) { // NOPMD // ignore the bad number } // $ FALL - THROUGH $ case 'd' : case 'D' : try { final Double d = Double . valueOf ( str ) ; if ( ! ( d . isInfinite ( ) || d . floatValue ( ) == 0.0D && ! allZeros ) ) { return ( Optional ) Optional . of ( d ) ; } } catch ( final NumberFormatException nfe ) { // NOPMD // ignore the bad number } return ( Optional ) createBigDecimal ( numeric ) ; // $ FALL - THROUGH $ default : return Optional . empty ( ) ; } } // User doesn ' t have a preference on the return type , so let ' s start // small and go from there . . . if ( expPos > - 1 && expPos < str . length ( ) - 1 ) { exp = str . substring ( expPos + 1 , str . length ( ) ) ; } else { exp = null ; } if ( dec == null && exp == null ) { // no decimal point and no exponent // Must be an Integer , Long , Biginteger op = createInteger ( str ) . boxed ( ) ; if ( op . isPresent ( ) ) { return ( Optional ) op ; } else { op = createLong ( str ) . boxed ( ) ; if ( op . isPresent ( ) ) { return ( Optional ) op ; } else { return ( Optional ) createBigInteger ( str ) ; } } } // Must be a Float , Double , BigDecimal final boolean allZeros = isAllZeros ( mant ) && isAllZeros ( exp ) ; try { final Float f = Float . valueOf ( str ) ; final Double d = Double . valueOf ( str ) ; if ( ! f . isInfinite ( ) && ! ( f . floatValue ( ) == 0.0F && ! allZeros ) && f . toString ( ) . equals ( d . toString ( ) ) ) { return ( Optional ) Optional . of ( f ) ; } if ( ! d . isInfinite ( ) && ! ( d . doubleValue ( ) == 0.0D && ! allZeros ) ) { final Optional < BigDecimal > b = createBigDecimal ( str ) ; if ( b . isPresent ( ) && b . get ( ) . compareTo ( BigDecimal . valueOf ( d . doubleValue ( ) ) ) == 0 ) { return ( Optional ) Optional . of ( d ) ; } else { return ( Optional ) b ; } } } catch ( final NumberFormatException nfe ) { // NOPMD // ignore the bad number } return ( Optional ) createBigDecimal ( str ) ;
public class DataSetLookupEditor { /** * DataSetFilterEditor events */ void onFilterChanged ( @ Observes DataSetFilterChangedEvent event ) { } }
DataSetFilter filterOp = event . getFilter ( ) ; dataSetLookup . removeOperations ( DataSetOpType . FILTER ) ; if ( filterOp != null ) { dataSetLookup . addOperation ( 0 , filterOp ) ; } changeEvent . fire ( new DataSetLookupChangedEvent ( dataSetLookup ) ) ;
public class SchedulerStateManagerAdaptor { /** * Set the packing plan for the given topology * @ param packingPlan the packing plan of the topology * @ return Boolean - Success or Failure */ public Boolean setPackingPlan ( PackingPlans . PackingPlan packingPlan , String topologyName ) { } }
return awaitResult ( delegate . setPackingPlan ( packingPlan , topologyName ) ) ;
public class CmsGalleryControllerHandler { /** * Will be triggered when the sort parameters of the galleries list are changed . < p > * @ param galleries the updated galleries list * @ param selectedGalleries the list of galleries to select */ public void onUpdateGalleries ( List < CmsGalleryFolderBean > galleries , List < String > selectedGalleries ) { } }
m_galleryDialog . getGalleriesTab ( ) . updateListContent ( galleries , selectedGalleries ) ;
public class DiGraph { /** * Returns the number of arcs in < code > this < / code > directed * graph . * Complexity : linear in the size of the graph . Cached if the * < code > CACHING < / code > argument to the constructor was true . */ public long numArcs ( ) { } }
if ( CACHING && ( cachedNumArcs != - 1 ) ) { return cachedNumArcs ; } long numArcs = 0 ; for ( Vertex v : vertices ( ) ) { numArcs += getForwardNavigator ( ) . next ( v ) . size ( ) ; } if ( CACHING ) { cachedNumArcs = numArcs ; } return numArcs ;
public class X509SubjectAlternativeNameUPNPrincipalResolver { /** * Get alt name seq . * @ param sanValue subject alternative name value encoded as byte [ ] * @ return ASN1Sequence abstraction representing subject alternative name * @ see < a href = " http : / / docs . oracle . com / javase / 7 / docs / api / java / security / cert / X509Certificate . html # getSubjectAlternativeNames ( ) " > * X509Certificate # getSubjectAlternativeNames < / a > */ private static ASN1Sequence getAltnameSequence ( final byte [ ] sanValue ) { } }
try ( val bInput = new ByteArrayInputStream ( sanValue ) ; val input = new ASN1InputStream ( bInput ) ) { return ASN1Sequence . getInstance ( input . readObject ( ) ) ; } catch ( final IOException e ) { LOGGER . error ( "An error has occurred while reading the subject alternative name value" , e ) ; } return null ;
public class ConfinedDiffusionMSDCurveFit { /** * Fits the curve y = a * ( 1 - b * exp ( ( - 4 * D ) * ( x / a ) * c ) ) to the x - and y data . * The parameters have the follow meaning : * @ param xdata * @ param ydata */ public void doFit ( double [ ] xdata , double [ ] ydata , boolean reduced ) { } }
CurveFitter fitter = new CurveFitter ( xdata , ydata ) ; if ( reduced == false ) { double ia = Double . isNaN ( initA ) ? 0 : initA ; double ib = Double . isNaN ( initB ) ? 0 : initB ; double ic = Double . isNaN ( initC ) ? 0 : initC ; double id = Double . isNaN ( initD ) ? 0 : initD ; double [ ] initialParams = new double [ ] { ia , ib , ic , id } ; // , regest . evaluate ( ) [ 0 ] } ; fitter . setInitialParameters ( initialParams ) ; // fitter . doCustomFit ( " y = a * ( 1 - b * exp ( - 4 * c * d * x / a ) ) " , initialParams , false ) ; fitter . doCustomFit ( "y=sqrt(a*a)*(1-sqrt(b*b)*exp(-4*sqrt(c*c)*sqrt(d*d)*x/sqrt(a*a)))" , initialParams , false ) ; double [ ] params = fitter . getParams ( ) ; a = Math . abs ( params [ 0 ] ) ; b = Math . abs ( params [ 1 ] ) ; c = Math . abs ( params [ 2 ] ) ; D = Math . abs ( params [ 3 ] ) ; goodness = fitter . getFitGoodness ( ) ; } else { double ia = Double . isNaN ( initA ) ? 0 : initA ; double id = Double . isNaN ( initD ) ? 0 : initD ; double [ ] initialParams = new double [ ] { ia , id } ; // , regest . evaluate ( ) [ 0 ] } ; fitter . setInitialParameters ( initialParams ) ; // fitter . doCustomFit ( " y = a * ( 1 - b * exp ( - 4 * c * d * x / a ) ) " , initialParams , false ) ; fitter . doCustomFit ( "y=sqrt(a*a)*(1-exp(-4*sqrt(b*b)*x/sqrt(a*a)))" , initialParams , false ) ; double [ ] params = fitter . getParams ( ) ; a = Math . abs ( params [ 0 ] ) ; D = Math . abs ( params [ 1 ] ) ; goodness = fitter . getFitGoodness ( ) ; }
public class GuildManager { /** * Sets the afk { @ link net . dv8tion . jda . core . entities . Guild . Timeout Timeout } of this { @ link net . dv8tion . jda . core . entities . Guild Guild } . * @ param timeout * The new afk timeout for this { @ link net . dv8tion . jda . core . entities . Guild Guild } * @ throws IllegalArgumentException * If the provided timeout is { @ code null } * @ return GuildManager for chaining convenience */ @ CheckReturnValue public GuildManager setAfkTimeout ( Guild . Timeout timeout ) { } }
Checks . notNull ( timeout , "Timeout" ) ; this . afkTimeout = timeout . getSeconds ( ) ; set |= AFK_TIMEOUT ; return this ;
public class TxTMHelper { /** * UOWScopeCallbackAgent interface */ @ Override public void registerCallback ( UOWScopeCallback callback ) { } }
if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "registerCallback" , callback ) ; UserTransactionImpl . instance ( ) . registerCallback ( callback ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "registerCallback" ) ;
public class FrenchRepublicanCalendar { /** * / * [ deutsch ] * < p > Erzeugt ein neues franz & ouml ; sisches Republikdatum . < / p > * @ param year republican year in range 1-1202 * @ param month republican month in range 1-12 * @ param dayOfMonth day of month in range 1-30 * @ return new instance of { @ code FrenchRepublicanCalendar } * @ throws IllegalArgumentException in case of any inconsistencies */ public static FrenchRepublicanCalendar of ( int year , int month , int dayOfMonth ) { } }
if ( ( year < 1 ) || ( year > MAX_YEAR ) || ( month < 1 ) || ( month > 12 ) || ( dayOfMonth < 1 ) || ( dayOfMonth > 30 ) ) { throw new IllegalArgumentException ( "Invalid French republican date: year=" + year + ", month=" + month + ", day=" + dayOfMonth ) ; } return new FrenchRepublicanCalendar ( year , ( month - 1 ) * 30 + dayOfMonth ) ;
public class DefaultEncoderFactory { /** * { @ inheritDoc } */ public BinaryEncoder createBinaryEncoder ( final Encoding encoding ) throws UnsupportedEncodingException { } }
if ( Encoding . QUOTED_PRINTABLE . equals ( encoding ) ) { return new QuotedPrintableCodec ( ) ; } else if ( Encoding . BASE64 . equals ( encoding ) ) { return new Base64 ( ) ; } throw new UnsupportedEncodingException ( MessageFormat . format ( UNSUPPORTED_ENCODING_MESSAGE , encoding ) ) ;
public class ReflectUtils { /** * Gets the all interface names of this class * @ param c The class of one object * @ return Returns the all interface names */ public static String [ ] getInterfaceNames ( Class < ? > c ) { } }
Class < ? > [ ] interfaces = c . getInterfaces ( ) ; List < String > names = new ArrayList < > ( ) ; for ( Class < ? > i : interfaces ) { names . add ( i . getName ( ) ) ; } return names . toArray ( new String [ 0 ] ) ;
public class QueryUtils { /** * Checks if the provided candidate is explicitly contained in the provided indices . */ public static boolean isExplicitlyRequested ( String candidate , String ... indices ) { } }
boolean result = false ; for ( String indexOrAlias : indices ) { boolean include = true ; if ( indexOrAlias . charAt ( 0 ) == '+' || indexOrAlias . charAt ( 0 ) == '-' ) { include = indexOrAlias . charAt ( 0 ) == '+' ; indexOrAlias = indexOrAlias . substring ( 1 ) ; } if ( indexOrAlias . equals ( "*" ) || indexOrAlias . equals ( "_all" ) ) { return false ; } if ( Regex . isSimpleMatchPattern ( indexOrAlias ) ) { if ( Regex . simpleMatch ( indexOrAlias , candidate ) ) { if ( include ) { result = true ; } else { return false ; } } } else { if ( candidate . equals ( indexOrAlias ) ) { if ( include ) { result = true ; } else { return false ; } } } } return result ;
public class XMLUtils { /** * Get DOM parser . * @ return DOM document builder instance . * @ throws RuntimeException if instantiating DocumentBuilder failed */ public static DocumentBuilder getDocumentBuilder ( ) { } }
DocumentBuilder builder ; try { builder = factory . newDocumentBuilder ( ) ; } catch ( final ParserConfigurationException e ) { throw new RuntimeException ( e ) ; } if ( Configuration . DEBUG ) { builder = new DebugDocumentBuilder ( builder ) ; } return builder ;
public class ConfigUtil { /** * Like { @ link # loadInheritedProperties ( String , ClassLoader ) } but the properties are loaded into * the supplied properties object . Properties that already exist in the supplied object will * be overwritten by the loaded properties where they have the same key . * @ exception FileNotFoundException thrown if no properties files are found for the specified * path . */ public static void loadInheritedProperties ( String path , ClassLoader loader , Properties target ) throws IOException { } }
// first look for the files in the supplied class loader Enumeration < URL > enm = getResources ( path , loader ) ; if ( ! enm . hasMoreElements ( ) ) { // if we couldn ' t find anything there , try the system class loader ( but only if that ' s // not where we were already looking ) try { ClassLoader sysloader = ClassLoader . getSystemClassLoader ( ) ; if ( sysloader != loader ) { enm = getResources ( path , sysloader ) ; } } catch ( AccessControlException ace ) { // can ' t get the system loader , no problem ! } } // stick the matches into an array list so that we can count them ArrayList < URL > rsrcs = new ArrayList < URL > ( ) ; while ( enm . hasMoreElements ( ) ) { rsrcs . add ( enm . nextElement ( ) ) ; } // load up the metadata for the properties files PropRecord root = null , crown = null ; HashMap < String , PropRecord > map = null ; if ( rsrcs . size ( ) == 0 ) { // if we found no resources in our enumerations , complain throw new FileNotFoundException ( path ) ; } else if ( rsrcs . size ( ) == 1 ) { // parse the metadata for our only properties file root = parseMetaData ( path , rsrcs . get ( 0 ) ) ; } else { map = new HashMap < String , PropRecord > ( ) ; for ( int ii = 0 ; ii < rsrcs . size ( ) ; ii ++ ) { // parse the metadata for this properties file PropRecord record = parseMetaData ( path , rsrcs . get ( ii ) ) ; // make sure the record we parseded is valid because we ' re going to be doing // overrides record . validate ( ) ; // then map it according to its package defintion map . put ( record . _package , record ) ; // if this guy overrides nothing , he ' s the root property if ( record . _overrides == null ) { // make sure there aren ' t two or more roots if ( root != null ) { String errmsg = record + " cannot have the same path as " + root + " without one overriding the other." ; throw new IOException ( errmsg ) ; } root = record ; } } // now wire up all the records according to the hierarchy for ( PropRecord prec : map . values ( ) ) { if ( prec . _overrides == null ) { // sanity check if ( prec != root ) { String errmsg = "Internal error: found multiple roots where we shouldn't " + "have [root=" + root + ", prec=" + prec + "]" ; throw new IOException ( errmsg ) ; } continue ; } // wire this guy up to whomever he overrides for ( String ppkg : prec . _overrides ) { PropRecord parent = map . get ( ppkg ) ; if ( parent == null ) { throw new IOException ( "Cannot find parent '" + ppkg + "' for " + prec ) ; } parent . add ( prec ) ; } } // verify that there is only one crown ArrayList < PropRecord > crowns = new ArrayList < PropRecord > ( ) ; for ( PropRecord prec : map . values ( ) ) { if ( prec . size ( ) == 0 ) { crowns . add ( prec ) ; } } if ( crowns . size ( ) == 0 ) { String errmsg = "No top-level property override could be found, perhaps there " + "are circular references " + StringUtil . toString ( map . values ( ) ) ; throw new IOException ( errmsg ) ; } else if ( crowns . size ( ) > 1 ) { StringBuilder errmsg = new StringBuilder ( ) ; errmsg . append ( "Multiple top-level properties were found, " ) ; errmsg . append ( "one definitive top-level file must provide " ) ; errmsg . append ( "an order for all others:\n" ) ; for ( int ii = 0 ; ii < crowns . size ( ) ; ii ++ ) { if ( ii > 0 ) { errmsg . append ( "\n" ) ; } errmsg . append ( crowns . get ( ii ) ) ; } throw new IOException ( errmsg . toString ( ) ) ; } crown = crowns . get ( 0 ) ; } // if the root extends another file , resolve that first if ( ! StringUtil . isBlank ( root . _extends ) ) { try { loadInheritedProperties ( root . _extends , loader , target ) ; } catch ( FileNotFoundException fnfe ) { throw new IOException ( "Unable to locate parent '" + root . _extends + "' for '" + root . path + "'" ) ; } } // now apply all of the overrides , in the appropriate order if ( crown != null ) { HashMap < String , PropRecord > applied = new HashMap < String , PropRecord > ( ) ; loadPropertiesOverrides ( crown , map , applied , loader , target ) ; } else { // we have no overrides , so load our props up straight InputStream in = root . sourceURL . openStream ( ) ; target . load ( in ) ; in . close ( ) ; } // finally remove the metadata properties target . remove ( PACKAGE_KEY ) ; target . remove ( EXTENDS_KEY ) ; target . remove ( OVERRIDES_KEY ) ;
public class IndexImage { /** * Converts the input image ( must be { @ code TYPE _ INT _ RGB } or * { @ code TYPE _ INT _ ARGB } ) to an indexed image . Using the supplied * { @ code IndexColorModel } ' s palette . * Dithering , transparency and color selection is controlled with the * { @ code pHints } parameter . * The image returned is a new image , the input image is not modified . * @ param pImage the BufferedImage to index * @ param pColors an { @ code IndexColorModel } containing the color information * @ param pHints RenderingHints that control output quality and speed . * @ return the indexed BufferedImage . The image will be of type * { @ code BufferedImage . TYPE _ BYTE _ INDEXED } or * { @ code BufferedImage . TYPE _ BYTE _ BINARY } , and use an * { @ code IndexColorModel } . * @ see # DITHER _ DIFFUSION * @ see # DITHER _ NONE * @ see # COLOR _ SELECTION _ FAST * @ see # COLOR _ SELECTION _ QUALITY * @ see # TRANSPARENCY _ OPAQUE * @ see # TRANSPARENCY _ BITMASK * @ see BufferedImage # TYPE _ BYTE _ INDEXED * @ see BufferedImage # TYPE _ BYTE _ BINARY * @ see IndexColorModel */ public static BufferedImage getIndexedImage ( BufferedImage pImage , IndexColorModel pColors , int pHints ) { } }
return getIndexedImage ( pImage , pColors , null , pHints ) ;
public class RandomAccessFile { /** * Closes this file . * @ throws IOException * if an error occurs while closing this file . */ public void close ( ) throws IOException { } }
guard . close ( ) ; synchronized ( this ) { if ( channel != null && channel . isOpen ( ) ) { channel . close ( ) ; // j2objc : since a @ RetainedWith field cannot be reassigned , the following line is // commented out . If a channel is already closed , the predicate above will be false // and so this branch will not be taken . FileInputStream and FileOutputStream // simply call channel . close ( ) when channel is not null witout even checking if // it ' s still open ( and that ' s ok ) . // channel = null ; } IoUtils . close ( fd ) ; }
public class TopicsInner { /** * Create a topic . * Asynchronously creates a new topic with the specified parameters . * @ param resourceGroupName The name of the resource group within the user ' s subscription . * @ param topicName Name of the topic * @ param topicInfo Topic information * @ throws IllegalArgumentException thrown if parameters fail the validation * @ return the observable to the TopicInner object */ public Observable < TopicInner > beginCreateOrUpdateAsync ( String resourceGroupName , String topicName , TopicInner topicInfo ) { } }
return beginCreateOrUpdateWithServiceResponseAsync ( resourceGroupName , topicName , topicInfo ) . map ( new Func1 < ServiceResponse < TopicInner > , TopicInner > ( ) { @ Override public TopicInner call ( ServiceResponse < TopicInner > response ) { return response . body ( ) ; } } ) ;
public class KxPublisherActor { /** * same as with onError */ @ Override @ CallerSideMethod public void onNext ( IN in ) { } }
if ( in == null ) throw null ; _onNext ( in ) ;
public class AvailableNumber { /** * Convenience factory method to return local numbers based on a given search criteria for a given client * @ param client the client * @ param params the params * @ return the list * @ throws IOException unexpected error . */ public static List < AvailableNumber > searchLocal ( final BandwidthClient client , final Map < String , Object > params ) throws Exception { } }
final String tollFreeUri = BandwidthConstants . AVAILABLE_NUMBERS_LOCAL_URI_PATH ; final JSONArray array = toJSONArray ( client . get ( tollFreeUri , params ) ) ; final List < AvailableNumber > numbers = new ArrayList < AvailableNumber > ( ) ; for ( final Object obj : array ) { numbers . add ( new AvailableNumber ( client , ( JSONObject ) obj ) ) ; } return numbers ;
public class Client { /** * Log the user in and get a valid access token . * @ param email * @ param password * @ return non - null ApiResponse if request succeeds , check getError ( ) for * " invalid _ grant " to see if access is denied . */ public ApiResponse authorizeAppUser ( String email , String password ) { } }
validateNonEmptyParam ( email , "email" ) ; validateNonEmptyParam ( password , "password" ) ; assertValidApplicationId ( ) ; loggedInUser = null ; accessToken = null ; currentOrganization = null ; Map < String , Object > formData = new HashMap < String , Object > ( ) ; formData . put ( "grant_type" , "password" ) ; formData . put ( "username" , email ) ; formData . put ( "password" , password ) ; ApiResponse response = apiRequest ( HttpMethod . POST , formData , null , organizationId , applicationId , "token" ) ; if ( response == null ) { return response ; } if ( ! isEmpty ( response . getAccessToken ( ) ) && ( response . getUser ( ) != null ) ) { loggedInUser = response . getUser ( ) ; accessToken = response . getAccessToken ( ) ; currentOrganization = null ; log . info ( "Client.authorizeAppUser(): Access token: " + accessToken ) ; } else { log . info ( "Client.authorizeAppUser(): Response: " + response ) ; } return response ;
public class NetworkBartenderServiceImpl { /** * public void addClusterPortConfig ( ConfigProgram program ) * _ bartenderPortConfig . addProgram ( program ) ; */ public boolean start ( ) throws Exception { } }
// ServerNetwork clusterServer = getServerNetwork ( _ selfServer ) ; if ( _selfServer . port ( ) >= 0 ) { // _ hmuxProtocol = HmuxProtocol . create ( ) ; _httpProtocol = new ProtocolHttp ( ) ; _httpProtocolBartender = new ProtocolHttp ( ) ; _httpProtocol . extensionProtocol ( _protocolBartenderPublic ) ; _httpProtocolBartender . extensionProtocol ( _protocolBartender ) ; ProtocolHttp protocolPublic = _httpProtocol ; /* if ( _ serverConfig . getPortBartender ( ) < 0 ) { protocolPublic = _ httpProtocolBartender ; */ Config config = _config ; PortTcpBuilder portBuilder = new PortTcpBuilder ( config ) ; portBuilder . portName ( "server" ) ; // portBuilder . serverSocket ( _ serverConfig . getServerSocket ( ) ) ; portBuilder . protocol ( protocolPublic ) ; portBuilder . ampManager ( AmpSystem . currentManager ( ) ) ; // XXX : config timing issues , see network / 0330, // NetworkServerConfig . getClusterIdleTime ( ) _portPublic = new TcpPortBartender ( portBuilder , _selfServer ) ; portBuilder . portDefault ( 8080 ) ; if ( config . get ( "bartender.port" , int . class , 0 ) >= 0 ) { portBuilder = new PortTcpBuilder ( config ) ; portBuilder . portName ( "bartender" ) ; // portBuilder . serverSocket ( _ serverConfig . getSocketBartender ( ) ) ; portBuilder . protocol ( _httpProtocolBartender ) ; // portBuilder . portDefault ( _ serverConfig . getPortBartender ( ) ) ; portBuilder . ampManager ( AmpSystem . currentManager ( ) ) ; _portBartender = new TcpPortBartender ( portBuilder , _selfServer ) ; } /* _ bartenderPortConfig . configure ( _ portPublic ) ; _ serverConfig . configurePort ( _ portPublic ) ; if ( _ portBartender ! = null ) { _ bartenderPortConfig . configure ( _ portBartender ) ; _ serverConfig . configurePort ( _ portBartender ) ; */ } startClusterPort ( ) ; // validateHub ( _ selfServer . getPod ( ) ) ; return true ;
public class DateTimeField { /** * Get this field as a java calendar value . * @ return This field as a calendar value . */ public Calendar getCalendar ( ) { } }
// Get this field ' s value java . util . Date dateValue = ( java . util . Date ) this . getData ( ) ; // Get the physical data if ( dateValue == null ) return null ; Calendar calendar = Calendar . getInstance ( ) ; calendar . setTime ( dateValue ) ; return calendar ;
public class Rule { /** * Static for inline ( 2x ) */ static boolean checkWildCards ( final SearchableString value , final Literal [ ] suffixes , final int start , final int end ) { } }
if ( suffixes == null ) { // No wildcards return start == end + 1 ; } // One wildcard if ( suffixes . length == 0 ) { return start <= end + 1 ; } int from = start ; for ( final Literal suffix : suffixes ) { final int match = checkWildCard ( value , suffix , from ) ; if ( match == - 1 ) { return false ; } from = suffix . getLength ( ) + match ; if ( from > end + 1 ) { return false ; } } return true ;
public class AbstractSupervisedProjectionVectorFilter { /** * Partition the bundle based on the class label . * @ param classcolumn * @ return Partitioned data set . */ protected < O > Map < O , IntList > partition ( List < ? extends O > classcolumn ) { } }
Map < O , IntList > classes = new HashMap < > ( ) ; Iterator < ? extends O > iter = classcolumn . iterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; i ++ ) { O lbl = iter . next ( ) ; IntList ids = classes . get ( lbl ) ; if ( ids == null ) { ids = new IntArrayList ( ) ; classes . put ( lbl , ids ) ; } ids . add ( i ) ; } return classes ;
public class ServletExternalContextImplBase { /** * ~ Methods which only rely on the ServletContext - - - - - */ @ Override public Map < String , Object > getApplicationMap ( ) { } }
if ( _applicationMap == null ) { _applicationMap = new ApplicationMap ( _servletContext ) ; } return _applicationMap ;
public class WorkflowClient { /** * Retrieve all workflow instances for a given workflow name between a specific time period * @ param workflowName the name of the workflow * @ param version the version of the workflow definition . Defaults to 1. * @ param startTime the start time of the period * @ param endTime the end time of the period * @ return returns a list of workflows created during the specified during the time period */ public List < String > getWorkflowsByTimePeriod ( String workflowName , int version , Long startTime , Long endTime ) { } }
Preconditions . checkArgument ( StringUtils . isNotBlank ( workflowName ) , "Workflow name cannot be blank" ) ; Preconditions . checkNotNull ( startTime , "Start time cannot be null" ) ; Preconditions . checkNotNull ( endTime , "End time cannot be null" ) ; Object [ ] params = new Object [ ] { "version" , version , "startTime" , startTime , "endTime" , endTime } ; return getForEntity ( "workflow/running/{name}" , params , new GenericType < List < String > > ( ) { } , workflowName ) ;
public class BeanUtil { /** * 使用Map填充Bean对象 * @ param < T > Bean类型 * @ param map Map * @ param bean Bean * @ param copyOptions 属性复制选项 { @ link CopyOptions } * @ return Bean */ public static < T > T fillBeanWithMap ( Map < ? , ? > map , T bean , CopyOptions copyOptions ) { } }
return fillBeanWithMap ( map , bean , false , copyOptions ) ;
public class Matrix3d { /** * / * ( non - Javadoc ) * @ see org . joml . Matrix3dc # rotateZ ( double , org . joml . Matrix3d ) */ public Matrix3d rotateZ ( double ang , Matrix3d dest ) { } }
double sin , cos ; sin = Math . sin ( ang ) ; cos = Math . cosFromSin ( sin , ang ) ; double rm00 = cos ; double rm10 = - sin ; double rm01 = sin ; double rm11 = cos ; // add temporaries for dependent values double nm00 = m00 * rm00 + m10 * rm01 ; double nm01 = m01 * rm00 + m11 * rm01 ; double nm02 = m02 * rm00 + m12 * rm01 ; // set non - dependent values directly dest . m10 = m00 * rm10 + m10 * rm11 ; dest . m11 = m01 * rm10 + m11 * rm11 ; dest . m12 = m02 * rm10 + m12 * rm11 ; // set other values dest . m00 = nm00 ; dest . m01 = nm01 ; dest . m02 = nm02 ; dest . m20 = m20 ; dest . m21 = m21 ; dest . m22 = m22 ; return dest ;
public class CmsXmlSitemapUrlBean { /** * Writes a single XML element with text content to a string buffer . < p > * @ param buffer the string buffer to write to * @ param tag the XML tag name * @ param content the content of the XML element */ public void writeElement ( StringBuffer buffer , String tag , String content ) { } }
buffer . append ( "<" + tag + ">" ) ; buffer . append ( CmsEncoder . escapeXml ( content ) ) ; buffer . append ( "</" + tag + ">" ) ;
public class Client { /** * Called when we receive a pong packet . We may be in the process of calculating the client / * server time differential , or we may have already done that at which point we ignore pongs . */ protected void gotPong ( PongResponse pong ) { } }
// if we ' re not currently calculating our delta , then we can throw away the pong if ( _dcalc != null ) { // we update the delta after every receipt so as to immediately obtain an estimate of // the clock delta and then refine it as more packets come in _dcalc . gotPong ( pong ) ; _serverDelta = _dcalc . getTimeDelta ( ) ; }
public class StatementManager { /** * bind BetweenCriteria * @ param stmt the PreparedStatement * @ param index the position of the parameter to bind * @ param crit the Criteria containing the parameter * @ param cld the ClassDescriptor * @ return next index for PreparedStatement */ private int bindStatement ( PreparedStatement stmt , int index , BetweenCriteria crit , ClassDescriptor cld ) throws SQLException { } }
index = bindStatementValue ( stmt , index , crit . getAttribute ( ) , crit . getValue ( ) , cld ) ; return bindStatementValue ( stmt , index , crit . getAttribute ( ) , crit . getValue2 ( ) , cld ) ;
public class ClassBuilder { /** * Build the member summary contents of the page . * @ param node the XML element that specifies which components to document * @ param classContentTree the content tree to which the documentation will be added */ public void buildMemberSummary ( XMLNode node , Content classContentTree ) throws Exception { } }
Content memberSummaryTree = writer . getMemberTreeHeader ( ) ; configuration . getBuilderFactory ( ) . getMemberSummaryBuilder ( writer ) . buildChildren ( node , memberSummaryTree ) ; classContentTree . addContent ( writer . getMemberSummaryTree ( memberSummaryTree ) ) ;
public class OperationUtils { /** * Awaits for an operation to be completed . * @ param service * the media contract * @ param operation * the operation id to wait for . * @ return the final state of the operation . If the entity has not operationId , returns OperationState . Succeeded . * @ throws ServiceException */ public static OperationState await ( MediaContract service , EntityWithOperationIdentifier entity ) throws ServiceException { } }
if ( entity . hasOperationIdentifier ( ) ) { return await ( service , entity . getOperationId ( ) ) ; } return OperationState . Succeeded ;
public class CommonOps_DDF4 { /** * Sets all the diagonal elements equal to one and everything else equal to zero . * If this is a square matrix then it will be an identity matrix . * @ param a A matrix . */ public static void setIdentity ( DMatrix4x4 a ) { } }
a . a11 = 1 ; a . a21 = 0 ; a . a31 = 0 ; a . a41 = 0 ; a . a12 = 0 ; a . a22 = 1 ; a . a32 = 0 ; a . a42 = 0 ; a . a13 = 0 ; a . a23 = 0 ; a . a33 = 1 ; a . a43 = 0 ; a . a14 = 0 ; a . a24 = 0 ; a . a34 = 0 ; a . a44 = 1 ;
public class MLInt32 { /** * Converts byte [ ] [ ] to Long [ ] * @ param dd * @ return */ private static Integer [ ] int2DToInteger ( int [ ] [ ] dd ) { } }
Integer [ ] d = new Integer [ dd . length * dd [ 0 ] . length ] ; for ( int n = 0 ; n < dd [ 0 ] . length ; n ++ ) { for ( int m = 0 ; m < dd . length ; m ++ ) { d [ m + n * dd . length ] = dd [ m ] [ n ] ; } } return d ;
public class RequestContext { /** * Renders with { " data " : obj } . * @ param data the specified JSON data * @ return this context */ public RequestContext renderData ( final Object data ) { } }
if ( renderer instanceof JsonRenderer ) { final JsonRenderer r = ( JsonRenderer ) renderer ; final JSONObject ret = r . getJSONObject ( ) ; ret . put ( Keys . DATA , data ) ; } return this ;
public class PasswordlessRequestCodeFormView { /** * Notifies the form that a new country code was selected by the user . * @ param isoCode the selected country iso code ( 2 chars ) . * @ param dialCode the dial code for this country */ @ SuppressWarnings ( "unused" ) public void onCountryCodeSelected ( String isoCode , String dialCode ) { } }
Country selectedCountry = new Country ( isoCode , dialCode ) ; countryCodeSelector . setSelectedCountry ( selectedCountry ) ;
public class Leader { /** * Entering broadcasting phase , leader broadcasts proposal to * followers . * @ throws InterruptedException if it ' s interrupted . * @ throws TimeoutException in case of timeout . * @ throws IOException in case of IO failure . * @ throws ExecutionException in case of exception from executors . */ void broadcasting ( ) throws TimeoutException , InterruptedException , IOException , ExecutionException { } }
// Initialization . broadcastingInit ( ) ; try { while ( this . quorumMap . size ( ) >= clusterConfig . getQuorumSize ( ) ) { MessageTuple tuple = filter . getMessage ( config . getTimeoutMs ( ) ) ; Message msg = tuple . getMessage ( ) ; String source = tuple . getServerId ( ) ; // Checks if it ' s DISCONNECTED message . if ( msg . getType ( ) == MessageType . DISCONNECTED ) { String peerId = msg . getDisconnected ( ) . getServerId ( ) ; if ( quorumMap . containsKey ( peerId ) ) { onDisconnected ( tuple ) ; } else { this . transport . clear ( peerId ) ; } continue ; } if ( ! quorumMap . containsKey ( source ) ) { // Received a message sent from a peer who is outside the quorum . handleMessageOutsideQuorum ( tuple ) ; } else { // Received a message sent from the peer who is in quorum . handleMessageFromQuorum ( tuple ) ; PeerHandler ph = quorumMap . get ( source ) ; if ( ph != null ) { ph . updateHeartbeatTime ( ) ; } checkFollowerLiveness ( ) ; } } LOG . debug ( "Detects the size of the ensemble is less than the" + "quorum size {}, goes back to electing phase." , getQuorumSize ( ) ) ; } finally { ackProcessor . shutdown ( ) ; preProcessor . shutdown ( ) ; commitProcessor . shutdown ( ) ; syncProcessor . shutdown ( ) ; snapProcessor . shutdown ( ) ; this . lastDeliveredZxid = commitProcessor . getLastDeliveredZxid ( ) ; this . participantState . updateLastDeliveredZxid ( this . lastDeliveredZxid ) ; }
public class NonProductiveMethodCall { /** * implements the visitor to look for return values of common immutable method calls , that are thrown away . * @ param seen * the opcode of the currently parsed instruction */ @ Override public void sawOpcode ( int seen ) { } }
String methodInfo = null ; try { stack . precomputation ( this ) ; switch ( seen ) { case Const . INVOKEVIRTUAL : case Const . INVOKEINTERFACE : case Const . INVOKESTATIC : String sig = getSigConstantOperand ( ) ; if ( ! sig . endsWith ( Values . SIG_VOID ) ) { methodInfo = getClassConstantOperand ( ) + '@' + getNameConstantOperand ( ) + getSigConstantOperand ( ) ; } break ; case Const . POP : case Const . POP2 : if ( stack . getStackDepth ( ) > 0 ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; String mInfo = ( String ) item . getUserValue ( ) ; if ( mInfo != null ) { for ( Pattern p : IMMUTABLE_METHODS ) { Matcher m = p . matcher ( mInfo ) ; if ( m . matches ( ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . NPMC_NON_PRODUCTIVE_METHOD_CALL . name ( ) , NORMAL_PRIORITY ) . addClass ( this ) . addMethod ( this ) . addSourceLine ( this ) . addString ( mInfo ) ) ; break ; } } } } break ; } } finally { stack . sawOpcode ( this , seen ) ; if ( ( methodInfo != null ) && ( stack . getStackDepth ( ) > 0 ) ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; item . setUserValue ( methodInfo ) ; } }
public class SysProcDuplicateCounter { /** * It is possible that duplicate counter will get mixed dummy responses and * real responses from replicas , think elastic join and rejoin . The * requirement here is that the duplicate counter should never mix these two * types of responses together in the list of tables for a given * dependency . Mixing them will cause problems for union later . In case of * mixed responses , real responses are always preferred . As long as there * are real responses for a dependency , dummy responses will be dropped for * that dependency . */ @ Override int offer ( FragmentResponseMessage message ) { } }
long hash = 0 ; for ( int i = 0 ; i < message . getTableCount ( ) ; i ++ ) { int depId = message . getTableDependencyIdAtIndex ( i ) ; VoltTable dep = message . getTableAtIndex ( i ) ; List < VoltTable > tables = m_alldeps . get ( depId ) ; if ( tables == null ) { tables = new ArrayList < VoltTable > ( ) ; m_alldeps . put ( depId , tables ) ; } if ( ! message . isRecovering ( ) ) { /* * If the current table is a real response , check if * any previous responses were dummy , if so , replace * the dummy ones with this legit response . */ if ( ! tables . isEmpty ( ) && tables . get ( 0 ) . getStatusCode ( ) == VoltTableUtil . NULL_DEPENDENCY_STATUS ) { tables . clear ( ) ; } // Only update the hash with non - dummy responses hash ^= MiscUtils . cheesyBufferCheckSum ( dep . getBuffer ( ) ) ; } else { /* If it ' s a dummy response , record it if and only if * it ' s the first response . If the previous response * is a real response , we don ' t want the dummy response . * If the previous one is also a dummy , one should be * enough . */ if ( ! tables . isEmpty ( ) ) { continue ; } } tables . add ( dep ) ; } // needs to be a three long array to work int [ ] hashes = new int [ ] { ( int ) hash , 0 , 0 } ; return checkCommon ( hashes , message . isRecovering ( ) , null , message , false ) ;
public class MoneyUtils { /** * Subtracts the second { @ code Money } from the first , handling null . * This returns { @ code money1 - money2 } where null is ignored . * If both input values are null , then null is returned . * @ param money1 the first money instance , null treated as zero * @ param money2 the first money instance , null returns money1 * @ return the total , where null is ignored , null if both inputs are null * @ throws CurrencyMismatchException if the currencies differ */ public static Money subtract ( Money money1 , Money money2 ) { } }
if ( money2 == null ) { return money1 ; } if ( money1 == null ) { return money2 . negated ( ) ; } return money1 . minus ( money2 ) ;
public class ErrMessage { /** * AT & T Requires a specific Error Format for RESTful Services , which AAF complies with . * This code will create a meaningful string from this format . * @ param ps * @ param df * @ param r * @ throws APIException */ public void printErr ( PrintStream ps , String attErrJson ) throws APIException { } }
StringBuilder sb = new StringBuilder ( ) ; Error err = errDF . newData ( ) . in ( TYPE . JSON ) . load ( attErrJson ) . asObject ( ) ; ps . println ( toMsg ( sb , err ) ) ;
public class KeyFactory { /** * Resets the KeyFactory to its initial state . * @ return { @ code this } for chaining */ public KeyFactory reset ( ) { } }
setProjectId ( pi ) ; setNamespace ( ns ) ; kind = null ; ancestors . clear ( ) ; return this ;
public class SubnetworkClient { /** * Set whether VMs in this subnet can access Google services without assigning external IP * addresses through Private Google Access . * < p > Sample code : * < pre > < code > * try ( SubnetworkClient subnetworkClient = SubnetworkClient . create ( ) ) { * ProjectRegionSubnetworkName subnetwork = ProjectRegionSubnetworkName . of ( " [ PROJECT ] " , " [ REGION ] " , " [ SUBNETWORK ] " ) ; * SubnetworksSetPrivateIpGoogleAccessRequest subnetworksSetPrivateIpGoogleAccessRequestResource = SubnetworksSetPrivateIpGoogleAccessRequest . newBuilder ( ) . build ( ) ; * Operation response = subnetworkClient . setPrivateIpGoogleAccessSubnetwork ( subnetwork , subnetworksSetPrivateIpGoogleAccessRequestResource ) ; * < / code > < / pre > * @ param subnetwork Name of the Subnetwork resource . * @ param subnetworksSetPrivateIpGoogleAccessRequestResource * @ throws com . google . api . gax . rpc . ApiException if the remote call fails */ @ BetaApi public final Operation setPrivateIpGoogleAccessSubnetwork ( ProjectRegionSubnetworkName subnetwork , SubnetworksSetPrivateIpGoogleAccessRequest subnetworksSetPrivateIpGoogleAccessRequestResource ) { } }
SetPrivateIpGoogleAccessSubnetworkHttpRequest request = SetPrivateIpGoogleAccessSubnetworkHttpRequest . newBuilder ( ) . setSubnetwork ( subnetwork == null ? null : subnetwork . toString ( ) ) . setSubnetworksSetPrivateIpGoogleAccessRequestResource ( subnetworksSetPrivateIpGoogleAccessRequestResource ) . build ( ) ; return setPrivateIpGoogleAccessSubnetwork ( request ) ;
public class JsfFaceletScannerPlugin { /** * end method initialize */ @ Override public void configure ( ) { } }
if ( getProperties ( ) . containsKey ( PROPERTY_NAME_FILE_PATTERN ) ) { filePattern = Pattern . compile ( getProperties ( ) . get ( PROPERTY_NAME_FILE_PATTERN ) . toString ( ) ) ; } else { filePattern = Pattern . compile ( DEFAULT_FILE_PATTERN ) ; }
import java . util . ArrayList ; import java . util . List ; class Main { /** * Function to remove all empty lists from a given list of lists . * Args : * inputList ( ArrayList ) : A list possibly containing empty lists alongside other items . * Returns : * ArrayList : A list containing only non - empty items from the input list . * Examples : * > > > filterOutEmptyLists ( [ [ ] , [ ] , [ ] , ' Red ' , ' Green ' , [ 1 , 2 ] , ' Blue ' , [ ] , [ ] ] ) * [ ' Red ' , ' Green ' , [ 1 , 2 ] , ' Blue ' ] * > > > filterOutEmptyLists ( [ [ ] , [ ] , [ ] , [ ] , [ ] , ' Green ' , [ 1 , 2 ] , ' Blue ' , [ ] , [ ] ] ) * [ ' Green ' , [ 1 , 2 ] , ' Blue ' ] * > > > filterOutEmptyLists ( [ [ ] , [ ] , [ ] , ' Python ' , [ ] , [ ] , ' programming ' , ' language ' , [ ] , [ ] , [ ] , [ ] , [ ] ] ) * [ ' Python ' , ' programming ' , ' language ' ] */ public static ArrayList filterOutEmptyLists ( ArrayList inputList ) { } }
ArrayList < Object > filteredList = new ArrayList < > ( ) ; for ( Object element : inputList ) { if ( element != null && ! element . toString ( ) . isEmpty ( ) ) { filteredList . add ( element ) ; } } return filteredList ;
public class RestClientUtil { /** * 获取文档MapSearchHit对象 , 封装了索引文档的所有属性数据 * @ param indexName * @ param documentId * @ return * @ throws ElasticSearchException */ public MapSearchHit getDocumentHit ( String indexName , String documentId ) throws ElasticSearchException { } }
return getDocumentHit ( indexName , _doc , documentId ) ;
public class AppsImpl { /** * Returns the available endpoint deployment regions and URLs . * @ param appId The application ID . * @ throws IllegalArgumentException thrown if parameters fail the validation * @ throws ErrorResponseException thrown if the request is rejected by server * @ throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @ return the Map & lt ; String , String & gt ; object if successful . */ public Map < String , String > listEndpoints ( UUID appId ) { } }
return listEndpointsWithServiceResponseAsync ( appId ) . toBlocking ( ) . single ( ) . body ( ) ;
public class VisualizationTree { /** * Filtered iteration over a stacked hierarchy . * This is really messy because the visualization hierarchy is typed Object . * @ param context Visualization context * @ return Iterator of results . */ public static It < Object > findVis ( VisualizerContext context ) { } }
return new StackedIter < > ( context . getHierarchy ( ) . iterAll ( ) , context . getVisHierarchy ( ) ) ;
public class AttributeDefinition { /** * Takes the given { @ code value } , resolves it using the given { @ code resolver } * and validates it using this attribute ' s { @ link # getValidator ( ) validator } . If the value is * undefined and a { @ link # getDefaultValue ( ) default value } is available , the default value is used . * @ param resolver the expression resolver * @ param value a node that is expected to be a valid value for an attribute defined by this definition * @ return the resolved value , possibly the default value if { @ code value } is not defined * @ throws OperationFailedException if the value is not valid */ public ModelNode resolveValue ( final ExpressionResolver resolver , final ModelNode value ) throws OperationFailedException { } }
final ModelNode node = value . clone ( ) ; if ( ! node . isDefined ( ) && defaultValue != null && defaultValue . isDefined ( ) ) { node . set ( defaultValue ) ; } ModelNode resolved = resolver . resolveExpressions ( node ) ; resolved = parseResolvedValue ( value , resolved ) ; validator . validateParameter ( name , resolved ) ; return resolved ;
public class AbstractNamedInputHandler { /** * Updates bean by using PropertyDescriptors . Values are read from * source . * Is used by { @ link # updateBean ( Object , java . util . Map ) } * @ param target target Bean * @ param source source Map */ private void updateProperties ( T target , Map < String , Object > source ) { } }
Map < String , PropertyDescriptor > mapTargetProps = MappingUtils . mapPropertyDescriptors ( target . getClass ( ) ) ; for ( String sourceKey : source . keySet ( ) ) { if ( mapTargetProps . containsKey ( sourceKey ) == true ) { MappingUtils . callSetter ( target , mapTargetProps . get ( sourceKey ) , source . get ( sourceKey ) ) ; } }
public class DataLoaderRegistry { /** * Returns the dataloader that was registered under the specified key * @ param key the key of the data loader * @ param < K > the type of keys * @ param < V > the type of values * @ return a data loader or null if its not present */ @ SuppressWarnings ( "unchecked" ) public < K , V > DataLoader < K , V > getDataLoader ( String key ) { } }
return ( DataLoader < K , V > ) dataLoaders . get ( key ) ;
public class TypeRegistry { /** * Gets registered alias for a provided object type . This is used to identify which { @ link TypeEncoder } to use for decoding . */ public String getAlias ( Object obj ) { } }
if ( obj == null ) return null ; return getClassAlias ( obj . getClass ( ) ) ;
public class UserApi { /** * Get a list of users using the specified page and per page settings . * < pre > < code > GitLab Endpoint : GET / users < / code > < / pre > * @ param page the page to get * @ param perPage the number of users per page * @ return the list of Users in the specified range * @ throws GitLabApiException if any exception occurs */ public List < User > getUsers ( int page , int perPage ) throws GitLabApiException { } }
Response response = get ( Response . Status . OK , getPageQueryParams ( page , perPage , customAttributesEnabled ) , "users" ) ; return ( response . readEntity ( new GenericType < List < User > > ( ) { } ) ) ;
public class ASTUtil { /** * Returns the < CODE > MethodDeclaration < / CODE > for the specified * < CODE > MethodAnnotation < / CODE > . The method has to be declared in the * specified < CODE > TypeDeclaration < / CODE > . * @ param type * The < CODE > TypeDeclaration < / CODE > , where the * < CODE > MethodDeclaration < / CODE > is declared in . * @ param methodAnno * The < CODE > MethodAnnotation < / CODE > , which contains the method * name and signature of the < CODE > MethodDeclaration < / CODE > * @ return the < CODE > MethodDeclaration < / CODE > found in the specified * < CODE > TypeDeclaration < / CODE > . * @ throws MethodDeclarationNotFoundException * if no matching < CODE > MethodDeclaration < / CODE > was found . */ public static MethodDeclaration getMethodDeclaration ( TypeDeclaration type , MethodAnnotation methodAnno ) throws MethodDeclarationNotFoundException { } }
Objects . requireNonNull ( methodAnno , "method annotation" ) ; return getMethodDeclaration ( type , methodAnno . getMethodName ( ) , methodAnno . getMethodSignature ( ) ) ;
public class XmlStreamReaderUtils { /** * Returns the value of an attribute as a float . If the attribute is empty , this method throws * an exception . * @ param reader * < code > XMLStreamReader < / code > that contains attribute values . * @ param namespace * namespace * @ param localName * the local name of the attribute . * @ return value of attribute as float * @ throws XMLStreamException * if attribute is empty . */ public static float requiredFloatAttribute ( final XMLStreamReader reader , final String namespace , final String localName ) throws XMLStreamException { } }
final String value = reader . getAttributeValue ( namespace , localName ) ; if ( value != null ) { return Float . parseFloat ( value ) ; } throw new XMLStreamException ( MessageFormat . format ( "Attribute {0}:{1} is required" , namespace , localName ) ) ;
public class FieldDescriptor { /** * returns a comparator that allows to sort a Vector of FieldMappingDecriptors * according to their m _ Order entries . */ public static Comparator getComparator ( ) { } }
return new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { FieldDescriptor fmd1 = ( FieldDescriptor ) o1 ; FieldDescriptor fmd2 = ( FieldDescriptor ) o2 ; if ( fmd1 . getColNo ( ) < fmd2 . getColNo ( ) ) { return - 1 ; } else if ( fmd1 . getColNo ( ) > fmd2 . getColNo ( ) ) { return 1 ; } else { return 0 ; } } } ;
public class Math { /** * Returns the root of a function whose derivative is available known * to lie between x1 and x2 by Newton - Raphson method . The root will be * refined until its accuracy is within xacc . * @ param func the function to be evaluated . * @ param x1 the left end of search interval . * @ param x2 the right end of search interval . * @ param tol the accuracy tolerance . * @ return the root . */ public static double root ( DifferentiableFunction func , double x1 , double x2 , double tol ) { } }
return root ( func , x1 , x2 , tol , 100 ) ;
public class CoffeeScriptGenerator { /** * ( non - Javadoc ) * @ see * net . jawr . web . resource . bundle . generator . AbstractCachedGenerator # resetCache */ @ Override protected void resetCache ( ) { } }
super . resetCache ( ) ; cacheProperties . put ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_LOCATION , config . getProperty ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_LOCATION , DEFAULT_COFFEE_SCRIPT_JS_LOCATION ) ) ; cacheProperties . put ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_OPTIONS , config . getProperty ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_OPTIONS , COFFEE_SCRIPT_DEFAULT_OPTIONS ) ) ; cacheProperties . put ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_JS_ENGINE , config . getJavascriptEngineName ( JAWR_JS_GENERATOR_COFFEE_SCRIPT_JS_ENGINE ) ) ;
public class GroupElement { /** * $ r = a * A + b * B $ where $ a = a [ 0 ] + 256 * a [ 1 ] + \ dots + 256 ^ { 31 } a [ 31 ] $ , $ b = * b [ 0 ] + 256 * b [ 1 ] + \ dots + 256 ^ { 31 } b [ 31 ] $ and $ B $ is this point . * $ A $ must have been previously precomputed . * @ param A in P3 representation . * @ param a $ = a [ 0 ] + 256 * a [ 1 ] + \ dots + 256 ^ { 31 } a [ 31 ] $ * @ param b $ = b [ 0 ] + 256 * b [ 1 ] + \ dots + 256 ^ { 31 } b [ 31 ] $ * @ return the GroupElement */ public org . mariadb . jdbc . internal . com . send . authentication . ed25519 . math . GroupElement doubleScalarMultiplyVariableTime ( final org . mariadb . jdbc . internal . com . send . authentication . ed25519 . math . GroupElement A , final byte [ ] a , final byte [ ] b ) { } }
// TODO - CR BR : A check that this is the base point is needed . final byte [ ] aslide = slide ( a ) ; final byte [ ] bslide = slide ( b ) ; org . mariadb . jdbc . internal . com . send . authentication . ed25519 . math . GroupElement r = this . curve . getZero ( Representation . P2 ) ; int i ; for ( i = 255 ; i >= 0 ; -- i ) { if ( aslide [ i ] != 0 || bslide [ i ] != 0 ) { break ; } } synchronized ( this ) { // TODO - CR BR strange comment below . // TODO : Get opinion from a crypto professional . // This should in practice never be necessary , the only point that // this should get called on is EdDSA ' s B . // precompute ( ) ; for ( ; i >= 0 ; -- i ) { org . mariadb . jdbc . internal . com . send . authentication . ed25519 . math . GroupElement t = r . dbl ( ) ; if ( aslide [ i ] > 0 ) { t = t . toP3 ( ) . madd ( A . dblPrecmp [ aslide [ i ] / 2 ] ) ; } else if ( aslide [ i ] < 0 ) { t = t . toP3 ( ) . msub ( A . dblPrecmp [ ( - aslide [ i ] ) / 2 ] ) ; } if ( bslide [ i ] > 0 ) { t = t . toP3 ( ) . madd ( this . dblPrecmp [ bslide [ i ] / 2 ] ) ; } else if ( bslide [ i ] < 0 ) { t = t . toP3 ( ) . msub ( this . dblPrecmp [ ( - bslide [ i ] ) / 2 ] ) ; } r = t . toP2 ( ) ; } } return r ;
public class FileUtilsV2_2 { /** * Returns the size of the specified file or directory . If the provided * { @ link File } is a regular file , then the file ' s length is returned . * If the argument is a directory , then the size of the directory is * calculated recursively . If a directory or subdirectory is security * restricted , its size will not be included . * @ param file the regular file or directory to return the size * of ( must not be < code > null < / code > ) . * @ return the length of the file , or recursive size of the directory , * provided ( in bytes ) . * @ throws NullPointerException if the file is < code > null < / code > * @ throws IllegalArgumentException if the file does not exist . * @ since 2.0 */ public static long sizeOf ( File file ) { } }
if ( ! file . exists ( ) ) { String message = file + " does not exist" ; throw new IllegalArgumentException ( message ) ; } if ( file . isDirectory ( ) ) { return sizeOfDirectory ( file ) ; } else { return file . length ( ) ; }
public class PropertyToTriple { /** * This method tests if a given value can be converted . * The scenario when this may not be true is for ( weak ) reference properties that target an non - existent resource . * This scenario generally should not be possible , but the following bug introduced the possibility : * https : / / jira . duraspace . org / browse / FCREPO - 2323 * @ param value to be tested for whether it can be converted to an RDFNode or not * @ return true if value can be converted */ private boolean valueCanBeConverted ( final Value value ) { } }
try { valueConverter . convert ( value ) ; return true ; } catch ( final RepositoryRuntimeException e ) { LOGGER . warn ( "Reference to non-existent resource encounterd: {}" , value ) ; return false ; }
public class MsWordUtils { /** * 添加一张表格 * @ param alignment 对齐方式 * @ param rows 行数 * @ param cols 列数 * @ param values 所有值 , 包括标题 * @ param rowHeight 行高 * @ param colWidth 列宽 * @ param cellMargins 单元格边缘 * @ param styles 样式 */ public static void appendTable ( ParagraphAlignment [ ] alignment , int rows , int cols , String [ ] [ ] values , int [ ] rowHeight , int [ ] colWidth , Map < String , Integer > cellMargins , Map < String , Object > styles ) { } }
createXwpfDocumentIfNull ( ) ; xwpfDocument . createParagraph ( ) ; XWPFTable table = xwpfDocument . createTable ( rows , cols ) ; XWPFParagraph paragraph ; XWPFTableRow row ; XWPFTableCell cell ; CTTcPr cellPr ; XWPFRun run ; if ( Checker . isNotEmpty ( cellMargins ) ) { int top = MsUtils . checkInteger ( cellMargins . get ( "top" ) ) ; int left = MsUtils . checkInteger ( cellMargins . get ( "left" ) ) ; int bottom = MsUtils . checkInteger ( cellMargins . get ( "bottom" ) ) ; int right = MsUtils . checkInteger ( cellMargins . get ( "right" ) ) ; table . setCellMargins ( top , left , bottom , right ) ; } int minRow = Math . min ( rows , values . length ) ; for ( int i = 0 ; i < minRow ; i ++ ) { row = table . getRow ( i ) ; int height = i < rowHeight . length ? rowHeight [ i ] : rowHeight [ rowHeight . length - 1 ] ; row . setHeight ( height ) ; String [ ] value = values [ i ] ; int minCol = Math . min ( cols , value . length ) ; for ( int j = 0 ; j < minCol ; j ++ ) { cell = row . getCell ( j ) ; cellPr = cell . getCTTc ( ) . addNewTcPr ( ) ; int width = j < colWidth . length ? colWidth [ j ] : colWidth [ colWidth . length - 1 ] ; cellPr . addNewTcW ( ) . setW ( BigInteger . valueOf ( width ) ) ; paragraph = cell . getParagraphs ( ) . get ( 0 ) ; int idx = i * cols + j ; ParagraphAlignment align = idx < alignment . length ? alignment [ idx ] : alignment [ alignment . length - 1 ] ; paragraph . setAlignment ( align ) ; run = paragraph . createRun ( ) ; run . setText ( value [ j ] ) ; setStyle ( run , styles ) ; } }
public class Utils { /** * Creates a mutable HashSet instance containing the given elements in unspecified order */ public static < T > Set < T > newSet ( T ... values ) { } }
Set < T > set = new HashSet < > ( values . length ) ; Collections . addAll ( set , values ) ; return set ;
public class GraphDotFileWriter { /** * Writes a given graph ' s internal data structure as a dot file . * @ param file the file of the dot file to write * @ param graph the graph * @ param < T > the type of the graph content * @ throws IOException if there was a problem writing the file */ public static < T > void write ( final File file , final Graph < T > graph ) throws IOException { } }
final StringBuilder sb = new StringBuilder ( String . format ( "strict graph {%n" ) ) ; Set < Node < T > > doneNodes = new LinkedHashSet < > ( ) ; for ( Node < T > d : graph . nodes ( ) ) { for ( Node < T > n : d . neighbours ( ) ) if ( ! doneNodes . contains ( n ) ) sb . append ( " " ) . append ( d . content ( ) ) . append ( " -- " ) . append ( n . content ( ) ) . append ( System . lineSeparator ( ) ) ; doneNodes . add ( d ) ; } for ( Node < T > d : graph . nodes ( ) ) { if ( d . neighbours ( ) . isEmpty ( ) ) { sb . append ( " " ) . append ( d . content ( ) ) . append ( System . lineSeparator ( ) ) ; } } sb . append ( "}" ) ; try ( BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( file ) , StandardCharsets . UTF_8 ) ) ) { writer . append ( sb ) ; writer . flush ( ) ; }
public class SClassDefinitionAssistantTC { public Set < PDefinition > findMatches ( SClassDefinition classdef , ILexNameToken sought ) { } }
Set < PDefinition > set = af . createPDefinitionListAssistant ( ) . findMatches ( classdef . getDefinitions ( ) , sought ) ; set . addAll ( af . createPDefinitionListAssistant ( ) . findMatches ( classdef . getAllInheritedDefinitions ( ) , sought ) ) ; return set ;
public class CommandArgs { /** * Add a double argument . * @ param n the double argument . * @ return the command args . */ public CommandArgs < K , V > add ( double n ) { } }
singularArguments . add ( DoubleArgument . of ( n ) ) ; return this ;
public class AfplibFactoryImpl { /** * < ! - - begin - user - doc - - > * < ! - - end - user - doc - - > * @ generated */ public String convertOBPYoaOrentToString ( EDataType eDataType , Object instanceValue ) { } }
return instanceValue == null ? null : instanceValue . toString ( ) ;
public class SearchIndex { /** * Sets the name of the class that implements { @ link SpellChecker } . The * default value is < code > null < / code > ( none set ) . * @ param className * name of the class that implements { @ link SpellChecker } . */ @ SuppressWarnings ( "unchecked" ) public void setSpellCheckerClass ( String className ) { } }
try { Class < ? > clazz = ClassLoading . forName ( className , this ) ; if ( SpellChecker . class . isAssignableFrom ( clazz ) ) { spellCheckerClass = ( Class < ? extends SpellChecker > ) clazz ; } else { log . warn ( "Invalid value for spellCheckerClass, {} " + "does not implement SpellChecker interface." , className ) ; } } catch ( ClassNotFoundException e ) { log . warn ( "Invalid value for spellCheckerClass," + " class {} not found." , className ) ; }
public class XMLConfiguration { protected void initDisplayName ( XmlParser . Node node ) { } }
getWebApplicationContext ( ) . setDisplayName ( node . toString ( false , true ) ) ;
public class CamelVersionHelper { /** * Checks whether other > = base * @ param base the base version * @ param other the other version * @ return < tt > true < / tt > if GE , < tt > false < / tt > otherwise */ public static boolean isGE ( String base , String other ) { } }
ComparableVersion v1 = new ComparableVersion ( base ) ; ComparableVersion v2 = new ComparableVersion ( other ) ; return v2 . compareTo ( v1 ) >= 0 ;
public class UniversalDateAndTimeStampImpl { /** * < ! - - begin - user - doc - - > * < ! - - end - user - doc - - > * @ generated */ @ Override public void eUnset ( int featureID ) { } }
switch ( featureID ) { case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__RESERVED : setReserved ( RESERVED_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__YEAR_AD : setYearAD ( YEAR_AD_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__MONTH : setMonth ( MONTH_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__DAY : setDay ( DAY_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__HOUR : setHour ( HOUR_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__MINUTE : setMinute ( MINUTE_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__SECOND : setSecond ( SECOND_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__TIME_ZONE : setTimeZone ( TIME_ZONE_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__UTC_DIFF_H : setUTCDiffH ( UTC_DIFF_H_EDEFAULT ) ; return ; case AfplibPackage . UNIVERSAL_DATE_AND_TIME_STAMP__UTC_DIFF_M : setUTCDiffM ( UTC_DIFF_M_EDEFAULT ) ; return ; } super . eUnset ( featureID ) ;
public class DateUtil { /** * 解析时间 , 格式HH : mm : ss , 默认为1970-01-01 * @ param timeString 标准形式的日期字符串 * @ return 日期对象 */ public static DateTime parseTime ( String timeString ) { } }
timeString = normalize ( timeString ) ; return parse ( timeString , DatePattern . NORM_TIME_FORMAT ) ;
public class Main { /** * Scan the arguments to find an option that specifies a number . */ public static int findNumberOption ( String [ ] args , String option ) { } }
int rc = 0 ; for ( int i = 0 ; i < args . length ; ++ i ) { if ( args [ i ] . equals ( option ) ) { if ( args . length > i + 1 ) { rc = Integer . parseInt ( args [ i + 1 ] ) ; } } } return rc ;
public class DefaultTaskController { /** * Launch a new JVM for the task . * This method launches the new JVM for the task by executing the * the JVM command using the { @ link Shell . ShellCommandExecutor } */ void launchTaskJVM ( TaskController . TaskControllerContext context ) throws IOException { } }
JvmEnv env = context . env ; List < String > wrappedCommand = TaskLog . captureOutAndError ( env . setup , env . vargs , env . stdout , env . stderr , env . logSize , true ) ; ShellCommandExecutor shexec = new ShellCommandExecutor ( wrappedCommand . toArray ( new String [ 0 ] ) , env . workDir , env . env ) ; // set the ShellCommandExecutor for later use . context . shExec = shexec ; shexec . execute ( ) ;
public class MatchingEngine { /** * Calculates the total cost or proceeds at market price of the specified bid / ask amount . * @ param orderType Ask or bid . * @ param amount The amount . * @ return The market cost / proceeds * @ throws ExchangeException If there is insufficient liquidity . */ public BigDecimal marketCostOrProceeds ( OrderType orderType , BigDecimal amount ) { } }
BigDecimal remaining = amount ; BigDecimal cost = ZERO ; List < BookLevel > orderbookSide = orderType . equals ( BID ) ? asks : bids ; for ( BookOrder order : FluentIterable . from ( orderbookSide ) . transformAndConcat ( BookLevel :: getOrders ) ) { BigDecimal available = order . getRemainingAmount ( ) ; BigDecimal tradeAmount = remaining . compareTo ( available ) >= 0 ? available : remaining ; BigDecimal tradeCost = tradeAmount . multiply ( order . getLimitPrice ( ) ) ; cost = cost . add ( tradeCost ) ; remaining = remaining . subtract ( tradeAmount ) ; if ( remaining . compareTo ( ZERO ) == 0 ) return cost ; } throw new ExchangeException ( "Insufficient liquidity in book" ) ;
public class AmazonRedshiftClient { /** * Reboots a cluster . This action is taken as soon as possible . It results in a momentary outage to the cluster , * during which the cluster status is set to < code > rebooting < / code > . A cluster event is created when the reboot is * completed . Any pending cluster modifications ( see < a > ModifyCluster < / a > ) are applied at this reboot . For more * information about managing clusters , go to < a * href = " https : / / docs . aws . amazon . com / redshift / latest / mgmt / working - with - clusters . html " > Amazon Redshift Clusters < / a > * in the < i > Amazon Redshift Cluster Management Guide < / i > . * @ param rebootClusterRequest * @ return Result of the RebootCluster operation returned by the service . * @ throws InvalidClusterStateException * The specified cluster is not in the < code > available < / code > state . * @ throws ClusterNotFoundException * The < code > ClusterIdentifier < / code > parameter does not refer to an existing cluster . * @ sample AmazonRedshift . RebootCluster * @ see < a href = " http : / / docs . aws . amazon . com / goto / WebAPI / redshift - 2012-12-01 / RebootCluster " target = " _ top " > AWS API * Documentation < / a > */ @ Override public Cluster rebootCluster ( RebootClusterRequest request ) { } }
request = beforeClientExecution ( request ) ; return executeRebootCluster ( request ) ;
public class ResourceGroovyMethods { /** * Helper method to create a buffered writer for a file . If the given * charset is " UTF - 16BE " or " UTF - 16LE " , the requisite byte order mark is * written to the stream before the writer is returned . * @ param file a File * @ param charset the name of the encoding used to write in this file * @ param append true if in append mode * @ return a BufferedWriter * @ throws IOException if an IOException occurs . * @ since 1.0 */ public static BufferedWriter newWriter ( File file , String charset , boolean append ) throws IOException { } }
if ( append ) { return new EncodingAwareBufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( file , append ) , charset ) ) ; } else { // first write the Byte Order Mark for Unicode encodings FileOutputStream stream = new FileOutputStream ( file ) ; writeUTF16BomIfRequired ( charset , stream ) ; return new EncodingAwareBufferedWriter ( new OutputStreamWriter ( stream , charset ) ) ; }
public class AWSServiceCatalogClient { /** * Updates the specified product . * @ param updateProductRequest * @ return Result of the UpdateProduct operation returned by the service . * @ throws ResourceNotFoundException * The specified resource was not found . * @ throws InvalidParametersException * One or more parameters provided to the operation are not valid . * @ throws TagOptionNotMigratedException * An operation requiring TagOptions failed because the TagOptions migration process has not been performed * for this account . Please use the AWS console to perform the migration process before retrying the * operation . * @ sample AWSServiceCatalog . UpdateProduct * @ see < a href = " http : / / docs . aws . amazon . com / goto / WebAPI / servicecatalog - 2015-12-10 / UpdateProduct " target = " _ top " > AWS * API Documentation < / a > */ @ Override public UpdateProductResult updateProduct ( UpdateProductRequest request ) { } }
request = beforeClientExecution ( request ) ; return executeUpdateProduct ( request ) ;
public class PgDatabaseMetaData { /** * Add the user described by the given acl to the Lists of users with the privileges described by * the acl . */ private static void addACLPrivileges ( String acl , Map < String , Map < String , List < String [ ] > > > privileges ) { } }
int equalIndex = acl . lastIndexOf ( "=" ) ; int slashIndex = acl . lastIndexOf ( "/" ) ; if ( equalIndex == - 1 ) { return ; } String user = acl . substring ( 0 , equalIndex ) ; String grantor = null ; if ( user . isEmpty ( ) ) { user = "PUBLIC" ; } String privs ; if ( slashIndex != - 1 ) { privs = acl . substring ( equalIndex + 1 , slashIndex ) ; grantor = acl . substring ( slashIndex + 1 , acl . length ( ) ) ; } else { privs = acl . substring ( equalIndex + 1 , acl . length ( ) ) ; } for ( int i = 0 ; i < privs . length ( ) ; i ++ ) { char c = privs . charAt ( i ) ; if ( c != '*' ) { String sqlpriv ; String grantable ; if ( i < privs . length ( ) - 1 && privs . charAt ( i + 1 ) == '*' ) { grantable = "YES" ; } else { grantable = "NO" ; } switch ( c ) { case 'a' : sqlpriv = "INSERT" ; break ; case 'r' : case 'p' : sqlpriv = "SELECT" ; break ; case 'w' : sqlpriv = "UPDATE" ; break ; case 'd' : sqlpriv = "DELETE" ; break ; case 'D' : sqlpriv = "TRUNCATE" ; break ; case 'R' : sqlpriv = "RULE" ; break ; case 'x' : sqlpriv = "REFERENCES" ; break ; case 't' : sqlpriv = "TRIGGER" ; break ; // the following can ' t be granted to a table , but // we ' ll keep them for completeness . case 'X' : sqlpriv = "EXECUTE" ; break ; case 'U' : sqlpriv = "USAGE" ; break ; case 'C' : sqlpriv = "CREATE" ; break ; case 'T' : sqlpriv = "CREATE TEMP" ; break ; default : sqlpriv = "UNKNOWN" ; } Map < String , List < String [ ] > > usersWithPermission = privileges . get ( sqlpriv ) ; String [ ] grant = { grantor , grantable } ; if ( usersWithPermission == null ) { usersWithPermission = new HashMap < String , List < String [ ] > > ( ) ; List < String [ ] > permissionByGrantor = new ArrayList < String [ ] > ( ) ; permissionByGrantor . add ( grant ) ; usersWithPermission . put ( user , permissionByGrantor ) ; privileges . put ( sqlpriv , usersWithPermission ) ; } else { List < String [ ] > permissionByGrantor = usersWithPermission . get ( user ) ; if ( permissionByGrantor == null ) { permissionByGrantor = new ArrayList < String [ ] > ( ) ; permissionByGrantor . add ( grant ) ; usersWithPermission . put ( user , permissionByGrantor ) ; } else { permissionByGrantor . add ( grant ) ; } } } }
public class AbstractGauge { /** * Sets the color from which the custom user ledcolor will be calculated * @ param COLOR */ public void setCustomUserLedColor ( final Color COLOR ) { } }
model . setCustomUserLedColor ( new CustomLedColor ( COLOR ) ) ; final boolean LED_WAS_ON = currentUserLedImage . equals ( ledImageOn ) ? true : false ; switch ( getOrientation ( ) ) { case HORIZONTAL : recreateUserLedImages ( getHeight ( ) ) ; break ; case VERTICAL : recreateUserLedImages ( getWidth ( ) ) ; break ; default : recreateUserLedImages ( ) ; break ; } if ( currentUserLedImage != null ) { currentUserLedImage . flush ( ) ; } currentUserLedImage = LED_WAS_ON == true ? userLedImageOn : userLedImageOff ; repaint ( getInnerBounds ( ) ) ;
public class HelpFormatter { /** * Render the specified text and return the rendered Options * in a StringBuilder . * @ param sb the StringBuilder to place the rendered text into * @ param width the number of characters to display per line * @ param nextLineTabStop the position on the next line for the first tab * @ param text the text to be rendered */ public static void renderWrappedText ( StringBuilder sb , int width , int nextLineTabStop , String text ) { } }
int pos = OptionUtils . findWrapPos ( text , width , 0 ) ; if ( pos == - 1 ) { sb . append ( OptionUtils . rtrim ( text ) ) ; return ; } sb . append ( OptionUtils . rtrim ( text . substring ( 0 , pos ) ) ) . append ( NEW_LINE ) ; if ( nextLineTabStop >= width ) { // stops infinite loop happening nextLineTabStop = 1 ; } // all following lines must be padded with nextLineTabStop space characters String padding = OptionUtils . createPadding ( nextLineTabStop ) ; String line = text ; while ( true ) { line = padding + line . substring ( pos ) . trim ( ) ; pos = OptionUtils . findWrapPos ( line , width , 0 ) ; if ( pos == - 1 ) { sb . append ( line ) ; return ; } if ( line . length ( ) > width && pos == nextLineTabStop - 1 ) { pos = width ; } sb . append ( OptionUtils . rtrim ( line . substring ( 0 , pos ) ) ) . append ( NEW_LINE ) ; }
public class CmsSecurityManager { /** * Inserts an entry in the published resource table . < p > * This is done during static export . < p > * @ param context the current request context * @ param resourceName The name of the resource to be added to the static export * @ param linkType the type of resource exported ( 0 = non - parameter , 1 = parameter ) * @ param linkParameter the parameters added to the resource * @ param timestamp a time stamp for writing the data into the db * @ throws CmsException if something goes wrong */ public void writeStaticExportPublishedResource ( CmsRequestContext context , String resourceName , int linkType , String linkParameter , long timestamp ) throws CmsException { } }
CmsDbContext dbc = m_dbContextFactory . getDbContext ( context ) ; try { m_driverManager . writeStaticExportPublishedResource ( dbc , resourceName , linkType , linkParameter , timestamp ) ; } catch ( Exception e ) { dbc . report ( null , Messages . get ( ) . container ( Messages . ERR_WRITE_STATEXP_PUBLISHED_RESOURCES_3 , resourceName , linkParameter , new Date ( timestamp ) ) , e ) ; } finally { dbc . clear ( ) ; }
public class MtasDataCollectorResult { /** * Gets the data . * @ return the data * @ throws IOException Signals that an I / O exception has occurred . */ public final MtasDataItem < T1 , T2 > getData ( ) throws IOException { } }
if ( collectorType . equals ( DataCollector . COLLECTOR_TYPE_DATA ) ) { return item ; } else { throw new IOException ( "type " + collectorType + " not supported" ) ; }
public class NIOFileUtil { /** * Returns all the files in a directory that match the given pattern , and that don ' t * have the given extension . * @ param directory the directory to look for files in , subdirectories are not * considered * @ param syntaxAndPattern the syntax and pattern to use for matching ( see * { @ link java . nio . file . FileSystem # getPathMatcher } * @ param excludesExt the extension to exclude , or null to exclude nothing * @ return a list of files , sorted by name * @ throws IOException */ static List < Path > getFilesMatching ( Path directory , String syntaxAndPattern , String excludesExt ) throws IOException { } }
PathMatcher matcher = directory . getFileSystem ( ) . getPathMatcher ( syntaxAndPattern ) ; List < Path > parts = Files . walk ( directory ) . filter ( matcher :: matches ) . filter ( path -> excludesExt == null || ! path . toString ( ) . endsWith ( excludesExt ) ) . collect ( Collectors . toList ( ) ) ; Collections . sort ( parts ) ; return parts ;
public class MainFrameMenu { /** * enable / disable preferences menu */ public void enablePreferencesMenuItem ( boolean b ) { } }
getPreferencesMenuItem ( ) . setEnabled ( b ) ; if ( MainFrame . MAC_OS_X ) { if ( osxPrefsEnableMethod != null ) { Object args [ ] = { b } ; try { osxPrefsEnableMethod . invoke ( osxAdapter , args ) ; } catch ( Exception e ) { System . err . println ( "Exception while enabling Preferences menu: " + e ) ; } } }
public class Util { /** * Overwrites the contents of the file with a random * string and then deletes the file . * @ param file file to remove */ public static boolean destroy ( File file ) { } }
if ( ! file . exists ( ) ) return false ; RandomAccessFile f = null ; long size = file . length ( ) ; try { f = new RandomAccessFile ( file , "rw" ) ; long rec = size / DMSG . length ( ) ; int left = ( int ) ( size - rec * DMSG . length ( ) ) ; while ( rec != 0 ) { f . write ( DMSG . getBytes ( ) , 0 , DMSG . length ( ) ) ; rec -- ; } if ( left > 0 ) { f . write ( DMSG . getBytes ( ) , 0 , left ) ; } } catch ( Exception e ) { return false ; } finally { try { if ( f != null ) f . close ( ) ; } catch ( Exception e ) { } } return file . delete ( ) ;
public class CmsWorkplaceEditorConfiguration { /** * Logs configuration errors and invalidates the current configuration . < p > * @ param message the message specifying the configuration error * @ param t the Throwable object or null */ private void logConfigurationError ( String message , Throwable t ) { } }
setValidConfiguration ( false ) ; if ( LOG . isErrorEnabled ( ) ) { if ( t == null ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_EDITOR_CONFIG_ERROR_1 , message ) ) ; } else { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_EDITOR_CONFIG_ERROR_1 , message ) , t ) ; } }
public class ProcessOutput { /** * @ return output of the finished process converted to a String . * @ param charset The name of a supported char set . */ public String getString ( String charset ) { } }
try { return new String ( getBytes ( ) , charset ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException ( e . getMessage ( ) ) ; }
public class HtmlSanitizerUtil { /** * Apply sanitization rules to a HTML string . * @ param input the ( potentially ) tainted HTML to sanitize * @ param policy the AntiSamy policy to apply * @ return sanitized HTML */ public static String sanitize ( final String input , final Policy policy ) { } }
if ( policy == null ) { throw new SystemException ( "AntiSamy policy cannot be null" ) ; } if ( Util . empty ( input ) ) { return input ; } try { CleanResults results = ANTISAMY . scan ( input , policy ) ; String result = results . getCleanHTML ( ) ; // Escape brackets for handlebars result = WebUtilities . encodeBrackets ( result ) ; return result ; } catch ( ScanException | PolicyException ex ) { throw new SystemException ( "Cannot sanitize " + ex . getMessage ( ) , ex ) ; }
public class BCryptOpenBSDProtocol { /** * Perform the central password hashing step in the * bcrypt scheme * @ param rounds the actual rounds , not the binary logarithm * @ param salt the binary salt to hash with the password * @ param password the password to hash * of rounds of hashing to apply * @ param cdata the plaintext to encrypt * @ return an array containing the binary hashed password */ byte [ ] cryptRaw ( long rounds , byte [ ] salt , byte [ ] password , int [ ] cdata ) { } }
if ( rounds < 0 ) { throw new IllegalArgumentException ( "rounds must not be negative" ) ; } int clen = cdata . length ; if ( salt . length != BCrypt . SALT_LENGTH ) { throw new IllegalArgumentException ( "bad salt length" ) ; } int [ ] P = P_orig . clone ( ) ; int [ ] S = S_orig . clone ( ) ; enhancedKeySchedule ( P , S , salt , password ) ; for ( long roundCount = 0 ; roundCount != rounds ; roundCount ++ ) { key ( P , S , password ) ; key ( P , S , salt ) ; } for ( int i = 0 ; i < 64 ; i ++ ) { for ( int j = 0 ; j < ( clen >> 1 ) ; j ++ ) { encipher ( P , S , cdata , j << 1 ) ; } } byte [ ] ret = new byte [ clen * 4 ] ; for ( int i = 0 , j = 0 ; i < clen ; i ++ ) { ret [ j ++ ] = ( byte ) ( ( cdata [ i ] >> 24 ) & 0xff ) ; ret [ j ++ ] = ( byte ) ( ( cdata [ i ] >> 16 ) & 0xff ) ; ret [ j ++ ] = ( byte ) ( ( cdata [ i ] >> 8 ) & 0xff ) ; ret [ j ++ ] = ( byte ) ( cdata [ i ] & 0xff ) ; } return ret ;
public class DeveloperInfoMarshaller { /** * Marshall the given parameter object . */ public void marshall ( DeveloperInfo developerInfo , ProtocolMarshaller protocolMarshaller ) { } }
if ( developerInfo == null ) { throw new SdkClientException ( "Invalid argument passed to marshall(...)" ) ; } try { protocolMarshaller . marshall ( developerInfo . getDeveloperName ( ) , DEVELOPERNAME_BINDING ) ; protocolMarshaller . marshall ( developerInfo . getPrivacyPolicy ( ) , PRIVACYPOLICY_BINDING ) ; protocolMarshaller . marshall ( developerInfo . getEmail ( ) , EMAIL_BINDING ) ; protocolMarshaller . marshall ( developerInfo . getUrl ( ) , URL_BINDING ) ; } catch ( Exception e ) { throw new SdkClientException ( "Unable to marshall request to JSON: " + e . getMessage ( ) , e ) ; }
public class UserCoreDao { /** * Query the SQL for a single result object with the expected data type * @ param sql * sql statement * @ param args * arguments * @ param column * column index * @ param dataType * GeoPackage data type * @ return result , null if no result * @ since 3.1.0 */ public Object querySingleResult ( String sql , String [ ] args , int column , GeoPackageDataType dataType ) { } }
return db . querySingleResult ( sql , args , column , dataType ) ;
public class GeometryUtil { /** * Checks whether there is intersection of the line ( x1 , y1 ) - ( x2 , y2 ) and the quad curve * ( qx1 , qy1 ) - ( qx2 , qy2 ) - ( qx3 , qy3 ) . The parameters of the intersection area saved to * { @ code params } . Therefore { @ code params } must be of length at least 4. * @ return the number of roots that lie in the defined interval . */ public static int intersectLineAndQuad ( double x1 , double y1 , double x2 , double y2 , double qx1 , double qy1 , double qx2 , double qy2 , double qx3 , double qy3 , double [ ] params ) { } }
double [ ] eqn = new double [ 3 ] ; double [ ] t = new double [ 2 ] ; double [ ] s = new double [ 2 ] ; double dy = y2 - y1 ; double dx = x2 - x1 ; int quantity = 0 ; int count = 0 ; eqn [ 0 ] = dy * ( qx1 - x1 ) - dx * ( qy1 - y1 ) ; eqn [ 1 ] = 2 * dy * ( qx2 - qx1 ) - 2 * dx * ( qy2 - qy1 ) ; eqn [ 2 ] = dy * ( qx1 - 2 * qx2 + qx3 ) - dx * ( qy1 - 2 * qy2 + qy3 ) ; if ( ( count = Crossing . solveQuad ( eqn , t ) ) == 0 ) { return 0 ; } for ( int i = 0 ; i < count ; i ++ ) { if ( dx != 0 ) { s [ i ] = ( quad ( t [ i ] , qx1 , qx2 , qx3 ) - x1 ) / dx ; } else if ( dy != 0 ) { s [ i ] = ( quad ( t [ i ] , qy1 , qy2 , qy3 ) - y1 ) / dy ; } else { s [ i ] = 0f ; } if ( t [ i ] >= 0 && t [ i ] <= 1 && s [ i ] >= 0 && s [ i ] <= 1 ) { params [ 2 * quantity ] = t [ i ] ; params [ 2 * quantity + 1 ] = s [ i ] ; ++ quantity ; } } return quantity ;
public class filterpolicy_binding { /** * Use this API to fetch filterpolicy _ binding resource of given name . */ public static filterpolicy_binding get ( nitro_service service , String name ) throws Exception { } }
filterpolicy_binding obj = new filterpolicy_binding ( ) ; obj . set_name ( name ) ; filterpolicy_binding response = ( filterpolicy_binding ) obj . get_resource ( service ) ; return response ;
public class AmazonApiGatewayV2Client { /** * Updates an Integration . * @ param updateIntegrationRequest * @ return Result of the UpdateIntegration operation returned by the service . * @ throws NotFoundException * The resource specified in the request was not found . * @ throws TooManyRequestsException * The client is sending more than the allowed number of requests per unit of time . * @ throws BadRequestException * One of the parameters in the request is invalid . * @ throws ConflictException * The resource already exists . * @ sample AmazonApiGatewayV2 . UpdateIntegration */ @ Override public UpdateIntegrationResult updateIntegration ( UpdateIntegrationRequest request ) { } }
request = beforeClientExecution ( request ) ; return executeUpdateIntegration ( request ) ;
public class BoxCollection { /** * Returns an iterator over the items in this collection . * @ return an iterator over the items in this collection . */ @ Override public Iterator < BoxItem . Info > iterator ( ) { } }
URL url = GET_COLLECTION_ITEMS_URL . build ( this . getAPI ( ) . getBaseURL ( ) , BoxCollection . this . getID ( ) ) ; return new BoxItemIterator ( BoxCollection . this . getAPI ( ) , url ) ;
public class XDMClientChildSbb { /** * ( non - Javadoc ) * @ see * org . restcomm . slee . enabler . xdmc . XDMClientControl # putIfNoneMatch ( java . * net . URI , java . lang . String , java . lang . String , byte [ ] , java . lang . String ) */ public void putIfNoneMatch ( URI uri , String eTag , String mimetype , byte [ ] content , String assertedUserId ) throws IOException { } }
putIfNoneMatch ( uri , eTag , mimetype , content , assertedUserId , null ) ;