Package com.iizix.urn.file
Class FileURN
- java.lang.Object
- com.iizix.urn.URN
- com.iizix.urn.URNResource
- com.iizix.urn.file.FileURN
 
 
 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 - Direct Known Subclasses:
- ImageURN
 - public class FileURN extends URNResource implements java.lang.Cloneable, java.io.Serializable File Uniform Resource Naming (URN) instance class, holding a file name referencing a resource type with an identifier. The identifier is a Long or a String value depending on the resource type.- The IIZI file URN's are formatted as: - urn:iz-file:type:[id:]fileName- The types supported without - idparameter, but using the case sensitive- fileNameparameter:- common-dbor- URNResourceType.COMMON_DATABASE_PERSISTENT: Common server files stored in database (cached on the server even for starts/stops).
- common-persistor- URNResourceType.COMMON_PERSISTENT: Common server files (persists when server starts/stops).
- common-volatileor- URNResourceType.COMMON_VOLATILE: Common server files (volatile when server starts/stops).
- externalor- URNResourceType.EXTERNAL_FILES: External files (typically accessible using the 'file:' protocol). The- fileNameparameter must be a- {@link URI}.
 - Author:
- Christopher Mindus
- See Also:
- URN,- URNResourceType, Serialized Form
 
- Field Summary- Fields inherited from class com.iizix.urn.URNResource- id, type
 
 - Constructor Summary- Constructors - Modifier - Constructor - Description - protected- FileURN(java.lang.String urnString, URNResourceType type, java.lang.Object id, java.lang.String fileName)Constructor for a File URN.
 - Method Summary- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - boolean- equals(java.lang.Object obj)Checks if another URN is equal to this one.- static FileURN- fromExternalFile(java.io.File file)Creates an external File URN from a URI.- static FileURN- fromExternalFile(java.lang.String fileName)Creates an external File URN from a URI.- static FileURN- fromExternalFile(java.net.URI uriFile)Creates an external File URN from a URI.- static FileURN- fromFileResource(URNResourceType type, java.lang.Object id, java.lang.String fileName)Creates a File URN from a string.- java.lang.String- getParamString()Gets the parameter string for the- URN.toString()method.- java.lang.String- getURL()Gets the URL of this resource relative the current web server.- int- hashCode()Gets the hash code of the instance.- Methods inherited from class com.iizix.urn.URNResource- asURNResource, getID, getImageTarget, getType, isImageTargetSupported, isURNResource
 - Methods inherited from class com.iizix.urn.URN- from, getURNString, toString
 
 
- Constructor Detail- FileURN- protected FileURN(java.lang.String urnString, URNResourceType type, java.lang.Object id, java.lang.String fileName)Constructor for a File URN.- Parameters:
- urnString- The full URN String.
- type- The URN resource type.
- id- The URN resource ID for the type: a Long or a String depending of the- type,- nullfor none.
- fileName- The file name.
 
 
 - Method Detail- fromExternalFile- public static FileURN fromExternalFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException Creates an external File URN from a URI.- Parameters:
- fileName- The file name.
- Throws:
- java.lang.NullPointerException- If the- fileis null.
- java.io.FileNotFoundException- If the- fileis not found or is a directory.
- java.io.IOException- If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries.
- java.lang.SecurityException- If a required system property value cannot be accessed, or if a security manager exists and its- SecurityManager.checkRead(java.io.FileDescriptor)method denies read access to the file.
 
 - fromExternalFile- public static FileURN fromExternalFile(java.io.File file) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException Creates an external File URN from a URI.- Parameters:
- file- The file.
- Throws:
- java.lang.NullPointerException- If the- fileis null.
- java.io.FileNotFoundException- If the- fileis not found or is a directory.
- java.io.IOException- If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries.
- java.lang.SecurityException- If a required system property value cannot be accessed, or if a security manager exists and its- SecurityManager.checkRead(java.io.FileDescriptor)method denies read access to the file.
- java.net.MalformedURLException
 
 - fromExternalFile- public static FileURN fromExternalFile(java.net.URI uriFile) throws java.net.MalformedURLException Creates an external File URN from a URI.- Parameters:
- uriFile- The file URI.
- Throws:
- java.lang.NullPointerException- If the- uriFileis null.
- java.lang.IllegalArgumentException- If- uriFileas URL is not absolute.
- java.net.MalformedURLException- If- uriFileas URL protocol handler could not be found, or if some other error occurred while constructing the URL.
 
 - fromFileResource- public static FileURN fromFileResource(URNResourceType type, java.lang.Object id, java.lang.String fileName) throws java.net.MalformedURLException, MalformedURNException Creates a File URN from a string.- Parameters:
- type- The URN resource type.
- id- The ID used for database identification, Long or String,- nullwhen database is not used.- This value depends on the URNResourceType. The types are: - Long  :- URNResourceType.COMMON_DATABASE_PERSISTENT: Common database persistent files.
- String:- URNResourceType.APPLICATION_DATABASE_PERSISTENT: Application ID database persistent files.
- Long :- URNResourceType.GROUP_DATABASE_FILES: Group ID database persistent files.
- Long :- URNResourceType.USER_DATABASE_FILES: User ID database persistent files.
- nullFor all other- {@link URNResourceType}'s.
 
- fileName- The file name.
- Throws:
- java.lang.NullPointerException- If the- typeor- fileNameis null.
- IllegalArgumentExecption- If the class of the- idparameter does not match the- type- URNResourceTypeparameter. Currently, only {code Long} and {code String} values are allowed.
- java.net.MalformedURLException- If the- urlis malformed.
- MalformedURNException- If the- urlis malformed for an IIZI URN URL.
 
 - hashCode- public int hashCode() Gets the hash code of the instance. The original URN string is not used for this hash code, rather the URN 'NID' and the parameters.- Overrides:
- hashCodein class- URNResource
- Returns:
- A hash code value.
 
 - equals- public boolean equals(java.lang.Object obj) Checks if another URN is equal to this one. The original URN string is not used for this comparison, rather the URN 'NID' and the parameters.- Overrides:
- equalsin class- URNResource
- Parameters:
- obj- The other object to compare with.
- Returns:
- true if the URN's are equal, false otherwise.
 
 - getParamString- public java.lang.String getParamString() Gets the parameter string for the- URN.toString()method.- Overrides:
- getParamStringin class- URNResource
- Returns:
- The parameter string, always non-null.
 
 - getURL- public java.lang.String getURL() throws java.io.IOExceptionGets the URL of this resource relative the current web server.- Overrides:
- getURLin class- URNResource
- Returns:
- The URL relative the current server, if based on the current server.
- Throws:
- java.io.IOException- If there was a problem retrieving the file or an SQL error.