Hilbert II - Version 0.03.04

org.qedeq.kernel.bo.load
Class DefaultModuleAddress

java.lang.Object
  extended byorg.qedeq.kernel.bo.load.DefaultModuleAddress
All Implemented Interfaces:
ModuleAddress

public class DefaultModuleAddress
extends Object
implements ModuleAddress

An object of this class represents an address for a QEDEQ module.

Version:
$Revision: 1.1 $

Constructor Summary
DefaultModuleAddress(File file)
          Constructor.
DefaultModuleAddress(String address)
          Constructor.
DefaultModuleAddress(String address, DefaultModuleAddress parent)
          Constructor.
DefaultModuleAddress(URL u)
          Constructor.
DefaultModuleAddress(URL u, DefaultModuleAddress parent)
          Constructor.
 
Method Summary
 ModuleContext createModuleContext()
          Get module address as ModuleContext.
 String createRelativeAddress(ModuleAddress reference)
          Create relative address from this to reference.
static String createRelativeAddress(String origin, String next)
          Create relative address from orgin to next.
 boolean equals(Object object)
           
 String getAddress()
          Get module address.
 String getFileName()
          Get module file name.
 String getHeader()
          Get address header (including protocol, host, port, user) but without file path.
static String getModuleFileName(Specification spec)
          Get the file name of the specified module.
static ModuleAddress[] getModulePaths(QedeqBo module, Specification spec)
          Get all potential module addresses from a module specification.
 String getName()
          Get name of module (file name without .xml).
 String getPath()
          Get address path (without protocol, host, port and file name).
 URL getURL()
          Get fully qualified URL of module.
 int hashCode()
           
 boolean isFileAddress()
          Is this a local QEDEQ file.
 boolean isRelativeAddress()
          Was this module address created relatively?
 String localizeInFileSystem(String url)
          Transform an URL address into a local file path.
static String newEnding(String address, String newEnding)
          Get module address with new ending.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultModuleAddress

public DefaultModuleAddress(URL u,
                            DefaultModuleAddress parent)
                     throws IOException
Constructor.

Parameters:
u - Address of module.
parent - Address of parent module
Throws:
IOException - if address is formally incorrect

DefaultModuleAddress

public DefaultModuleAddress(URL u)
                     throws IOException
Constructor.

Parameters:
u - Address of module.
Throws:
IOException - if address is formally incorrect

DefaultModuleAddress

public DefaultModuleAddress(File file)
                     throws IOException
Constructor.

Parameters:
file - File path of module.
Throws:
IOException - Address is formally incorrect

DefaultModuleAddress

public DefaultModuleAddress(String address)
                     throws IOException
Constructor.

Parameters:
address - Address of module.
Throws:
IOException - Address is formally incorrect

DefaultModuleAddress

public DefaultModuleAddress(String address,
                            DefaultModuleAddress parent)
                     throws IOException
Constructor.

Parameters:
address - address of module
parent - address of parent module
Throws:
IOException - if address is formally incorrect
Method Detail

getAddress

public final String getAddress()
Get module address.

Specified by:
getAddress in interface ModuleAddress
Returns:
module address

createModuleContext

public final ModuleContext createModuleContext()
Get module address as ModuleContext. Creates a new object.

Specified by:
createModuleContext in interface ModuleAddress
Returns:
Module address as ModuleContext.

getHeader

public final String getHeader()
Get address header (including protocol, host, port, user) but without file path.

Specified by:
getHeader in interface ModuleAddress
Returns:
address header

getPath

public final String getPath()
Get address path (without protocol, host, port and file name).

Specified by:
getPath in interface ModuleAddress
Returns:
module path

getFileName

public final String getFileName()
Get module file name.

Specified by:
getFileName in interface ModuleAddress
Returns:
Module file name.

getName

public final String getName()
Get name of module (file name without .xml).

Specified by:
getName in interface ModuleAddress
Returns:
Module name.

getURL

public final URL getURL()
Get fully qualified URL of module.

Specified by:
getURL in interface ModuleAddress
Returns:
URL for QEDEQ module.

isRelativeAddress

public final boolean isRelativeAddress()
Was this module address created relatively?

Specified by:
isRelativeAddress in interface ModuleAddress
Returns:
Relatively created?

isFileAddress

public final boolean isFileAddress()
Is this a local QEDEQ file. That means the address starts with file:.

Specified by:
isFileAddress in interface ModuleAddress
Returns:
Is the QEDEQ module a local file?

localizeInFileSystem

public final String localizeInFileSystem(String url)
Transform an URL address into a local file path.

Specified by:
localizeInFileSystem in interface ModuleAddress
Parameters:
url - transform this URL
Returns:
result of transformation

createRelativeAddress

public final String createRelativeAddress(ModuleAddress reference)
Create relative address from this to reference.

Specified by:
createRelativeAddress in interface ModuleAddress
Parameters:
reference - this should be the next location
Returns:
relative (or if neccessary absolute) address

toString

public final String toString()

hashCode

public final int hashCode()

equals

public final boolean equals(Object object)

getModuleFileName

public static final String getModuleFileName(Specification spec)
Get the file name of the specified module. TODO mime 20070326: is this function really neccessary?

Parameters:
spec - here are the (perhaps relative) addresses to another module
Returns:
file name of specified module

getModulePaths

public static final ModuleAddress[] getModulePaths(QedeqBo module,
                                                   Specification spec)
                                            throws IOException
Get all potential module addresses from a module specification. TODO mime 20070326: add context information (for error case)

Parameters:
module - Starting from that module (has an absolute address).
spec - Here are the (perhaps relative) addresses to another module.
Returns:
Array of absolute address strings.
Throws:
IOException - One address is not correctly formed.

createRelativeAddress

public static final String createRelativeAddress(String origin,
                                                 String next)
Create relative address from orgin to next.

Parameters:
origin - This is the original location (URL!).
next - This should be the next location (URL!).
Returns:
Relative (or if necessary absolute) address.

newEnding

public static final String newEnding(String address,
                                     String newEnding)
Get module address with new ending. E.g.: ".html" instead of ".qedeq".

Parameters:
address - The address of something (e.g.: a module).
newEnding - This should be the new ending (e.g.: "html").
Returns:
module address with substituted ending

Hilbert II - Version 0.03.04

©left GNU General Public Licence
All Rights Reserved.