/// <summary> /// The id of the reference referred to. null of the reference is null or has a /// null id itself. /// </summary> public string getResourceId(){ if (resource != null) { return resource.getId(); } return null; }
/// <summary> /// Adds the resource to the table of contents of the book as a child section of /// the given parentSection /// </summary> /// <param name="parentSection"></param> /// <param name="sectionTitle"></param> /// <param name="resource"></param> public TOCReference addSection(TOCReference parentSection, string sectionTitle, Resource resource) { getResources().add(resource); if (spine.findFirstResourceById(resource.getId()) < 0) { spine.addSpineReference(new SpineReference(resource)); } return parentSection.addChildSection(new TOCReference(sectionTitle, resource)); }
/// <summary> /// Adds the resource to the table of contents of the book as a child section of /// the given parentSection /// </summary> /// <param name="parentSection"></param> /// <param name="sectionTitle"></param> /// <param name="resource"></param> public TOCReference addSection(TOCReference parentSection, string sectionTitle, Resource resource) { getResources().add(resource); if (spine.findFirstResourceById(resource.getId()) < 0) { spine.addSpineReference(new SpineReference(resource)); } return parentSection.addChildSection(new TOCReference(sectionTitle, resource)); }
/// <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); }
/// <summary> /// Adds a resource to the book's set of resources, table of contents and if there /// is no resource with the id in the spine also adds it to the spine. /// </summary> /// <param name="title"></param> /// <param name="resource"></param> public TOCReference addSection(string title, Resource resource) { getResources().add(resource); TOCReference tocReference = tableOfContents.addTOCReference(new TOCReference(title, resource)); if (spine.findFirstResourceById(resource.getId()) < 0) { spine.addSpineReference(new SpineReference(resource)); } return tocReference; }
/// <summary> /// Adds a resource to the book's set of resources, table of contents and if there /// is no resource with the id in the spine also adds it to the spine. /// </summary> /// <param name="title"></param> /// <param name="resource"></param> public TOCReference addSection(string title, Resource resource) { getResources().add(resource); TOCReference tocReference = tableOfContents.addTOCReference(new TOCReference(title, resource)); if (spine.findFirstResourceById(resource.getId()) < 0) { spine.addSpineReference(new SpineReference(resource)); } return tocReference; }
/// <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); }