GOF as aspects?


Should 876 be able to handle this aspect?

(Taken from http://www.cs.ubc.ca/~jan/AODPs/);



-


package ca.ubc.cs.spl.pattern.library;

/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset:
4 -*-
*

  • This file is part of the design patterns project at UBC

*

  • The contents of this file are subject to the Mozilla Public License

  • Version 1.1 (the "License"); you may not use this file except in

  • compliance with the License. You may obtain a copy of the License at

*

  • Software distributed under the License is distributed on an "AS IS"

basis,

  • WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

  • for the specific language governing rights and limitations under the

  • License.

*

  • The Original Code is ca.ubc.cs.spl.pattern.

*

  • Contributor(s):

*/

/**

  • Implements the abstracted Visitor design pattern.<p>

*

  • Intent: <i>Represents an operation to be performed on the elements

of an

  • object structure. Visitor lets you define a new operation without

changing

  • the classes of the elements on which it operates</i><p>

*

  • This code defines the roles <code>VisitorNode</code>, <code>VRegularNode

  • </code>, and <code>VLeaf</code>, representing a general node interface,

  • a non-terminal binary tree node, and a terminal node, respectively.

  • This aspect attaches default implementations of the various

  • <code>accept(..)</code> methods to the (abstract) participants. Concrete

  • subaspects just have to assign roles. Concrete Visitors implement the

  • inner interface <code>NodeVisitor</code>. <p>

*

  • Note that this implementation only deals with two different kind of

nodes:

  • terminal and non-terminal nodes. In cases where the aggregate

structure

  • contains more types of nodes, this aspect cannot be used without

  • modifications. <p>

*

  • Note further that whenever the aggregate structure is unimportant, the

  • additional functionality can be added using AspectJ's open classes

  • mechanism, i.e. by simply attaching the new methods to existing classes.

*

  • @author Jan Hannemann

  • @author Gregor Kiczales

  • @version 1.0, 06/13/02

*/

public abstract aspect VisitorProtocol {

/**

  • Defines the <i>Element</i> role. The inerface is public so that

  • concrete visitors can use the type.

*/

public interface VisitorNode {}

/**

  • Defines a <i>ConcreteElement</i> role for non-terminal nodes in

  • a binary tree structure. The inerface is protected as it is only

used

  • bu concrete subaspects.

*/

protected interface VRegularNode extends VisitorNode {}

/**

  • Defines a <i>ConcreteElement</i> role for terminal nodes in

  • a tree structure. The inerface is protected as it is only used

  • bu concrete subaspects.

*/

protected interface VLeaf extends VisitorNode {}

/**

  • This inerface is implemented by <i>ConcreteVisitor</i>s.

*/

public interface NodeVisitor {

/**

  • Defines a method signature for visiting regular nodes.

*

  • @param node the regular node to visit

*/

public void visitRegularNode(VisitorNode node);

/**

  • Defines a method signature for visiting leaf nodes.

*

  • @param node the leaf node to visit

*/

public void visitLeaf(VisitorNode node);

/**

  • Defines a method signature for returning the visitor's results

*

  • @param node a string containig the visitor's results

*/

public String report();
}

/**

  • Attaches the <code>accept(..)</code> code to nodes

*

  • @param nv the visitor that is to be accepted

*/

public void VisitorNode.accept(NodeVisitor nv) {}

/**

  • Attaches the <code>accept(..)</code> code to regular nodes

*

  • @param nv the visitor that is to be accepted

*/

public void VRegularNode.accept(NodeVisitor nv) {
nv.visitRegularNode(this);
}

/**

  • Attaches the <code>accept(..)</code> code to leaf nodes

*

  • @param nv the visitor that is to be accepted

*/

public void VLeaf.accept(NodeVisitor nv) {
nv.visitLeaf(this);
}
}

2 comments
Comment actions Permalink

Please use jetbrains.intellij.eap.aspectj newsgroup.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Barry Kaplan" <bkaplan@integratedtrading.com> wrote in message
news:bgjsqa$akm$1@is.intellij.net...
>

Should 876 be able to handle this aspect?

>

(Taken from http://www.cs.ubc.ca/~jan/AODPs/);

>
>
>

----
package ca.ubc.cs.spl.pattern.library;

>

/

  • -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset:

4 -*-
*

  • This file is part of the design patterns project at UBC

*

  • The contents of this file are subject to the Mozilla Public License

  • Version 1.1 (the "License"); you may not use this file except in

  • compliance with the License. You may obtain a copy of the License at

*

  • Software distributed under the License is distributed on an "AS IS"

basis,

  • WITHOUT WARRANTY OF ANY KIND, either express or implied. See the

License

  • * for the specific language governing rights and limitations under the

  • License.

*

  • The Original Code is ca.ubc.cs.spl.pattern.

*

  • Contributor(s):

*/

>

/**

  • Implements the abstracted Visitor design pattern.<p>

*

  • Intent: <i>Represents an operation to be performed on the elements

of an

  • object structure. Visitor lets you define a new operation without

changing

  • the classes of the elements on which it operates</i><p>

*

  • This code defines the roles <code>VisitorNode</code>,

]]>VRegularNode

  • * </code>, and <code>VLeaf</code>, representing a general node

interface,

  • * a non-terminal binary tree node, and a terminal node, respectively.

  • This aspect attaches default implementations of the various

  • <code>accept(..)</code> methods to the (abstract) participants.

Concrete

  • * subaspects just have to assign roles. Concrete Visitors implement the

  • inner interface <code>NodeVisitor</code>. <p>

*

  • Note that this implementation only deals with two different kind of

nodes:

  • terminal and non-terminal nodes. In cases where the aggregate

structure

  • contains more types of nodes, this aspect cannot be used without

  • modifications. <p>

*

  • Note further that whenever the aggregate structure is unimportant, the

  • additional functionality can be added using AspectJ's open classes

  • mechanism, i.e. by simply attaching the new methods to existing

classes.

*

  • @author Jan Hannemann

  • @author Gregor Kiczales

  • @version 1.0, 06/13/02

*/

>

public abstract aspect VisitorProtocol {

>

/**

  • Defines the <i>Element</i> role. The inerface is public so that

  • concrete visitors can use the type.

*/

>

public interface VisitorNode {}

>

/**

  • Defines a <i>ConcreteElement</i> role for non-terminal nodes in

  • a binary tree structure. The inerface is protected as it is only

used

  • bu concrete subaspects.

*/

>

protected interface VRegularNode extends VisitorNode {}

>

/**

  • Defines a <i>ConcreteElement</i> role for terminal nodes in

  • a tree structure. The inerface is protected as it is only used

  • bu concrete subaspects.

*/

>

protected interface VLeaf extends VisitorNode {}

>

/**

  • This inerface is implemented by <i>ConcreteVisitor</i>s.

*/

>

public interface NodeVisitor {

>

/**

  • Defines a method signature for visiting regular nodes.

*

  • @param node the regular node to visit

*/

>

public void visitRegularNode(VisitorNode node);

>

/**

  • Defines a method signature for visiting leaf nodes.

*

  • @param node the leaf node to visit

*/

>

public void visitLeaf(VisitorNode node);

>

/**

  • Defines a method signature for returning the visitor's results

*

  • @param node a string containig the visitor's results

*/

>

public String report();
}

>

/**

  • Attaches the <code>accept(..)</code> code to nodes

*

  • @param nv the visitor that is to be accepted

*/

>

public void VisitorNode.accept(NodeVisitor nv) {}

>

/**

  • Attaches the <code>accept(..)</code> code to regular nodes

*

  • @param nv the visitor that is to be accepted

*/

>

public void VRegularNode.accept(NodeVisitor nv) {
nv.visitRegularNode(this);
}

>

/**

  • Attaches the <code>accept(..)</code> code to leaf nodes

*

  • @param nv the visitor that is to be accepted

*/

>

public void VLeaf.accept(NodeVisitor nv) {
nv.visitLeaf(this);
}
}

>


0
Comment actions Permalink

Thanks, didn't know that group exists. And of course a quick scan of
messages answered this post.

-bk

Valentin Kipiatkov wrote:

Please use jetbrains.intellij.eap.aspectj newsgroup.


0

Please sign in to leave a comment.