setId() public method

Sets the Resource's id: Make sure it is unique and a valid identifier.
public setId ( string id ) : void
id string id
return void
示例#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);
        }
示例#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);
        }