Drools :: Core 6.0.0.Beta5

org.drools.core.util
Class CodedHierarchyImpl<T>

java.lang.Object
  extended by org.drools.core.util.CodedHierarchyImpl<T>
All Implemented Interfaces:
Externalizable, Serializable, CodedHierarchy<T>
Direct Known Subclasses:
HierarchyEncoderImpl, TypeHierarchy

public class CodedHierarchyImpl<T>
extends Object
implements CodedHierarchy<T>, Externalizable

See Also:
Serialized Form

Nested Class Summary
protected static class CodedHierarchyImpl.HierCodeComparator
           
protected static class CodedHierarchyImpl.HierNode<T>
           
 
Field Summary
protected  boolean fixedRoot
           
protected  SortedMap<BitSet,CodedHierarchyImpl.HierNode<T>> line
           
 
Constructor Summary
CodedHierarchyImpl()
           
 
Method Summary
protected  void add(CodedHierarchyImpl.HierNode<T> node)
           
 void addMember(T val, BitSet key)
           
protected  Set<CodedHierarchyImpl.HierNode<T>> ancestorNodes(CodedHierarchyImpl.HierNode<T> x)
           
 Collection<T> ancestors(BitSet key)
           
 Collection<T> ancestors(T x)
           
protected  Collection<T> ancestorValues(CodedHierarchyImpl.HierNode<T> node)
           
 Collection<T> children(BitSet key)
           
 Collection<T> children(T x)
           
protected  Collection<T> childrenValues(CodedHierarchyImpl.HierNode<T> node)
           
 void clear()
           
protected  boolean contains(CodedHierarchyImpl.HierNode<T> node)
           
protected  Set<CodedHierarchyImpl.HierNode<T>> descendantNodes(CodedHierarchyImpl.HierNode<T> y)
           
 Collection<T> descendants(BitSet key)
           
 Collection<T> descendants(T y)
           
protected  Collection<T> descendantValues(CodedHierarchyImpl.HierNode<T> node)
           
 BitSet getCode(T val)
           
 T getMember(BitSet key)
           
protected  CodedHierarchyImpl.HierNode<T> getNode(T name)
           
protected  CodedHierarchyImpl.HierNode<T> getNodeByKey(BitSet key)
           
protected  Collection<CodedHierarchyImpl.HierNode<T>> getNodes()
           
 Map<T,BitSet> getSortedMap()
           
 List<T> getSortedMembers()
           
 boolean hasKey(BitSet key)
           
 Collection<T> immediateChildren(BitSet key)
          * Return the "ceiling" of the key's descendants, excluding the element whose code is key, if any
 Collection<T> immediateParents(BitSet key)
          Return the "floor" of the key's ancetsors, down to and excluding the element whose code is key
 BitSet joinCode(Collection<BitSet> codes)
           
 BitSet jointMembersCode(Collection<T> vals)
           
 Collection<T> lowerBorder(BitSet key)
          Return the "ceiling" of the key's descendants, up to and including the element whose code is key
 Collection<T> lowerDescendants(BitSet key)
          Returns all elements whose code is a descendant of key
 BitSet meetCode(Collection<BitSet> codes)
           
 BitSet metMembersCode(Collection<T> vals)
           
 Collection<T> parents(BitSet x)
           
 Collection<T> parents(T x)
           
protected  Collection<T> parentValues(CodedHierarchyImpl.HierNode<T> node)
           
 void readExternal(ObjectInput objectInput)
           
protected  void remove(CodedHierarchyImpl.HierNode<T> node)
           
 void removeMember(BitSet key)
           
 void removeMember(T val)
           
 int size()
           
static BitSet stringToBitSet(String s)
           
static boolean supersetOrEqualset(BitSet n1, BitSet n2)
           
protected  String toBinaryString(BitSet mask)
           
protected  String toBinaryString(BitSet mask, int len)
           
 String toString()
           
 Collection<T> upperAncestors(BitSet key)
          Returns all elements whose code is an ancestor of key
 Collection<T> upperBorder(BitSet key)
          Return the "floor" of the key's ancestors, down to and including the element whose code is key, if any
 void writeExternal(ObjectOutput objectOutput)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

line

protected SortedMap<BitSet,CodedHierarchyImpl.HierNode<T>> line

fixedRoot

protected boolean fixedRoot
Constructor Detail

CodedHierarchyImpl

public CodedHierarchyImpl()
Method Detail

size

public int size()
Specified by:
size in interface CodedHierarchy<T>

hasKey

public boolean hasKey(BitSet key)
Specified by:
hasKey in interface CodedHierarchy<T>

getNodeByKey

protected CodedHierarchyImpl.HierNode<T> getNodeByKey(BitSet key)

getNode

protected CodedHierarchyImpl.HierNode<T> getNode(T name)

add

protected void add(CodedHierarchyImpl.HierNode<T> node)

remove

protected void remove(CodedHierarchyImpl.HierNode<T> node)

contains

protected boolean contains(CodedHierarchyImpl.HierNode<T> node)

getNodes

protected Collection<CodedHierarchyImpl.HierNode<T>> getNodes()

getCode

public BitSet getCode(T val)
Specified by:
getCode in interface CodedHierarchy<T>

metMembersCode

