idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
11,100 | public static < T > Set < T > toSet ( final Collection < T > collection ) { if ( isEmpty ( collection ) ) { return new HashSet < T > ( 0 ) ; } else { return new HashSet < T > ( collection ) ; } } | Convert given collection to a set . |
11,101 | public static < T > T [ ] toArray ( final Collection < T > collection ) { T next = getFirstNotNullValue ( collection ) ; if ( next != null ) { Object [ ] objects = collection . toArray ( ) ; @ SuppressWarnings ( "unchecked" ) T [ ] convertedObjects = ( T [ ] ) Array . newInstance ( next . getClass ( ) , objects . length ) ; System . arraycopy ( objects , 0 , convertedObjects , 0 , objects . length ) ; return convertedObjects ; } else { return null ; } } | Convert given collection to an array . |
11,102 | public void setMappings ( List < String > mappings ) { if ( mappings . size ( ) > 0 ) { @ SuppressWarnings ( "unchecked" ) Pair < String , String > [ ] renames = ( Pair < String , String > [ ] ) Array . newInstance ( Pair . class , mappings . size ( ) ) ; for ( int i = 0 ; i < _renames . length ; ++ i ) { String [ ] names = mappings . get ( i ) . split ( "[ ,]+" ) ; renames [ i ] = new Pair < String , String > ( names [ 0 ] , names [ 1 ] ) ; } _renames = renames ; } } | Defines parameter mappings . One parameter can be mapped to multiple new names so a list is used instead of a map as the input to this method . |
11,103 | public static ICommonsNavigableSet < EContinent > getContinentsOfCountry ( final Locale aLocale ) { final Locale aCountry = CountryCache . getInstance ( ) . getCountry ( aLocale ) ; if ( aCountry != null ) { final ICommonsNavigableSet < EContinent > ret = s_aMap . get ( aCountry ) ; if ( ret != null ) return ret . getClone ( ) ; } return null ; } | Get all continents for the specified country ID |
11,104 | public boolean isLoadable ( ) { if ( getPayload ( ) instanceof NullPayload ) { return false ; } try { InputStream is = getInputStream ( ) ; try { is . read ( ) ; return true ; } finally { is . close ( ) ; } } catch ( IOException ex ) { return false ; } } | Tests whether the Cargo s payload is loadable . |
11,105 | public String loadString ( String encoding ) throws IOException { byte [ ] bytes = loadByteArray ( ) ; ByteOrderMask bom = ByteOrderMask . valueOf ( bytes ) ; if ( bom != null ) { int offset = ( bom . getBytes ( ) ) . length ; return new String ( bytes , offset , bytes . length - offset , bom . getEncoding ( ) ) ; } return new String ( bytes , encoding ) ; } | Loads the string in the user specified character encoding . |
11,106 | public Result transfer ( long count ) { if ( count < 0L ) throw new IllegalArgumentException ( "negative count" ) ; return buffer == null ? transferNoBuffer ( count ) : transferBuffered ( count ) ; } | Transfers the specified number of bytes from the source to the target . Fewer bytes may be transferred if an end - of - stream condition occurs in either the source or the target . |
11,107 | public static TreePath getPath ( TreePath path , Tree target ) { path . getClass ( ) ; target . getClass ( ) ; class Result extends Error { static final long serialVersionUID = - 5942088234594905625L ; TreePath path ; Result ( TreePath path ) { this . path = path ; } } class PathFinder extends TreePathScanner < TreePath , Tree > { public TreePath scan ( Tree tree , Tree target ) { if ( tree == target ) { throw new Result ( new TreePath ( getCurrentPath ( ) , target ) ) ; } return super . scan ( tree , target ) ; } } if ( path . getLeaf ( ) == target ) { return path ; } try { new PathFinder ( ) . scan ( path , target ) ; } catch ( Result result ) { return result . path ; } return null ; } | Gets a tree path for a tree node within a subtree identified by a TreePath object . |
11,108 | public Reifier addTypeSet ( Class < ? > spec ) { for ( Field field : spec . getDeclaredFields ( ) ) { if ( Modifier . isPublic ( field . getModifiers ( ) ) ) { String name = field . getName ( ) ; try { _named . put ( name , new Validator ( name , field . getType ( ) , field ) ) ; } catch ( IllegalArgumentException x ) { Trace . g . std . note ( Reifier . class , "Ignored " + name + ": " + x . getMessage ( ) ) ; } } else { Trace . g . std . note ( Reifier . class , "Ignored non-public field: " + field . getName ( ) ) ; } } return this ; } | Adds a set of data type specifications . |
11,109 | public < T extends DataObject > T collect ( T data , Map < String , String > binder ) throws SecurityException , DataValidationException { return collect ( data , binder , null ) ; } | Populates a data object by collecting and validating the named values from a Map< ; String String> ; . |
11,110 | public static boolean localeSupportsCurrencyRetrieval ( final Locale aLocale ) { return aLocale != null && aLocale . getCountry ( ) != null && aLocale . getCountry ( ) . length ( ) == 2 ; } | Check if a currency could be available for the given locale . |
11,111 | public static BigDecimal parseCurrency ( final String sStr , final DecimalFormat aFormat , final BigDecimal aDefault , final RoundingMode eRoundingMode ) { if ( StringHelper . hasNoText ( sStr ) ) return aDefault ; aFormat . setParseBigDecimal ( true ) ; aFormat . setRoundingMode ( eRoundingMode ) ; final BigDecimal aNum = LocaleParser . parseBigDecimal ( sStr , aFormat ) ; if ( aNum == null ) return aDefault ; return aNum . setScale ( aFormat . getMaximumFractionDigits ( ) , eRoundingMode ) ; } | Parse a currency value from string using a custom rounding mode . |
11,112 | private static String _getTextValueForDecimalSeparator ( final String sTextValue , final EDecimalSeparator eDecimalSep , final EGroupingSeparator eGroupingSep ) { ValueEnforcer . notNull ( eDecimalSep , "DecimalSeparator" ) ; ValueEnforcer . notNull ( eGroupingSep , "GroupingSeparator" ) ; final String ret = StringHelper . trim ( sTextValue ) ; if ( ret != null && ret . indexOf ( eDecimalSep . getChar ( ) ) < 0 ) switch ( eDecimalSep ) { case COMMA : { if ( ret . indexOf ( '.' ) > - 1 && eGroupingSep . getChar ( ) != '.' ) { return StringHelper . replaceAll ( ret , '.' , eDecimalSep . getChar ( ) ) ; } break ; } case POINT : { if ( ret . indexOf ( ',' ) > - 1 && eGroupingSep . getChar ( ) != ',' ) { return StringHelper . replaceAll ( ret , ',' , eDecimalSep . getChar ( ) ) ; } break ; } default : throw new IllegalStateException ( "Unexpected decimal separator [" + eDecimalSep + "]" ) ; } return ret ; } | Adopt the passed text value according to the requested decimal separator . |
11,113 | public static void setRoundingMode ( final ECurrency eCurrency , final RoundingMode eRoundingMode ) { getSettings ( eCurrency ) . setRoundingMode ( eRoundingMode ) ; } | Change the rounding mode of this currency . |
11,114 | public List < Symbol > functionalInterfaceBridges ( TypeSymbol origin ) { Assert . check ( isFunctionalInterface ( origin ) ) ; Symbol descSym = findDescriptorSymbol ( origin ) ; CompoundScope members = membersClosure ( origin . type , false ) ; ListBuffer < Symbol > overridden = new ListBuffer < > ( ) ; outer : for ( Symbol m2 : members . getElementsByName ( descSym . name , bridgeFilter ) ) { if ( m2 == descSym ) continue ; else if ( descSym . overrides ( m2 , origin , Types . this , false ) ) { for ( Symbol m3 : overridden ) { if ( isSameType ( m3 . erasure ( Types . this ) , m2 . erasure ( Types . this ) ) || ( m3 . overrides ( m2 , origin , Types . this , false ) && ( pendingBridges ( ( ClassSymbol ) origin , m3 . enclClass ( ) ) || ( ( ( MethodSymbol ) m2 ) . binaryImplementation ( ( ClassSymbol ) m3 . owner , Types . this ) != null ) ) ) ) { continue outer ; } } overridden . add ( m2 ) ; } } return overridden . toList ( ) ; } | Find the minimal set of methods that are overridden by the functional descriptor in origin . All returned methods are assumed to have different erased signatures . |
11,115 | public boolean isEqualityComparable ( Type s , Type t , Warner warn ) { if ( t . isNumeric ( ) && s . isNumeric ( ) ) return true ; boolean tPrimitive = t . isPrimitive ( ) ; boolean sPrimitive = s . isPrimitive ( ) ; if ( ! tPrimitive && ! sPrimitive ) { return isCastable ( s , t , warn ) || isCastable ( t , s , warn ) ; } else { return false ; } } | Can t and s be compared for equality? Any primitive == primitive or primitive == object comparisons here are an error . Unboxing and correct primitive == primitive comparisons are already dealt with in Attr . visitBinary . |
11,116 | public Type elemtype ( Type t ) { switch ( t . getTag ( ) ) { case WILDCARD : return elemtype ( wildUpperBound ( t ) ) ; case ARRAY : t = t . unannotatedType ( ) ; return ( ( ArrayType ) t ) . elemtype ; case FORALL : return elemtype ( ( ( ForAll ) t ) . qtype ) ; case ERROR : return t ; default : return null ; } } | The element type of an array . |
11,117 | public int rank ( Type t ) { t = t . unannotatedType ( ) ; switch ( t . getTag ( ) ) { case CLASS : { ClassType cls = ( ClassType ) t ; if ( cls . rank_field < 0 ) { Name fullname = cls . tsym . getQualifiedName ( ) ; if ( fullname == names . java_lang_Object ) cls . rank_field = 0 ; else { int r = rank ( supertype ( cls ) ) ; for ( List < Type > l = interfaces ( cls ) ; l . nonEmpty ( ) ; l = l . tail ) { if ( rank ( l . head ) > r ) r = rank ( l . head ) ; } cls . rank_field = r + 1 ; } } return cls . rank_field ; } case TYPEVAR : { TypeVar tvar = ( TypeVar ) t ; if ( tvar . rank_field < 0 ) { int r = rank ( supertype ( tvar ) ) ; for ( List < Type > l = interfaces ( tvar ) ; l . nonEmpty ( ) ; l = l . tail ) { if ( rank ( l . head ) > r ) r = rank ( l . head ) ; } tvar . rank_field = r + 1 ; } return tvar . rank_field ; } case ERROR : case NONE : return 0 ; default : throw new AssertionError ( ) ; } } | The rank of a class is the length of the longest path between the class and java . lang . Object in the class inheritance graph . Undefined for all but reference types . |
11,118 | public boolean covariantReturnType ( Type t , Type s , Warner warner ) { return isSameType ( t , s ) || allowCovariantReturns && ! t . isPrimitive ( ) && ! s . isPrimitive ( ) && isAssignable ( t , s , warner ) ; } | Is t an appropriate return type in an overrider for a method that returns s? |
11,119 | public ClassSymbol boxedClass ( Type t ) { return reader . enterClass ( syms . boxedName [ t . getTag ( ) . ordinal ( ) ] ) ; } | Return the class that boxes the given primitive . |
11,120 | protected String getSpace ( Request req ) { String spaceToken = req . headers ( SPACE_TOKEN_HEADER ) ; if ( StringUtils . isBlank ( spaceToken ) ) { throw new MissingSpaceTokenException ( "Missing header '" + SPACE_TOKEN_HEADER + "'." ) ; } String space = this . spacesService . getSpaceForAuthenticationToken ( spaceToken ) ; if ( space == null ) { throw new InvalidSpaceTokenException ( spaceToken ) ; } return space ; } | Extract spaceToken from request headers . |
11,121 | public WithCache . CacheState getCacheState ( ) { return new WithCache . CacheState ( size ( ) , _max , _get , _hit , _rep ) ; } | Reports the cumulative statistics of this cache . |
11,122 | static Class < ? > resolveParameterName ( String parameterName , Class < ? > target ) { Map < Type , Type > typeVariableMap = getTypeVariableMap ( target ) ; Set < Entry < Type , Type > > set = typeVariableMap . entrySet ( ) ; Type type = Object . class ; for ( Entry < Type , Type > entry : set ) { if ( entry . getKey ( ) . toString ( ) . equals ( parameterName ) ) { type = entry . getKey ( ) ; break ; } } return resolveType ( type , typeVariableMap ) ; } | Resolves the generic parameter name of a class . |
11,123 | public List < Widget > putFactories ( Iterable < ? extends IWidgetFactory > factories ) throws IndexOutOfBoundsException { List < Widget > instances = new LinkedList < Widget > ( ) ; for ( IWidgetFactory factory : factories ) { instances . add ( put ( factory ) ) ; } return instances ; } | Creates widgets instance from given iterable and adds it to this panel |
11,124 | protected List < File > getSpooledFileList ( ) { final List < File > spooledFileList = new ArrayList < File > ( ) ; for ( final File file : spoolDirectory . listFiles ( ) ) { if ( file . isFile ( ) ) { spooledFileList . add ( file ) ; } } return spooledFileList ; } | protected for overriding during unit tests |
11,125 | public void add ( Collection < Application > applications ) { for ( Application application : applications ) this . applications . put ( application . getId ( ) , application ) ; } | Adds the application list to the applications for the account . |
11,126 | public ApplicationHostCache applicationHosts ( long applicationId ) { ApplicationHostCache cache = applicationHosts . get ( applicationId ) ; if ( cache == null ) applicationHosts . put ( applicationId , cache = new ApplicationHostCache ( applicationId ) ) ; return cache ; } | Returns the cache of application hosts for the given application creating one if it doesn t exist . |
11,127 | public KeyTransactionCache keyTransactions ( long applicationId ) { KeyTransactionCache cache = keyTransactions . get ( applicationId ) ; if ( cache == null ) keyTransactions . put ( applicationId , cache = new KeyTransactionCache ( applicationId ) ) ; return cache ; } | Returns the cache of key transactions for the given application creating one if it doesn t exist . |
11,128 | public void addKeyTransactions ( Collection < KeyTransaction > keyTransactions ) { for ( KeyTransaction keyTransaction : keyTransactions ) { long applicationId = keyTransaction . getLinks ( ) . getApplication ( ) ; Application application = applications . get ( applicationId ) ; if ( application != null ) keyTransactions ( applicationId ) . add ( keyTransaction ) ; else logger . severe ( String . format ( "Unable to find application for key transaction '%s': %d" , keyTransaction . getName ( ) , applicationId ) ) ; } } | Adds the key transactions to the applications for the account . |
11,129 | public DeploymentCache deployments ( long applicationId ) { DeploymentCache cache = deployments . get ( applicationId ) ; if ( cache == null ) deployments . put ( applicationId , cache = new DeploymentCache ( applicationId ) ) ; return cache ; } | Returns the cache of deployments for the given application creating one if it doesn t exist . |
11,130 | public LabelCache labels ( long applicationId ) { LabelCache cache = labels . get ( applicationId ) ; if ( cache == null ) labels . put ( applicationId , cache = new LabelCache ( applicationId ) ) ; return cache ; } | Returns the cache of labels for the given application creating one if it doesn t exist . |
11,131 | public void addLabel ( Label label ) { List < Long > applicationIds = label . getLinks ( ) . getApplications ( ) ; for ( long applicationId : applicationIds ) { Application application = applications . get ( applicationId ) ; if ( application != null ) labels ( applicationId ) . add ( label ) ; else logger . severe ( String . format ( "Unable to find application for label '%s': %d" , label . getKey ( ) , applicationId ) ) ; } } | Adds the label to the applications for the account . |
11,132 | private static < T , R > Function < T , R > doThrow ( Supplier < ? extends RuntimeException > exceptionSupplier ) { return t -> { throw exceptionSupplier . get ( ) ; } ; } | Returns a function that throws the exception supplied by the given supplier . |
11,133 | @ SuppressWarnings ( "unchecked" ) public < E extends BaseException > E put ( String name , Object value ) { properties . put ( name , value ) ; return ( E ) this ; } | Put a property in this exception . |
11,134 | @ Path ( "uniquetag/{uniqueTag}" ) public Response findByUniqueTag ( @ PathParam ( "uniqueTag" ) String uniqueTag ) { checkNotNull ( uniqueTag ) ; DContact contact = dao . findByUniqueTag ( null , uniqueTag ) ; return null != contact ? Response . ok ( contact ) . build ( ) : Response . status ( Response . Status . NOT_FOUND ) . build ( ) ; } | Find a contact based on its unique tag . |
11,135 | public static void generate ( ConfigurationImpl configuration ) { ProfileIndexFrameWriter profilegen ; DocPath filename = DocPaths . PROFILE_OVERVIEW_FRAME ; try { profilegen = new ProfileIndexFrameWriter ( configuration , filename ) ; profilegen . buildProfileIndexFile ( "doclet.Window_Overview" , false ) ; profilegen . close ( ) ; } catch ( IOException exc ) { configuration . standardmessage . error ( "doclet.exception_encountered" , exc . toString ( ) , filename ) ; throw new DocletAbortException ( exc ) ; } } | Generate the profile index file named profile - overview - frame . html . |
11,136 | protected Content getProfile ( String profileName ) { Content profileLinkContent ; Content profileLabel ; profileLabel = new StringContent ( profileName ) ; profileLinkContent = getHyperLink ( DocPaths . profileFrame ( profileName ) , profileLabel , "" , "packageListFrame" ) ; Content li = HtmlTree . LI ( profileLinkContent ) ; return li ; } | Gets each profile name as a separate link . |
11,137 | public void newRound ( Context context ) { this . context = context ; this . log = Log . instance ( context ) ; clearRoundState ( ) ; } | Update internal state for a new round . |
11,138 | public static GameSettings getInstance ( ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new GamePermission ( "readSettings" ) ) ; } return INSTANCE ; } | Checks if the caller has permission to read the game settings |
11,139 | public static ClassFileReader newInstance ( Path path , JarFile jf ) throws IOException { return new JarFileReader ( path , jf ) ; } | Returns a ClassFileReader instance of a given JarFile . |
11,140 | Type rawInstantiate ( Env < AttrContext > env , Type site , Symbol m , ResultInfo resultInfo , List < Type > argtypes , List < Type > typeargtypes , boolean allowBoxing , boolean useVarargs , Warner warn ) throws Infer . InferenceException { Type mt = types . memberType ( site , m ) ; List < Type > tvars = List . nil ( ) ; if ( typeargtypes == null ) typeargtypes = List . nil ( ) ; if ( ! mt . hasTag ( FORALL ) && typeargtypes . nonEmpty ( ) ) { } else if ( mt . hasTag ( FORALL ) && typeargtypes . nonEmpty ( ) ) { ForAll pmt = ( ForAll ) mt ; if ( typeargtypes . length ( ) != pmt . tvars . length ( ) ) throw inapplicableMethodException . setMessage ( "arg.length.mismatch" ) ; List < Type > formals = pmt . tvars ; List < Type > actuals = typeargtypes ; while ( formals . nonEmpty ( ) && actuals . nonEmpty ( ) ) { List < Type > bounds = types . subst ( types . getBounds ( ( TypeVar ) formals . head ) , pmt . tvars , typeargtypes ) ; for ( ; bounds . nonEmpty ( ) ; bounds = bounds . tail ) if ( ! types . isSubtypeUnchecked ( actuals . head , bounds . head , warn ) ) throw inapplicableMethodException . setMessage ( "explicit.param.do.not.conform.to.bounds" , actuals . head , bounds ) ; formals = formals . tail ; actuals = actuals . tail ; } mt = types . subst ( pmt . qtype , pmt . tvars , typeargtypes ) ; } else if ( mt . hasTag ( FORALL ) ) { ForAll pmt = ( ForAll ) mt ; List < Type > tvars1 = types . newInstances ( pmt . tvars ) ; tvars = tvars . appendList ( tvars1 ) ; mt = types . subst ( pmt . qtype , pmt . tvars , tvars1 ) ; } boolean instNeeded = tvars . tail != null ; for ( List < Type > l = argtypes ; l . tail != null && ! instNeeded ; l = l . tail ) { if ( l . head . hasTag ( FORALL ) ) instNeeded = true ; } if ( instNeeded ) return infer . instantiateMethod ( env , tvars , ( MethodType ) mt , resultInfo , ( MethodSymbol ) m , argtypes , allowBoxing , useVarargs , currentResolutionContext , warn ) ; DeferredAttr . DeferredAttrContext dc = currentResolutionContext . deferredAttrContext ( m , infer . emptyContext , resultInfo , warn ) ; currentResolutionContext . methodCheck . argumentsAcceptable ( env , dc , argtypes , mt . getParameterTypes ( ) , warn ) ; dc . complete ( ) ; return mt ; } | Try to instantiate the type of a method so that it fits given type arguments and argument types . If successful return the method s instantiated type else return null . The instantiation will take into account an additional leading formal parameter if the method is an instance method seen as a member of an under determined site . In this case we treat site as an additional parameter and the parameters of the class containing the method as additional type variables that get instantiated . |
11,141 | @ SuppressWarnings ( "fallthrough" ) Symbol selectBest ( Env < AttrContext > env , Type site , List < Type > argtypes , List < Type > typeargtypes , Symbol sym , Symbol bestSoFar , boolean allowBoxing , boolean useVarargs , boolean operator ) { if ( sym . kind == ERR || ! sym . isInheritedIn ( site . tsym , types ) ) { return bestSoFar ; } else if ( useVarargs && ( sym . flags ( ) & VARARGS ) == 0 ) { return bestSoFar . kind >= ERRONEOUS ? new BadVarargsMethod ( ( ResolveError ) bestSoFar . baseSymbol ( ) ) : bestSoFar ; } Assert . check ( sym . kind < AMBIGUOUS ) ; try { Type mt = rawInstantiate ( env , site , sym , null , argtypes , typeargtypes , allowBoxing , useVarargs , types . noWarnings ) ; if ( ! operator || verboseResolutionMode . contains ( VerboseResolutionMode . PREDEF ) ) currentResolutionContext . addApplicableCandidate ( sym , mt ) ; } catch ( InapplicableMethodException ex ) { if ( ! operator ) currentResolutionContext . addInapplicableCandidate ( sym , ex . getDiagnostic ( ) ) ; switch ( bestSoFar . kind ) { case ABSENT_MTH : return new InapplicableSymbolError ( currentResolutionContext ) ; case WRONG_MTH : if ( operator ) return bestSoFar ; bestSoFar = new InapplicableSymbolsError ( currentResolutionContext ) ; default : return bestSoFar ; } } if ( ! isAccessible ( env , site , sym ) ) { return ( bestSoFar . kind == ABSENT_MTH ) ? new AccessError ( env , site , sym ) : bestSoFar ; } return ( bestSoFar . kind > AMBIGUOUS ) ? sym : mostSpecific ( argtypes , sym , bestSoFar , env , site , allowBoxing && operator , useVarargs ) ; } | Select the best method for a call site among two choices . |
11,142 | Symbol findMethod ( Env < AttrContext > env , Type site , Name name , List < Type > argtypes , List < Type > typeargtypes , boolean allowBoxing , boolean useVarargs , boolean operator ) { Symbol bestSoFar = methodNotFound ; bestSoFar = findMethod ( env , site , name , argtypes , typeargtypes , site . tsym . type , bestSoFar , allowBoxing , useVarargs , operator ) ; return bestSoFar ; } | Find best qualified method matching given name type and value arguments . |
11,143 | public void printscopes ( Scope s ) { while ( s != null ) { if ( s . owner != null ) System . err . print ( s . owner + ": " ) ; for ( Scope . Entry e = s . elems ; e != null ; e = e . sibling ) { if ( ( e . sym . flags ( ) & ABSTRACT ) != 0 ) System . err . print ( "abstract " ) ; System . err . print ( e . sym + " " ) ; } System . err . println ( ) ; s = s . next ; } } | print all scopes starting with scope s and proceeding outwards . used for debugging . |
11,144 | Symbol resolveBinaryOperator ( DiagnosticPosition pos , JCTree . Tag optag , Env < AttrContext > env , Type left , Type right ) { return resolveOperator ( pos , optag , env , List . of ( left , right ) ) ; } | Resolve binary operator . |
11,145 | private boolean matches ( String classname , AccessFlags flags ) { if ( options . apiOnly && ! flags . is ( AccessFlags . ACC_PUBLIC ) ) { return false ; } else if ( options . includePattern != null ) { return options . includePattern . matcher ( classname . replace ( '/' , '.' ) ) . matches ( ) ; } else { return true ; } } | Tests if the given class matches the pattern given in the - include option or if it s a public class if - apionly option is specified |
11,146 | private String replacementFor ( String cn ) { String name = cn ; String value = null ; while ( value == null && name != null ) { try { value = ResourceBundleHelper . jdkinternals . getString ( name ) ; } catch ( MissingResourceException e ) { int i = name . lastIndexOf ( '.' ) ; name = i > 0 ? name . substring ( 0 , i ) : null ; } } return value ; } | Returns the recommended replacement API for the given classname ; or return null if replacement API is not known . |
11,147 | public void setContract ( Contract c ) { super . setContract ( c ) ; for ( Field f : params ) { f . setContract ( c ) ; } if ( returns != null ) { returns . setContract ( c ) ; } } | Sets the Contract for this Function . Propegates this down to its param and return Fields |
11,148 | public Object invoke ( RpcRequest req , Object handler ) throws RpcException , IllegalAccessException , InvocationTargetException { if ( contract == null ) { throw new IllegalStateException ( "contract cannot be null" ) ; } if ( req == null ) { throw new IllegalArgumentException ( "req cannot be null" ) ; } if ( handler == null ) { throw new IllegalArgumentException ( "handler cannot be null" ) ; } Method method = getMethod ( handler ) ; Object reqParams [ ] = unmarshalParams ( req , method ) ; return marshalResult ( method . invoke ( handler , reqParams ) ) ; } | Invokes this Function against the given handler Class for the given request . This is the heart of the RPC dispatch and is where your application code gets run . |
11,149 | public Object [ ] marshalParams ( RpcRequest req ) throws RpcException { Object [ ] converted = new Object [ params . size ( ) ] ; Object [ ] reqParams = req . getParams ( ) ; if ( reqParams . length != converted . length ) { String msg = "Function '" + req . getMethod ( ) + "' expects " + params . size ( ) + " param(s). " + reqParams . length + " given." ; throw invParams ( msg ) ; } for ( int i = 0 ; i < converted . length ; i ++ ) { converted [ i ] = params . get ( i ) . getTypeConverter ( ) . marshal ( reqParams [ i ] ) ; } return converted ; } | Marshals the req . params to their RPC format equivalents . For example a Java Struct class will be converted to a Map . |
11,150 | public Object unmarshalResult ( Object respObj ) throws RpcException { if ( returns == null ) { if ( respObj != null ) { throw new IllegalArgumentException ( "Function " + name + " is a notification and should not have a result" ) ; } } return returns . getTypeConverter ( ) . unmarshal ( respObj ) ; } | Unmarshals respObj into its Java representation |
11,151 | public Object [ ] unmarshalParams ( RpcRequest req ) throws RpcException { Object reqParams [ ] = req . getParams ( ) ; if ( reqParams . length != params . size ( ) ) { String msg = "Function '" + req . getMethod ( ) + "' expects " + params . size ( ) + " param(s). " + reqParams . length + " given." ; throw invParams ( msg ) ; } Object convParams [ ] = new Object [ reqParams . length ] ; for ( int i = 0 ; i < convParams . length ; i ++ ) { convParams [ i ] = params . get ( i ) . getTypeConverter ( ) . unmarshal ( reqParams [ i ] ) ; } return convParams ; } | Unmarshals req . params into their Java representations |
11,152 | public static String getCompactMessage ( final String sMsg ) { UPCA . validateMessage ( sMsg ) ; final String sUPCA = UPCA . handleChecksum ( sMsg , EEANChecksumMode . AUTO ) ; final byte nNumberSystem = _extractNumberSystem ( sUPCA ) ; if ( nNumberSystem != 0 && nNumberSystem != 1 ) return null ; final byte nCheck = StringParser . parseByte ( sUPCA . substring ( 11 , 12 ) , ( byte ) - 1 ) ; if ( nCheck == ( byte ) - 1 ) return null ; final StringBuilder aSB = new StringBuilder ( ) ; aSB . append ( Byte . toString ( nNumberSystem ) ) ; final String manufacturer = sUPCA . substring ( 1 , 1 + 5 ) ; final String product = sUPCA . substring ( 6 , 6 + 5 ) ; String mtemp = manufacturer . substring ( 2 , 2 + 3 ) ; String ptemp = product . substring ( 0 , 0 + 2 ) ; if ( "000|100|200" . indexOf ( mtemp ) >= 0 && "00" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 2 ) ) ; aSB . append ( product . substring ( 2 , 2 + 3 ) ) ; aSB . append ( mtemp . charAt ( 0 ) ) ; } else { ptemp = product . substring ( 0 , 0 + 3 ) ; if ( "300|400|500|600|700|800|900" . indexOf ( mtemp ) >= 0 && "000" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 0 + 3 ) ) ; aSB . append ( product . substring ( 3 , 3 + 2 ) ) ; aSB . append ( '3' ) ; } else { mtemp = manufacturer . substring ( 3 , 3 + 2 ) ; ptemp = product . substring ( 0 , 0 + 4 ) ; if ( "10|20|30|40|50|60|70|80|90" . indexOf ( mtemp ) >= 0 && "0000" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 0 + 4 ) ) ; aSB . append ( product . substring ( 4 , 4 + 1 ) ) ; aSB . append ( '4' ) ; } else { mtemp = manufacturer . substring ( 4 , 4 + 1 ) ; ptemp = product . substring ( 4 , 4 + 1 ) ; if ( ! "0" . equals ( mtemp ) && "5|6|7|8|9" . indexOf ( ptemp ) >= 0 ) { aSB . append ( manufacturer ) ; aSB . append ( ptemp ) ; } else { return null ; } } } } aSB . append ( Byte . toString ( nCheck ) ) ; return aSB . toString ( ) ; } | Compacts an UPC - A message to an UPC - E message if possible . |
11,153 | public static String getExpandedMessage ( final String sMsg ) { final char cCheck = sMsg . length ( ) == 8 ? sMsg . charAt ( 7 ) : '\u0000' ; final String sUpce = sMsg . substring ( 0 , 0 + 7 ) ; final byte nNumberSystem = _extractNumberSystem ( sUpce ) ; if ( nNumberSystem != 0 && nNumberSystem != 1 ) throw new IllegalArgumentException ( "Invalid UPC-E message: " + sMsg ) ; final StringBuilder aSB = new StringBuilder ( ) ; aSB . append ( Byte . toString ( nNumberSystem ) ) ; final byte nMode = StringParser . parseByte ( sUpce . substring ( 6 , 6 + 1 ) , ( byte ) - 1 ) ; if ( nMode >= 0 && nMode <= 2 ) { aSB . append ( sUpce . substring ( 1 , 1 + 2 ) ) ; aSB . append ( Byte . toString ( nMode ) ) ; aSB . append ( "0000" ) ; aSB . append ( sUpce . substring ( 3 , 3 + 3 ) ) ; } else if ( nMode == 3 ) { aSB . append ( sUpce . substring ( 1 , 1 + 3 ) ) ; aSB . append ( "00000" ) ; aSB . append ( sUpce . substring ( 4 , 4 + 2 ) ) ; } else if ( nMode == 4 ) { aSB . append ( sUpce . substring ( 1 , 1 + 4 ) ) ; aSB . append ( "00000" ) ; aSB . append ( sUpce . substring ( 5 , 5 + 1 ) ) ; } else if ( nMode >= 5 && nMode <= 9 ) { aSB . append ( sUpce . substring ( 1 , 1 + 5 ) ) ; aSB . append ( "0000" ) ; aSB . append ( Byte . toString ( nMode ) ) ; } else { throw new IllegalArgumentException ( "Internal error" ) ; } final String sUpcaFinished = aSB . toString ( ) ; final char cExpectedCheck = calcChecksumChar ( sUpcaFinished , sUpcaFinished . length ( ) ) ; if ( cCheck != '\u0000' && cCheck != cExpectedCheck ) throw new IllegalArgumentException ( "Invalid checksum. Expected " + cExpectedCheck + " but was " + cCheck ) ; return sUpcaFinished + cExpectedCheck ; } | Expands an UPC - E message to an UPC - A message . |
11,154 | public static EValidity validateMessage ( final String sMsg ) { final int nLen = StringHelper . getLength ( sMsg ) ; if ( nLen >= 7 && nLen <= 8 ) { final byte nNumberSystem = _extractNumberSystem ( sMsg ) ; if ( nNumberSystem >= 0 && nNumberSystem <= 1 ) return EValidity . VALID ; } return EValidity . INVALID ; } | Validates an UPC - E message . The message can also be UPC - A in which case the message is compacted to a UPC - E message if possible . If it s not possible an IllegalArgumentException is thrown |
11,155 | public Iterable < DUser > queryByBirthInfo ( java . lang . String birthInfo ) { return queryByField ( null , DUserMapper . Field . BIRTHINFO . getFieldName ( ) , birthInfo ) ; } | query - by method for field birthInfo |
11,156 | public Iterable < DUser > queryByFriends ( java . lang . Object friends ) { return queryByField ( null , DUserMapper . Field . FRIENDS . getFieldName ( ) , friends ) ; } | query - by method for field friends |
11,157 | public Iterable < DUser > queryByPassword ( java . lang . String password ) { return queryByField ( null , DUserMapper . Field . PASSWORD . getFieldName ( ) , password ) ; } | query - by method for field password |
11,158 | public Iterable < DUser > queryByPhoneNumber1 ( java . lang . String phoneNumber1 ) { return queryByField ( null , DUserMapper . Field . PHONENUMBER1 . getFieldName ( ) , phoneNumber1 ) ; } | query - by method for field phoneNumber1 |
11,159 | public Iterable < DUser > queryByPhoneNumber2 ( java . lang . String phoneNumber2 ) { return queryByField ( null , DUserMapper . Field . PHONENUMBER2 . getFieldName ( ) , phoneNumber2 ) ; } | query - by method for field phoneNumber2 |
11,160 | public Iterable < DUser > queryByPreferredLanguage ( java . lang . String preferredLanguage ) { return queryByField ( null , DUserMapper . Field . PREFERREDLANGUAGE . getFieldName ( ) , preferredLanguage ) ; } | query - by method for field preferredLanguage |
11,161 | public Iterable < DUser > queryByTimeZoneCanonicalId ( java . lang . String timeZoneCanonicalId ) { return queryByField ( null , DUserMapper . Field . TIMEZONECANONICALID . getFieldName ( ) , timeZoneCanonicalId ) ; } | query - by method for field timeZoneCanonicalId |
11,162 | public DUser findByUsername ( java . lang . String username ) { return queryUniqueByField ( null , DUserMapper . Field . USERNAME . getFieldName ( ) , username ) ; } | find - by method for unique field username |
11,163 | public < T > T executeSelect ( Connection conn , DataObject object , ResultSetWorker < T > worker ) throws Exception { PreparedStatement statement = conn . prepareStatement ( _sql ) ; try { load ( statement , object ) ; return worker . process ( statement . executeQuery ( ) ) ; } finally { statement . close ( ) ; } } | Executes the SELECT statement passing the result set to the ResultSetWorker for processing . |
11,164 | public ClassDoc [ ] enums ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < ClassDocImpl > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isEnum ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; } | Get included enum types in this package . |
11,165 | public ClassDoc [ ] interfaces ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < ClassDocImpl > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isInterface ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; } | Get included interfaces in this package omitting annotation types . |
11,166 | public Rejected acquirePermits ( long number , long nanoTime ) { for ( int i = 0 ; i < backPressureList . size ( ) ; ++ i ) { BackPressure < Rejected > bp = backPressureList . get ( i ) ; Rejected rejected = bp . acquirePermit ( number , nanoTime ) ; if ( rejected != null ) { rejectedCounts . write ( rejected , number , nanoTime ) ; for ( int j = 0 ; j < i ; ++ j ) { backPressureList . get ( j ) . releasePermit ( number , nanoTime ) ; } return rejected ; } } return null ; } | Acquire permits for task execution . If the acquisition is rejected then a reason will be returned . If the acquisition is successful null will be returned . |
11,167 | public void releasePermitsWithoutResult ( long number , long nanoTime ) { for ( BackPressure < Rejected > backPressure : backPressureList ) { backPressure . releasePermit ( number , nanoTime ) ; } } | Release acquired permits without result . Since there is not a known result the result count object and latency will not be updated . |
11,168 | @ Path ( "{taskName}" ) public Response enqueueTask ( @ PathParam ( "taskName" ) String taskName ) { checkNotNull ( taskName ) ; taskQueue . enqueueTask ( taskName , requestParamsProvider . get ( ) ) ; return Response . ok ( ) . build ( ) ; } | Enqueue an admin task for processing . The request will return immediately and the task will be run in a separate thread . The execution model depending on the implementation of the queue . |
11,169 | @ Path ( "{taskName}" ) public Response processTask ( @ PathParam ( "taskName" ) String taskName ) { checkNotNull ( requestParamsProvider . get ( ) ) ; checkNotNull ( taskName ) ; LOGGER . info ( "Processing task for {}..." , taskName ) ; for ( AdminTask adminTask : adminTasks ) { final Object body = adminTask . processTask ( taskName , requestParamsProvider . get ( ) ) ; LOGGER . info ( "Processed tasks for {}: {}" , taskName , body ) ; } return Response . ok ( ) . build ( ) ; } | Process an admin task . The admin task will be processed on the requesting thread . |
11,170 | public void run ( Map < String , Object > extra ) { if ( getParameterConfig ( ) != null ) { Boolean parametersRequired = false ; List < String > requiredParameters = new ArrayList < String > ( ) ; for ( ParamConfig paramConfig : getParameterConfig ( ) ) { if ( BooleanUtils . isTrue ( paramConfig . getRequired ( ) ) ) { try { if ( StringUtils . isBlank ( ObjectUtils . toString ( PropertyUtils . getProperty ( paramConfig , "value" ) ) ) ) { parametersRequired = true ; requiredParameters . add ( paramConfig . getName ( ) ) ; } } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } catch ( InvocationTargetException e ) { e . printStackTrace ( ) ; } catch ( NoSuchMethodException e ) { e . printStackTrace ( ) ; } } } if ( parametersRequired ) { errors . add ( "Some required parameters weren't filled in: " + StringUtils . join ( requiredParameters , ", " ) + "." ) ; return ; } } runReport ( extra ) ; } | Runs the report . |
11,171 | public static Date getDateFromString ( final String dateString , final String pattern ) { try { SimpleDateFormat df = buildDateFormat ( pattern ) ; return df . parse ( dateString ) ; } catch ( ParseException e ) { throw new DateException ( String . format ( "Could not parse %s with pattern %s." , dateString , pattern ) , e ) ; } } | Get data from data string using the given pattern and the default date format symbols for the default locale . |
11,172 | public static String getDateFormat ( final Date date , final String pattern ) { SimpleDateFormat simpleDateFormat = buildDateFormat ( pattern ) ; return simpleDateFormat . format ( date ) ; } | Format date by given pattern . |
11,173 | public static Date getDateOfSecondsBack ( final int secondsBack , final Date date ) { return dateBack ( Calendar . SECOND , secondsBack , date ) ; } | Get specify seconds back form given date . |
11,174 | public static Date getDateOfMinutesBack ( final int minutesBack , final Date date ) { return dateBack ( Calendar . MINUTE , minutesBack , date ) ; } | Get specify minutes back form given date . |
11,175 | public static Date getDateOfHoursBack ( final int hoursBack , final Date date ) { return dateBack ( Calendar . HOUR_OF_DAY , hoursBack , date ) ; } | Get specify hours back form given date . |
11,176 | public static Date getDateOfDaysBack ( final int daysBack , final Date date ) { return dateBack ( Calendar . DAY_OF_MONTH , daysBack , date ) ; } | Get specify days back from given date . |
11,177 | public static Date getDateOfWeeksBack ( final int weeksBack , final Date date ) { return dateBack ( Calendar . WEEK_OF_MONTH , weeksBack , date ) ; } | Get specify weeks back from given date . |
11,178 | public static Date getDateOfMonthsBack ( final int monthsBack , final Date date ) { return dateBack ( Calendar . MONTH , monthsBack , date ) ; } | Get specify months back from given date . |
11,179 | public static Date getDateOfYearsBack ( final int yearsBack , final Date date ) { return dateBack ( Calendar . YEAR , yearsBack , date ) ; } | Get specify years back from given date . |
11,180 | public static boolean isLastDayOfTheMonth ( final Date date ) { Date dateOfMonthsBack = getDateOfMonthsBack ( - 1 , date ) ; int dayOfMonth = getDayOfMonth ( dateOfMonthsBack ) ; Date dateOfDaysBack = getDateOfDaysBack ( dayOfMonth , dateOfMonthsBack ) ; return dateOfDaysBack . equals ( date ) ; } | Return true if the given date is the last day of the month ; false otherwise . |
11,181 | public static long subSeconds ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . SECOND ) ; } | Get how many seconds between two date . |
11,182 | public static long subMinutes ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . MINUTE ) ; } | Get how many minutes between two date . |
11,183 | public static long subHours ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . HOUR ) ; } | Get how many hours between two date . |
11,184 | public static long subDays ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . DAY ) ; } | Get how many days between two date . |
11,185 | public static long subMonths ( final String dateString1 , final String dateString2 ) { Date date1 = getDateFromString ( dateString1 , DEFAULT_DATE_SIMPLE_PATTERN ) ; Date date2 = getDateFromString ( dateString2 , DEFAULT_DATE_SIMPLE_PATTERN ) ; return subMonths ( date1 , date2 ) ; } | Get how many months between two date the date pattern is yyyy - MM - dd . |
11,186 | public static long subMonths ( final Date date1 , final Date date2 ) { Calendar calendar1 = buildCalendar ( date1 ) ; int monthOfDate1 = calendar1 . get ( Calendar . MONTH ) ; int yearOfDate1 = calendar1 . get ( Calendar . YEAR ) ; Calendar calendar2 = buildCalendar ( date2 ) ; int monthOfDate2 = calendar2 . get ( Calendar . MONTH ) ; int yearOfDate2 = calendar2 . get ( Calendar . YEAR ) ; int subMonth = Math . abs ( monthOfDate1 - monthOfDate2 ) ; int subYear = Math . abs ( yearOfDate1 - yearOfDate2 ) ; return subYear * 12 + subMonth ; } | Get how many months between two date . |
11,187 | public static long subYears ( final Date date1 , final Date date2 ) { return Math . abs ( getYear ( date1 ) - getYear ( date2 ) ) ; } | Get how many years between two date . |
11,188 | private static SimpleDateFormat buildDateFormat ( final String pattern ) { SimpleDateFormat simpleDateFormat = simpleDateFormatCache . get ( ) ; if ( simpleDateFormat == null ) { simpleDateFormat = new SimpleDateFormat ( ) ; simpleDateFormatCache . set ( simpleDateFormat ) ; } simpleDateFormat . applyPattern ( pattern ) ; return simpleDateFormat ; } | Get a SimpleDateFormat object by given pattern . |
11,189 | Type fold1 ( int opcode , Type operand ) { try { Object od = operand . constValue ( ) ; switch ( opcode ) { case nop : return operand ; case ineg : return syms . intType . constType ( - intValue ( od ) ) ; case ixor : return syms . intType . constType ( ~ intValue ( od ) ) ; case bool_not : return syms . booleanType . constType ( b2i ( intValue ( od ) == 0 ) ) ; case ifeq : return syms . booleanType . constType ( b2i ( intValue ( od ) == 0 ) ) ; case ifne : return syms . booleanType . constType ( b2i ( intValue ( od ) != 0 ) ) ; case iflt : return syms . booleanType . constType ( b2i ( intValue ( od ) < 0 ) ) ; case ifgt : return syms . booleanType . constType ( b2i ( intValue ( od ) > 0 ) ) ; case ifle : return syms . booleanType . constType ( b2i ( intValue ( od ) <= 0 ) ) ; case ifge : return syms . booleanType . constType ( b2i ( intValue ( od ) >= 0 ) ) ; case lneg : return syms . longType . constType ( new Long ( - longValue ( od ) ) ) ; case lxor : return syms . longType . constType ( new Long ( ~ longValue ( od ) ) ) ; case fneg : return syms . floatType . constType ( new Float ( - floatValue ( od ) ) ) ; case dneg : return syms . doubleType . constType ( new Double ( - doubleValue ( od ) ) ) ; default : return null ; } } catch ( ArithmeticException e ) { return null ; } } | Fold unary operation . |
11,190 | public synchronized void addHandler ( Class iface , Object handler ) { try { iface . cast ( handler ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Handler: " + handler . getClass ( ) . getName ( ) + " does not implement: " + iface . getName ( ) ) ; } if ( contract . getInterfaces ( ) . get ( iface . getSimpleName ( ) ) == null ) { throw new IllegalArgumentException ( "Interface: " + iface . getName ( ) + " is not a part of this Contract" ) ; } if ( contract . getPackage ( ) == null ) { setContractPackage ( iface ) ; } handlers . put ( iface . getSimpleName ( ) , handler ) ; } | Associates the handler instance with the given IDL interface . Replaces an existing handler for this iface if one was previously registered . |
11,191 | @ SuppressWarnings ( "unchecked" ) public void call ( Serializer ser , InputStream is , OutputStream os ) throws IOException { Object obj = null ; try { obj = ser . readMapOrList ( is ) ; } catch ( Exception e ) { String msg = "Unable to deserialize request: " + e . getMessage ( ) ; ser . write ( new RpcResponse ( null , RpcException . Error . PARSE . exc ( msg ) ) . marshal ( ) , os ) ; return ; } if ( obj instanceof List ) { List list = ( List ) obj ; List respList = new ArrayList ( ) ; for ( Object o : list ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) o ) ; respList . add ( call ( rpcReq ) . marshal ( ) ) ; } ser . write ( respList , os ) ; } else if ( obj instanceof Map ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) obj ) ; ser . write ( call ( rpcReq ) . marshal ( ) , os ) ; } else { ser . write ( new RpcResponse ( null , RpcException . Error . INVALID_REQ . exc ( "Invalid Request" ) ) . marshal ( ) , os ) ; } } | Reads a RpcRequest from the input stream deserializes it invokes the matching handler method serializes the result and writes it to the output stream . |
11,192 | public RpcResponse call ( RpcRequest req ) { for ( Filter filter : filters ) { RpcRequest tmp = filter . alterRequest ( req ) ; if ( tmp != null ) { req = tmp ; } } RpcResponse resp = null ; for ( Filter filter : filters ) { resp = filter . preInvoke ( req ) ; if ( resp != null ) { break ; } } if ( resp == null ) { resp = callInternal ( req ) ; } for ( int i = filters . size ( ) - 1 ; i >= 0 ; i -- ) { RpcResponse tmp = filters . get ( i ) . postInvoke ( req , resp ) ; if ( tmp != null ) { resp = tmp ; } } return resp ; } | Calls the method associated with the RpcRequest and wraps the result as a RpcResponse . |
11,193 | public static String doGet ( final String url , final int retryTimes ) { try { return doGetByLoop ( url , retryTimes ) ; } catch ( HttpException e ) { throw new HttpException ( format ( "Failed to download content for url: '%s'. Tried '%s' times" , url , Math . max ( retryTimes + 1 , 1 ) ) ) ; } } | access given url by get request if get exception will retry by given retryTimes . |
11,194 | public static String doPost ( final String action , final Map < String , String > parameters , final int retryTimes ) { try { return doPostByLoop ( action , parameters , retryTimes ) ; } catch ( HttpException e ) { throw new HttpException ( format ( "Failed to download content for action url: '%s' with parameters. Tried '%s' times" , action , parameters , Math . max ( retryTimes + 1 , 1 ) ) ) ; } } | access given action with given parameters by post if get exception will retry by given retryTimes . |
11,195 | public < A extends Appendable > A document ( A output ) throws IOException { StringBuilder line = new StringBuilder ( ) ; for ( Field field : Beans . getKnownInstanceFields ( _prototype ) ) { description d = field . getAnnotation ( description . class ) ; if ( d == null ) continue ; placeholder p = field . getAnnotation ( placeholder . class ) ; String n = Strings . splitCamelCase ( field . getName ( ) , "-" ) . toLowerCase ( ) ; char key = getShortOptionKey ( field ) ; if ( ( field . getType ( ) == Boolean . class || field . getType ( ) == Boolean . TYPE ) && _booleans . containsKey ( key ) ) { line . append ( " -" ) . append ( key ) . append ( ", --" ) . append ( n ) ; } else { line . append ( " --" ) . append ( n ) . append ( '=' ) . append ( p != null ? p . value ( ) : "value" ) ; } if ( line . length ( ) < 16 ) { for ( int i = line . length ( ) ; i < 16 ; ++ i ) line . append ( ' ' ) ; line . append ( d . value ( ) ) ; } else { line . append ( "\n\t\t" ) . append ( d . value ( ) ) ; } output . append ( line . toString ( ) ) . append ( '\n' ) ; line . setLength ( 0 ) ; } return output ; } | Writes usage documentation to an Appendable . |
11,196 | public static InetAddress getAddress ( String host ) throws UnknownHostException { if ( timeToClean ( ) ) { synchronized ( storedAddresses ) { if ( timeToClean ( ) ) { cleanOldAddresses ( ) ; } } } Pair < InetAddress , Long > cachedAddress ; synchronized ( storedAddresses ) { cachedAddress = storedAddresses . get ( host ) ; } if ( cachedAddress != null ) { InetAddress address = cachedAddress . getFirst ( ) ; if ( address == null ) { throw new UnknownHostException ( "Could not find host " + host + " (cached response)" ) ; } else { return address ; } } else { fetchDnsAddressLock . acquireUninterruptibly ( ) ; try { InetAddress addr = InetAddress . getByName ( host ) ; synchronized ( storedAddresses ) { storedAddresses . put ( host , new Pair < > ( addr , System . currentTimeMillis ( ) ) ) ; } return addr ; } catch ( UnknownHostException exp ) { synchronized ( storedAddresses ) { storedAddresses . put ( host , new Pair < InetAddress , Long > ( null , System . currentTimeMillis ( ) ) ) ; } Log . i ( "[Dns lookup] " + host + " ) ; throw exp ; } finally { fetchDnsAddressLock . release ( ) ; } } } | only allow 5 simultaneous DNS requests |
11,197 | private VarSymbol enterConstant ( String name , Type type ) { VarSymbol c = new VarSymbol ( PUBLIC | STATIC | FINAL , names . fromString ( name ) , type , predefClass ) ; c . setData ( type . constValue ( ) ) ; predefClass . members ( ) . enter ( c ) ; return c ; } | Enter a constant into symbol table . |
11,198 | private void enterBinop ( String name , Type left , Type right , Type res , int opcode ) { predefClass . members ( ) . enter ( new OperatorSymbol ( makeOperatorName ( name ) , new MethodType ( List . of ( left , right ) , res , List . < Type > nil ( ) , methodClass ) , opcode , predefClass ) ) ; } | Enter a binary operation into symbol table . |
11,199 | private OperatorSymbol enterUnop ( String name , Type arg , Type res , int opcode ) { OperatorSymbol sym = new OperatorSymbol ( makeOperatorName ( name ) , new MethodType ( List . of ( arg ) , res , List . < Type > nil ( ) , methodClass ) , opcode , predefClass ) ; predefClass . members ( ) . enter ( sym ) ; return sym ; } | Enter a unary operation into symbol table . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.