org.allenai.common.StringUtils

StringExtras

Related Doc: package StringUtils

trait StringExtras extends Any

Extension methods for String. Meant to be mixed into an extension method implicit class, which is why it extends Any. While we provide a StringImplicits implementation below that uses this trait, we define this trait separately so that client projects can extend the extension methods further (because you cannot extend an extension method class).

To understand the quirky rules of extension method implicit classes, see http://docs.scala-lang.org/overviews/core/value-classes.html#extension-methods

A String extension method class should be defined like: format: OFF

implicit class MyStringImplicits(val str: String) extends AnyVal with StringExtras {
  def anotherExtensionMethod = str.replaceAll("foo", "bar")

format: ON

Linear Supertypes
Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. StringExtras
  2. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def getClass(): Class[_]

    Definition Classes
    Any
  2. abstract def str: String

    value that is transformed by extension methods.

    value that is transformed by extension methods. Must be declared as the constructor argument for the implementing extension method class (see trait scaladoc)

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  2. final def ##(): Int

    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def collapseWhitespace: String

  6. def equals(arg0: Any): Boolean

    Definition Classes
    Any
  7. def hashCode(): Int

    Definition Classes
    Any
  8. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  9. def normalize: String

    returns

    Trim white spaces, lower case, then strip the accents.

  10. def removeNonAlpha: String

  11. def removePunctuation: String

  12. def removeUnprintable: String

  13. def replaceFancyUnicodeChars: String

  14. def splitOnWhitespace: Array[String]

  15. def titleCase(): String

    Properly capitalize a title.

    Properly capitalize a title. http://titlecapitalization.com/#

  16. def titleCaseIfAllCaps(): String

  17. def toString(): String

    Definition Classes
    Any
  18. def trimChars(chars: String): String

    chars

    String containing the blacklist chars.

    returns

    Trim characters from the right that belongs to a blacklist.

  19. def trimNonAlphabetic(): String

    returns

    Trim non-letter chars from the beginning and end

  20. def trimRight(filter: (Char) ⇒ Boolean): String

    filter

    Determine if a character is blacklisted and should be trimmed.

    returns

    String with blacklisted chars trimmed from the right.

  21. def unescaped: String

Inherited from Any

Ungrouped