Hi again,
As a general purpose DescriptorVisitor I'd imagined something like
Eclipse's hierarchical ASTVisitor:
public abstract class Descriptor {
public boolean visit(ModuleDescriptor md) {
return true;
}
public boolean visit(ServicePointDescriptor spd) {
return true;
}
...
public void endVisit(ServicePointDescriptor spd) {
}
public void endVisit(ModuleDescriptor md) {
}
}
The boolean returned by the visit() methods would signify whether the
children of the visited descriptor should be visited or not. The
Descriptor classes would have an accept(DescriptorVisitor) method
which implements the visiting of the children. E.g.
public class ModuleDescriptor {
public void accept(DescriptorVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren && _servicePoints != null)
// _servicePoints.each { sp | sp.accept(visitor); }
visitor.endVisit(this);
}
}
Implementing a visitor is then simply a matter of extending
DescriptorVisitor and overload the respective methods required.
Is this overkill? Other ideas?
--knut
On Thu, 14 Oct 2004 16:45:55 +0200, Knut Wannheden
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've committed the changes to CVS now. As I said it should be regarded
> as a first (but yet feature complete) implementation of the new
> HiveDoc generator. I see the following things needing refactoring:
>
> - Schema objects should be added to the Descriptors in which they were
> defined. Descriptors referencing schemas defined elsewhere should only
> have a String id thereof. This will delegate the schema linking
> responsibility to the RegistryBuilder, which IMO makes more sense.
> This should further allow us to remove the dependency on
> RegistryAssembly in DescriptorParser.
> - There should be a switch on the DescriptorParser to control whether
> annotations should be parsed or not. The client of
> XmlModuleDescriptorParser obviously needs to be in control of this
> switch.
> - Howard's suggested XMLWriter and visiting pattern for the Descriptor
> classes should be considered. Alternatively a more general purpose
> visitor class could be implemented. It would also be useful to the
> RegistryBuilder.
>
> That's all I've written down anyway ;-)
>
> Support for scripts (e.g. Groovy) should be within reach now.
>
> --knut
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]