Class ContentFile


  • public final class ContentFile
    extends Object
    Reference to a file that contains a content fragment (e.g. JSON, JCR XML).
    • Constructor Detail

      • ContentFile

        public ContentFile​(File file,
                           String path,
                           String subPath,
                           ContentFileCache contentFileCache)
        Parameters:
        file - File with content fragment
        path - Root path of the content file
        subPath - Relative path addressing content fragment inside file
        contentFileCache - Content file cache
      • ContentFile

        public ContentFile​(File file,
                           String path,
                           String subPath,
                           ContentFileCache contentFileCache,
                           ContentType contentType)
        Parameters:
        file - File with content fragment
        path - Root path of the content file
        subPath - Relative path addressing content fragment inside file
        contentFileCache - Content file cache
        contentType - Content type
    • Method Detail

      • getFile

        public File getFile()
        Returns:
        File with content fragment
      • getPath

        public String getPath()
        Returns:
        Root path of content file
      • getSubPath

        public String getSubPath()
        Returns:
        Relative path addressing content fragment inside file
      • getContent

        public ContentElement getContent()
        Content object referenced by sub path.
        Returns:
        Map if resource, property value if property.
      • hasContent

        public boolean hasContent()
        Returns:
        true if any content was found.
      • getValueMap

        public org.apache.sling.api.resource.ValueMap getValueMap()
        Returns:
        ValueMap for resource. Never null.
      • navigateToAbsolute

        public ContentFile navigateToAbsolute​(String newSubPath)
        Navigate to another sub path position in content file.
        Parameters:
        newSubPath - New sub path related to root path of content file
        Returns:
        Content file
      • navigateToRelative

        public ContentFile navigateToRelative​(String newSubPath)
        Navigate to another sub path position in content file.
        Parameters:
        newSubPath - New sub path relative to current sub path in content file
        Returns:
        Content file