Class FileURIPropCnr

  • All Implemented Interfaces:
    EventListener, IGProp<GProp<?>[]>, IPropCnr, java.lang.Cloneable
    Direct Known Subclasses:
    FilePropCnr

    public class FileURIPropCnr
    extends PropCnr
    A PropCnr that can refer to an IFile object can be loaded and saved as well as checked for modification from last time. An exception can also be set for load errors.
    Author:
    Christopher Mindus
    • Constructor Detail

      • FileURIPropCnr

        public FileURIPropCnr()
        Creates a FilePropCnr for the designer with the specified name with a null value.
      • FileURIPropCnr

        public FileURIPropCnr​(Atom propertyAtom)
        Creates a FilePropCnr for the designer with the specified name with a null value.
        Parameters:
        propertyAtom - the property atom.
      • FileURIPropCnr

        public FileURIPropCnr​(Atom propertyAtom,
                              java.io.File file)
        Creates a FilePropCnr for the designer with the specified name with a null value.
        Parameters:
        propertyAtom - the property atom.
        file - the file.
      • FileURIPropCnr

        public FileURIPropCnr​(Atom propertyAtom,
                              java.net.URL url,
                              long modificationTime,
                              long size)
        Creates a FilePropCnr for the designer with the specified name with a null value.
        Parameters:
        propertyAtom - The property atom.
        url - The file URL.
        modificationTime - Last modification time.
        size - Size in bytes.
    • Method Detail

      • getURL

        public java.net.URL getURL()
        Gets the file name URI for this property.
      • getChildReferencePropName

        public java.lang.String getChildReferencePropName​(GProp<?> child)
        Gets the child's reference property name for this property.
        Overrides:
        getChildReferencePropName in class GProp<GProp<?>[]>
        Parameters:
        child - The child requesting the name.
        Returns:
        The default is to return getReferencePropName()+'/'+child.getPropName(), but for children named Atom.DATA_CONTAINER, that name is skipped thus returning getReferencePropName().
      • clone

        public FileURIPropCnr clone()
                             throws java.lang.CloneNotSupportedException
        Clone must be overridden.
        Overrides:
        clone in class PropCnr
        Throws:
        java.lang.CloneNotSupportedException - If a subclass doesn't allow cloning, e.g. the client properties.
      • isPropFolder

        public final boolean isPropFolder()
        Checks if this is a Folder property container. It is overridden by FolderPropCnr.
        Specified by:
        isPropFolder in interface IGProp<GProp<?>[]>
        Overrides:
        isPropFolder in class GProp<GProp<?>[]>
        Returns:
        true for FolderURIPropCnr, false otherwise.
      • isPropFile

        public final boolean isPropFile()
        Checks if this is a File property container. It is overridden by FilePropCnr.
        Specified by:
        isPropFile in interface IGProp<GProp<?>[]>
        Overrides:
        isPropFile in class GProp<GProp<?>[]>
        Returns:
        true for FileURIPropCnr, false otherwise.
      • isAssetFile

        public boolean isAssetFile()
        Checks if this file is located in the Assets directory. This is only handled in the Editor.
        Returns:
        Always true in the Server or Client.
      • getFile

        public java.io.File getFile()
        Returns the file.
        Returns:
        The file, or null for none.
      • getPropFromReference

        public GProp<?> getPropFromReference​(java.lang.String ref)
        Gets a property from a reference name. This can be called from any property in the property tree, and will direct the request to the root property.
        Specified by:
        getPropFromReference in interface IGProp<GProp<?>[]>
        Overrides:
        getPropFromReference in class GProp<GProp<?>[]>
        Parameters:
        ref - The reference string.
        Returns:
        The property with the reference in question, or null if not found.
      • getPropReferenceTarget

        protected GProp<?> getPropReferenceTarget()
        Retargets the reference request as required. This is used e.g. by the File property container to retarget the request to the data container.
        Overrides:
        getPropReferenceTarget in class GProp<GProp<?>[]>
        Returns:
        Returns the data property container named Atom.DATA_CONTAINER if present, otherwise this.
      • getSize

        public long getSize()
        Returns the size of the resource in bytes.
        Returns:
        The size, or -1 if resource is not found.
      • getModificationTime

        public long getModificationTime()
        Returns the modification time of the resource.
        Returns:
        The modification time, or zero if resource is not found.