Android Programming Press on the image to return to the main documentation page.

MFLib

Written by Manfred Fuchs - \u00a9 2014 - http://www.vulpessoft.de

List of types:

MF_Base
MF_File
MF_Math
MF_String

MF_Base


Events:

None

Members:


Members description:


MF_File


Events:

None

Members:


  ChangeExt (path As String, newExt As String) As String

  Exists (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As Boolean

  FileDir (path As String) As String

  FileExt (path As String) As String

  FileName (path As String) As String

  Find (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As String

  ListFiles (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As java.util.List

  ListFiles2 (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean, recursive As Boolean, includeFiles As Boolean, includeDirs As Boolean) As java.util.List

  MakePath (dirName As String, fileName As String) As String

  Rename (dirSource As String, fileSource As String, dirTarget As String, fileTarget As String) As Boolean

Members description:

ChangeExt (path As String, newExt As String) As String
Change the file extension from a given path.
A empty string parameter removes the extension.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim path As String
Dim fName As String
path = MF_File.MakePath(File.DirInternal, "testfile.txt")
fName = MF_File.ChangeExt(path, ".log")
End Sub
Exists (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As Boolean
Check if file exists in directory, the filename can use wildcard characters (*, ?).
Set ignoreCase to True to ignore case sensitivity on compare.
If extendedCompare is True the filename can also contains the wildcard + and character ranges ([a,b,c] or [a-z]).
Wildcard + is same as * but at least one character must exist (* accepts empty strings).

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_File.Exists(File.DirInternal, "*.jpg", True, False)
End Sub
FileDir (path As String) As String
Returns the full directory name from a given path.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim path As String
Dim fName As String
path = MF_File.MakePath(File.DirInternal, "testfile.txt")
fName = MF_File.FileDir(path)
End Sub
FileExt (path As String) As String
Returns the file extension from a given path.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim path As String
Dim fName As String
path = MF_File.MakePath(File.DirInternal, "testfile.txt")
fName = MF_File.FileExt(path)
End Sub
FileName (path As String) As String
Returns the file name from a given path.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim path As String
Dim fName As String
path = MF_File.MakePath(File.DirInternal, "testfile.txt")
fName = MF_File.FileName(path)
End Sub
Find (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As String
Returns the real file name if the file exists in directory or an empty string if not.
The filename can use wildcard characters (*, ?).
Set ignoreCase to True to ignore case sensitivity on compare.
If extendedCompare is True the filename can also contains the wildcard + and character ranges ([a,b,c] or [a-z]).
Wildcard + is same as * but at least one character must exist (* accepts empty strings).

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim fName As String
fName = MF_File.Find(File.DirInternal, "*.jpg", True, False)
End Sub
ListFiles (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean) As java.util.List
Returns a list of matching files from directory, the filename can use wildcard characters (*, ?).
Set ignoreCase to True to ignore case sensitivity on compare.
If extendedCompare is True the filename can also contains the wildcard + and character ranges ([a,b,c] or [a-z]).
Wildcard + is same as * but at least one character must exist (* accepts empty strings).

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim fList As List
fList = MF_File.ListFiles(File.DirInternal, "*.jpg", True, False)
End Sub
ListFiles2 (dirName As String, fileName As String, ignoreCase As Boolean, extendedCompare As Boolean, recursive As Boolean, includeFiles As Boolean, includeDirs As Boolean) As java.util.List
Returns a list of matching files from directory, the filename can use wildcard characters (*, ?).
Set ignoreCase to True to ignore case sensitivity on compare.
If extendedCompare is True the filename can also contains the wildcard + and character ranges ([a,b,c] or [a-z]).
Wildcard + is same as * but at least one character must exist (* accepts empty strings).
If resursive is True then subfolders will also scanned.
If listFiles is True then files will included in the result list.
If listDirs is True then directories will included in the result list.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim fList As List
fList = MF_File.ListFiles2(File.DirInternal, "*.jpg", True, False, True, True, False)
End Sub
MakePath (dirName As String, fileName As String) As String
Combines directory name and file name with correct separator.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim path As String
path = MF_File.MakePath(File.DirInternal, "first.jpg")
End Sub
Rename (dirSource As String, fileSource As String, dirTarget As String, fileTarget As String) As Boolean
Rename a file.

Example:
Sub Process_Globals
Dim MF_File As MF_File
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_File.Rename(File.DirInternal, "first.jpg", File.DirInternal, "second.jpg")
End Sub

MF_Math


Events:

None

Members:


  CompareFloat (value1 As Double, value2 As Double, tolerance As Double, percent As Boolean) As Int

  CompareInt (value1 As Int, value2 As Int, tolerance As Int, percent As Boolean) As Int

  ConstrainFloat (value As Double, valueMin As Double, valueMax As Double) As Double

  ConstrainInt (value As Int, valueMin As Int, valueMax As Int) As Int

  EqualsFloat (value1 As Double, value2 As Double, tolerance As Double, percent As Boolean) As Boolean

  EqualsInt (value1 As Int, value2 As Int, tolerance As Int, percent As Boolean) As Boolean

  MapFloat (value As Double, inMin As Double, inMax As Double, outMin As Double, outMax As Double) As Double

  MapInt (value As Int, inMin As Int, inMax As Int, outMin As Int, outMax As Int) As Int

Members description:

CompareFloat (value1 As Double, value2 As Double, tolerance As Double, percent As Boolean) As Int
Compare two float numbers with tolerance.
Set percent to true and tolerance is used as pecentage value from value1/value2 average.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Int
result = MF_Math.CompareFloat(145.23, 145.0, 0.5, False)
End Sub
CompareInt (value1 As Int, value2 As Int, tolerance As Int, percent As Boolean) As Int
Compare two int numbers with tolerance.
Set percent to true and tolerance is used as pecentage value from value1/value2 average.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Int
result = MF_Math.CompareInt(1277, 1280, 5, False)
End Sub
ConstrainFloat (value As Double, valueMin As Double, valueMax As Double) As Double
Check the min and max value of a float number and correct if needed.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Double
result = MF_Math.ConstrainFloat(422.32, 32.0, 350.0)
End Sub
ConstrainInt (value As Int, valueMin As Int, valueMax As Int) As Int
Check the min and max value of a int number and correct if needed.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Int
result = MF_Math.ConstrainInt(231, 0, 255)
End Sub
EqualsFloat (value1 As Double, value2 As Double, tolerance As Double, percent As Boolean) As Boolean
Check if two float numbers are equal with tolerance.
Set percent to true and tolerance is used as pecentage value from value1/value2 average.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_Math.EqualsFloat(145.23, 145.0, 0.5, False)
End Sub
EqualsInt (value1 As Int, value2 As Int, tolerance As Int, percent As Boolean) As Boolean
Check if two int numbers are equal with tolerance.
Set percent to true and tolerance is used as pecentage value from value1/value2 average.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_Math.EqualsInt(1277, 1280, 5, False)
End Sub
MapFloat (value As Double, inMin As Double, inMax As Double, outMin As Double, outMax As Double) As Double
Map a float number from first min/max range to second min/max range.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Double
result = MF_Math.MapFloat(74.12, 32.0, 160.0, 12.0, 280.0)
End Sub
MapInt (value As Int, inMin As Int, inMax As Int, outMin As Int, outMax As Int) As Int
Map a int number from first min/max range to second min/max range.

Example:
Sub Process_Globals
Dim MF_Math As MF_Math
End Sub

Sub AppStart (Args() As String)
Dim result As Int
result = MF_Math.MapInt(347, 0, 1024, 0, 256)
End Sub

MF_String


Events:

None

Members:


  Append (str As String, appendStr As String, delimiter As String) As String

  BestLevenshtein (word As String, wordList As java.util.List, threshold As Double, ignoreCase As Boolean) As java.util.List

  Compare (str As String, pattern As String, ignoreCase As Boolean, extendedCompare As Boolean) As Boolean

  ContainsNumber (str As String) As Boolean

  LevenshteinDistance (src As String, dest As String, ignoreCase As Boolean) As Int

  TokenList (str As String, delim As String, repeater As Boolean, ignoreFirst As Boolean, ignoreLast As Boolean) As java.util.List

  TokenList2 (str As String, delim As String, startQuotas As String, endQuotas As String, repeater As Boolean, ignoreFirst As Boolean, ignoreLast As Boolean, includeQuotas As Boolean) As java.util.List

Members description:

Append (str As String, appendStr As String, delimiter As String) As String
Append string on another string with delimiter. If the first string is empty, no delimiter is used.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim str As String
str = ""
str = MF_String.Append(str, "first", ";")
str = MF_String.Append(str, "second", ";")
str = MF_String.Append(str, "third", ";")
End Sub
BestLevenshtein (word As String, wordList As java.util.List, threshold As Double, ignoreCase As Boolean) As java.util.List
Compare the levenshtein distance between a word and all entries in a wordlist.
All entries with a score >= threshold (between 0.0 and 1.0) are part of the result list.
Set ignoreCase to true to ignore case sensitivity on compare.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim words As List
words.Initialize
words.Add("number")
words.Add("plumber")
words.Add("cucumber")
words.Add("")
Dim result As List
result = MF_String.BestLevenshtein("number", words, 0.7, True)
End Sub
Compare (str As String, pattern As String, ignoreCase As Boolean, extendedCompare As Boolean) As Boolean
Compares string with pattern, the pattern can use wildcard characters (*, ?).
Set ignoreCase to true to ignore case sensitivity on compare.
If extendedCompare ist true the pattern can also contains the wildcard + and character ranges ([a,b,c] or [a-z]).
Wildcard + is same as * but at least one character must exist (* accepts empty strings).

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_String.Compare("This is a test string", "*TEST*", true, false)
result = MF_String.Compare("This is my best string", "*[B,T]EST*", true, true)
End Sub
ContainsNumber (str As String) As Boolean
Check if a string contains numeric digit.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim result As Boolean
result = MF_String.ContainsNumber("This is a number 1 string")
End Sub
LevenshteinDistance (src As String, dest As String, ignoreCase As Boolean) As Int
Calculate the levenshtein distance between two strings.
Set ignoreCase to true to ignore case sensitivity on calc.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim result As Int
result = MF_String.LevenshteinDistance("This is the first string", "This is the second string", True)
End Sub
TokenList (str As String, delim As String, repeater As Boolean, ignoreFirst As Boolean, ignoreLast As Boolean) As java.util.List
Split a string at given delimiters.
If repeater is true then following delimiters will inspected as one delimiter.
If ignoreFirst is True then a empty string before the first delimiter will be ignored.
If ignoreLast is True then a empty string after the last delimiter will be ignored.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim result As List<String>
result = MF_String.TokenList("This is the string", " ", True, True, True)
End Sub
TokenList2 (str As String, delim As String, startQuotas As String, endQuotas As String, repeater As Boolean, ignoreFirst As Boolean, ignoreLast As Boolean, includeQuotas As Boolean) As java.util.List
Split a string at given delimiters.
If startQuotas and endQuotas are not empty, delimiters between quotas will be ignored.
If repeater is true then following delimiters will inspected as one delimiter.
If ignoreFirst is True then a empty string before the first delimiter will be ignored.
If ignoreLast is True then a empty string after the last delimiter will be ignored.
If includeQuotas is true then available quotas will included in the result.

Example:
Sub Process_Globals
Dim MF_String As MF_String
End Sub

Sub AppStart (Args() As String)
Dim result As List<String>
result = MF_String.TokenList2("This is 'the string'", " ", "'", "'", True, True, True, False)
End Sub

Top