Class FileURIPropCnr

All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, 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
  • Field Details

    • EMPTY_ARRAY

      public static final FileURIPropCnr[] EMPTY_ARRAY
      Empty array.
  • Constructor Details

    • 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, 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, 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 Details

    • getURL

      public URL getURL()
      Gets the file name URI for this property.
      Returns:
      The URL, none-null.
    • getChildReferencePropName

      public 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

      Clone must be overridden.
      Overrides:
      clone in class PropCnr
      Throws:
      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 File getFile()
      Returns the file.
      Returns:
      The file, or null for none.
    • getPropFromReference

      public GProp<?> getPropFromReference(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.
    • equalsTree

      protected final Object equalsTree(PropCnr pc2, int how)
      Checks for equality in the whole container structure.

      NOTE: This method should not be overridden except in extreme situations, e.g. for MememtoPropCnr.

      Overrides:
      equalsTree in class PropCnr
      Parameters:
      pc2 - The property value to compare with.
      how - Flags EQC_* values for equal checking.
      Returns:
      Both atom and value are equal on all levels.
    • equalsTree

      protected final Object equalsTree(PropCnr pc2, Class<? extends IGProp<?>> arrayItemClass, int how)
      Checks for equality in the whole container structure.

      NOTE: This method should not be overridden except in extreme situations, e.g. for MememtoPropCnr.

      Overrides:
      equalsTree in class PropCnr
      Parameters:
      pc2 - The property value to compare with.
      how - Flags EQC_* values for equal checking.
      Returns:
      Both atom and value are equal on all levels.
    • hashCode

      public final int hashCode()
      Returns the hash code of this object.
      Overrides:
      hashCode in class Object
      Returns:
      This object's hash code.
    • paramString

      protected String paramString(boolean includeFullProperties)
      Returns the parameter string representing the state of this event. This string is useful for debugging. Subclasses adds extra information to the string by preceding it with a comma followed by the extra information.
      Overrides:
      paramString in class GProp<GProp<?>[]>
      Parameters:
      includeFullProperties - Flag to include full properties or not.
      Returns:
      the parameter string of this event.
    • setResolvedURL

      public void setResolvedURL(URL url, long modificationTime, long size, String serverReference)
      Resolves the URL, size, modification time and the client resource name.
      Parameters:
      url - The file URL in the Jar.
      modificationTime - Last modification time.
      size - Size in bytes.
      serverReference - The server reference.
      Throws:
      IllegalStateException - If not called from the server Jar file loader.
    • getClientResourceString

      public String getClientResourceString()
      Gets the Client resource string in form "module$/path/filename.ext".
      Returns:
      null If not valid.