setId() public méthode

Sets the Resource's id: Make sure it is unique and a valid identifier.
public setId ( string id ) : void
id string id
Résultat void
Exemple #1
0
        /// <summary>
        /// Checks the id of the given resource and changes to a unique identifier if it
        /// isn't one already.
        /// </summary>
        /// <param name="resource">resource</param>
        public void fixResourceId(Resource resource)
        {

            string resourceId = resource.getId();
            if (StringUtil.isBlank(resource.getId()))
            {
                resourceId = StringUtil.substringBeforeLast(resource.getHref(), '.');
                resourceId = StringUtil.substringAfterLast(resourceId, '/');
            }

            resourceId = makeValidId(resourceId, resource);

            // check if the id is unique. if not: create one from scratch
            if (StringUtil.isBlank(resourceId) || containsId(resourceId))
            {
                resourceId = createUniqueResourceId(resource);
            }
            resource.setId(resourceId);
        }
Exemple #2
0
        /// <summary>
        /// Checks the id of the given resource and changes to a unique identifier if it
        /// isn't one already.
        /// </summary>
        /// <param name="resource">resource</param>
        public void fixResourceId(Resource resource)
        {
            string resourceId = resource.getId();
            if (StringUtil.isBlank(resource.getId()))
            {
                resourceId = StringUtil.substringBeforeLast(resource.getHref(), '.');
                resourceId = StringUtil.substringAfterLast(resourceId, '/');
            }

            resourceId = makeValidId(resourceId, resource);

            // check if the id is unique. if not: create one from scratch
            if (StringUtil.isBlank(resourceId) || containsId(resourceId))
            {
                resourceId = createUniqueResourceId(resource);
            }
            resource.setId(resourceId);
        }