eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'NameSpace':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: NameSpace


Inheritance:

   Object
   |
   +--NameSpace
      |
      +--JavaPackage

Package:
stx:libbasic
Category:
Kernel-Classes
Version:
rev: 1.92 date: 2024/04/29 12:55:18
user: stefan
file: NameSpace.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


A NameSpace is actually a dummy class, providing a home
for its private classes. 
Thus, internally, the same mechanism is used for classes in
a NameSpace and private classes.
This has two advantages:
    - we only need one mechanism for both namespaces
      and private classes

    - there are no possible conflicts between a class
      and a namespace named alike.

copyright

COPYRIGHT (c) 1996 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

Compatibility-VW5.4
o  defineClass: name superclass: superclass indexedType: indexed private: private instanceVariableNames: instVars classInstanceVariableNames: classInstVars imports: imports category: category
VW5i compatibility class/namespace creation

o  defineClass: name superclass: superclassOrName indexedType: indexed private: private instanceVariableNames: instVars classInstanceVariableNames: classInstVars imports: imports category: category attributes: annotations
VW5i compatibility class/namespace creation

o  defineNameSpace: nameSymbol private: private imports: imports category: category
VW5i compatibility class/namespace creation

accessing
o  allClasses

o  allClassesWithAllPrivateClasses

o  allClassesWithAllPrivateClassesDo: aBlock

o  at: classNameSymbol
return a class from the namespace defined by the receiver

o  at: classNameSymbol ifAbsent: exceptionBlock
return a class or an alternative
from the namespace defined by the receiver

o  at: aKey ifPresent: aBlock
try to retrieve the value stored at aKey.
If there is nothing stored under this key, do nothing.
Otherwise, evaluate aBlock, passing the retrieved value as argument.

o  at: classNameSymbol put: aClass
add a class to the namespace defined by the receiver

o  classNamed: aString
return the class with name aString, or nil if absent.
To get to the metaClass, append ' class' to the string.

o  classNames

o  import: aNameSpace

o  imports

o  includesKey: aClassNameStringOrSymbol
return true if such a key is present

o  loadedClassNamed: aString
return the class with name aString, or nil if absent.
To get to the metaClass, append ' class' to the string.
Do not autoload the owning class of a private class.

o  package
all nameSpaces are outside of any package

Usage example(s):

the nameSpace class itself has a package

o  subclasses
most of my subs are NameSpaces. Do not return these.

Usage example(s):

    self subclasses

enumerating
o  allBehaviorsDo: aBlock
enumerate all classes in this namespace

o  allClassesDo: aBlock
enumerate all classes in this namespace

o  allClassesForWhich: filter
return a collection with all classes in the system,
for which filter evaluates to true.

Usage example(s):

     Smalltalk
        allClassesForWhich:[:cls | cls name startsWith:'Po']

o  allClassesForWhich: filter do: aBlock
evaluate the argument, aBlock for all classes in the system, for which filter evaluates to true.

Usage example(s):

     Smalltalk
        allClassesForWhich:[:cls | cls name startsWith:'Po']
        do:[:aClass | Transcript showCR:aClass name]

o  allMethodsDo: aBlock
enumerate all methods in this namespace's classes

o  allMethodsWithSelectorDo: aBlock
enumerate all methods in the Smalltalk namespace's classes

o  keyAtValue: anObject
return the symbol under which anObject is stored - or nil

Usage example(s):

Smalltalk keyAtValue:Object

o  keys
return all class names in this namespace

Usage example(s):

     Benchmarks keys

o  keysDo: aBlock
enumerate all class names in this namespace

Usage example(s):

     Benchmarks keysDo:[:k | Transcript showCR:k]

fileOut
o  fileOutDefinitionOn: aStream
redefined to generate another definition message

fileOut-xml
o  fileOutXMLDefinitionOn: aStream
redefined to generate another definition message

instance creation
o  fullName: aFullNameSpacePathName
given a possibly nested name of a namespace, create all required
intermediate spaces (if not already existing) and return the
bottom-level space.

o  fullName: aFullNameSpacePathName createIfAbsent: createIfAbsent
given a possibly nested name of a namespace, lookup and return
a namespace instance for it.
If createIfAbsent is true, create all required intermediate spaces (if not already existing)
and return the bottom-level space.
If false, and if any namespace along the path does not exist, reutrn nil.

o  name: aStringOrSymbol
create a new nameSpace, named aStringOrSymbol.
Notice, that the nameSpace is created in the current one -
don't get confused; we recommend, not to nest them too much.

Usage example(s):

     NameSpace name:'foo'
     (NameSpace name:'foo') category:'my name space'
     foo at:#bar put:(Metaclass new new)
     (NameSpace name:'foo') name:'bar'

Usage example(s):

     NameSpace name:'an-invalid++name'
     NameSpace name:'another:invalidName'
     NameSpace name:'another::invalidName'

o  new
catch new - namespaces are not to be created by the user

misc ui support
o  inspectorClass
( an extension from the stx:libtool package )
redefined to launch a DictionaryInspector
(instead of the default Inspector).

printing & storing
o  displayOn: aGCOrStream
Compatibility
append a printed description on some stream (Dolphin, Squeak)
OR:
display the receiver in a graphicsContext at 0@0 (ST80).
This method allows for any object to be displayed in some view
(although the fallBack is to display its printString ...)

private
o  setImports: anArrayOrNil
Sets namespace imports. Private entry,
Use 'self import: theNamespace' instead

queries
o  allNameSpaces
return a list of all namespaces

o  allNameSpacesIn: anEnvironment
return a list of all namespaces

o  allNamespaces
return a list of all namespaces

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  allNamespacesIn: anEnvironment
return a list of all namespaces

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  canHaveExtensions
return true, if this class allows extensions from other packages.
Private classes, namespaces and projectDefinitions don't allow this

Usage example(s):

     Smalltalk allClasses select:[:each | each canHaveExtensions not]

o  hasNameSpaces
return true - if I support sub-namespaces

o  hasNamespaces
return true - if I support sub-namespaces

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  isBehavior
return true, if the receiver is a class.
Unconditionally false here for subclasses - my subclasses are namespaces

o  isClass
return true, if the receiver is a class.
Unconditionally false here for subclasses - my subclasses are namespaces

o  isNameSpace
return true, if the receiver is a nameSpace.
Unconditionally true here for subclasses - my subclasses are namespaces

o  isRealNameSpace
return true, if the receiver is a nameSpace, but not Smalltalk (which is also a class).
Unconditionally true here for subclasses - my subclasses are namespaces

o  isTopLevelNameSpace

o  isTopLevelNamespace
obsolete - use isTopLevelNameSpace

** This is an obsolete interface - do not use it (it may vanish in future versions) **



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 10 Dec 2024 09:16:32 GMT