thinkmap.context
Class ThinkmapConfig

java.lang.Object
  extended by thinkmap.context.ThinkmapConfig

public class ThinkmapConfig
extends Object

The ThinkmapConfig is the base class for Thinkmap configuration objects; a Thinkmap configuration object constructs and initializes the objects which constitute a Thinkmap. This class provides methods for initializing the ThinkmapConfig and for obtaining objects which are constructed by the ThinkmapConfig as part of the application.

Version:
$Revision: 1.11 $

Constructor Summary
ThinkmapConfig()
           
ThinkmapConfig(IThinkmapContext context, File base)
           
ThinkmapConfig(IThinkmapContext context, URL baseURL)
           
 
Method Summary
 void assignId(String id, Object value)
          Associate an object with an identifier in this configuration
 File createFile(String s)
          Creates a File based on a String.
 URL createURL(String s)
          Creates a URL based on a String.
 IThinkmapContext getContext()
          Get the context which represents the environment that this Thinkmap runs in.
 URL getDocumentBase()
          Returns a URL that corresponds to the root of where documents are stored for this context.
 File getFileBase()
          Returns a string which represents the absolute path on the local machine of the code base, or null if files cannot be used.
 Object getObjectById(String id)
          Objects can be stored by id in the thinkmap config, this method gets an object by its id.
 Object getRoot()
          Get the root object of this configuration.
 IPropertyHandler getRootPropertyHandler()
           
 void setContext(IThinkmapContext context)
          Sets the ThinkmapContext on this ThinkmapConfig.
 void setDocumentBase(URL urlBase)
           
 void setDocumentBase(URL urlBase, File fileBase)
          Initialize this configuration.
 void setFileBase(File fileBase)
           
 void setRoot(Object root)
          Sets the root object of this configuration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThinkmapConfig

public ThinkmapConfig()

ThinkmapConfig

public ThinkmapConfig(IThinkmapContext context,
                      File base)

ThinkmapConfig

public ThinkmapConfig(IThinkmapContext context,
                      URL baseURL)
Method Detail

getRoot

public Object getRoot()
Get the root object of this configuration.

Returns:
the root object of this configuration.

setRoot

public void setRoot(Object root)
Sets the root object of this configuration

Parameters:
root - the root object of this configuration

getContext

public IThinkmapContext getContext()
Get the context which represents the environment that this Thinkmap runs in.

Returns:
the context which represents the environment that this Thinkmap runs in.

setContext

public void setContext(IThinkmapContext context)
Sets the ThinkmapContext on this ThinkmapConfig. The ThinkmapContext allows this configuration to interact with the environment it runs in.

Parameters:
context - the context which represents the environment that this Thinkmap will operate in.

setDocumentBase

public final void setDocumentBase(URL urlBase,
                                  File fileBase)
Initialize this configuration. This should be called by the IThinkmapContext after the setContext() call.


setDocumentBase

public void setDocumentBase(URL urlBase)

setFileBase

public void setFileBase(File fileBase)

getObjectById

public Object getObjectById(String id)
Objects can be stored by id in the thinkmap config, this method gets an object by its id.

Parameters:
id - the id of the object to retrieve
Returns:
the object known by that id, or null if none exists.

assignId

public void assignId(String id,
                     Object value)
Associate an object with an identifier in this configuration

Parameters:
id - the id to assign
value - to associate with the id

getRootPropertyHandler

public IPropertyHandler getRootPropertyHandler()

getFileBase

public File getFileBase()
Returns a string which represents the absolute path on the local machine of the code base, or null if files cannot be used. For applets and servlets running within a WAR file, this method will return null. For servlets that are running in an "expanded" web application, this will return ServletContext.getRealPath("/"); For applications, this should return the absolute path of the current working directory.

Returns:
the file which represents the absolute path on the local machine of the code base, or null if files cannot be used.

getDocumentBase

public URL getDocumentBase()
Returns a URL that corresponds to the root of where documents are stored for this context. In an applet, this maps directly to the Applet.getDocumentBase() method. In a servlet, this maps to the root directory for this context root, or ServletContext.getResource("/"). This method may return null, when the concept of a document base is not applicable, such as in an embedded device with no network access or file system.

Returns:
a URL that corresponds to the root of where documents are stored for this context, or null, if a document base is not available.
See Also:
Applet, ServletContext

createURL

public URL createURL(String s)
              throws MalformedURLException
Creates a URL based on a String. If the string passed in is not an absolute URL, The url is constructed relative to the document base of the Context.

Parameters:
s - the string to convert to a URL
Returns:
a URL, based on the input
Throws:
MalformedURLException - if a URL cannot be created.

createFile

public File createFile(String s)
Creates a File based on a String. If the string passed in is not an absolute path, it is constructed relative to the "CodeBaseRoot" of the context.

Parameters:
s - the string to convert to a File
Returns:
a File, based on the input


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.