AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.util.JavaStringUtils Class Reference

Static Public Member Functions

static String joinStrings (List< Object > listOfStrings, String separator)
 
static String replaceAllMappingsDictionaryOrder (String text, Map< Object, Object > mappings)
 
static String replaceAllMappingsLongestStringOrder (String text, Map< Object, Object > mappings)
 
static String replaceAllMappingsEarliestOccurrenceOrder (String text, Map< Object, Object > mappings)
 
static String replaceAllMappings (String text, Map< Object, Object > mappings, MappingOrder order)
 

Static Public Attributes

static final String LOG_TAG_JOIN_STRINGS = "JavaJoinListOfStrings"
 

Detailed Description

Java implementation of string utility methods for use in Scheme calls. Used for ease of reasoning about the solution or to address issues with Kawa (e.g. memory problems). See runtime.scm

Definition at line 27 of file JavaStringUtils.java.

Member Function Documentation

◆ joinStrings()

static String com.google.appinventor.components.runtime.util.JavaStringUtils.joinStrings ( List< Object >  listOfStrings,
String  separator 
)
static

Java implementation of join-strings since the Kawa version appears to run of space. See runtime.scm

The elements in listOString are Kawa strings, but these are not necessarily Java Strings. They might be FStrings. So we accept a list of Objects and use toString to do a conversion.

Implements the following operation

(define join-strings (strings separator) (JavaJoinListOfStrings:joinStrings strings separator))

I'm writing this in Java, rather than using Kawa in runtime.scm because Kawa seems to blow out memory (or stack?) on small-memory systems and large lists.

Author
halab.nosp@m.elso.nosp@m.n@goo.nosp@m.gle..nosp@m.com (Hal Abelson)

Definition at line 189 of file JavaStringUtils.java.

◆ replaceAllMappings()

static String com.google.appinventor.components.runtime.util.JavaStringUtils.replaceAllMappings ( String  text,
Map< Object, Object >  mappings,
MappingOrder  order 
)
static

Replaces the specified text string with the specified mappings, which is a map containing Key Value pairs where the key is the substring to replace, and the value is the value to replace the substring with. An order parameter is specified to indicate the order of mapping applications.

Parameters
textText to apply mappings to
mappingsMap containing mappings
orderOrder to use for replacing mappings
Returns
Text with the mappings applied

Definition at line 265 of file JavaStringUtils.java.

◆ replaceAllMappingsDictionaryOrder()

static String com.google.appinventor.components.runtime.util.JavaStringUtils.replaceAllMappingsDictionaryOrder ( String  text,
Map< Object, Object >  mappings 
)
static

Replaces the specified text string with the specified mappings in dictionary element order.

See also
#replaceAllMappings(String, Map, MappingOrder)
MappingOrder
Parameters
textText to apply mappings to
mappingsMap containing mappings
Returns
Text with the mappings applied

Definition at line 222 of file JavaStringUtils.java.

◆ replaceAllMappingsEarliestOccurrenceOrder()

static String com.google.appinventor.components.runtime.util.JavaStringUtils.replaceAllMappingsEarliestOccurrenceOrder ( String  text,
Map< Object, Object >  mappings 
)
static

Replaces the specified text string with the specified mappings in earliest occurrence first order.

See also
#replaceAllMappings(String, Map, MappingOrder)
MappingEarliestOccurrenceFirstOrder
Parameters
textText to apply mappings to
mappingsMap containing mappings
Returns
Text with the mappings applied

Definition at line 250 of file JavaStringUtils.java.

◆ replaceAllMappingsLongestStringOrder()

static String com.google.appinventor.components.runtime.util.JavaStringUtils.replaceAllMappingsLongestStringOrder ( String  text,
Map< Object, Object >  mappings 
)
static

Replaces the specified text string with the specified mappings in longest string first order.

See also
#replaceAllMappings(String, Map, MappingOrder)
MappingLongestStringFirstOrder
Parameters
textText to apply mappings to
mappingsMap containing mappings
Returns
Text with the mappings applied

Definition at line 236 of file JavaStringUtils.java.

Member Data Documentation

◆ LOG_TAG_JOIN_STRINGS

final String com.google.appinventor.components.runtime.util.JavaStringUtils.LOG_TAG_JOIN_STRINGS = "JavaJoinListOfStrings"
static

Definition at line 158 of file JavaStringUtils.java.


The documentation for this class was generated from the following file: