LongestPrefixMatch

This class stores data belonging to decimal number ranges. This can be used inside dial plans. Ranges with more than 2 permutations are compressed automatically. When querying this the value of the longest matching path will be returned. So if there are the ranges 1 and 11-13 when querying with 12, the later's value will be returned. This is as it holds the longer prefix (2 digits instead of 1).

Example usage:

val lpm = new LongestPrefixMatch[String].
 addValueForRange("123", "456", "V1").
 addValueForRange("12345", "12349", "V2")
lpm.getValueFromPrefix("1234")  // will return Some("V1")
lpm.getValueFromPrefix("12347") // will return Some("V2")
class Object
trait Matchable
class Any

Value members

Constructors

def this()

Concrete methods

@throws(scala.Predef.classOf[scala.IllegalArgumentException])
def addValueForRange(rangeStart: String, rangeEnd: String, value: T): LongestPrefixMatch[T]

Adds a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.

Adds a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.

Value parameters:
rangeEnd

the inclusive end of the range

rangeStart

the inclusive start of the range

value

the data to be stored for this range

Returns:

an updated instance of [this]

@throws(scala.Predef.classOf[scala.IllegalArgumentException])
def deleteValueForRange(rangeStart: String, rangeEnd: String): LongestPrefixMatch[T]

Removes a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.

Removes a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.

Value parameters:
rangeEnd

the inclusive end of the range

rangeStart

the inclusive start of the range

Returns:

an updated instance of [this]

def getValueFromPrefix(prefix: String): Option[T]

Retrieves the value stored under the longest range matching.

Retrieves the value stored under the longest range matching.

Value parameters:
prefix

the number to match prefixes against

def size(): Int
override def toString(): String
Definition Classes
Any

Inherited methods

def +(rangeStart: String, rangeEnd: String, value: T): LongestPrefixMatch[T]
def -(rangeStart: String, rangeEnd: String): LongestPrefixMatch[T]
def apply(prefix: String): Option[T]