org.qedeq.kernel.se.common
Class DefaultModuleAddress

java.lang.Object
  extended by org.qedeq.kernel.se.common.DefaultModuleAddress
All Implemented Interfaces:
ModuleAddress

public class DefaultModuleAddress
extends java.lang.Object
implements ModuleAddress

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

Author:
Michael Meyling

Field Summary
static DefaultModuleAddress MEMORY
          Default memory module address with identifier "default".
 
Constructor Summary
DefaultModuleAddress()
          Default constructor for memory modules.
DefaultModuleAddress(boolean memory, java.lang.String identifier)
          Constructor mainly used for memory modules.
DefaultModuleAddress(java.io.File file)
          Constructor.
DefaultModuleAddress(java.lang.String u)
          Constructor.
DefaultModuleAddress(java.lang.String address, ModuleAddress parent)
          Constructor.
DefaultModuleAddress(java.net.URL u)
          Constructor.
 
Method Summary
 ModuleContext createModuleContext()
          Get module address as ModuleContext.
static java.lang.String createRelative(java.lang.String org, java.lang.String nex)
          Create relative address.
static java.lang.String createRelativeAddress(java.lang.String origin, java.lang.String next)
          Create relative address from origin to next.
 boolean equals(java.lang.Object object)
           
 java.lang.String getFileName()
          Get module file name.
 java.lang.String getHeader()
          Get address header (including protocol, host, port, user) but without file path.
 ModuleAddress[] getModulePaths(Specification spec)
          Get all potential module addresses from a module specification.
 java.lang.String getName()
          Get name of module (file name without .xml).
 java.lang.String getPath()
          Get address path (without protocol, host, port and file name).
 java.lang.String 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?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MEMORY

public static final DefaultModuleAddress MEMORY
Default memory module address with identifier "default".

Constructor Detail

DefaultModuleAddress

public DefaultModuleAddress(java.lang.String u)
                     throws java.net.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:
java.net.MalformedURLException - Address is formally incorrect.

DefaultModuleAddress

public DefaultModuleAddress(java.net.URL u)
                     throws java.net.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:
java.net.MalformedURLException - Address is formally incorrect.

DefaultModuleAddress

public DefaultModuleAddress(java.io.File file)
                     throws java.io.IOException
Constructor.

Parameters:
file - File path of module. Must address a file with extension ".xml".
Throws:
java.io.IOException - Problem with file location.

DefaultModuleAddress

public DefaultModuleAddress()
Default constructor for memory modules.


DefaultModuleAddress

public DefaultModuleAddress(boolean memory,
                            java.lang.String identifier)
Constructor mainly used for memory modules. TODO 20110227 m31: this is no object oriented design: a parameter must be true??? refactor code and create extra memory module address class!

Parameters:
memory - Must be true. If not a runtime exception occurs.
identifier - Identifies the module in memory. Must not be null.

DefaultModuleAddress

public DefaultModuleAddress(java.lang.String address,
                            ModuleAddress parent)
                     throws java.net.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:
java.net.MalformedURLException - Address is formally incorrect.
Method Detail

createModuleContext

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

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

getHeader

public java.lang.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 java.lang.String getPath()
Get address path (without protocol, host, port and file name).

Specified by:
getPath in interface ModuleAddress
Returns:
module path

getFileName

public java.lang.String getFileName()
Get module file name.

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

getName

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

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

getUrl

public java.lang.String getUrl()
Get fully qualified URL of module.

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

isRelativeAddress

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

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

isFileAddress

public 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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

getModulePaths

public final ModuleAddress[] getModulePaths(Specification spec)
                                     throws java.io.IOException
Description copied from interface: ModuleAddress
Get all potential module addresses from a module specification. TODO mime 20070326: add context information (for error case)

Specified by:
getModulePaths in interface ModuleAddress
Parameters:
spec - Here are the (perhaps relative) addresses to another module.
Returns:
Array of absolute address strings.
Throws:
java.io.IOException - One address is not correctly formed.

createRelativeAddress

public static final java.lang.String createRelativeAddress(java.lang.String origin,
                                                           java.lang.String next)
Create relative address from origin to next. If both addresses point to the same file we return "".

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

createRelative

public static java.lang.String createRelative(java.lang.String org,
                                              java.lang.String nex)
Create relative address. Assume only file paths.

Parameters:
org - This is the original location.
nex - This should be the next location.
Returns:
Relative path (if possible).


Copyright © 2014. All Rights Reserved.