idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
37,600 | private static Map < Direction , Map < Parity , String > > createBorders ( ) { Map < Direction , Map < Parity , String > > m = createDirectionParityMap ( ) ; m . get ( Direction . RIGHT ) . put ( Parity . EVEN , "bcfguvyz" ) ; m . get ( Direction . LEFT ) . put ( Parity . EVEN , "0145hjnp" ) ; m . get ( Direction . TOP... | Returns a map to be used in hash border calculations . | 156 | 11 |
37,601 | private static Map < Direction , Map < Parity , String > > createDirectionParityMap ( ) { Map < Direction , Map < Parity , String > > m = newHashMap ( ) ; m . put ( Direction . BOTTOM , GeoHash . < Parity , String > newHashMap ( ) ) ; m . put ( Direction . TOP , GeoHash . < Parity , String > newHashMap ( ) ) ; m . put ... | Create a direction and parity map for use in adjacent hash calculations . | 146 | 13 |
37,602 | private static void addOddParityEntries ( Map < Direction , Map < Parity , String > > m ) { m . get ( Direction . BOTTOM ) . put ( Parity . ODD , m . get ( Direction . LEFT ) . get ( Parity . EVEN ) ) ; m . get ( Direction . TOP ) . put ( Parity . ODD , m . get ( Direction . RIGHT ) . get ( Parity . EVEN ) ) ; m . get ... | Puts odd parity entries in the map m based purely on the even entries . | 173 | 16 |
37,603 | public static List < String > neighbours ( String hash ) { List < String > list = new ArrayList < String > ( ) ; String left = adjacentHash ( hash , Direction . LEFT ) ; String right = adjacentHash ( hash , Direction . RIGHT ) ; list . add ( left ) ; list . add ( right ) ; list . add ( adjacentHash ( hash , Direction .... | Returns a list of the 8 surrounding hashes for a given hash in order left right top bottom left - top left - bottom right - top right - bottom . | 168 | 31 |
37,604 | public static String encodeHash ( LatLong p , int length ) { return encodeHash ( p . getLat ( ) , p . getLon ( ) , length ) ; } | Returns a geohash of given length for the given WGS84 point . | 37 | 16 |
37,605 | static String fromLongToString ( long hash ) { int length = ( int ) ( hash & 0xf ) ; if ( length > 12 || length < 1 ) throw new IllegalArgumentException ( "invalid long geohash " + hash ) ; char [ ] geohash = new char [ length ] ; for ( int pos = 0 ; pos < length ; pos ++ ) { geohash [ pos ] = BASE32 . charAt ( ( ( int... | Takes a hash represented as a long and returns it as a string . | 122 | 15 |
37,606 | private static void refineInterval ( double [ ] interval , int cd , int mask ) { if ( ( cd & mask ) != 0 ) interval [ 0 ] = ( interval [ 0 ] + interval [ 1 ] ) / 2 ; else interval [ 1 ] = ( interval [ 0 ] + interval [ 1 ] ) / 2 ; } | Refines interval by a factor or 2 in either the 0 or 1 ordinate . | 69 | 17 |
37,607 | public static int hashLengthToCoverBoundingBox ( double topLeftLat , double topLeftLon , double bottomRightLat , double bottomRightLon ) { boolean isEven = true ; double minLat = - 90.0 , maxLat = 90 ; double minLon = - 180.0 , maxLon = 180.0 ; for ( int bits = 0 ; bits < MAX_HASH_LENGTH * 5 ; bits ++ ) { if ( isEven )... | Returns the maximum length of hash that covers the bounding box . If no hash can enclose the bounding box then 0 is returned . | 254 | 28 |
37,608 | public static boolean hashContains ( String hash , double lat , double lon ) { LatLong centre = decodeHash ( hash ) ; return Math . abs ( centre . getLat ( ) - lat ) <= heightDegrees ( hash . length ( ) ) / 2 && Math . abs ( to180 ( centre . getLon ( ) - lon ) ) <= widthDegrees ( hash . length ( ) ) / 2 ; } | Returns true if and only if the bounding box corresponding to the hash contains the given lat and long . | 92 | 21 |
37,609 | public static Coverage coverBoundingBox ( double topLeftLat , final double topLeftLon , final double bottomRightLat , final double bottomRightLon , final int length ) { return new Coverage ( coverBoundingBoxLongs ( topLeftLat , topLeftLon , bottomRightLat , bottomRightLon , length ) ) ; } | Returns the hashes of given length that are required to cover the given bounding box . | 72 | 17 |
37,610 | private static double calculateWidthDegrees ( int n ) { double a ; if ( n % 2 == 0 ) a = - 1 ; else a = - 0.5 ; double result = 180 / Math . pow ( 2 , 2.5 * n + a ) ; return result ; } | Returns the width in degrees of the region represented by a geohash of length n . | 61 | 18 |
37,611 | public static String gridAsString ( String hash , int fromRight , int fromBottom , int toRight , int toBottom ) { return gridAsString ( hash , fromRight , fromBottom , toRight , toBottom , Collections . < String > emptySet ( ) ) ; } | Returns a String of lines of hashes to represent the relative positions of hashes on a map . | 58 | 18 |
37,612 | public void setLocation ( String latitude , String longitude ) { this . latitude = new BigDecimal ( latitude ) ; this . longitude = new BigDecimal ( longitude ) ; } | Sets the coordinates of the location object . | 40 | 9 |
37,613 | private BigDecimal getLongitudeHour ( Calendar date , Boolean isSunrise ) { int offset = 18 ; if ( isSunrise ) { offset = 6 ; } BigDecimal dividend = BigDecimal . valueOf ( offset ) . subtract ( getBaseLongitudeHour ( ) ) ; BigDecimal addend = divideBy ( dividend , BigDecimal . valueOf ( 24 ) ) ; BigDecimal longHour = ... | Computes the longitude time t in the algorithm . | 112 | 11 |
37,614 | private BigDecimal getMeanAnomaly ( BigDecimal longitudeHour ) { BigDecimal meanAnomaly = multiplyBy ( new BigDecimal ( "0.9856" ) , longitudeHour ) . subtract ( new BigDecimal ( "3.289" ) ) ; return setScale ( meanAnomaly ) ; } | Computes the mean anomaly of the Sun M in the algorithm . | 71 | 13 |
37,615 | public static Calendar getSunrise ( double latitude , double longitude , TimeZone timeZone , Calendar date , double degrees ) { SolarEventCalculator solarEventCalculator = new SolarEventCalculator ( new Location ( latitude , longitude ) , timeZone ) ; return solarEventCalculator . computeSunriseCalendar ( new Zenith ( ... | Computes the sunrise for an arbitrary declination . | 83 | 10 |
37,616 | public static Calendar getSunset ( double latitude , double longitude , TimeZone timeZone , Calendar date , double degrees ) { SolarEventCalculator solarEventCalculator = new SolarEventCalculator ( new Location ( latitude , longitude ) , timeZone ) ; return solarEventCalculator . computeSunsetCalendar ( new Zenith ( 90... | Computes the sunset for an arbitrary declination . | 83 | 10 |
37,617 | private static synchronized void closeRegisteredConnections ( ) { for ( Connection connection : activeConnections ) { LOGGER . log ( Level . INFO , "Forcing connection to {0}:{1} closed." , new Object [ ] { connection . getHostname ( ) , connection . getPort ( ) } ) ; // force closed just in case connection . close ( )... | Closes all the registered connections . | 88 | 7 |
37,618 | public List < String > getJavas ( SlaveComputer computer , TaskListener listener , Connection connection ) { return getJavas ( listener , connection ) ; } | Returns the list of possible places where java executable might exist . | 34 | 12 |
37,619 | private void cleanupConnection ( TaskListener listener ) { // we might be called multiple times from multiple finally/catch block, if ( connection != null ) { connection . close ( ) ; connection = null ; listener . getLogger ( ) . println ( Messages . SSHLauncher_ConnectionClosed ( getTimestamp ( ) ) ) ; } } | Called to terminate the SSH connection . Used liberally when we back out from an error . | 72 | 19 |
37,620 | private void verifyNoHeaderJunk ( TaskListener listener ) throws IOException , InterruptedException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; connection . exec ( "exit 0" , baos ) ; final String s ; //TODO: Seems we need to retrieve the encoding from the connection destination try { s = baos . toSt... | Makes sure that SSH connection won t produce any unwanted text which will interfere with sftp execution . | 187 | 21 |
37,621 | private void startAgent ( SlaveComputer computer , final TaskListener listener , String java , String workingDirectory ) throws IOException { session = connection . openSession ( ) ; expandChannelBufferSize ( session , listener ) ; String cmd = "cd \"" + workingDirectory + "\" && " + java + " " + getJvmOptions ( ) + " ... | Starts the agent process . | 348 | 6 |
37,622 | private void copyAgentJar ( TaskListener listener , String workingDirectory ) throws IOException , InterruptedException { String fileName = workingDirectory + SLASH_AGENT_JAR ; listener . getLogger ( ) . println ( Messages . SSHLauncher_StartingSFTPClient ( getTimestamp ( ) ) ) ; SFTPClient sftpClient = null ; try { sf... | Method copies the agent jar to the remote system . | 767 | 10 |
37,623 | static String getMd5Hash ( byte [ ] bytes ) throws NoSuchAlgorithmException { String hash ; try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; md . update ( bytes ) ; byte [ ] digest = md . digest ( ) ; char [ ] hexCode = "0123456789ABCDEF" . toCharArray ( ) ; StringBuilder r = new StringBuilder ( digest ... | Method reads a byte array and returns an upper case md5 hash for it . | 178 | 16 |
37,624 | static byte [ ] readInputStreamIntoByteArrayAndClose ( InputStream inputStream ) throws IOException { byte [ ] bytes = null ; try { bytes = ByteStreams . toByteArray ( inputStream ) ; } catch ( IOException e ) { throw e ; } finally { IOUtils . closeQuietly ( inputStream ) ; if ( bytes == null ) { bytes = new byte [ 1 ]... | Method reads an input stream into a byte array and closes the input stream when finished . Added for reading the remoting jar and generating a hash value for it . | 95 | 32 |
37,625 | private void copySlaveJarUsingSCP ( TaskListener listener , String workingDirectory ) throws IOException , InterruptedException { SCPClient scp = new SCPClient ( connection ) ; try { // check if the working directory exists if ( connection . exec ( "test -d " + workingDirectory , listener . getLogger ( ) ) != 0 ) { lis... | Method copies the agent jar to the remote system using scp . | 348 | 13 |
37,626 | private boolean reportTransportLoss ( Connection c , TaskListener listener ) { Throwable cause = c . getReasonClosedCause ( ) ; if ( cause != null ) { cause . printStackTrace ( listener . error ( "Socket connection to SSH server was lost" ) ) ; } return cause != null ; } | If the SSH connection as a whole is lost report that information . | 67 | 13 |
37,627 | private String getSessionOutcomeMessage ( Session session , boolean isConnectionLost ) throws InterruptedException { session . waitForCondition ( ChannelCondition . EXIT_STATUS | ChannelCondition . EXIT_SIGNAL , 3000 ) ; Integer exitCode = session . getExitStatus ( ) ; if ( exitCode != null ) return "Slave JVM has term... | Find the exit code or exit status which are differentiated in SSH protocol . | 159 | 14 |
37,628 | static TrileadVersionSupport getTrileadSupport ( ) { try { if ( isAfterTrilead8 ( ) ) { return createVersion9Instance ( ) ; } } catch ( Exception | LinkageError e ) { LOGGER . log ( Level . WARNING , "Could not create Trilead support class. Using legacy Trilead features" , e ) ; } // We're on an old version of Triilead... | Craetes an instance of TrileadVersionSupport that can provide functionality relevant to the version of Trilead available in the current executing instance of Jenkins . | 111 | 30 |
37,629 | protected String resolveJava ( ) throws InterruptedException , IOException { for ( JavaProvider provider : JavaProvider . all ( ) ) { for ( String javaCommand : provider . getJavas ( computer , listener , connection ) ) { LOGGER . fine ( "Trying Java at " + javaCommand ) ; try { return checkJavaVersion ( listener , jav... | return javaPath if specified in the configuration . Finds local Java . | 142 | 14 |
37,630 | public HostKey getHostKey ( Computer host ) throws IOException { HostKey key = cache . get ( host ) ; if ( null == key ) { File hostKeyFile = getSshHostKeyFile ( host . getNode ( ) ) ; if ( hostKeyFile . exists ( ) ) { XmlFile xmlHostKeyFile = new XmlFile ( hostKeyFile ) ; key = ( HostKey ) xmlHostKeyFile . read ( ) ; ... | Retrieve the currently trusted host key for the requested computer or null if no key is currently trusted . | 118 | 20 |
37,631 | public void saveHostKey ( Computer host , HostKey hostKey ) throws IOException { XmlFile xmlHostKeyFile = new XmlFile ( getSshHostKeyFile ( host . getNode ( ) ) ) ; xmlHostKeyFile . write ( hostKey ) ; cache . put ( host , hostKey ) ; } | Persists an SSH key to disk for the requested host . This effectively marks the requested key as trusted for all future connections to the host until any future save attempt replaces this key . | 69 | 36 |
37,632 | public void mkdirs ( String path , int posixPermission ) throws IOException { SFTPv3FileAttributes atts = _stat ( path ) ; if ( atts != null && atts . isDirectory ( ) ) return ; int idx = path . lastIndexOf ( ' ' ) ; if ( idx > 0 ) mkdirs ( path . substring ( 0 , idx ) , posixPermission ) ; try { mkdir ( path , posixPe... | Makes sure that the directory exists by creating it if necessary . | 134 | 13 |
37,633 | public void chmod ( String path , int permissions ) throws IOException { SFTPv3FileAttributes atts = new SFTPv3FileAttributes ( ) ; atts . permissions = permissions ; setstat ( path , atts ) ; } | Change file or directory permissions . | 51 | 6 |
37,634 | protected Device resolveWithPlatform ( DeviceType deviceType , DevicePlatform devicePlatform ) { return LiteDevice . from ( deviceType , devicePlatform ) ; } | Wrapper method for allow subclassing platform based resolution | 31 | 10 |
37,635 | protected void init ( ) { getMobileUserAgentPrefixes ( ) . addAll ( Arrays . asList ( KNOWN_MOBILE_USER_AGENT_PREFIXES ) ) ; getMobileUserAgentKeywords ( ) . addAll ( Arrays . asList ( KNOWN_MOBILE_USER_AGENT_KEYWORDS ) ) ; getTabletUserAgentKeywords ( ) . addAll ( Arrays . asList ( KNOWN_TABLET_USER_AGENT_KEYWORDS ) )... | Initialize this device resolver implementation . Registers the known set of device signature strings . Subclasses may override to register additional strings . | 117 | 27 |
37,636 | public static SitePreference getCurrentSitePreference ( RequestAttributes attributes ) { return ( SitePreference ) attributes . getAttribute ( CURRENT_SITE_PREFERENCE_ATTRIBUTE , RequestAttributes . SCOPE_REQUEST ) ; } | Get the current site preference for the user from the request attributes map . | 53 | 14 |
37,637 | protected String optionalPort ( HttpServletRequest request ) { if ( "http" . equals ( request . getScheme ( ) ) && request . getServerPort ( ) != 80 || "https" . equals ( request . getScheme ( ) ) && request . getServerPort ( ) != 443 ) { return ":" + request . getServerPort ( ) ; } else { return null ; } } | Returns the HTTP port specified on the given request if it s a non - standard port . The port is considered non - standard if it s not port 80 for insecure request and not port 443 of secure requests . | 86 | 42 |
37,638 | @ Override protected Map < String , Set < String > > filterQueryParamsByKey ( QueryParamsParserContext context , String queryKey ) { Map < String , Set < String > > filteredQueryParams = new HashMap <> ( ) ; for ( String paramName : context . getParameterNames ( ) ) { if ( paramName . startsWith ( queryKey ) ) { filter... | Filters provided query params to one starting with provided string key . This override also splits param values if they are contained in a comma - delimited list . | 119 | 31 |
37,639 | public static String getProperty ( Object bean , String field ) { Object property = PropertyUtils . getProperty ( bean , field ) ; if ( property == null ) { return "null" ; } return property . toString ( ) ; } | Get bean s property value and maps to String | 50 | 9 |
37,640 | public FilterSpec addExpression ( FilterSpec expr ) { if ( expressions == null ) { expressions = new ArrayList <> ( ) ; } expressions . add ( ( FilterSpec ) expr ) ; return this ; } | Adds the given expression to the expression list and returns itself . | 45 | 12 |
37,641 | private static void addMergeInclusions ( JpaQueryExecutor < ? > executor , QuerySpec querySpec ) { ArrayDeque < String > attributePath = new ArrayDeque <> ( ) ; Class < ? > resourceClass = querySpec . getResourceClass ( ) ; addMergeInclusions ( attributePath , executor , resourceClass ) ; } | related attribute that are merged into a resource should be loaded by graph control to avoid lazy - loading or potential lack of session in serialization . | 77 | 28 |
37,642 | public QueryParams buildQueryParams ( QueryParamsParserContext context ) { try { return queryParamsParser . parse ( context ) ; } catch ( KatharsisException e ) { throw e ; } catch ( RuntimeException e ) { throw new ParametersDeserializationException ( e . getMessage ( ) , e ) ; } } | Parses the query parameters of the current request using this builder s QueryParamsParser and the given context . | 71 | 23 |
37,643 | @ Override public void filter ( ContainerRequestContext requestContext , ContainerResponseContext responseContext ) throws IOException { Object response = responseContext . getEntity ( ) ; if ( response == null ) { return ; } // only modify responses which contain a single or a list of Katharsis resources if ( isResour... | Creates JSON API responses for custom JAX - RS actions returning Katharsis resources . | 339 | 18 |
37,644 | private boolean isResourceResponse ( Object response ) { boolean singleResource = response . getClass ( ) . getAnnotation ( JsonApiResource . class ) != null ; boolean resourceList = ResourceListBase . class . isAssignableFrom ( response . getClass ( ) ) ; return singleResource || resourceList ; } | Determines whether the given response entity is either a Katharsis resource or a list of Katharsis resources . | 68 | 24 |
37,645 | public SimpleModule build ( ResourceRegistry resourceRegistry , boolean isClient ) { SimpleModule simpleModule = new SimpleModule ( JSON_API_MODULE_NAME , new Version ( 1 , 0 , 0 , null , null , null ) ) ; simpleModule . addSerializer ( new ErrorDataSerializer ( ) ) ; simpleModule . addDeserializer ( ErrorData . class ... | Creates Katharsis Jackson module with all required serializers | 96 | 12 |
37,646 | @ SuppressWarnings ( "unchecked" ) private Set < Resource > lookupRelationshipField ( Collection < Resource > sourceResources , ResourceField relationshipField , QueryAdapter queryAdapter , RepositoryMethodParameterProvider parameterProvider , Map < ResourceIdentifier , Resource > resourceMap , Map < ResourceIdentifier... | Loads all related resources for the given resources and relationship field . It updates the relationship data of the source resources accordingly and returns the loaded resources for potential inclusion in the result document . | 541 | 36 |
37,647 | public Object [ ] buildParameters ( Object [ ] firstParameters , Method method , QueryAdapter queryAdapter , Class < ? extends Annotation > annotationType ) { int parametersLength = method . getParameterTypes ( ) . length ; if ( firstParameters . length > 0 && parametersLength < 1 ) { throw new RepositoryMethodExceptio... | Build a list of parameters that can be provided to a method . | 230 | 13 |
37,648 | @ Override public < M extends MetaInformation > M as ( Class < M > metaClass ) { try { return mapper . readerFor ( metaClass ) . readValue ( data ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } } | Converts this generic meta information to the provided type . | 59 | 11 |
37,649 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public Serializable parseIdString ( String id ) { Class idType = getIdField ( ) . getType ( ) ; return parser . parse ( id , idType ) ; } | Converts the given id string into its object representation . | 57 | 11 |
37,650 | public Response dispatchRequest ( JsonPath jsonPath , String method , Map < String , Set < String > > parameters , RepositoryMethodParameterProvider parameterProvider , Document requestBody ) { try { BaseController controller = controllerRegistry . getController ( jsonPath , method ) ; ResourceInformation resourceInfor... | Dispatch the request from a client | 238 | 6 |
37,651 | public static String buildPath ( JsonPath jsonPath ) { List < String > urlParts = new LinkedList <> ( ) ; JsonPath currentJsonPath = jsonPath ; String pathPart ; do { if ( currentJsonPath instanceof RelationshipsPath ) { pathPart = RELATIONSHIP_MARK + SEPARATOR + currentJsonPath . getElementName ( ) ; } else if ( curre... | Creates a path using the provided JsonPath structure . | 238 | 12 |
37,652 | public RegistryEntry addEntry ( Class < ? > resource , RegistryEntry registryEntry ) { resources . put ( resource , registryEntry ) ; registryEntry . initialize ( moduleRegistry ) ; logger . debug ( "Added resource {} to ResourceRegistry" , resource . getName ( ) ) ; return registryEntry ; } | Adds a new resource definition to a registry . | 65 | 9 |
37,653 | @ Bean public BraveModule braveModule ( ) { String serviceName = "exampleApp" ; Endpoint localEndpoint = Endpoint . builder ( ) . serviceName ( serviceName ) . build ( ) ; InheritableServerClientAndLocalSpanState spanState = new InheritableServerClientAndLocalSpanState ( localEndpoint ) ; Brave . Builder builder = new ... | Basic monitoring setup with Brave | 121 | 5 |
37,654 | @ Bean public JpaModule jpaModule ( ) { JpaModule module = JpaModule . newServerModule ( em , transactionRunner ) ; // directly expose entity module . addRepository ( JpaRepositoryConfig . builder ( ScheduleEntity . class ) . build ( ) ) ; // additionally expose entity as a mapped dto module . addRepository ( JpaReposi... | Expose JPA entities as repositories . | 284 | 8 |
37,655 | public String getMethodName ( Method method ) { String name ; if ( ClassUtils . isBooleanGetter ( method ) ) { name = extractMethodName ( method , 2 ) ; } else { name = extractMethodName ( method , 3 ) ; } return name ; } | Extract Java bean name from getter s name | 59 | 10 |
37,656 | public static Method findMethodWith ( Class < ? > searchClass , Class < ? extends Annotation > annotationClass ) { Method foundMethod = null ; methodFinder : while ( searchClass != null && searchClass != Object . class ) { for ( Method method : searchClass . getDeclaredMethods ( ) ) { if ( method . isAnnotationPresent ... | Return a first occurrence of a method annotated with specified annotation | 110 | 12 |
37,657 | public static < T > T newInstance ( Class < T > clazz ) { try { return clazz . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new ResourceException ( String . format ( "couldn't create a new instance of %s" , clazz ) ) ; } } | Create a new instance of a resource using a default constructor | 70 | 11 |
37,658 | public static JpaModule newServerModule ( EntityManagerFactory emFactory , EntityManager em , TransactionRunner transactionRunner ) { return new JpaModule ( emFactory , em , transactionRunner ) ; } | Creates a new JpaModule for a Katharsis server . All entities managed by the provided EntityManagerFactory are registered to the module and exposed as JSON API resources if not later configured otherwise . | 41 | 40 |
37,659 | public < T > void addRepository ( JpaRepositoryConfig < T > config ) { checkNotInitialized ( ) ; Class < ? > resourceClass = config . getResourceClass ( ) ; if ( repositoryConfigurationMap . containsKey ( resourceClass ) ) { throw new IllegalArgumentException ( resourceClass . getName ( ) + " is already registered" ) ;... | Adds the repository to this module . | 91 | 7 |
37,660 | private void setupRelationshipRepositories ( Class < ? > resourceClass , boolean mapped ) { MetaLookup metaLookup = mapped ? resourceMetaLookup : jpaMetaLookup ; Class < ? extends MetaDataObject > metaClass = mapped ? MetaJsonObject . class : MetaJpaDataObject . class ; MetaDataObject meta = metaLookup . getMeta ( reso... | Sets up relationship repositories for the given resource class . In case of a mapper the resource class might not correspond to the entity class . | 532 | 28 |
37,661 | @ Override public void addRelations ( Task task , Iterable < ObjectId > projectIds , String fieldName ) { List < Project > newProjectList = new LinkedList <> ( ) ; Iterable < Project > projectsToAdd = projectRepository . findAll ( projectIds , null ) ; for ( Project project : projectsToAdd ) { newProjectList . add ( pr... | A simple implementation of the addRelations method which presents the general concept of the method . It SHOULD NOT be used in production because of possible race condition - production ready code should perform an atomic operation . | 213 | 39 |
37,662 | @ Override public void removeRelations ( Task task , Iterable < ObjectId > projectIds , String fieldName ) { try { if ( PropertyUtils . getProperty ( task , fieldName ) != null ) { Iterable < Project > projects = ( Iterable < Project > ) PropertyUtils . getProperty ( task , fieldName ) ; Iterator < Project > iterator =... | A simple implementation of the removeRelations method which presents the general concept of the method . It SHOULD NOT be used in production because of possible race condition - production ready code should perform an atomic operation . | 221 | 39 |
37,663 | public static ByAttribute attribute ( final String name , final String value ) { if ( name == null ) throw new IllegalArgumentException ( "Cannot find elements when the attribute name is null" ) ; return new ByAttribute ( name , value ) ; } | Finds elements by an named attribute matching a given value irrespective of element name . Currently implemented via XPath . | 53 | 22 |
37,664 | public static ByComposite composite ( By . ByTagName b0 , By . ByClassName b1 ) { return new ByComposite ( b0 , b1 ) ; } | Finds elements a composite of other By strategies | 40 | 9 |
37,665 | public FluentSelect deselectByIndex ( final int index ) { executeAndWrapReThrowIfNeeded ( new DeselectByIndex ( index ) , Context . singular ( context , "deselectByIndex" , null , index ) , true ) ; return new FluentSelect ( super . delegate , currentElement . getFound ( ) , this . context , monitor , booleanInsteadOfN... | Deselect the option at the given index . This is done by examining the index attribute of an element and not merely by counting . | 89 | 27 |
37,666 | public static MethodIdentifier of ( final String containingClass , final String methodName , final String signature , final boolean staticMethod ) { final String returnType = JavaUtils . getReturnType ( signature ) ; final List < String > parameters = JavaUtils . getParameters ( signature ) ; return new MethodIdentifie... | Creates an identifier of the given parameters . | 82 | 9 |
37,667 | public static MethodIdentifier ofNonStatic ( final String containingClass , final String methodName , final String returnType , final String ... parameterTypes ) { return of ( containingClass , methodName , returnType , false , parameterTypes ) ; } | Creates an identifier of a non - static method . | 50 | 11 |
37,668 | public static MethodIdentifier ofStatic ( final String containingClass , final String methodName , final String returnType , final String ... parameterTypes ) { return of ( containingClass , methodName , returnType , true , parameterTypes ) ; } | Creates an identifier of a static method . | 49 | 9 |
37,669 | public static boolean isAssignableTo ( final String leftType , final String rightType ) { if ( leftType . equals ( rightType ) ) return true ; final boolean firstTypeArray = leftType . charAt ( 0 ) == ' ' ; if ( firstTypeArray ^ rightType . charAt ( 0 ) == ' ' ) { return false ; } final Class < ? > leftClass = loadClas... | Checks if the left type is assignable to the right type i . e . the right type is of the same or a sub - type . | 193 | 30 |
37,670 | public static List < String > getTypeParameters ( final String type ) { if ( type . charAt ( 0 ) != ' ' ) return emptyList ( ) ; int lastStart = type . indexOf ( ' ' ) + 1 ; final List < String > parameters = new ArrayList <> ( ) ; if ( lastStart > 0 ) { int depth = 0 ; for ( int i = lastStart ; i < type . length ( ) -... | Returns the type parameters of the given type . Will be an empty list if the type is not parametrized . | 177 | 24 |
37,671 | public static List < String > getParameters ( final String methodDesc ) { // final String[] types = resolveMethodSignature(methodDesc); // return IntStream.range(0, types.length).mapToObj(i -> types[i]).collect(Collectors.toList()); if ( methodDesc == null ) return emptyList ( ) ; final char [ ] buffer = methodDesc . t... | Returns the parameter types of the given method signature . Parametrized types are supported . | 273 | 18 |
37,672 | public static void debug ( final Throwable throwable ) { final StringWriter errors = new StringWriter ( ) ; throwable . printStackTrace ( new PrintWriter ( errors ) ) ; debugLogger . accept ( errors . toString ( ) ) ; } | Logs the stacktrace of the throwable to the debug logger . | 54 | 14 |
37,673 | public void analyze ( ) { final Resources resources = new ProjectAnalyzer ( analysis . classPaths ) . analyze ( analysis . projectClassPaths , analysis . projectSourcePaths , analysis . ignoredResources ) ; if ( resources . isEmpty ( ) ) { LogProvider . info ( "Empty JAX-RS analysis result, omitting output" ) ; return ... | Analyzes the JAX - RS project at the class path and produces the output as configured . | 146 | 19 |
37,674 | public static TypeRepresentation ofEnum ( final TypeIdentifier identifier , final String ... enumValues ) { return new EnumTypeRepresentation ( identifier , new HashSet <> ( Arrays . asList ( enumValues ) ) ) ; } | Creates a type representation of an enum type plus the available enumeration values . | 51 | 16 |
37,675 | public static < V , W > Pair < V , W > of ( final V left , final W right ) { return new Pair <> ( left , right ) ; } | Creates a new pair with left and right value . | 36 | 11 |
37,676 | public void addProjectMethod ( final ProjectMethod method ) { readWriteLock . writeLock ( ) . lock ( ) ; try { availableMethods . add ( method ) ; } finally { readWriteLock . writeLock ( ) . unlock ( ) ; } } | Adds a project method to the pool . | 53 | 8 |
37,677 | public Method get ( final MethodIdentifier identifier ) { // search for available methods readWriteLock . readLock ( ) . lock ( ) ; try { final Optional < ? extends IdentifiableMethod > method = availableMethods . stream ( ) . filter ( m -> m . matches ( identifier ) ) . findAny ( ) ; if ( method . isPresent ( ) ) retu... | Returns a method identified by an method identifier . | 115 | 9 |
37,678 | static Set < Integer > findLoadIndexes ( final List < Instruction > instructions , final Predicate < LoadInstruction > isLoadIgnored ) { return instructions . stream ( ) . filter ( i -> i . getType ( ) == Instruction . InstructionType . LOAD ) . map ( i -> ( LoadInstruction ) i ) . filter ( i -> ! isLoadIgnored . test ... | Searches for all LOAD indexes which occur in the given instructions . The LOAD instruction is checked against the given predicate if it should be ignored . | 114 | 31 |
37,679 | static Set < Integer > findReturnsAndThrows ( final List < Instruction > instructions ) { return find ( instruction -> instruction . getType ( ) == Instruction . InstructionType . RETURN || instruction . getType ( ) == Instruction . InstructionType . THROW , instructions ) ; } | Searches for return instructions in the given instructions . | 58 | 11 |
37,680 | private static Set < Integer > find ( final Predicate < Instruction > predicate , final List < Instruction > instructions ) { final Set < Integer > positions = new HashSet <> ( ) ; for ( int i = 0 ; i < instructions . size ( ) ; i ++ ) { final Instruction instruction = instructions . get ( i ) ; if ( predicate . test (... | Searches for certain instruction positions be testing against the predicate . | 92 | 13 |
37,681 | public Element simulate ( final List < Instruction > instructions ) { lock . lock ( ) ; try { returnElement = null ; return simulateInternal ( instructions ) ; } finally { lock . unlock ( ) ; } } | Simulates the instructions and collects information about the resource method . | 43 | 12 |
37,682 | private void simulate ( final Instruction instruction ) { switch ( instruction . getType ( ) ) { case PUSH : final PushInstruction pushInstruction = ( PushInstruction ) instruction ; runtimeStack . push ( new Element ( pushInstruction . getValueType ( ) , pushInstruction . getValue ( ) ) ) ; break ; case METHOD_HANDLE ... | Simulates the instruction . | 578 | 5 |
37,683 | private void simulateMethodHandle ( final InvokeDynamicInstruction instruction ) { final List < Element > arguments = IntStream . range ( 0 , instruction . getDynamicIdentifier ( ) . getParameters ( ) . size ( ) ) . mapToObj ( t -> runtimeStack . pop ( ) ) . collect ( Collectors . toList ( ) ) ; Collections . reverse (... | Simulates the invoke dynamic call . Pushes a method handle on the stack . | 159 | 16 |
37,684 | private void simulateInvoke ( final InvokeInstruction instruction ) { final List < Element > arguments = new LinkedList <> ( ) ; MethodIdentifier identifier = instruction . getIdentifier ( ) ; IntStream . range ( 0 , identifier . getParameters ( ) . size ( ) ) . forEach ( i -> arguments . add ( runtimeStack . pop ( ) )... | Simulates the invoke instruction . | 234 | 6 |
37,685 | private void simulateStore ( final StoreInstruction instruction ) { final int index = instruction . getNumber ( ) ; final Element elementToStore = runtimeStack . pop ( ) ; if ( elementToStore instanceof MethodHandle ) mergeMethodHandleStore ( index , ( MethodHandle ) elementToStore ) ; else mergeElementStore ( index , ... | Simulates the store instruction . | 83 | 6 |
37,686 | private void mergeElementStore ( final int index , final String type , final Element element ) { // new element must be created for immutability final String elementType = type . equals ( Types . OBJECT ) ? determineLeastSpecificType ( element . getTypes ( ) . toArray ( new String [ element . getTypes ( ) . size ( ) ] ... | Merges a stored element to the local variables . | 113 | 10 |
37,687 | private void mergeMethodHandleStore ( final int index , final MethodHandle methodHandle ) { localVariables . merge ( index , new MethodHandle ( methodHandle ) , Element :: merge ) ; } | Merges a stored method handle to the local variables . | 40 | 11 |
37,688 | private void mergePossibleResponse ( ) { // TODO only HttpResponse element? if ( ! runtimeStack . isEmpty ( ) && runtimeStack . peek ( ) . getTypes ( ) . contains ( Types . RESPONSE ) ) { mergeReturnElement ( runtimeStack . peek ( ) ) ; } } | Checks if the current stack element is eligible for being merged with the returned element . | 65 | 17 |
37,689 | private void simulateSizeChange ( final SizeChangingInstruction instruction ) { IntStream . range ( 0 , instruction . getNumberOfPops ( ) ) . forEach ( i -> runtimeStack . pop ( ) ) ; IntStream . range ( 0 , instruction . getNumberOfPushes ( ) ) . forEach ( i -> runtimeStack . push ( new Element ( ) ) ) ; } | Simulates the size change instruction . | 81 | 7 |
37,690 | public Resources interpret ( final Set < ClassResult > classResults ) { resources = new Resources ( ) ; resources . setBasePath ( PathNormalizer . getApplicationPath ( classResults ) ) ; javaTypeAnalyzer = new JavaTypeAnalyzer ( resources . getTypeRepresentations ( ) ) ; dynamicTypeAnalyzer = new DynamicTypeAnalyzer ( ... | Interprets the class results . | 153 | 7 |
37,691 | private void interpretClassResult ( final ClassResult classResult ) { classResult . getMethods ( ) . forEach ( m -> interpretMethodResult ( m , classResult ) ) ; } | Interprets the class result . | 38 | 7 |
37,692 | private void interpretMethodResult ( final MethodResult methodResult , final ClassResult classResult ) { if ( methodResult . getSubResource ( ) != null ) { interpretClassResult ( methodResult . getSubResource ( ) ) ; return ; } // determine resource of the method final String path = PathNormalizer . getPath ( methodRes... | Interprets the method result . | 100 | 7 |
37,693 | private ResourceMethod interpretResourceMethod ( final MethodResult methodResult , final ClassResult classResult ) { final MethodComment methodDoc = methodResult . getMethodDoc ( ) ; final String description = methodDoc != null ? methodDoc . getComment ( ) : null ; final ResourceMethod resourceMethod = new ResourceMeth... | Interprets the result of a resource method . | 336 | 10 |
37,694 | private void addMediaTypes ( final MethodResult methodResult , final ClassResult classResult , final ResourceMethod resourceMethod ) { // accept media types -> inherit resourceMethod . getRequestMediaTypes ( ) . addAll ( methodResult . getRequestMediaTypes ( ) ) ; if ( resourceMethod . getRequestMediaTypes ( ) . isEmpt... | Adds the request and response media type information to the resource method . | 197 | 13 |
37,695 | void buildPackagePrefix ( final String className ) { // TODO test final int lastPackageSeparator = className . lastIndexOf ( ' ' ) ; final String packageName = className . substring ( 0 , lastPackageSeparator == - 1 ? className . length ( ) : lastPackageSeparator ) ; final String [ ] splitPackage = packageName . split ... | Builds the project package prefix for the class of given method . The current project which is analyzed is identified by the first two package nodes . | 170 | 28 |
37,696 | Set < ProjectMethod > findProjectMethods ( final List < Instruction > instructions ) { final Set < ProjectMethod > projectMethods = new HashSet <> ( ) ; addProjectMethods ( instructions , projectMethods ) ; return projectMethods ; } | Searches for own project method invoke instructions in the given list . | 49 | 14 |
37,697 | private boolean isProjectMethod ( final InvokeInstruction instruction ) { final MethodIdentifier identifier = instruction . getIdentifier ( ) ; // check if method is in own package return identifier . getContainingClass ( ) . startsWith ( projectPackagePrefix ) ; } | Checks if the given instruction invokes a method defined in the analyzed project . | 56 | 16 |
37,698 | private static boolean isStackCleared ( final Instruction instruction ) { return instruction . getType ( ) == Instruction . InstructionType . RETURN || instruction . getType ( ) == Instruction . InstructionType . THROW ; } | Checks if the stack will be cleared on invoking the given instruction . | 45 | 14 |
37,699 | private int findBacktrackPosition ( final int position ) { int currentPosition = position ; // check against stack size after the instruction was executed while ( stackSizes . get ( currentPosition ) . getRight ( ) > 0 ) { currentPosition ++ ; } return currentPosition ; } | Returns the next position where the stack will be empty . | 58 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.