public final class ModuleRegistry extends Object
Module
objects, searching sourceHabitats
,
like a "ClassLoader" does for Java classes.
load_instantiated(String)
.
load_uninstantiated(String)
has been made public.
Text2Udom
EXPLICITLY calling
load_local_module(MemScanner,String)
, and thus retrieved little later
by "load_instantiated()", when processing the text header.
clearLocalModuleDefs()
.
Resolver.resolve(Module)
.
load_instantiated(String = module id) IFF already found in cache -> return chached instantiated Module object (or null in case of former error) -> do_load_uninstantiated(String = module id) ->sourceHabitats.searchAllPlaces(id, suffices) ->load_toplevel_module_from_stream() -> XantlrTdom.parse() -> Reducer.reduce() -> Navigate.LocalReferenceNormalizer.match(); -> Resolver.resolve() ELSE load_dtd_module() -> Resolver.resolve() ELSE load_umod_module() // MISDING FIXME -> Resolver.resolve() // ELSE further formats possible
Modifier and Type | Class and Description |
---|---|
protected class |
ModuleRegistry.NoSuchSourceFound |
protected class |
ModuleRegistry.Printer |
protected class |
ModuleRegistry.PrinterInstantiated |
protected class |
ModuleRegistry.PrinterUninstantiated |
Modifier and Type | Field and Description |
---|---|
protected boolean |
cacheChanged |
protected File |
cacheFile |
protected static String[] |
D2D_DEF_FILENAME_EXTENSIONS
List of file suffices tested for module definitions.
|
protected Map<String,Module> |
instantiated |
protected @Opt ResolvedModule |
loadedMetaModule |
protected boolean |
metaModuleLoaded |
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> |
msg |
static String |
sourceHabitatErrorHint |
protected SourceHabitats |
sourceHabitats
Mangages all file system locations / http locations / jar resources etc.
|
protected Map<String,Module> |
toplevel_uninstantiated |
protected int |
tracelevel |
boolean |
useResolver34 |
protected Map<Module,Map<String,eu.bandm.tools.d2d2.base.ModuleRegistry.XsltLoaded>> |
xslt_loaded |
Constructor and Description |
---|
ModuleRegistry(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg,
boolean useResolver34) |
Modifier and Type | Method and Description |
---|---|
void |
appendToSourceList(String s)
Appends a string which is the representation of a possible location
of module sources to the END of the list of searched locations,
as maintained by
sourceHabitats . |
void |
clearLocalModuleDefs() |
protected @Opt Module |
do_load_uninstantiated(String modpath)
Loads a d2d definition module, from top or non-top level.
|
protected void |
ERROR(Exception ex,
Location<XMLDocumentIdentifier> loc,
String txt) |
protected void |
ERROR(String txt) |
protected void |
ERROR(String txt,
Exception ex) |
protected String |
fileSuffices_toString() |
static SourceLocator |
getRootSourceLocator(Throwable exception)
Published routine from the xalan project page,
http://xalan.apache.org/old/xalan-j/faq.html#faq-N103D5
|
void |
initCache(File f)
Opens the file, iff it exists, and reads its contents into a map.
|
protected @Opt Module |
load_dtd_module(String s)
Looks in all
sourceHabitats for a "[s].dtd" file, parses the found file
and converts it into a d2d definition module, which is stored under the name "s"
as an instantiated module. |
@Opt Module |
load_instantiated(String s)
Loads a module identified by its name (a sequence of identifiers
separated by
Chars.REGEXP_NAMING_LEVEL_SEPARATOR ) and
subsequently instantiates all imports etc. |
protected @Opt Module |
load_local_module(MemScanner mem,
String filename)
Feed the prefix of a text document into the cache of uninstantiated modules,
to retrieve it instantiated (a few steps later).
|
protected @Opt Module |
load_toplevel_module_from_reader(Reader charstream,
String filename,
boolean local)
Loads a top-level d2d definition module (with all sub-modules, uninstantiaated),
which has not yet been read in at all.
Is called (internally) for a top-level module, which (together with its sub-modules contained therein) makes up the whole stream content, --- or externally for local modules, which start at the current stream reading position. |
protected @Opt Module |
load_toplevel_module_from_stream(InputStream stream,
String filename,
boolean local)
Only converts the byte source to a character source, assuming utf-8 encoding.
|
protected @Opt Module |
load_umod_module(String s)
Looks in all
sourceHabitats for a "[s].umod" file, parses the found file
and converts it into a d2d definition module, which is stored under the name "s"
as an instantiated module. |
@Opt Module |
load_uninstantiated(String s)
External entry point for loading an uninstantiated, unchecked (GLOBAL!) d2d
module, but only iff it exists in the genuine d2d-definition format ".df2"/".ddf".
|
protected @Opt ResolvedModule |
loadMetaModule()
Returns null in case of error.
|
@Opt Templates |
loadXslt(Module sourceModule,
String targetModule,
@Opt String targetTopTag)
Loads the xslt definitions coming with the d2d module definitions.
|
protected void |
LOG(String txt) |
protected void |
LOGEND(String txt) |
protected void |
LOGSTART(String txt) |
static ModuleRegistry |
makeInstance(@Opt String[] searchpath,
MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr,
int debug) |
static ModuleRegistry |
makeInstance(@Opt String[] searchpath,
MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr,
int debug,
boolean useResolver3)
Wrapper which creates and initializes.
|
protected void |
markCacheChanged() |
void |
print_instantiated(String name,
PrintStream p,
int w) |
void |
print_uninstantiated(String name,
PrintStream p,
int w) |
void |
saveCache()
Write all parsed module definitions als xslt Templates into the cache file,
iff one has been set by calling
initCache(File) . |
protected void |
sendFileNotFoundErrorMsg(String modname,
boolean includealternatives) |
void |
setMsgReceiver(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg) |
void |
setTracelevel(int tracelevel) |
void |
trace(int level,
String txt) |
protected void |
trace(int level,
String txt,
Object... obj) |
protected boolean |
transformerException2errorMessage(Throwable ex,
LocationMap<XMLDocumentIdentifier,XMLDocumentIdentifier> stringpos2filepos)
ATTENTION pure heuristics WHERE to find the error diagnosis !?!?!
Returns true iff an error message could be created.
|
protected void |
WARNING(String txt) |
public static final String sourceHabitatErrorHint
public boolean useResolver34
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg
protected int tracelevel
protected SourceHabitats sourceHabitats
protected File cacheFile
protected boolean cacheChanged
protected static final String[] D2D_DEF_FILENAME_EXTENSIONS
protected boolean metaModuleLoaded
@Opt protected @Opt ResolvedModule loadedMetaModule
public ModuleRegistry(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, boolean useResolver34)
public void setTracelevel(int tracelevel)
public void appendToSourceList(String s)
sourceHabitats
.protected void markCacheChanged()
public void initCache(File f)
saveCache()
.public void saveCache()
initCache(File)
.public void clearLocalModuleDefs()
public void setMsgReceiver(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg)
public static ModuleRegistry makeInstance(@Opt @Opt String[] searchpath, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr, int debug)
public static ModuleRegistry makeInstance(@Opt @Opt String[] searchpath, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgr, int debug, boolean useResolver3)
protected String fileSuffices_toString()
public void trace(int level, String txt)
protected void WARNING(String txt)
protected void ERROR(String txt)
protected void ERROR(Exception ex, Location<XMLDocumentIdentifier> loc, String txt)
protected void LOG(String txt)
protected void LOGSTART(String txt)
protected void LOGEND(String txt)
protected void sendFileNotFoundErrorMsg(String modname, boolean includealternatives)
@Opt public @Opt Module load_instantiated(String s)
Chars.REGEXP_NAMING_LEVEL_SEPARATOR
) and
subsequently instantiates all imports etc.
sourceHabitats
, whether there is a "ddf",
and then look again in sourceHabitats
for a "umod" or "dtd".null
when errors occured in loading an existing source file,
or when no single source file variant is visible.@Opt public @Opt Module load_uninstantiated(String s)
Chars.REGEXP_NAMING_LEVEL_SEPARATOR
).
May be called eg. for documentation generation.
Sends log and error messages to msg
and returns
null
on failure, including file-not-found.@Opt protected @Opt Module load_dtd_module(String s) throws ModuleRegistry.NoSuchSourceFound
sourceHabitats
for a "[s].dtd" file, parses the found file
and converts it into a d2d definition module, which is stored under the name "s"
as an instantiated module.
returns "null" in case of error and sends error messages to GLO IN msg.
But throws ModuleRegistry.NoSuchSourceFound
when no file is visible, to let the caller
test an alternative.ModuleRegistry.NoSuchSourceFound
@Opt protected @Opt ResolvedModule loadMetaModule()
@Opt protected @Opt Module load_umod_module(String s) throws ModuleRegistry.NoSuchSourceFound
sourceHabitats
for a "[s].umod" file, parses the found file
and converts it into a d2d definition module, which is stored under the name "s"
as an instantiated module.
returns "null" in case of error and sends error messages to GLO IN msg.
But throws ModuleRegistry.NoSuchSourceFound
when no file is visible, to let the caller
test an alternative.ModuleRegistry.NoSuchSourceFound
@Opt protected @Opt Module do_load_uninstantiated(String modpath) throws ModuleRegistry.NoSuchSourceFound
load_instantiated(String)
and load_uninstantiated(String)
.null
on error (and send error messages to receiver!){@link
- NoSuchSourceFound} iff no file can be locatedModuleRegistry.NoSuchSourceFound
@Opt protected @Opt Module load_local_module(MemScanner mem, String filename)
@Opt protected @Opt Module load_toplevel_module_from_stream(InputStream stream, String filename, boolean local)
@Opt protected @Opt Module load_toplevel_module_from_reader(Reader charstream, String filename, boolean local)
toplevel_uninstantiated
,
and retrieved from there when resolving the (subsequent) document type decl,
cf. Text2Udom.scanForHeader()
.@Opt public @Opt Templates loadXslt(Module sourceModule, String targetModule, @Opt @Opt String targetTopTag)
xslt_loaded
, ie. tries to parse
and compile a certain stylesheet only once in each run of this program.
This mainly because called by "Main.udom2xslt2document", which is
used by "Ddf2Doc" for rendering the docu texts into xhtml.
sourceModule
- the 2d module which defines the transformation sourcestargetModule
- name of the target module as it appears in the
key of the transformation rule, eg. "xhtml_1_0" in "to_xhtml_1_0"targetTopTag
- tag of the result. This is required because
the d2d-special-format for xslt rules interleaves parsing of xslt-syntax
and of the target syntax. For the latter, a preparational step collects all
open-tags reachable from this "top-level" element.protected boolean transformerException2errorMessage(Throwable ex, LocationMap<XMLDocumentIdentifier,XMLDocumentIdentifier> stringpos2filepos)
public static SourceLocator getRootSourceLocator(Throwable exception)
public void print_instantiated(String name, PrintStream p, int w)
public void print_uninstantiated(String name, PrintStream p, int w)
see also the complete user documentation .