Class AssetReferences

All Implemented Interfaces:
EventListener, IGProp<String>, IReferencingGProp, Cloneable
Direct Known Subclasses:
CSSAssetReferences

public abstract class AssetReferences extends StringProp implements IReferencingGProp
The Asset References property class hold the references to zero or more FileURIPropCnr property containers. The reference names are separated by comma in the string.
Author:
Christopher Mindus
  • Constructor Details

    • AssetReferences

      protected AssetReferences()
      Creates a Asset References property with no name and with a null value.
    • AssetReferences

      public AssetReferences(Atom propertyAtom)
      Creates a Asset References property with the specified name with a null value.
      Parameters:
      propertyAtom - the property atom.
    • AssetReferences

      public AssetReferences(Atom propertyAtom, String newValue) throws PropValidateException
      Creates a Asset References property with the specified name and value.
      Parameters:
      propertyAtom - the property atom.
      newValue - the new string value for the property.
      Throws:
      PropValidateException - When the constraints are not met.
  • Method Details

    • clone

      public AssetReferences clone()
      Clones this property.
      Overrides:
      clone in class StringProp
      Returns:
      An AssetReferences instance.
    • onPropDispose

      protected void onPropDispose()
      Property disposed of: dispose of reference.
      Overrides:
      onPropDispose in class GProp<String>
    • equalsErrors

      protected boolean equalsErrors(PropError pe1, PropError pe2, int how)
      Processes error property verification. The default processing is to verify the two error properties pe1 and pe2 for equality if includeErrors is 0 or 1, and returns true if the value is 2=no comparison with error properties.

      Override to verify property errors for reference properties.

      Overrides:
      equalsErrors in class GProp<String>
      Parameters:
      pe1 - The first error property, may be null.
      pe2 - The second error property, may be null.
      how - Flags EQC_* values for equal checking.
      Returns:
      Equality flag depending on includeErrors value.
    • getReferenceType

      public IPropReference.IRefType getReferenceType()
      Gets the reference Type.
      Specified by:
      getReferenceType in interface IReferencingGProp
      Returns:
      IPropReference.RefType.AssetsFile.
    • onEventSelf

      public void onEventSelf(GEvent event)
      Called when a property event is send to this property.

      A subclass can override this method to perform appropriate processing and is not required to call super.onEventSelf(e).

      Specified by:
      onEventSelf in interface IGProp<String>
      Overrides:
      onEventSelf in class GProp<String>
      Parameters:
      event - The property event.
    • onReferenceEvent

      protected void onReferenceEvent(ResolveReferencesEvent event)
      Called to perform reference resolving. A property should override this method if it needs to perform reference resolving and validation.

      Subclasses override this method and only subclasses extending PropCnr needs to call super.onReferenceEvent(ResolveReferenceEvent event).

      Overrides:
      onReferenceEvent in class GProp<String>
      Parameters:
      event - The resolve references event.
    • onProjectNameChanged

      protected void onProjectNameChanged(ProjectNameEvent event)
      Called when a project name has been changed.
      Parameters:
      event - The project name event.
    • getAllFiles

      public FileURIPropCnr[] getAllFiles()
      Gets the resources associates with the references. The array may contain null members in which case that reference is not resolved.
      Returns:
      The array returned is never null but may be of length zero.
    • getResourceReferences

      public String[] getResourceReferences()
      Gets all the resource reference strings.
      Returns:
      An array of string resources.
    • fireChanged

      protected void fireChanged()
      Call this method to inform a listener.
    • isReferencingMultipleTargets

      public final boolean isReferencingMultipleTargets()
      Gets if this referencing property is of single-reference type or that can have between zero and many references.
      Specified by:
      isReferencingMultipleTargets in interface IReferencingGProp
      Returns:
      true as there can be multiple references.
    • getDirectReferencedTarget

      public final IGProp<?> getDirectReferencedTarget()
      Gets the single-referenced target. Referencing properties that can have multiple targets should ALWAYS return null for this method and use the method getDirectReferencedTargetSet() instead.
      Specified by:
      getDirectReferencedTarget in interface IReferencingGProp
      Returns:
      Always null as there can be multiple references.
    • getDirectReferencedTargetSet

      public final Set<IGProp<?>> getDirectReferencedTargetSet()
      Gets the properties that this referencing property directly references. Referencing properties that only has a single target should ALWAYS return null for this method and use the method getDirectReferencedTarget() instead.
      Specified by:
      getDirectReferencedTargetSet in interface IReferencingGProp
      Returns:
      A list of properties, or null for none. All properties returned are of FileURIPropCnr types.
    • getDirectReferencedTargetFiles

      public final Set<FileURIPropCnr> getDirectReferencedTargetFiles()
      Gets the properties that this referencing property directly references. Referencing properties that only has a single target should ALWAYS return null for this method and use the method getDirectReferencedTarget() instead.
      Returns:
      A list of target FileURIPropCnr's, or null for none.
    • assignServerAppFiles

      public void assignServerAppFiles(FileURIPropCnr[] serverFiles, String[] clientResourcePaths)
      The files when running in the server in a loaded app, null otherwise.

      This method cannot be called from elsewhere than the server app loader, and once only.

      Parameters:
      clientResourcePaths - The client resource paths.
      fixedServerFiles - The server files to assign.
      Throws:
      IllegalStateException - In case this is not done from the server app loader.
    • fixedClientResourceURLs

      public List<String> fixedClientResourceURLs()
      Gets the client resource URLs to the files when loaded from Jar in server. The list is not modifiable.
      Returns:
      The list of client resource URLs, or null when app is not loaded from a Jar in the server.
    • isValidFileExtension

      protected abstract boolean isValidFileExtension(String ext)
      Validates each asset file for correct file extension.
      Parameters:
      ext - The asset file extension to verify, without the "." prefix, meaning if there is no file extension, then an empty string is passed.
      Returns:
      true if extension is valid, false otherwise.
    • getFileTypeDescr

      protected abstract String getFileTypeDescr()
      The file type description.
      Returns:
      The file type description, e.g. "CSS file".
    • getErrorMessage

      protected abstract String getErrorMessage(String fullPathOrURL)
      Gets the error message for an invalid file extension.
      Parameters:
      fullPathOrURL - The full file name or URL path.
      Returns:
      The error message.
    • verify

      public boolean verify(PropVerification verification)
      Verifies this property. The check performed is the extension of classes and that no circular reference is present.
      Specified by:
      verify in interface IGProp<String>
      Overrides:
      verify in class GProp<String>
      Parameters:
      verification - The property verification class.
      Returns:
      true if verification should proceed, false if disposed of and verification should not take place.