[jboss-cvs] JBossAS SVN: r76029 - in projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree: search/match and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jul 20 17:06:13 EDT 2008
Author: flavia.rainone at jboss.com
Date: 2008-07-20 17:06:12 -0400 (Sun, 20 Jul 2008)
New Revision: 76029
Modified:
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/ExtendedLengthRange.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/KeyPart.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotFlagSystem.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/search/match/LengthRange.java
Log:
[JBAOP-509] Integration required tree cloning and clearing abilities.
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/ExtendedLengthRange.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/ExtendedLengthRange.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/ExtendedLengthRange.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -95,6 +95,12 @@
return (byte) (super.getLength() - 1);
}
+ public ExtendedLengthRange clone()
+ {
+ return new ExtendedLengthRange(getLength(), getPostPrefixMinLength(),
+ getPostPrefixMaxLength(), this.elementLengthRange.clone());
+ }
+
public String toString()
{
return super.toString().substring(0, super.toString().length() - 1) +
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/InternalNode.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -53,6 +53,16 @@
}
/**
+ * Constructor for cloning.
+ */
+ @SuppressWarnings("all")
+ private InternalNode(InternalNode<E> internalNode)
+ {
+ super(internalNode.keyPart.clone());
+ this.children = internalNode.children.clone();
+ }
+
+ /**
* Inserts <code>value</code>, identified by <code>insertionKey</code>, in
* one of the child nodes.
*/
@@ -123,6 +133,11 @@
return null;
}
+ public InternalNode<E> clone()
+ {
+ return new InternalNode<E>(this);
+ }
+
public String toString()
{
return "(" + this.keyPart + ", " + this.children + ")";
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/KeyPart.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/KeyPart.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/KeyPart.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -39,7 +39,7 @@
* @see Tree
* @see org.jboss.aop.joinpoint.graph.tree
*/
-public class KeyPart
+public class KeyPart implements Cloneable
{
/**
* Empty key end, represents the end of a key.
@@ -144,6 +144,22 @@
}
/**
+ * Private constructor for cloning.
+ *
+ * @param keyPart key part to be cloned.
+ */
+ private KeyPart(KeyPart keyPart)
+ {
+ this.keyElements = new String[keyPart.keyElements.length];
+ for (int i = 0; i < keyElements.length; i++)
+ {
+ this.keyElements[i] = keyPart.keyElements[i];
+ }
+ this.lastElementComplete = keyPart.lastElementComplete;
+ this.lengthRange = keyPart.lengthRange.clone();
+ }
+
+ /**
* Private constructor, for internal use only.
*
* @param keyElements the elements of the key part
@@ -385,6 +401,11 @@
(byte) (suffixPart.getKeyElements()[0].length() + length)};
}
+ public KeyPart clone()
+ {
+ return new KeyPart(this);
+ }
+
public String toString()
{
String result = "[";
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/MultiValueLeafNode.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import org.jboss.aop.joinpoint.graph.tree.search.Flags;
@@ -81,6 +82,17 @@
result.addAll(this.values);
}
}
+ public MultiValueLeafNode<E> clone()
+ {
+ Iterator<E> iterator = this.values.iterator();
+ MultiValueLeafNode<E> node = new MultiValueLeafNode<E>(keyPart, iterator.next(),
+ iterator.next());
+ while(iterator.hasNext())
+ {
+ node.values.add(iterator.next());
+ }
+ return node;
+ }
public String toString()
{
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Node.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -35,7 +35,7 @@
* @author Flavia Rainone
* @see Tree
*/
-abstract class Node<E>
+abstract class Node<E> implements Cloneable
{
/**
* The contents of the node.
@@ -120,4 +120,9 @@
*/
protected abstract Node<E> internalInsert(InsertionKey insertionKey,
E value);
+
+ /**
+ * Clones this node.
+ */
+ public abstract Node<E> clone();
}
\ No newline at end of file
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SingleValueLeafNode.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -76,6 +76,11 @@
}
}
+ public SingleValueLeafNode<E> clone()
+ {
+ return new SingleValueLeafNode<E>(keyPart, value);
+ }
+
public String toString()
{
return "(" + this.keyPart + ", " + this.value + ")";
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotCollection.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -31,7 +31,7 @@
*
* @author Flavia Rainone
*/
-class SlotCollection<E>
+class SlotCollection<E> implements Cloneable
{
/**
* SlotFlagSystem that indicates whether a slot is empty.
@@ -79,6 +79,21 @@
}
/**
+ * Constructor for cloning.
+ *
+ * @param slotCollection collection to be cloned
+ */
+ private SlotCollection(SlotCollection slotCollection)
+ {
+ this.flagSystem = slotCollection.flagSystem.clone();
+ this.contents = new Object[slotCollection.contents.length];
+ for (int i = 0; i < contents.length; i++)
+ {
+ contents[i] = slotCollection.contents[i];
+ }
+ }
+
+ /**
* Loads the slot identified by <code>identifier</code>.
* <p>
* This operation must be executed before any other operation on a slot.
@@ -177,6 +192,11 @@
return contents;
}
+ public SlotCollection clone()
+ {
+ return new SlotCollection(this);
+ }
+
public String toString()
{
String result = "(";
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotFlagSystem.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotFlagSystem.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/SlotFlagSystem.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -30,7 +30,7 @@
* @author Flavia Rainone
* @see SlotCollection
*/
-class SlotFlagSystem
+class SlotFlagSystem implements Cloneable
{
/**
* The offset of the flags. All flags should have an identifier greater than
@@ -83,6 +83,26 @@
}
/**
+ * Constructor for cloning.
+ *
+ * @param flagSystem flag system to be cloned.
+ */
+ private SlotFlagSystem(SlotFlagSystem flagSystem)
+ {
+ this.flags = new char[flagSystem.flags.length];
+ for (int i = 0; i < flags.length; i++)
+ {
+ this.flags[i] = flagSystem.flags[i];
+ }
+ this.count = new byte[flagSystem.count.length];
+ for (int i = 0; i < count.length; i++)
+ {
+ this.count[i] = flagSystem.count[i];
+ }
+ this.flag = new Flag();
+ }
+
+ /**
* Loads a flag identified by <code>id</code>.
* <p>
* This operation must be executed before any other operation on a flag.
@@ -202,6 +222,11 @@
return total;
}
+ public SlotFlagSystem clone()
+ {
+ return new SlotFlagSystem(this);
+ }
+
/**
* Represents a flag of the flag system. A flag is identified by a character
* and indicates if the character slot is empty or not, besides being able
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/Tree.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -36,7 +36,7 @@
*
* @author Flavia Rainone
*/
-public class Tree<E>
+public class Tree<E> implements Cloneable
{
/**
* Separator char that splits the keys into elements.
@@ -143,6 +143,15 @@
{
return state.searchElement(new SearchKey(searchKey, separator));
}
+
+ /**
+ * Clears the content of this tree.
+ */
+ public void clear()
+ {
+ this.root = null;
+ this.state = new EmptyState();
+ }
/**
* The state of the tree, defines how the insertion and search operations
@@ -243,4 +252,15 @@
{
return "" + root;
}
+
+ /**
+ * Creates an identical copy of this tree.
+ */
+ public Tree<E> clone()
+ {
+ Tree<E> tree = new Tree<E>(this.separator);
+ tree.state = this.state;
+ tree.root = this.root.clone();
+ return tree;
+ }
}
\ No newline at end of file
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/search/match/LengthRange.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/search/match/LengthRange.java 2008-07-20 21:03:54 UTC (rev 76028)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/tree/search/match/LengthRange.java 2008-07-20 21:06:12 UTC (rev 76029)
@@ -33,7 +33,7 @@
* @author Flavia Rainone
*
*/
-public class LengthRange
+public class LengthRange implements Cloneable
{
/**
* The number of components contained in the target.
@@ -208,6 +208,12 @@
postPrefixMaxLength = (byte) Math.max(postPrefixMaxLength, ppMaxLength);
}
+ public LengthRange clone()
+ {
+ return new LengthRange(this.length, this.postPrefixMinLength,
+ this.postPrefixMaxLength);
+ }
+
public String toString()
{
return "[length=" + this.length + ", ppMinLength=" +
More information about the jboss-cvs-commits
mailing list