idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
7,900 | private static List < Column > getAncestorColumns ( Resource currentResource , Resource rootResource ) { List < Column > columns = new ArrayList < > ( ) ; List < Resource > ancestors = getAncestors ( currentResource , rootResource ) ; for ( int i = 0 ; i < ancestors . size ( ) ; i ++ ) { Resource r = ancestors . get ( ... | Generate column for each ancestor . |
7,901 | public void _waitForNonStaleResults ( Duration waitTimeout ) { theWaitForNonStaleResults = true ; timeout = ObjectUtils . firstNonNull ( waitTimeout , getDefaultTimeout ( ) ) ; } | Instruct the query to wait for non stale result for the specified wait timeout . This shouldn t be used outside of unit tests unless you are well aware of the implications |
7,902 | public List < String > getProjectionFields ( ) { return fieldsToFetchToken != null && fieldsToFetchToken . projections != null ? Arrays . asList ( fieldsToFetchToken . projections ) : Collections . emptyList ( ) ; } | Gets the fields for projection |
7,903 | public void _randomOrdering ( String seed ) { assertNoRawQuery ( ) ; if ( StringUtils . isBlank ( seed ) ) { _randomOrdering ( ) ; return ; } _noCaching ( ) ; orderByTokens . add ( OrderByToken . createRandom ( seed ) ) ; } | Order the search results randomly using the specified seed this is useful if you want to have repeatable random queries |
7,904 | @ SuppressWarnings ( "ConstantConditions" ) public void _whereLucene ( String fieldName , String whereClause , boolean exact ) { fieldName = ensureValidFieldName ( fieldName , false ) ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; appendOperatorIfNeeded ( tokens ) ; negateIfNeeded ( tokens , fieldName ) ; W... | Filter the results from the index using the specified where clause . |
7,905 | public void _openSubclause ( ) { _currentClauseDepth ++ ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; appendOperatorIfNeeded ( tokens ) ; negateIfNeeded ( tokens , null ) ; tokens . add ( OpenSubclauseToken . INSTANCE ) ; } | Simplified method for opening a new clause within the query |
7,906 | public void _closeSubclause ( ) { _currentClauseDepth -- ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; tokens . add ( CloseSubclauseToken . INSTANCE ) ; } | Simplified method for closing a clause within the query |
7,907 | public void _whereIn ( String fieldName , Collection < Object > values ) { _whereIn ( fieldName , values , false ) ; } | Check that the field has one of the specified value |
7,908 | public void _whereEndsWith ( String fieldName , Object value , boolean exact ) { WhereParams whereParams = new WhereParams ( ) ; whereParams . setFieldName ( fieldName ) ; whereParams . setValue ( value ) ; whereParams . setAllowWildcards ( true ) ; Object transformToEqualValue = transformValue ( whereParams ) ; List <... | Matches fields which ends with the specified value . |
7,909 | public void _whereBetween ( String fieldName , Object start , Object end , boolean exact ) { fieldName = ensureValidFieldName ( fieldName , false ) ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; appendOperatorIfNeeded ( tokens ) ; negateIfNeeded ( tokens , fieldName ) ; WhereParams startParams = new WherePa... | Matches fields where the value is between the specified start and end inclusive |
7,910 | public void _orElse ( ) { List < QueryToken > tokens = getCurrentWhereTokens ( ) ; if ( tokens . isEmpty ( ) ) { return ; } if ( tokens . get ( tokens . size ( ) - 1 ) instanceof QueryOperatorToken ) { throw new IllegalStateException ( "Cannot add OR, previous token was already an operator token." ) ; } tokens . add ( ... | Add an OR to the query |
7,911 | public void _orderBy ( String field , OrderingType ordering ) { assertNoRawQuery ( ) ; String f = ensureValidFieldName ( field , false ) ; orderByTokens . add ( OrderByToken . createAscending ( f , ordering ) ) ; } | Order the results by the specified fields The fields are the names of the fields to sort defaulting to sorting by ascending . You can prefix a field name with - to indicate sorting by descending or + to sort by ascending |
7,912 | public void _orderByDescending ( String field , OrderingType ordering ) { assertNoRawQuery ( ) ; String f = ensureValidFieldName ( field , false ) ; orderByTokens . add ( OrderByToken . createDescending ( f , ordering ) ) ; } | Order the results by the specified fields The fields are the names of the fields to sort defaulting to sorting by descending . You can prefix a field name with - to indicate sorting by descending or + to sort by ascending |
7,913 | protected IndexQuery generateIndexQuery ( String query ) { IndexQuery indexQuery = new IndexQuery ( ) ; indexQuery . setQuery ( query ) ; indexQuery . setStart ( start ) ; indexQuery . setWaitForNonStaleResults ( theWaitForNonStaleResults ) ; indexQuery . setWaitForNonStaleResultsTimeout ( timeout ) ; indexQuery . setQ... | Generates the index query . |
7,914 | public QueryResult createSnapshot ( ) { QueryResult queryResult = new QueryResult ( ) ; queryResult . setResults ( getResults ( ) ) ; queryResult . setIncludes ( getIncludes ( ) ) ; queryResult . setIndexName ( getIndexName ( ) ) ; queryResult . setIndexTimestamp ( getIndexTimestamp ( ) ) ; queryResult . setIncludedPat... | Creates a snapshot of the query results |
7,915 | public List < SubscriptionState > getSubscriptions ( int start , int take , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; GetSubscriptionsCommand command = new GetSubscriptionsCommand ( start , take ) ; requestE... | It downloads a list of all existing subscriptions in a database . |
7,916 | public void delete ( String name , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; DeleteSubscriptionCommand command = new DeleteSubscriptionCommand ( name ) ; requestExecutor . execute ( command ) ; } | Delete a subscription . |
7,917 | public SubscriptionState getSubscriptionState ( String subscriptionName , String database ) { if ( StringUtils . isEmpty ( subscriptionName ) ) { throw new IllegalArgumentException ( "SubscriptionName cannot be null" ) ; } RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( data... | Returns subscription definition and it s current state |
7,918 | public void dropConnection ( String name , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; DropSubscriptionConnectionCommand command = new DropSubscriptionConnectionCommand ( name ) ; requestExecutor . execute ( c... | Force server to close current client subscription connection to the server |
7,919 | private static String getContentPath ( HttpServletRequest request ) { String contentPath = ( String ) request . getAttribute ( Value . CONTENTPATH_ATTRIBUTE ) ; if ( contentPath == null ) { contentPath = ( ( SlingHttpServletRequest ) request ) . getRequestPathInfo ( ) . getSuffix ( ) ; } return contentPath ; } | Current content path |
7,920 | public static < T extends EventArgs > void invoke ( List < EventHandler < T > > delegates , Object sender , T event ) { for ( EventHandler < T > delegate : delegates ) { delegate . handle ( sender , event ) ; } } | Helper used for invoking event on list of delegates |
7,921 | private static void checkOffset ( String value , int offset , char expected ) throws IndexOutOfBoundsException { char found = value . charAt ( offset ) ; if ( found != expected ) { throw new IndexOutOfBoundsException ( "Expected '" + expected + "' character but found '" + found + "'" ) ; } } | Check if the expected character exist at the given offset of the |
7,922 | public void saveChanges ( ) { BatchOperation saveChangeOperation = new BatchOperation ( this ) ; try ( BatchCommand command = saveChangeOperation . createRequest ( ) ) { if ( command == null ) { return ; } if ( noTracking ) { throw new IllegalStateException ( "Cannot execute saveChanges when entity tracking is disabled... | Saves all the changes to the Raven server . |
7,923 | public boolean exists ( String id ) { if ( id == null ) { throw new IllegalArgumentException ( "id cannot be null" ) ; } if ( _knownMissingIds . contains ( id ) ) { return false ; } if ( documentsById . getValue ( id ) != null ) { return true ; } HeadDocumentCommand command = new HeadDocumentCommand ( id , null ) ; _re... | Check if document exists without loading it |
7,924 | public < T > void refresh ( T entity ) { DocumentInfo documentInfo = documentsByEntity . get ( entity ) ; if ( documentInfo == null ) { throw new IllegalStateException ( "Cannot refresh a transient instance" ) ; } incrementRequestCount ( ) ; GetDocumentsCommand command = new GetDocumentsCommand ( new String [ ] { docum... | Refreshes the specified entity from Raven server . |
7,925 | protected void spatial ( String field , Function < SpatialOptionsFactory , SpatialOptions > indexing ) { spatialOptionsStrings . put ( field , indexing . apply ( new SpatialOptionsFactory ( ) ) ) ; } | Register a field to be spatially indexed |
7,926 | @ SuppressWarnings ( "unchecked" ) public Object convertToEntity ( Class entityType , String id , ObjectNode document ) { try { if ( ObjectNode . class . equals ( entityType ) ) { return document ; } Object defaultValue = InMemoryDocumentSessionOperations . getDefaultValue ( entityType ) ; Object entity = defaultValue ... | Converts a json object to an entity . |
7,927 | protected final JSONArray getPages ( Iterator < Page > pages , int depth , PageFilter pageFilter ) throws JSONException { JSONArray pagesArray = new JSONArray ( ) ; while ( pages . hasNext ( ) ) { Page page = pages . next ( ) ; JSONObject pageObject = getPage ( page ) ; if ( pageObject != null ) { Iterator < Page > chi... | Generate JSON objects for pages . |
7,928 | protected final Iterator < Page > listChildren ( Resource parentResource , PageFilter pageFilter ) { return new PageIterator ( parentResource . listChildren ( ) , pageFilter ) ; } | Lists children using custom page iterator . |
7,929 | @ SuppressWarnings ( "null" ) protected final JSONObject getPage ( Page page ) throws JSONException { Resource resource = page . adaptTo ( Resource . class ) ; JSONObject pageObject = new JSONObject ( ) ; pageObject . put ( "name" , page . getName ( ) ) ; String title = page . getTitle ( ) ; if ( StringUtils . isEmpty ... | Generate JSON object for page |
7,930 | public String getIdentifier ( ) { if ( identifier != null ) { return identifier ; } if ( urls == null ) { return null ; } if ( database != null ) { return String . join ( "," , urls ) + " (DB: " + database + ")" ; } return String . join ( "," , urls ) ; } | Gets the identifier for this store . |
7,931 | public IDocumentSession openSession ( String database ) { SessionOptions sessionOptions = new SessionOptions ( ) ; sessionOptions . setDatabase ( database ) ; return openSession ( sessionOptions ) ; } | Opens the session for a particular database |
7,932 | public IDocumentStore initialize ( ) { if ( initialized ) { return this ; } assertValidConfiguration ( ) ; try { if ( getConventions ( ) . getDocumentIdGenerator ( ) == null ) { MultiDatabaseHiLoIdGenerator generator = new MultiDatabaseHiLoIdGenerator ( this , getConventions ( ) ) ; _multiDbHiLo = generator ; getConven... | Initializes this instance . |
7,933 | private static boolean isPageInTemplateDefinition ( Page page ) { Resource resource = page . adaptTo ( Resource . class ) ; if ( resource != null ) { Resource parent = resource . getParent ( ) ; if ( parent != null ) { return StringUtils . equals ( NT_TEMPLATE , parent . getValueMap ( ) . get ( JCR_PRIMARYTYPE , String... | Checks if the given page is part of the editable template definition itself . |
7,934 | public void execute ( IDocumentStore store , DocumentConventions conventions , String database ) { DocumentConventions oldConventions = getConventions ( ) ; try { setConventions ( ObjectUtils . firstNonNull ( conventions , getConventions ( ) , store . getConventions ( ) ) ) ; IndexDefinition indexDefinition = createInd... | Executes the index creation against the specified document database using the specified conventions |
7,935 | public static boolean is ( Set < String > runModes , String ... expectedRunModes ) { if ( runModes != null && expectedRunModes != null ) { for ( String expectedRunMode : expectedRunModes ) { if ( runModes . contains ( expectedRunMode ) ) { return true ; } } } return false ; } | Checks if given run mode is active . |
7,936 | public IndexDefinition createIndexDefinition ( ) { if ( conventions == null ) { conventions = new DocumentConventions ( ) ; } IndexDefinitionBuilder indexDefinitionBuilder = new IndexDefinitionBuilder ( getIndexName ( ) ) ; indexDefinitionBuilder . setIndexesStrings ( indexesStrings ) ; indexDefinitionBuilder . setAnal... | Creates the index definition . |
7,937 | protected PageFilter getPageFilter ( SlingHttpServletRequest request ) { String predicateName = RequestParam . get ( request , RP_PREDICATE ) ; if ( StringUtils . isNotEmpty ( predicateName ) ) { PredicateProvider predicateProvider = getPredicateProvider ( ) ; if ( predicateProvider == null ) { throw new RuntimeExcepti... | Can be overridden by subclasses to filter page list via page filter . If not overridden it supports defining a page filter via predicate request attribute . |
7,938 | private IndexedPropertyMethodMetadata < ? > getIndexedPropertyMethodMetadata ( Collection < MethodMetadata < ? , ? > > methodMetadataOfType ) { for ( MethodMetadata methodMetadata : methodMetadataOfType ) { AnnotatedMethod annotatedMethod = methodMetadata . getAnnotatedMethod ( ) ; Annotation indexedAnnotation = annota... | Determine the indexed property from a list of method metadata . |
7,939 | private Collection < MethodMetadata < ? , ? > > getMethodMetadataOfType ( AnnotatedType annotatedType , Collection < AnnotatedMethod > annotatedMethods ) { Collection < MethodMetadata < ? , ? > > methodMetadataOfType = new ArrayList < > ( ) ; for ( AnnotatedMethod annotatedMethod : annotatedMethods ) { MethodMetadata <... | Return the collection of method metadata from the given collection of annotated methods . |
7,940 | public static < T > DependencyResolver < T > newInstance ( Collection < T > elements , DependencyProvider < T > dependencyProvider ) { return new DependencyResolver < T > ( elements , dependencyProvider ) ; } | Creates an instance of the resolver . |
7,941 | public List < T > resolve ( ) { blockedBy = new HashMap < > ( ) ; Set < T > queue = new LinkedHashSet < > ( ) ; Set < T > allElements = new HashSet < > ( ) ; queue . addAll ( elements ) ; while ( ! queue . isEmpty ( ) ) { T element = queue . iterator ( ) . next ( ) ; Set < T > dependencies = dependencyProvider . getDep... | Resolves the dependencies to a list . |
7,942 | private void resolve ( T element , List < T > result ) { Set < T > dependencies = blockedBy . get ( element ) ; if ( dependencies != null ) { for ( T dependency : dependencies ) { resolve ( dependency , result ) ; } blockedBy . remove ( element ) ; result . add ( element ) ; } } | Resolves an element . |
7,943 | public void put ( Id id , Object value , Mode mode ) { if ( Mode . WRITE . equals ( mode ) ) { writeCache . put ( id , value ) ; } readCache . put ( new CacheKey ( id ) , value ) ; } | Put an instance into the cache . |
7,944 | public Object get ( Id id , Mode mode ) { Object value = writeCache . get ( id ) ; if ( value == null ) { value = readCache . get ( new CacheKey ( id ) ) ; if ( value != null && Mode . WRITE . equals ( mode ) ) { writeCache . put ( id , value ) ; } } return value ; } | Lookup an instance in the cache identified by its id . |
7,945 | public void remove ( Id id ) { readCache . remove ( new CacheKey ( id ) ) ; writeCache . remove ( id ) ; } | Removes an instance from the cache . |
7,946 | private void initializeEntity ( Collection < ? extends TypeMetadata > types , NodeState nodeState ) { for ( TypeMetadata type : types ) { Collection < TypeMetadata > superTypes = type . getSuperTypes ( ) ; initializeEntity ( superTypes , nodeState ) ; for ( MethodMetadata < ? , ? > methodMetadata : type . getProperties... | Initializes all relation properties of the given node state with empty collections . |
7,947 | public void log ( String message ) { switch ( level ) { case TRACE : LOGGER . trace ( message ) ; break ; case DEBUG : LOGGER . debug ( message ) ; break ; case INFO : LOGGER . info ( message ) ; break ; case WARN : LOGGER . warn ( message ) ; break ; case ERROR : LOGGER . error ( message ) ; break ; default : throw ne... | Log a message using the configured log level . |
7,948 | private Object convertParameter ( Object value ) { if ( entityInstanceManager . isInstance ( value ) ) { return entityInstanceManager . getDatastoreType ( value ) ; } else if ( relationInstanceManager . isInstance ( value ) ) { return relationInstanceManager . getDatastoreType ( value ) ; } else if ( value instanceof C... | Converts the given parameter value to instances which can be passed to the datastore . |
7,949 | public < P extends PluginRepository < ? , ? > > P getPluginManager ( Class < ? > pluginType ) { return ( P ) pluginRepositories . get ( pluginType ) ; } | Return a plugin repository identified by the plugin interface type . |
7,950 | private void ensureIndex ( DS session , EntityTypeMetadata < NodeMetadata < L > > entityTypeMetadata , IndexedPropertyMethodMetadata < IndexedPropertyMetadata > indexedProperty ) { if ( indexedProperty != null ) { IndexedPropertyMetadata datastoreMetadata = indexedProperty . getDatastoreMetadata ( ) ; if ( datastoreMet... | Ensures that an index exists for the given entity and property . |
7,951 | private void ensureIndex ( DS session , L label , PrimitivePropertyMethodMetadata < PropertyMetadata > propertyMethodMetadata , boolean unique ) { PropertyMetadata propertyMetadata = propertyMethodMetadata . getDatastoreMetadata ( ) ; String statement ; if ( unique ) { LOGGER . debug ( "Creating constraint for label {}... | Ensures that an index exists for the given label and property . |
7,952 | public CompositeType getCompositeType ( ) { return CompositeTypeBuilder . create ( CompositeObject . class , metadata , typeMetadata -> typeMetadata . getAnnotatedType ( ) . getAnnotatedElement ( ) ) ; } | Convert this set into a composite type . |
7,953 | public void registerInstanceListener ( Object instanceListener ) { for ( Method method : instanceListener . getClass ( ) . getMethods ( ) ) { evaluateMethod ( instanceListener , PostCreate . class , method , postCreateMethods ) ; evaluateMethod ( instanceListener , PreUpdate . class , method , preUpdateMethods ) ; eval... | Add an instance listener instance . |
7,954 | private void evaluateMethod ( Object listener , Class < ? extends Annotation > annotation , Method method , Map < Object , Set < Method > > methods ) { if ( method . isAnnotationPresent ( annotation ) ) { if ( method . getParameterTypes ( ) . length != 1 ) { throw new XOException ( "Life cycle method '" + method . toGe... | Evaluates a method if an annotation is present and if true adds to the map of life cycle methods . |
7,955 | private < T > void invoke ( Map < Object , Set < Method > > methods , T instance ) { for ( Map . Entry < Object , Set < Method > > entry : methods . entrySet ( ) ) { Object listener = entry . getKey ( ) ; Set < Method > listenerMethods = entry . getValue ( ) ; if ( listenerMethods != null ) { for ( Method method : list... | Invokes all registered lifecycle methods on a given instance . |
7,956 | public < T > T readInstance ( DatastoreType datastoreType ) { return getInstance ( datastoreType , TransactionalCache . Mode . READ ) ; } | Return the proxy instance which corresponds to the given datastore type for reading . |
7,957 | public < T > T createInstance ( DatastoreType datastoreType , DynamicType < ? > types ) { return newInstance ( getDatastoreId ( datastoreType ) , datastoreType , types , TransactionalCache . Mode . WRITE ) ; } | Return the proxy instance which corresponds to the given datastore type for writing . |
7,958 | private < T > T getInstance ( DatastoreType datastoreType , TransactionalCache . Mode cacheMode ) { DatastoreId id = getDatastoreId ( datastoreType ) ; Object instance = cache . get ( id , cacheMode ) ; if ( instance == null ) { DynamicType < ? > types = getTypes ( datastoreType ) ; instance = newInstance ( id , datast... | Return the proxy instance which corresponds to the given datastore type . |
7,959 | private < T > T newInstance ( DatastoreId id , DatastoreType datastoreType , DynamicType < ? > types , TransactionalCache . Mode cacheMode ) { validateType ( types ) ; InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler ( datastoreType , getProxyMethodService ( ) ) ; T instance = proxyFactory . ... | Create a proxy instance which corresponds to the given datastore type . |
7,960 | private void validateType ( DynamicType < ? > dynamicType ) { int size = dynamicType . getMetadata ( ) . size ( ) ; if ( size == 1 ) { if ( dynamicType . isAbstract ( ) ) { throw new XOException ( "Cannot create an instance of a single abstract type " + dynamicType ) ; } } else if ( dynamicType . isFinal ( ) ) { throw ... | Validates the given types . |
7,961 | public < Instance > boolean isInstance ( Instance instance ) { if ( instance instanceof CompositeObject ) { Object delegate = ( ( CompositeObject ) instance ) . getDelegate ( ) ; return isDatastoreType ( delegate ) ; } return false ; } | Determine if a given instance is a datastore type handled by this manager . |
7,962 | public < Instance > DatastoreType getDatastoreType ( Instance instance ) { InstanceInvocationHandler < DatastoreType > invocationHandler = proxyFactory . getInvocationHandler ( instance ) ; return invocationHandler . getDatastoreType ( ) ; } | Return the datastore type represented by an instance . |
7,963 | public DynamicType < RelationTypeMetadata < RelationMetadata > > getRelationTypes ( Set < EntityDiscriminator > sourceDiscriminators , RelationDiscriminator discriminator , Set < EntityDiscriminator > targetDiscriminators ) { DynamicType < RelationTypeMetadata < RelationMetadata > > dynamicType = new DynamicType < > ( ... | Determine the relation type for the given source discriminators relation descriminator and target discriminators . |
7,964 | private < T > Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > prepareExample ( Example < T > example , Class < ? > type , Class < ? > ... types ) { Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > exampleEntity = new HashMap < > ( ) ; ExampleProxyMethodService < T > proxyMetho... | Setup an example entity . |
7,965 | private < T > ResultIterable < T > findByExample ( Class < ? > type , Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > entity ) { sessionContext . getCacheSynchronizationService ( ) . flush ( ) ; EntityTypeMetadata < EntityMetadata > entityTypeMetadata = sessionContext . getMetadataProvider ( ) . g... | Find entities according to the given example entity . |
7,966 | private Set < Discriminator > getAggregatedDiscriminators ( EntityTypeMetadata < EntityMetadata > typeMetadata ) { Set < Discriminator > discriminators = aggregatedDiscriminators . get ( typeMetadata ) ; if ( discriminators == null ) { discriminators = new HashSet < > ( ) ; Discriminator discriminator = typeMetadata . ... | Determine the set of discriminators for one type i . e . the discriminator of the type itself and of all it s super types . |
7,967 | public static Collection < Class < ? > > getTypes ( Collection < String > typeNames ) { Set < Class < ? > > types = new HashSet < > ( ) ; for ( String typeName : typeNames ) { types . add ( ClassHelper . getType ( typeName ) ) ; } return types ; } | Load a collection of classes . |
7,968 | public static < T > T newInstance ( Class < T > type ) { try { return type . newInstance ( ) ; } catch ( InstantiationException e ) { throw new XOException ( "Cannot create instance of type '" + type . getName ( ) + "'" , e ) ; } catch ( IllegalAccessException e ) { throw new XOException ( "Access denied to type '" + t... | Create an instance of a class . |
7,969 | public static Class < ? > getTypeParameter ( Class < ? > genericType , Class < ? > type ) { Type [ ] genericInterfaces = type . getGenericInterfaces ( ) ; for ( Type genericInterface : genericInterfaces ) { if ( genericInterface instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ... | Determines the type of a class implementing a generic interface with one type parameter . |
7,970 | public Collection < AnnotatedMethod > getMethods ( ) { for ( Method method : type . getDeclaredMethods ( ) ) { if ( ! method . isSynthetic ( ) ) { Class < ? > returnType = method . getReturnType ( ) ; Type genericReturnType = method . getGenericReturnType ( ) ; Class < ? > [ ] parameterTypes = method . getParameterType... | Return the methods of the type . |
7,971 | private List < Content > rewriteAnchor ( Element element ) { if ( element . getContent ( ) . isEmpty ( ) ) { element . setText ( "" ) ; } Link link = getAnchorLink ( element ) ; Element anchorElement = buildAnchorElement ( link , element ) ; List < Content > content = new ArrayList < Content > ( ) ; if ( anchorElement ... | Checks if the given anchor element has to be rewritten . |
7,972 | private boolean getAnchorLegacyMetadataFromSingleData ( ValueMap resourceProps , Element element ) { boolean foundAny = false ; JSONObject metadata = null ; Attribute dataAttribute = element . getAttribute ( "data" ) ; if ( dataAttribute != null ) { String metadataString = dataAttribute . getValue ( ) ; if ( StringUtil... | Support legacy data structures where link metadata is stored as JSON fragment in single HTML5 data attribute . |
7,973 | private void getAnchorLegacyMetadataFromRel ( ValueMap resourceProps , Element element ) { String href = element . getAttributeValue ( "href" ) ; String linkWindowTarget = element . getAttributeValue ( "target" ) ; if ( href == null || href . startsWith ( "#" ) ) { return ; } JSONObject metadata = null ; String metadat... | Support legacy data structures where link metadata is stored as JSON fragment in rel attribute . |
7,974 | private List < Content > rewriteImage ( Element element ) { Media media = getImageMedia ( element ) ; Element imageElement = buildImageElement ( media , element ) ; List < Content > content = new ArrayList < Content > ( ) ; if ( imageElement != null ) { content . add ( imageElement ) ; } return content ; } | Checks if the given image element has to be rewritten . |
7,975 | private Element buildImageElement ( Media media , Element element ) { if ( media . isValid ( ) ) { element . setAttribute ( "src" , media . getUrl ( ) ) ; } return element ; } | Builds image element for given media metadata . |
7,976 | private String unexternalizeImageRef ( String ref ) { String unexternalizedRef = ref ; if ( StringUtils . isNotEmpty ( unexternalizedRef ) ) { unexternalizedRef = decodeIfEncoded ( unexternalizedRef ) ; unexternalizedRef = StringUtils . removeEnd ( unexternalizedRef , "/" + JcrConstants . JCR_CONTENT + ".default" ) ; u... | Converts the RTE externalized form of media reference to internal form . |
7,977 | private String decodeIfEncoded ( String value ) { if ( StringUtils . contains ( value , "%" ) ) { try { return URLDecoder . decode ( value , CharEncoding . UTF_8 ) ; } catch ( UnsupportedEncodingException ex ) { throw new RuntimeException ( ex ) ; } } return value ; } | URL - decode value if required . |
7,978 | public static Map < String , Object > keyValuePairAsMap ( String key , Object value ) { Map < String , Object > paramMap = new HashMap < > ( ) ; paramMap . put ( key , value ) ; return paramMap ; } | Convert key value pair to map |
7,979 | private Rendition getInlineRendition ( MediaArgs mediaArgs ) { return new InlineRendition ( this . resource , this . media , mediaArgs , this . fileName , this . adaptable ) ; } | Get inline rendition instance . |
7,980 | private void addRendition ( Set < RenditionMetadata > candidates , Rendition rendition , MediaArgs mediaArgs ) { if ( ! mediaArgs . isIncludeAssetThumbnails ( ) && AssetRendition . isThumbnailRendition ( rendition ) ) { return ; } boolean isIncludeAssetWebRenditions = mediaArgs . isIncludeAssetWebRenditions ( ) != null... | adds rendition to the list of candidates if it should be available for resolving |
7,981 | private Set < RenditionMetadata > getRendtionsMatchingFileExtensions ( String [ ] fileExtensions , MediaArgs mediaArgs ) { Set < RenditionMetadata > allRenditions = getAvailableRenditions ( mediaArgs ) ; if ( fileExtensions == null || fileExtensions . length == 0 ) { return allRenditions ; } Set < RenditionMetadata > m... | Get all renditions that match the requested list of file extension . |
7,982 | private String [ ] getRequestedFileExtensions ( MediaArgs mediaArgs ) { Set < String > mediaArgsFileExtensions = new HashSet < String > ( ) ; if ( mediaArgs . getFileExtensions ( ) != null && mediaArgs . getFileExtensions ( ) . length > 0 ) { mediaArgsFileExtensions . addAll ( ImmutableList . copyOf ( mediaArgs . getFi... | Get merged list of file extensions from both media formats and media args . |
7,983 | private RenditionMetadata getExactMatchRendition ( final Set < RenditionMetadata > candidates , MediaArgs mediaArgs ) { if ( mediaArgs . getFixedWidth ( ) > 0 || mediaArgs . getFixedHeight ( ) > 0 ) { for ( RenditionMetadata candidate : candidates ) { if ( candidate . matches ( mediaArgs . getFixedWidth ( ) , mediaArgs... | Get rendition that matches exactly with the given media args requirements . |
7,984 | private RenditionMetadata getOriginalOrFirstRendition ( Set < RenditionMetadata > candidates ) { if ( this . originalRendition != null && candidates . contains ( this . originalRendition ) ) { return this . originalRendition ; } else if ( ! candidates . isEmpty ( ) ) { return candidates . iterator ( ) . next ( ) ; } el... | Returns original rendition - if it is contained in the candidate set . Otherwise first candidate is returned . If a VirtualCropRenditionMetadata is present always the first one is returned . |
7,985 | @ SuppressWarnings ( "null" ) private < T > T visitMediaFormats ( MediaArgs mediaArgs , MediaFormatVisitor < T > mediaFormatVisitor ) { MediaFormat [ ] mediaFormats = mediaArgs . getMediaFormats ( ) ; if ( mediaFormats != null ) { for ( MediaFormat mediaFormat : mediaFormats ) { T returnValue = mediaFormatVisitor . vis... | Iterate over all media formats defined in media args . Ignores invalid media formats . If the media format visitor returns a value that is not null iteration is stopped and the value is returned from this method . |
7,986 | private boolean resolveFirstMatchRenditions ( Media media , Asset asset , MediaArgs mediaArgs ) { Rendition rendition = asset . getRendition ( mediaArgs ) ; if ( rendition != null ) { media . setRenditions ( ImmutableList . of ( rendition ) ) ; media . setUrl ( rendition . getUrl ( ) ) ; return true ; } return false ; ... | Check if a matching rendition is found for any of the provided media formats and other media args . The first match is returned . |
7,987 | private boolean resolveAllRenditions ( Media media , Asset asset , MediaArgs mediaArgs ) { boolean allMandatory = mediaArgs . isMediaFormatsMandatory ( ) ; boolean allResolved = true ; boolean anyResolved = false ; List < Rendition > resolvedRenditions = new ArrayList < > ( ) ; for ( MediaFormat mediaFormat : mediaArgs... | Iterates over all defined media format and tries to find a matching rendition for each of them in combination with the other media args . |
7,988 | public Page getRelativePage ( String relativePath ) { String path = getRootPath ( ) ; if ( path == null ) { return null ; } StringBuilder sb = new StringBuilder ( path ) ; if ( ! relativePath . startsWith ( "/" ) ) { sb . append ( "/" ) ; } sb . append ( relativePath ) ; return pageManager . getPage ( sb . toString ( )... | Get page relative to site root . |
7,989 | protected boolean isNotModified ( Resource resource , SlingHttpServletRequest request , SlingHttpServletResponse response ) throws IOException { return CacheHeader . isNotModified ( resource , request , response , false ) ; } | Checks if the resource was modified since last request |
7,990 | protected void sendBinaryData ( byte [ ] binaryData , String contentType , SlingHttpServletRequest request , SlingHttpServletResponse response ) throws IOException { response . setContentType ( contentType ) ; response . setContentLength ( binaryData . length ) ; if ( RequestPath . hasSelector ( request , SELECTOR_DOWN... | Send binary data to output stream . Respect optional content disposition header handling . |
7,991 | protected UrlConfig getUrlConfigForTarget ( Adaptable adaptable , Page targetPage ) { Resource targetResource = null ; if ( targetPage != null ) { targetResource = targetPage . adaptTo ( Resource . class ) ; } return getUrlConfigForTarget ( adaptable , targetResource ) ; } | Get URL configuration for target page . If this is invalid or not available get it from adaptable . |
7,992 | protected UrlConfig getUrlConfigForTarget ( Adaptable adaptable , Resource targetResource ) { UrlConfig config = null ; if ( targetResource != null ) { config = new UrlConfig ( targetResource ) ; } if ( config == null || ! config . isValid ( ) ) { config = new UrlConfig ( adaptable ) ; } return config ; } | Get URL configuration for target resource . If this is invalid or not available get it from adaptable . |
7,993 | public MediaFormat build ( ) { if ( this . name == null ) { throw new IllegalArgumentException ( "Name is missing." ) ; } return new MediaFormat ( name , label , description , width , minWidth , maxWidth , height , minHeight , maxHeight , ratio , ratioWidth , ratioHeight , fileSizeMax , nonNullArray ( extensions ) , re... | Builds the media format definition . |
7,994 | protected Rendition getDamRendition ( MediaArgs mediaArgs ) { return new DamRendition ( this . damAsset , this . cropDimension , this . rotation , mediaArgs , adaptable ) ; } | Get DAM rendition instance . |
7,995 | protected HtmlElement < ? > getImageElement ( Media media ) { Image img = new Image ( ) ; Asset asset = media . getAsset ( ) ; String altText = null ; if ( asset != null ) { altText = asset . getAltText ( ) ; } if ( StringUtils . isNotEmpty ( altText ) ) { img . setAlt ( altText ) ; } return img ; } | Create an IMG element with alt text . |
7,996 | protected void setResponsiveImageSource ( HtmlElement < ? > mediaElement , JSONArray responsiveImageSources , Media media ) { mediaElement . setData ( PROP_RESPONSIVE_SOURCES , responsiveImageSources . toString ( ) ) ; } | Set attribute on media element for responsive image sources |
7,997 | protected HtmlElement < ? > getImageElement ( Media media ) { Image img = new Image ( ) . addCssClass ( MediaNameConstants . CSS_DUMMYIMAGE ) ; return img ; } | Create an IMG element . |
7,998 | public HtmlComment createComment ( String text ) { HtmlComment comment = new HtmlComment ( text ) ; this . addContent ( comment ) ; return comment ; } | Creates and adds html comment . |
7,999 | private static boolean isNt ( Resource resource , String nodeTypeName ) { if ( resource != null ) { return StringUtils . equals ( resource . getResourceType ( ) , nodeTypeName ) ; } return false ; } | Checks if the given resource is a node with the given node type name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.