public BitSet metMembersCode(Collection<T> vals)
Specified by:
metMembersCode in interface CodedHierarchy<T>

jointMembersCode

public BitSet jointMembersCode(Collection<T> vals)
Specified by:
jointMembersCode in interface CodedHierarchy<T>

meetCode

public BitSet meetCode(Collection<BitSet> codes)
Specified by:
meetCode in interface CodedHierarchy<T>

joinCode

public BitSet joinCode(Collection<BitSet> codes)
Specified by:
joinCode in interface CodedHierarchy<T>

getSortedMembers

public List<T> getSortedMembers()
Specified by:
getSortedMembers in interface CodedHierarchy<T>

getSortedMap

public Map<T,BitSet> getSortedMap()
Specified by:
getSortedMap in interface CodedHierarchy<T>

getMember

public T getMember(BitSet key)
Specified by:
getMember in interface CodedHierarchy<T>

addMember

public void addMember(T val,
                      BitSet key)
Specified by:
addMember in interface CodedHierarchy<T>

removeMember

public void removeMember(T val)
Specified by:
removeMember in interface CodedHierarchy<T>

removeMember

public void removeMember(BitSet key)
Specified by:
removeMember in interface CodedHierarchy<T>

parentValues

protected Collection<T> parentValues(CodedHierarchyImpl.HierNode<T> node)

parents

public Collection<T> parents(T x)
Specified by:
parents in interface CodedHierarchy<T>

parents

public Collection<T> parents(BitSet x)
Specified by:
parents in interface CodedHierarchy<T>

ancestors

public Collection<T> ancestors(T x)
Specified by:
ancestors in interface CodedHierarchy<T>

ancestors

public Collection<T> ancestors(BitSet key)
Specified by:
ancestors in interface CodedHierarchy<T>

ancestorValues

protected Collection<T> ancestorValues(CodedHierarchyImpl.HierNode<T> node)

ancestorNodes

protected Set<CodedHierarchyImpl.HierNode<T>> ancestorNodes(CodedHierarchyImpl.HierNode<T> x)

upperAncestors

public Collection<T> upperAncestors(BitSet key)
Description copied from interface: CodedHierarchy
Returns all elements whose code is an ancestor of key

Specified by:
upperAncestors in interface CodedHierarchy<T>
Returns:

childrenValues

protected Collection<T> childrenValues(CodedHierarchyImpl.HierNode<T> node)

children

public Collection<T> children(T x)
Specified by:
children in interface CodedHierarchy<T>

children

public Collection<T> children(BitSet key)
Specified by:
children in interface CodedHierarchy<T>

descendantValues

protected Collection<T> descendantValues(CodedHierarchyImpl.HierNode<T> node)

descendants

public Collection<T> descendants(T y)
Specified by:
descendants in interface CodedHierarchy<T>

descendants

public Collection<T> descendants(BitSet key)
Specified by:
descendants in interface CodedHierarchy<T>

descendantNodes

protected Set<CodedHierarchyImpl.HierNode<T>> descendantNodes(CodedHierarchyImpl.HierNode<T> y)

lowerDescendants

public Collection<T> lowerDescendants(BitSet key)
Description copied from interface: CodedHierarchy
Returns all elements whose code is a descendant of key

Specified by:
lowerDescendants in interface CodedHierarchy<T>
Returns:

lowerBorder

public Collection<T> lowerBorder(BitSet key)
Description copied from interface: CodedHierarchy
Return the "ceiling" of the key's descendants, up to and including the element whose code is key

Specified by:
lowerBorder in interface CodedHierarchy<T>
Parameters:
key - a key, possibly the meet of a number of member keys
Returns:

immediateChildren

public Collection<T> immediateChildren(BitSet key)
Description copied from interface: CodedHierarchy
* Return the "ceiling" of the key's descendants, excluding the element whose code is key, if any

Specified by:
immediateChildren in interface CodedHierarchy<T>
Parameters:
key - a key, possibly the meet of a number of member keys
Returns:

upperBorder

public Collection<T> upperBorder(BitSet key)
Description copied from interface: CodedHierarchy
Return the "floor" of the key's ancestors, down to and including the element whose code is key, if any

Specified by:
upperBorder in interface CodedHierarchy<T>
Parameters:
key - a key, possibly the meet of a number of member keys
Returns:

immediateParents

public Collection<T> immediateParents(BitSet key)
Description copied from interface: CodedHierarchy
Return the "floor" of the key's ancetsors, down to and excluding the element whose code is key

Specified by:
immediateParents in interface CodedHierarchy<T>
Parameters:
key - a key, possibly the meet of a number of member keys
Returns:

toString

public String toString()
Overrides:
toString in class Object

toBinaryString

protected String toBinaryString(BitSet mask)

toBinaryString

protected String toBinaryString(BitSet mask,
                                int len)

supersetOrEqualset

public static boolean supersetOrEqualset(BitSet n1,
                                         BitSet n2)

writeExternal

public void writeExternal(ObjectOutput objectOutput)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput objectInput)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

clear

public void clear()

stringToBitSet

public static BitSet stringToBitSet(String s)

Drools :: Core 6.0.0.Beta5

Copyright © 2001-2013 JBoss by Red Hat. All Rights Reserved.