Hilbert II - Version 0.03.09

org.qedeq.kernel.bo.control
Class DefaultModuleAddress

java.lang.Object
  extended byorg.qedeq.kernel.bo.control.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 u)
          Constructor.
DefaultModuleAddress(String address, ModuleAddress parent)
          Constructor.
DefaultModuleAddress(URL u)
          Constructor.
 
Method Summary
 ModuleContext createModuleContext()
          Get module address as ModuleContext.
static String createRelativeAddress(String origin, String next)
          Create relative address from orgin to next.
 boolean equals(Object object)
           
 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(ModuleAddress address, 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?
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(String u)
                     throws MalformedURLException
Constructor.

Parameters:
u - Address of module. Must not be null. Must be a URL with protocol "file" or "http" and address a file with extension ".xml".
Throws:
MalformedURLException - Address is formally incorrect.

DefaultModuleAddress

public DefaultModuleAddress(URL u)
                     throws MalformedURLException
Constructor.

Parameters:
u - Address of module. Must not be null. Must be a URL with protocol "file" or "http" and address a file with extension ".xml".
Throws:
MalformedURLException - Address is formally incorrect.

DefaultModuleAddress

public DefaultModuleAddress(File file)
                     throws MalformedURLException
Constructor.

Parameters:
file - File path of module. Must address a file with extension ".xml".
Throws:
MalformedURLException - Address is formally incorrect.

DefaultModuleAddress

public DefaultModuleAddress(String address,
                            ModuleAddress parent)
                     throws MalformedURLException
Constructor.

Parameters:
address - Address of module. Must not be null. Must be a URL with protocol "file" or "http" (if parent is null) and address a file with extension ".xml".
parent - Address of parent module. Can be null.
Throws:
MalformedURLException - Address is formally incorrect.
Method Detail

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?

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.

Parameters:
spec - Here are the (perhaps relative) addresses to another module.
Returns:
File name of specified module.

getModulePaths

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

Parameters:
address - Starting from that module 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.09

©left GNU General Public Licence
All Rights Reserved.