/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { Object } from "../../types/java/lang/Object"; import type { String } from "../../types/java/lang/String"; /** * Utility interface for getting multiple Node property values in server-side Javascript. * *

* Extraction of property values from Nodes are typically performed using {@link PropertyUtil} * but this utility is less obtrusive to work with in server-side script contexts (WebApps, RESTApps, Script module etc.). *

*

* Property value types
* The value of a JCR Node property can be resolved as different types. * For instance a property with primary type {@link javax.jcr.PropertyType#DATE} can be resolved as {@code Calendar} or as {@code String}. * This utility returns values with a specific type: *

* * *

* Example
* Below is an example that demonstrates the behaviour and usage of this utility. *

   var properties = require('Properties');
 *    ...
 *
 *    // get examples
 *
 *    // Returns the identifier of the given Node, e.g: '4.540818ed12a6539aa3f80001645'
 *    pageId = properties.get(pageNode);
 *
 *    // Returns the URI property value of the given Node, e.g. '/4.540818ed12a6539aa3f80001645.html'
 *    pageUri = properties.get(pageNode, 'URI');
 *
 *    // Returns the displayName property value of the given Node, e.g. 'The page'
 *    pageName = properties.get(pageNode, 'displayName');
 *    pageName = properties.get(pageId, 'displayName');
 *    pageName = properties.get(pageUri, 'displayName');
 *
 *    // Returns a native script object with given properties (that exist) of the specified Node e.g:
 *    // {
 *    //    URI: '/4.540818ed12a6539aa3f80001645.html',
 *    //    displayName: 'The page',
 *    //    published: true,
 *    //    publishDate: 1227618333142
 *    // }
 *    pageData = properties.get(pageNode, 'URI', 'displayName', 'published', 'publishDate', 'nameOfNonExistingProperty');
 *
 *    // getArray examples
 *
 *    // Returns the identifier of the given Node as array, e.g: ['4.540818ed12a6539aa3f80001645']
 *    pageIdArray = properties.getArray(pageNode);
 *
 *    // Returns the identifier for the children of given Node as array, e.g:
 *    // [
 *    //    '19.540818ed12a6539aa3f80006889',
 *    //    '4.540818ed12a6539aa3f80001645_pageContent',
 *    //    ...
 *    // ]
 *    childIdsArray = properties.getArray(pageNode.getNodes());
 *
 *    // Returns the displayName for the nodes of a menu from a given Node as array, e.g:
 *    // [
 *    //    'The Page',
 *    //    'Another Page',
 *    //    ...
 *    // ]
 *    menuNamesArray = properties.getArray(nodeIteratorUtil.getMenuItems(pageNode), 'displayName');
 *
 *    // Returns the displayName and URI for the hits of a SearchResult as array, e.g:
 *    // [
 *    //    {
 *    //       displayName: 'Public API'
 *    //       URI: '/docs/public-api',
 *    //    },
 *    //    {
 *    //       displayName: 'REST API'
 *    //       URI: '/docs/rest-api',
 *    //    },
 *    //    ...
 *    // ]
 *    hitsDataArray = properties.getArray(searchResult, 'displayName', 'URI');
* *

* Security reminder! All output should always be escaped to prevent XSS! *

* * @param native script value * @author Magnus Lövgren * @since Sitevision 4.5.2 */ export interface Properties { /** * Gets named properties from a given Node-resolvable object. * *

* See code examples in the interface description above. *

* @param aJcrNodeResolvable something that can be resolved as a Node. Typically a Node, a Node identifier or a relative URL of a Node (the URI property) * @param aPropertyNames the names of the properties of interest * @return the properties as a native Javascript object * @throws Exception if the scripting engine fails to convert property values to a native Javascript object * @see #getEscaped(Object, String...) */ get( aJcrNodeResolvable: unknown, ...aPropertyNames: String[] | string[] ): unknown; /** * Gets escaped named properties from a given Node-resolvable object. * *

* This method is equivalent with {@link #get(Object, String...)} except that all string values will be escaped. *

* @param aJcrNodeResolvable something that can be resolved as a Node. Typically a Node, a Node identifier or a relative URL of a Node (the URI property) * @param aPropertyNames the names of the properties of interest * @return the escaped properties as a native Javascript object * @throws Exception if the scripting engine fails to convert property values to a native Javascript object * @since Sitevision 6.2 */ getEscaped( aJcrNodeResolvable: unknown, ...aPropertyNames: String[] | string[] ): unknown; /** * Processes an iterable object and returns an array of named properties for each Node-resolvable object that is iterated. * *

* This method is conceptually equivalent with the {@link #get(Object, String...) get} method but * the core functionality of this method is to process something that can be iterated in order to handle multiple nodes * and deliver properties for them as an array. *

* *

* See code examples in the interface description above. *

* @param aIterable something that can be resolved as a Node or something that can be iterated and contains objects that can be resolved as a Node. Typically an array, {@link javax.jcr.NodeIterator}, {@link senselogic.sitevision.api.search.SearchResult}, {@link java.util.Collection} or {@link senselogic.sitevision.api.base.FilterSplit} (the accepted nodes will be processed) * @param aPropertyNames the names of the properties of interest * @return a native Javascript array with properties * @throws Exception if the scripting engine fails to convert property values to a native Javascript object * @see senselogic.sitevision.api.node.NodeIteratorUtil * @see #getArrayEscaped(Object, String...) * @since Sitevision 6.1 */ getArray(aIterable: unknown, ...aPropertyNames: String[] | string[]): unknown; /** * Processes an iterable object and returns an array of escaped named properties for each Node-resolvable object that is iterated. * *

* This method is equivalent with {@link #getArray(Object, String...)} except that all string values will be escaped. *

* @param aIterable something that can be resolved as a Node or something that can be iterated and contains objects that can be resolved as a Node. Typically an array, {@link javax.jcr.NodeIterator}, {@link senselogic.sitevision.api.search.SearchResult}, {@link java.util.Collection} or {@link senselogic.sitevision.api.base.FilterSplit} (the accepted nodes will be processed) * @param aPropertyNames the names of the properties of interest * @return a native Javascript array with escaped properties * @throws Exception if the scripting engine fails to convert property values to a native Javascript object * @since Sitevision 6.2 */ getArrayEscaped( aIterable: unknown, ...aPropertyNames: String[] | string[] ): unknown; } declare namespace Properties {} declare var properties: Properties; export default properties;