idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
15,900 | protected ItemData getItemByIdentifier ( String cid ) throws RepositoryException , IllegalStateException { checkIfOpened ( ) ; try { ResultSet item = findItemByIdentifier ( cid ) ; try { if ( item . next ( ) ) { return itemData ( null , item , item . getInt ( COLUMN_CLASS ) , null ) ; } return null ; } finally { try { ... | Get Item By Identifier . | 182 | 6 |
15,901 | protected ItemData getItemByName ( NodeData parent , String parentId , QPathEntry name , ItemType itemType ) throws RepositoryException , IllegalStateException { checkIfOpened ( ) ; try { ResultSet item = null ; try { item = findItemByName ( parentId , name . getAsString ( ) , name . getIndex ( ) ) ; while ( item . nex... | Gets an item data from database . | 248 | 8 |
15,902 | private ItemData itemData ( QPath parentPath , ResultSet item , int itemClass , AccessControlList parentACL ) throws RepositoryException , SQLException , IOException { String cid = item . getString ( COLUMN_ID ) ; String cname = item . getString ( COLUMN_NAME ) ; int cversion = item . getInt ( COLUMN_VERSION ) ; String... | Build ItemData . | 364 | 4 |
15,903 | protected MixinInfo readMixins ( String cid ) throws SQLException , IllegalNameException { ResultSet mtrs = findPropertyByName ( cid , Constants . JCR_MIXINTYPES . getAsString ( ) ) ; try { List < InternalQName > mts = null ; boolean owneable = false ; boolean privilegeable = false ; if ( mtrs . next ( ) ) { mts = new ... | Read mixins from database . | 325 | 6 |
15,904 | protected PersistedPropertyData loadPropertyRecord ( QPath parentPath , String cname , String cid , String cpid , int cversion , int cptype , boolean cpmultivalued ) throws RepositoryException , SQLException , IOException { // NOTE: cpid never should be null or root parent (' ') try { QPath qpath = QPath . makeChildPat... | Load PropertyData record . | 283 | 5 |
15,905 | private void deleteValues ( String cid , PropertyData pdata , boolean update , ChangedSizeHandler sizeHandler ) throws IOException , SQLException , RepositoryException , InvalidItemStateException { Set < String > storages = new HashSet < String > ( ) ; final ResultSet valueRecords = findValueStorageDescAndSize ( cid ) ... | Delete Property Values . | 309 | 4 |
15,906 | private List < ValueDataWrapper > readValues ( String cid , int cptype , String identifier , int cversion ) throws IOException , SQLException , ValueStorageNotFoundException { List < ValueDataWrapper > data = new ArrayList < ValueDataWrapper > ( ) ; final ResultSet valueRecords = findValuesByPropertyId ( cid ) ; try { ... | Read Property Values . | 284 | 4 |
15,907 | protected ValueDataWrapper readValueData ( String identifier , int orderNumber , int type , String storageId ) throws SQLException , IOException , ValueStorageNotFoundException { ValueIOChannel channel = this . containerConfig . valueStorageProvider . getChannel ( storageId ) ; try { return channel . read ( identifier ... | Read ValueData from External Storage . | 92 | 7 |
15,908 | public IndexerIoModeHandler getModeHandler ( ) { if ( modeHandler == null ) { if ( ctx . getCache ( ) . getStatus ( ) != ComponentStatus . RUNNING ) { throw new IllegalStateException ( "The cache should be started first" ) ; } synchronized ( this ) { if ( modeHandler == null ) { this . modeHandler = new IndexerIoModeHa... | Get the mode handler | 150 | 4 |
15,909 | @ SuppressWarnings ( "rawtypes" ) protected void doPushState ( ) { final boolean debugEnabled = LOG . isDebugEnabled ( ) ; if ( debugEnabled ) { LOG . debug ( "start pushing in-memory state to cache cacheLoader collection" ) ; } Map < String , ChangesFilterListsWrapper > changesMap = new HashMap < String , ChangesFilte... | Flushes all cache content to underlying CacheStore | 748 | 9 |
15,910 | public static String getStatusDescription ( int status ) { String description = "" ; Integer statusKey = new Integer ( status ) ; if ( statusDescriptions . containsKey ( statusKey ) ) { description = statusDescriptions . get ( statusKey ) ; } return String . format ( "%s %d %s" , WebDavConst . HTTPVER , status , descri... | Returns status description by it s code . | 82 | 8 |
15,911 | private void spoolContent ( InputStream is ) throws IOException , FileNotFoundException { SwapFile swapFile = SwapFile . get ( spoolConfig . tempDirectory , System . currentTimeMillis ( ) + "_" + SEQUENCE . incrementAndGet ( ) , spoolConfig . fileCleaner ) ; try { OutputStream os = PrivilegedFileHelper . fileOutputStre... | Spools the content extracted from the URL | 167 | 8 |
15,912 | public MatchResult match ( QPath input ) { try { return match ( new Context ( input ) ) . getMatchResult ( ) ; } catch ( RepositoryException e ) { throw ( IllegalArgumentException ) new IllegalArgumentException ( "QPath not normalized" ) . initCause ( e ) ; } } | Matches this pattern against the input . | 66 | 8 |
15,913 | private void addPathsWithUnknownChangedSize ( ChangesItem changesItem , ItemState state ) { if ( ! state . isPersisted ( ) && ( state . isDeleted ( ) || state . isRenamed ( ) ) ) { String itemPath = getPath ( state . getData ( ) . getQPath ( ) ) ; for ( String trackedPath : quotaPersister . getAllTrackedNodes ( rName ,... | Checks if changes were made but changed size is unknown . If so determinate for which nodes data size should be recalculated at all and put those paths into respective collection . | 128 | 35 |
15,914 | private void behaveWhenQuotaExceeded ( String message ) throws ExceededQuotaLimitException { switch ( exceededQuotaBehavior ) { case EXCEPTION : throw new ExceededQuotaLimitException ( message ) ; case WARNING : LOG . warn ( message ) ; break ; } } | What to do if data size exceeded quota limit . Throwing exception or logging only . Depends on preconfigured parameter . | 63 | 25 |
15,915 | protected void pushChangesToCoordinator ( ChangesItem changesItem ) throws SecurityException , RPCException { if ( ! changesItem . isEmpty ( ) ) { rpcService . executeCommandOnCoordinator ( applyPersistedChangesTask , true , changesItem ) ; } } | Push changes to coordinator to apply . | 58 | 7 |
15,916 | private String getPath ( QPath path ) { try { return lFactory . createJCRPath ( path ) . getAsString ( false ) ; } catch ( RepositoryException e ) { throw new IllegalStateException ( e . getMessage ( ) , e ) ; } } | Returns item absolute path . | 58 | 5 |
15,917 | private Serializable executeCommand ( RemoteCommand command , Serializable ... args ) throws RPCException { try { return command . execute ( args ) ; } catch ( Throwable e ) //NOSONAR { throw new RPCException ( e . getMessage ( ) , e ) ; } } | Command executing . | 59 | 3 |
15,918 | public ItemState read ( ObjectReader in ) throws UnknownClassIdException , IOException { // read id int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . ITEM_STATE ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } ItemState is = null ; try { int state = in . readIn... | Read and set ItemState data . | 372 | 7 |
15,919 | public Response search ( Session session , HierarchicalProperty body , String baseURI ) { try { SearchRequestEntity requestEntity = new SearchRequestEntity ( body ) ; Query query = session . getWorkspace ( ) . getQueryManager ( ) . createQuery ( requestEntity . getQuery ( ) , requestEntity . getQueryLanguage ( ) ) ; Qu... | Webdav search method implementation . | 272 | 7 |
15,920 | public int getDoc ( IndexReader reader ) throws IOException { if ( doc == - 1 ) { TermDocs docs = reader . termDocs ( new Term ( FieldNames . UUID , id . toString ( ) ) ) ; try { if ( docs . next ( ) ) { return docs . doc ( ) ; } else { throw new IOException ( "Node with id " + id + " not found in index" ) ; } } finall... | Returns the document number for this score node . | 111 | 9 |
15,921 | private String [ ] safeListToArray ( List < String > v ) { return v != null ? v . toArray ( new String [ v . size ( ) ] ) : new String [ 0 ] ; } | Convert list to array . | 44 | 6 |
15,922 | public void removeWorkspaceIndex ( WorkspaceEntry wsConfig , boolean isSystem ) throws RepositoryConfigurationException , IOException { String indexDirName = wsConfig . getQueryHandler ( ) . getParameterValue ( QueryHandlerParams . PARAM_INDEX_DIR ) ; File indexDir = new File ( indexDirName ) ; if ( PrivilegedFileHelpe... | Remove all file of workspace index . | 155 | 7 |
15,923 | public PlainChangesLog pushLog ( QPath rootPath ) { // session instance is always present in SessionChangesLog PlainChangesLog cLog = new PlainChangesLogImpl ( getDescendantsChanges ( rootPath ) , session ) ; if ( rootPath . equals ( Constants . ROOT_PATH ) ) { clear ( ) ; } else { remove ( rootPath ) ; } return cLog ;... | Creates new changes log with rootPath and its descendants of this one and removes those entries . | 83 | 19 |
15,924 | protected void doRestore ( ) throws Throwable { PlainChangesLog changes = read ( ) ; TransactionChangesLog tLog = new TransactionChangesLog ( changes ) ; tLog . setSystemId ( Constants . JCR_CORE_RESTORE_WORKSPACE_INITIALIZER_SYSTEM_ID ) ; // mark changes dataManager . save ( tLog ) ; } | Perform restore operation . | 83 | 5 |
15,925 | private String removeAsterisk ( String str ) { if ( str . startsWith ( "*" ) ) { str = str . substring ( 1 ) ; } if ( str . endsWith ( "*" ) ) { str = str . substring ( 0 , str . length ( ) - 1 ) ; } return str ; } | Removes asterisk from beginning and from end of statement . | 71 | 12 |
15,926 | public Set < VersionResource > getVersions ( ) throws RepositoryException , IllegalResourceTypeException { Set < VersionResource > resources = new HashSet < VersionResource > ( ) ; VersionIterator versions = versionHistory . getAllVersions ( ) ; while ( versions . hasNext ( ) ) { Version version = versions . nextVersio... | Returns all versions of a resource . | 129 | 7 |
15,927 | public VersionResource getVersion ( String name ) throws RepositoryException , IllegalResourceTypeException { return new VersionResource ( versionURI ( name ) , versionedResource , versionHistory . getVersion ( name ) , namespaceContext ) ; } | Returns the version of resouce by name . | 48 | 10 |
15,928 | protected final URI versionURI ( String versionName ) { return URI . create ( versionedResource . getIdentifier ( ) . toASCIIString ( ) + "?version=" + versionName ) ; } | Returns URI of the resource version . | 43 | 7 |
15,929 | protected String buildPathX8 ( String fileName ) { final int xLength = 8 ; char [ ] chs = fileName . toCharArray ( ) ; StringBuilder path = new StringBuilder ( ) ; for ( int i = 0 ; i < xLength ; i ++ ) { path . append ( File . separator ) . append ( chs [ i ] ) ; } path . append ( fileName . substring ( xLength ) ) ; ... | best for now 12 . 07 . 07 | 104 | 8 |
15,930 | private void load ( ) throws IOException { if ( PrivilegedFileHelper . exists ( storage ) ) { InputStream in = PrivilegedFileHelper . fileInputStream ( storage ) ; try { Properties props = new Properties ( ) ; log . debug ( "loading namespace mappings..." ) ; props . load ( in ) ; // read mappings from properties Itera... | Loads currently known mappings from a . properties file . | 200 | 12 |
15,931 | private void store ( ) throws IOException { Properties props = new Properties ( ) ; // store mappings in properties Iterator < String > iter = prefixToURI . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String prefix = iter . next ( ) ; String uri = prefixToURI . get ( prefix ) ; props . setProperty ( pref... | Writes the currently known mappings into a . properties file . | 142 | 13 |
15,932 | public static RegistryEntry parse ( final byte [ ] bytes ) throws IOException , SAXException , ParserConfigurationException { try { return SecurityHelper . doPrivilegedExceptionAction ( new PrivilegedExceptionAction < RegistryEntry > ( ) { public RegistryEntry run ( ) throws Exception { return new RegistryEntry ( Docum... | Factory method to create RegistryEntry from serialized XML | 208 | 10 |
15,933 | public void addClassTag ( String tag , Class type ) { tagToClass . put ( tag , type ) ; classToTag . put ( type , tag ) ; } | Sets a tag to use instead of the fully qualifier class name . This can make the JSON easier to read . | 36 | 23 |
15,934 | public < T > void setSerializer ( Class < T > type , JsonSerializer < T > serializer ) { classToSerializer . put ( type , serializer ) ; } | Registers a serializer to use for the specified type instead of the default behavior of serializing all of an objects fields . | 40 | 25 |
15,935 | public void setElementType ( Class type , String fieldName , Class elementType ) { ObjectMap < String , FieldMetadata > fields = getFields ( type ) ; FieldMetadata metadata = fields . get ( fieldName ) ; if ( metadata == null ) throw new JsonException ( "Field not found: " + fieldName + " (" + type . getName ( ) + ")" ... | Sets the type of elements in a collection . When the element type is known the class for each element in the collection does not need to be written unless different from the element type . | 94 | 37 |
15,936 | public void setWriter ( Writer writer ) { if ( ! ( writer instanceof JsonWriter ) ) writer = new JsonWriter ( writer ) ; this . writer = ( JsonWriter ) writer ; this . writer . setOutputType ( outputType ) ; this . writer . setQuoteLongValues ( quoteLongValues ) ; } | Sets the writer where JSON output will be written . This is only necessary when not using the toJson methods . | 69 | 24 |
15,937 | public void writeFields ( Object object ) { Class type = object . getClass ( ) ; Object [ ] defaultValues = getDefaultValues ( type ) ; OrderedMap < String , FieldMetadata > fields = getFields ( type ) ; int i = 0 ; for ( FieldMetadata metadata : new OrderedMapValues < FieldMetadata > ( fields ) ) { Field field = metad... | Writes all fields of the specified object to the current JSON object . | 416 | 14 |
15,938 | public void writeField ( Object object , String fieldName , String jsonName , Class elementType ) { Class type = object . getClass ( ) ; ObjectMap < String , FieldMetadata > fields = getFields ( type ) ; FieldMetadata metadata = fields . get ( fieldName ) ; if ( metadata == null ) throw new JsonException ( "Field not f... | Writes the specified field to the current JSON object . | 316 | 11 |
15,939 | public void writeValue ( String name , Object value ) { try { writer . name ( name ) ; } catch ( IOException ex ) { throw new JsonException ( ex ) ; } if ( value == null ) writeValue ( value , null , null ) ; else writeValue ( value , value . getClass ( ) , null ) ; } | Writes the value as a field on the current JSON object without writing the actual class . | 72 | 18 |
15,940 | public void writeValue ( String name , Object value , Class knownType ) { try { writer . name ( name ) ; } catch ( IOException ex ) { throw new JsonException ( ex ) ; } writeValue ( value , knownType , null ) ; } | Writes the value as a field on the current JSON object writing the class of the object if it differs from the specified known type . | 55 | 27 |
15,941 | public void writeValue ( Object value ) { if ( value == null ) writeValue ( value , null , null ) ; else writeValue ( value , value . getClass ( ) , null ) ; } | Writes the value without writing the class of the object . | 42 | 12 |
15,942 | boolean detectLongRunningJob ( long currentTime , Job job ) { if ( job . status ( ) == JobStatus . RUNNING && ! longRunningJobs . containsKey ( job ) ) { int jobExecutionsCount = job . executionsCount ( ) ; Long jobStartedtimeInMillis = job . lastExecutionStartedTimeInMillis ( ) ; Thread threadRunningJob = job . thread... | Check whether a job is running for too long or not . | 262 | 12 |
15,943 | public Job schedule ( Runnable runnable , Schedule when ) { return schedule ( null , runnable , when ) ; } | Schedule the executions of a process . | 28 | 8 |
15,944 | public Optional < Job > findJob ( String name ) { return Optional . ofNullable ( indexedJobsByName . get ( name ) ) ; } | Find a job by its name | 32 | 6 |
15,945 | @ SneakyThrows public void gracefullyShutdown ( Duration timeout ) { logger . info ( "Shutting down..." ) ; if ( ! shuttingDown ) { synchronized ( this ) { shuttingDown = true ; threadPoolExecutor . shutdown ( ) ; } // stops jobs that have not yet started to be executed for ( Job job : jobStatus ( ) ) { Runnable runnin... | Wait until the current running jobs are executed and cancel jobs that are planned to be executed . | 175 | 18 |
15,946 | @ SneakyThrows private void launcher ( ) { while ( ! shuttingDown ) { Long timeBeforeNextExecution = null ; synchronized ( this ) { if ( nextExecutionsOrder . size ( ) > 0 ) { timeBeforeNextExecution = nextExecutionsOrder . get ( 0 ) . nextExecutionTimeInMillis ( ) - timeProvider . currentTime ( ) ; } } if ( timeBefore... | The daemon that will be in charge of placing the jobs in the thread pool when they are ready to be executed . | 380 | 23 |
15,947 | private void runJob ( Job jobToRun ) { long startExecutionTime = timeProvider . currentTime ( ) ; long timeBeforeNextExecution = jobToRun . nextExecutionTimeInMillis ( ) - startExecutionTime ; if ( timeBeforeNextExecution < 0 ) { logger . debug ( "Job '{}' execution is {}ms late" , jobToRun . name ( ) , - timeBeforeNex... | The wrapper around a job that will be executed in the thread pool . It is especially in charge of logging changing the job status and checking for the next job to be executed . | 325 | 35 |
15,948 | private HttpURLConnection configureURLConnection ( HttpMethod method , String urlString , Map < String , String > httpHeaders , int contentLength ) throws IOException { preconditionNotNull ( method , "method cannot be null" ) ; preconditionNotNull ( urlString , "urlString cannot be null" ) ; preconditionNotNull ( httpH... | Provides an internal convenience method to allow easy overriding by test classes | 290 | 13 |
15,949 | String getResponseEncoding ( URLConnection connection ) { String charset = null ; String contentType = connection . getHeaderField ( "Content-Type" ) ; if ( contentType != null ) { for ( String param : contentType . replace ( " " , "" ) . split ( ";" ) ) { if ( param . startsWith ( "charset=" ) ) { charset = param . sp... | Determine the response encoding if specified | 106 | 8 |
15,950 | public static PDFont mapDefaultFonts ( Font font ) { /* * Map default font names to the matching families. */ if ( fontNameEqualsAnyOf ( font , Font . SANS_SERIF , Font . DIALOG , Font . DIALOG_INPUT , "Arial" , "Helvetica" ) ) return chooseMatchingHelvetica ( font ) ; if ( fontNameEqualsAnyOf ( font , Font . MONOSPACE... | Find a PDFont for the given font object which does not need to be embedded . | 239 | 17 |
15,951 | public static PDFont chooseMatchingTimes ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . TIMES_BOLD_ITALIC ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . TIMES_ITALIC ; if ( ( font . getStyle... | Get a PDType1Font . TIMES - variant which matches the given font | 146 | 16 |
15,952 | public static PDFont chooseMatchingCourier ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . COURIER_BOLD_OBLIQUE ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . COURIER_OBLIQUE ; if ( ( font . ... | Get a PDType1Font . COURIER - variant which matches the given font | 157 | 18 |
15,953 | public static PDFont chooseMatchingHelvetica ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . HELVETICA_BOLD_OBLIQUE ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . HELVETICA_OBLIQUE ; if ( ( f... | Get a PDType1Font . HELVETICA - variant which matches the given font | 157 | 18 |
15,954 | @ SuppressWarnings ( "WeakerAccess" ) public void registerFont ( String fontName , File fontFile ) { if ( ! fontFile . exists ( ) ) throw new IllegalArgumentException ( "Font " + fontFile + " does not exist!" ) ; FontEntry entry = new FontEntry ( ) ; entry . overrideName = fontName ; entry . file = fontFile ; fontFiles... | Register a font . | 92 | 4 |
15,955 | @ SuppressWarnings ( "WeakerAccess" ) public void registerFont ( String name , PDFont font ) { fontMap . put ( name , font ) ; } | Register a font which is already associated with the PDDocument | 37 | 11 |
15,956 | @ SuppressWarnings ( "WeakerAccess" ) protected PDFont mapFont ( final Font font , final IFontTextDrawerEnv env ) throws IOException , FontFormatException { /* * If we have any font registering's, we must perform them now */ for ( final FontEntry fontEntry : fontFiles ) { if ( fontEntry . overrideName == null ) { Font ... | Try to map the java . awt . Font to a PDFont . | 353 | 15 |
15,957 | public float getPixelSize ( ) { if ( mVectorState == null && mVectorState . mVPathRenderer == null || mVectorState . mVPathRenderer . mBaseWidth == 0 || mVectorState . mVPathRenderer . mBaseHeight == 0 || mVectorState . mVPathRenderer . mViewportHeight == 0 || mVectorState . mVPathRenderer . mViewportWidth == 0 ) { ret... | The size of a pixel when scaled from the intrinsic dimension to the viewport dimension . This is used to calculate the path animation accuracy . | 229 | 27 |
15,958 | @ RequestMapping ( path = "/api" , method = RequestMethod . GET , produces = { "application/hal+json" , "application/json" } ) public HalRepresentation getHomeDocument ( final HttpServletRequest request ) { final String homeUrl = request . getRequestURL ( ) . toString ( ) ; return new HalRepresentation ( linkingTo ( ) ... | Entry point for the products REST API . | 142 | 8 |
15,959 | public static Builder copyOf ( final Link prototype ) { return new Builder ( prototype . rel , prototype . href ) . withType ( prototype . type ) . withProfile ( prototype . profile ) . withTitle ( prototype . title ) . withName ( prototype . name ) . withDeprecation ( prototype . deprecation ) . withHrefLang ( prototy... | Create a Builder instance and initialize it from a prototype Link . | 83 | 12 |
15,960 | public static Embedded embedded ( final String rel , final HalRepresentation embeddedItem ) { return new Embedded ( singletonMap ( rel , embeddedItem ) ) ; } | Create an Embedded instance with a single embedded HalRepresentations that will be rendered as a single item instead of an array of embedded items . | 35 | 28 |
15,961 | public static Embedded embedded ( final String rel , final List < ? extends HalRepresentation > embeddedRepresentations ) { return new Embedded ( singletonMap ( rel , new ArrayList <> ( embeddedRepresentations ) ) ) ; } | Create an Embedded instance with a list of nested HalRepresentations for a single link - relation type . | 49 | 21 |
15,962 | private int calcLastPage ( int total , int pageSize ) { if ( total == 0 ) { return firstPage ; } else { final int zeroBasedPageNo = total % pageSize > 0 ? total / pageSize : total / pageSize - 1 ; return firstPage + zeroBasedPageNo ; } } | Returns the number of the last page if the total number of items is known . | 65 | 16 |
15,963 | private String pageUri ( final UriTemplate uriTemplate , final int pageNumber , final int pageSize ) { if ( pageSize == MAX_VALUE ) { return uriTemplate . expand ( ) ; } return uriTemplate . set ( pageNumberVar ( ) , pageNumber ) . set ( pageSizeVar ( ) , pageSize ) . expand ( ) ; } | Return the HREF of the page specified by UriTemplate pageNumber and pageSize . | 78 | 17 |
15,964 | @ SuppressWarnings ( "rawtypes" ) public Stream < Link > stream ( ) { return links . values ( ) . stream ( ) . map ( obj -> { if ( obj instanceof List ) { return ( List ) obj ; } else { return singletonList ( obj ) ; } } ) . flatMap ( Collection :: stream ) ; } | Returns a Stream of links . | 75 | 6 |
15,965 | private int calcLastPageSkip ( int total , int skip , int limit ) { if ( skip > total - limit ) { return skip ; } if ( total % limit > 0 ) { return total - total % limit ; } return total - limit ; } | Calculate the number of items to skip for the last page . | 53 | 14 |
15,966 | private String pageUri ( final UriTemplate uriTemplate , final int skip , final int limit ) { if ( limit == MAX_VALUE ) { return uriTemplate . expand ( ) ; } return uriTemplate . set ( skipVar ( ) , skip ) . set ( limitVar ( ) , limit ) . expand ( ) ; } | Return the URI of the page with N skipped items and a page limitted to pages of size M . | 71 | 21 |
15,967 | public List < Product > searchFor ( final Optional < String > searchTerm ) { if ( searchTerm . isPresent ( ) ) { return products . stream ( ) . filter ( matchingProductsFor ( searchTerm . get ( ) ) ) . collect ( toList ( ) ) ; } else { return products ; } } | Searches for products using a case - insensitive search term . | 66 | 13 |
15,968 | HalRepresentation mergeWithEmbedding ( final Curies curies ) { this . curies = this . curies . mergeWith ( curies ) ; if ( this . links != null ) { removeDuplicateCuriesFromEmbedding ( curies ) ; this . links = this . links . using ( this . curies ) ; if ( embedded != null ) { embedded = embedded . using ( this . curie... | Merges the Curies of an embedded resource with the Curies of this resource and updates link - relation types in _links and _embedded items . | 119 | 31 |
15,969 | public < T extends HalRepresentation > T as ( final Class < T > type ) throws IOException { return objectMapper . readValue ( json , type ) ; } | Specify the type that is used to parse and map the json . | 36 | 14 |
15,970 | private Optional < JsonNode > findPossiblyCuriedEmbeddedNode ( final HalRepresentation halRepresentation , final JsonNode jsonNode , final String rel ) { final JsonNode embedded = jsonNode . get ( "_embedded" ) ; if ( embedded != null ) { final Curies curies = halRepresentation . getCuries ( ) ; final JsonNode curiedNo... | Returns the JsonNode of the embedded items by link - relation type and resolves possibly curied rels . | 153 | 22 |
15,971 | public void register ( final Link curi ) { if ( ! curi . getRel ( ) . equals ( "curies" ) ) { throw new IllegalArgumentException ( "Link must be a CURI" ) ; } final boolean alreadyRegistered = curies . stream ( ) . anyMatch ( link -> link . getHref ( ) . equals ( curi . getHref ( ) ) ) ; if ( alreadyRegistered ) { curi... | Registers a CURI link in the Curies instance . | 162 | 12 |
15,972 | public Curies mergeWith ( final Curies other ) { final Curies merged = copyOf ( this ) ; other . curies . forEach ( merged :: register ) ; return merged ; } | Merges this Curies with another instance of Curies and returns the merged instance . | 40 | 17 |
15,973 | public Traverson startWith ( final HalRepresentation resource ) { this . startWith = null ; this . lastResult = singletonList ( requireNonNull ( resource ) ) ; Optional < Link > self = resource . getLinks ( ) . getLinkBy ( "self" ) ; if ( self . isPresent ( ) ) { this . contextUrl = linkToUrl ( self . get ( ) ) ; } els... | Start traversal at the given HAL resource . | 186 | 9 |
15,974 | private static Link resolve ( final URL contextUrl , final Link link ) { if ( link != null && link . isTemplated ( ) ) { final String msg = "Link must not be templated" ; LOG . error ( msg ) ; throw new IllegalStateException ( msg ) ; } if ( link == null ) { return self ( contextUrl . toString ( ) ) ; } else { return c... | Resolved a link using the URL of the current resource and returns it as an absolute Link . | 123 | 19 |
15,975 | private void checkState ( ) { if ( startWith == null && lastResult == null ) { final String msg = "Please call startWith(uri) first." ; LOG . error ( msg ) ; throw new IllegalStateException ( msg ) ; } } | Checks the current state of the Traverson . | 53 | 10 |
15,976 | public Client build ( final ZipkinClientConfiguration configuration ) { final Client client = new JerseyClientBuilder ( environment ) . using ( configuration ) . build ( configuration . getServiceName ( ) ) ; return build ( client ) ; } | Build a new Jersey Client that is instrumented for Zipkin | 47 | 12 |
15,977 | public Client build ( final Client client ) { client . register ( TracingClientFilter . create ( tracing ) ) ; return client ; } | Instrument an existing Jersey client | 28 | 6 |
15,978 | public CreateResponse create ( ) throws IOException , PlivoRestException { validate ( ) ; Response < CreateResponse > response = obtainCall ( ) . execute ( ) ; handleResponse ( response ) ; return response . body ( ) ; } | Actually create an instance of the resource . | 49 | 8 |
15,979 | private static void getAccountInfo ( ) { try { Account response = Account . getter ( ) . get ( ) ; System . out . println ( response ) ; } catch ( PlivoRestException | IOException e ) { e . printStackTrace ( ) ; } } | trying to get account info without setting the client | 58 | 10 |
15,980 | private static void getAccountInfoBySettingClient ( ) { try { Account response = Account . getter ( ) . client ( client ) . get ( ) ; System . out . println ( response ) ; } catch ( PlivoRestException | IOException e ) { e . printStackTrace ( ) ; } } | trying to get account info by setting the client | 66 | 10 |
15,981 | private static void modifyAccountBySettingClient ( ) { try { AccountUpdateResponse response = Account . updater ( ) . city ( "Test city" ) . client ( client ) . update ( ) ; System . out . println ( response ) ; } catch ( PlivoRestException | IOException e ) { e . printStackTrace ( ) ; } } | update account with different client settings | 75 | 6 |
15,982 | private static void createSubAccountBySettingClient ( ) { try { SubaccountCreateResponse subaccount = Subaccount . creator ( "Test 2" ) . enabled ( true ) . client ( client ) . create ( ) ; System . out . println ( subaccount ) ; } catch ( PlivoRestException | IOException e ) { e . printStackTrace ( ) ; } } | create subaccount with different client settings | 80 | 7 |
15,983 | public void delete ( ) throws IOException , PlivoRestException { validate ( ) ; Response < ResponseBody > response = obtainCall ( ) . execute ( ) ; handleResponse ( response ) ; } | Actually delete the resource . | 41 | 5 |
15,984 | public T update ( ) throws IOException , PlivoRestException { validate ( ) ; Response < T > response = obtainCall ( ) . execute ( ) ; handleResponse ( response ) ; return response . body ( ) ; } | Actually update the resource . | 47 | 5 |
15,985 | public ListResponse < T > list ( ) throws IOException , PlivoRestException { validate ( ) ; Response < ListResponse < T > > response = obtainCall ( ) . execute ( ) ; handleResponse ( response ) ; return response . body ( ) ; } | Actually list instances of the resource . | 55 | 7 |
15,986 | @ Override protected Result check ( ) throws Exception { final ClusterHealthStatus status = client . admin ( ) . cluster ( ) . prepareHealth ( ) . get ( ) . getStatus ( ) ; if ( status == ClusterHealthStatus . RED || ( failOnYellow && status == ClusterHealthStatus . YELLOW ) ) { return Result . unhealthy ( "Last status... | Perform a check of the Elasticsearch cluster health . | 113 | 11 |
15,987 | public static void i ( String s , Throwable t ) { log ( Level . INFO , s , t ) ; } | Log an INFO message and the exception | 25 | 7 |
15,988 | public static void w ( String s , Throwable t ) { log ( Level . WARNING , s , t ) ; } | Log a WARNING message and the exception | 25 | 7 |
15,989 | public static byte [ ] fromHex ( String hex ) { char [ ] c = hex . toCharArray ( ) ; byte [ ] b = new byte [ c . length / 2 ] ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = ( byte ) ( HEX_DECODE_CHAR [ c [ i * 2 ] & 0xFF ] * 16 + HEX_DECODE_CHAR [ c [ i * 2 + 1 ] & 0xFF ] ) ; } return b ; } | Decode from hexadecimal | 117 | 7 |
15,990 | public static String toHexUpper ( byte [ ] b , int off , int len ) { return toHex ( b , off , len , HEX_UPPER_CHAR ) ; } | Encode to uppercase hexadecimal | 42 | 10 |
15,991 | public static String toHexLower ( byte [ ] b , int off , int len ) { return toHex ( b , off , len , HEX_LOWER_CHAR ) ; } | Encode to lowercase hexadecimal | 41 | 9 |
15,992 | public static byte [ ] add ( byte [ ] b1 , int off1 , int len1 , byte [ ] b2 , int off2 , int len2 ) { byte [ ] b = new byte [ len1 + len2 ] ; System . arraycopy ( b1 , off1 , b , 0 , len1 ) ; System . arraycopy ( b2 , off2 , b , len1 , len2 ) ; return b ; } | Concatenate 2 byte arrays | 94 | 7 |
15,993 | public static byte [ ] sub ( byte [ ] b , int off , int len ) { byte [ ] result = new byte [ len ] ; System . arraycopy ( b , off , result , 0 , len ) ; return result ; } | Truncate and keep middle part of a byte array | 50 | 11 |
15,994 | public static synchronized void chdir ( String path ) { if ( path != null ) { rootDir = new File ( getAbsolutePath ( path ) ) . getAbsolutePath ( ) ; } } | Change the current folder | 42 | 4 |
15,995 | public static void closeLogger ( Logger logger ) { for ( Handler handler : logger . getHandlers ( ) ) { logger . removeHandler ( handler ) ; handler . close ( ) ; } } | Close a logger | 42 | 3 |
15,996 | public static List < String > getClasses ( String ... packageNames ) { List < String > classes = new ArrayList <> ( ) ; for ( String packageName : packageNames ) { String packagePath = packageName . replace ( ' ' , ' ' ) ; URL url = Conf . class . getResource ( "/" + packagePath ) ; if ( url == null ) { return classes ... | Traverse all classes under given packages | 373 | 7 |
15,997 | public Entry borrow ( ) throws E { long now = System . currentTimeMillis ( ) ; if ( timeout > 0 ) { long accessed_ = accessed . get ( ) ; if ( now > accessed_ + Time . SECOND && accessed . compareAndSet ( accessed_ , now ) ) { Entry entry ; while ( ( entry = deque . pollLast ( ) ) != null ) { // inactiveCount.decrement... | Borrow an object from the pool or create a new object if no valid objects in the pool | 273 | 19 |
15,998 | public void await ( ) { if ( interrupted . get ( ) ) { return ; } try { mainLatch . await ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } } | Wait until a proper shutdown command is received then return . | 50 | 11 |
15,999 | public T get ( ) throws E { // use a temporary variable to reduce the number of reads of the volatile field // see commons-lang3 T result = object ; if ( object == null ) { synchronized ( this ) { result = object ; if ( object == null ) { object = result = initializer . get ( ) ; } } } return result ; } | Create or get the instance . | 75 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.