net.sf.jeters.components
Class RegExReplacer.DescriptionList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<RegExReplacer.DescriptionEntry>
              extended by net.sf.jeters.components.RegExReplacer.DescriptionList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<RegExReplacer.DescriptionEntry>, java.util.Collection<RegExReplacer.DescriptionEntry>, java.util.List<RegExReplacer.DescriptionEntry>, java.util.RandomAccess
Enclosing class:
RegExReplacer

protected static class RegExReplacer.DescriptionList
extends java.util.ArrayList<RegExReplacer.DescriptionEntry>

an internally used class representing a description list. (May be a tree-like structure, due to elementDescriptionList attributes.)

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected RegExReplacer.DescriptionList()
           
 
Method Summary
 boolean add(RegExReplacer.DescriptionEntry newEntry)
          own add-method that either adds a new description to the description list or modifies an existing description (increasing the rating of the existing description entry, modify the elementDescriptionList).
 boolean add(java.lang.String descriptionString, int rating)
          add-method for descriptions of single replacements.
 boolean add(java.lang.String descriptionString, RegExReplacer.DescriptionList elementDescriptionList)
          add-method for descriptions of replacement groups.
 boolean addAll(java.util.Collection<? extends RegExReplacer.DescriptionEntry> collection)
          own addAll-method that calls add(DescriptionEntry) for all elements of the collection
 java.lang.String toString()
          own toString-method that prints all descriptions sorted by rating.
 java.lang.String toString(int maxNumberDescriptions, int maxNumberElementDescriptions, int minSingleRating, int minTotalRating)
          parameterized toString-method that prints the descriptions sorted by rating.
 
Methods inherited from class java.util.ArrayList
add, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

RegExReplacer.DescriptionList

protected RegExReplacer.DescriptionList()
Method Detail

add

public boolean add(RegExReplacer.DescriptionEntry newEntry)
own add-method that either adds a new description to the description list or modifies an existing description (increasing the rating of the existing description entry, modify the elementDescriptionList).
Normally, you do not directly call this method (although it is possible) but use one of the two other add-methods instead.

Specified by:
add in interface java.util.Collection<RegExReplacer.DescriptionEntry>
Specified by:
add in interface java.util.List<RegExReplacer.DescriptionEntry>
Overrides:
add in class java.util.ArrayList<RegExReplacer.DescriptionEntry>
Returns:
true if this DescriptionList changed as a result of the call

add

public boolean add(java.lang.String descriptionString,
                   int rating)
add-method for descriptions of single replacements.

Parameters:
descriptionString - the text of the description you want to add to the list.
rating - the rating of this description (compare rating-attribute in RegExReplacer.Replacement).
Returns:
true if this DescriptionList changed as a result of the call

add

public boolean add(java.lang.String descriptionString,
                   RegExReplacer.DescriptionList elementDescriptionList)
add-method for descriptions of replacement groups. The values for rating and maxRating are calculated from elementDescriptionList.

Parameters:
descriptionString - the text of the group's description.
elementDescriptionList - description list for the group's elements.
Returns:
true if this DescriptionList changed as a result of the call

addAll

public boolean addAll(java.util.Collection<? extends RegExReplacer.DescriptionEntry> collection)
own addAll-method that calls add(DescriptionEntry) for all elements of the collection

Specified by:
addAll in interface java.util.Collection<RegExReplacer.DescriptionEntry>
Specified by:
addAll in interface java.util.List<RegExReplacer.DescriptionEntry>
Overrides:
addAll in class java.util.ArrayList<RegExReplacer.DescriptionEntry>

toString

public java.lang.String toString()
own toString-method that prints all descriptions sorted by rating. It calls the parameterized toString-method with -1 for every parameter (no limitations).

Overrides:
toString in class java.util.AbstractCollection<RegExReplacer.DescriptionEntry>

toString

public java.lang.String toString(int maxNumberDescriptions,
                                 int maxNumberElementDescriptions,
                                 int minSingleRating,
                                 int minTotalRating)
parameterized toString-method that prints the descriptions sorted by rating. The descriptions are separated by semicolons, the descriptions from elementDescriptionList are printed inside round brackets. Limits the number of entries are possible, as is specifying a minimum rating.

Parameters:
maxNumberDescriptions - the maximum number of descriptions in the resulting string. If there are more descriptions, those with the highest rating will be printed, followed by three dots. A value of -1 an unlimited number of descriptions.
maxNumberElementDescriptions - equivalent of maxNumberDescriptions for the descriptions in brackets.
minSingleRating - all descriptions whose maxRating value is lower than minSingleRating will be omitted.
minTotalRating - all descriptions whose rating value is lower than minTotalRating will be omitted.
Returns:
the generated string.