started compiling more of the kotlin library to JS; now testing the String methods in JS
This commit is contained in:
Generated
+1
@@ -0,0 +1 @@
|
||||
js.libraries
|
||||
@@ -26,10 +26,10 @@ native public trait CDATASection: Text {
|
||||
native public trait CharacterData: Node {
|
||||
public var data: String
|
||||
public val length: Int
|
||||
public fun replaceData(arg1: Int, arg2: Int, arg3: String): Unit = js.noImpl
|
||||
public fun replaceData(arg1: Int, arg2: Int, arg3: String?): Unit = js.noImpl
|
||||
public fun substringData(arg1: Int, arg2: Int): String = js.noImpl
|
||||
public fun appendData(arg1: String): Unit = js.noImpl
|
||||
public fun insertData(arg1: Int, arg2: String): Unit = js.noImpl
|
||||
public fun appendData(arg1: String?): Unit = js.noImpl
|
||||
public fun insertData(arg1: Int, arg2: String?): Unit = js.noImpl
|
||||
public fun deleteData(arg1: Int, arg2: Int): Unit = js.noImpl
|
||||
}
|
||||
|
||||
@@ -47,23 +47,23 @@ native public trait Document: Node {
|
||||
public val xmlEncoding: String
|
||||
public var xmlStandalone: Boolean
|
||||
public var xmlVersion: String
|
||||
public fun createElement(arg1: String): Element = js.noImpl
|
||||
public fun createComment(arg1: String): Comment = js.noImpl
|
||||
public fun createElement(arg1: String?): Element = js.noImpl
|
||||
public fun createComment(arg1: String?): Comment = js.noImpl
|
||||
public fun createDocumentFragment(): DocumentFragment = js.noImpl
|
||||
public fun createTextNode(arg1: String): Text = js.noImpl
|
||||
public fun createCDATASection(arg1: String): CDATASection = js.noImpl
|
||||
public fun createProcessingInstruction(arg1: String, arg2: String): ProcessingInstruction = js.noImpl
|
||||
public fun createAttribute(arg1: String): Attr = js.noImpl
|
||||
public fun createEntityReference(arg1: String): EntityReference = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
public fun createTextNode(arg1: String?): Text = js.noImpl
|
||||
public fun createCDATASection(arg1: String?): CDATASection = js.noImpl
|
||||
public fun createProcessingInstruction(arg1: String?, arg2: String?): ProcessingInstruction = js.noImpl
|
||||
public fun createAttribute(arg1: String?): Attr = js.noImpl
|
||||
public fun createEntityReference(arg1: String?): EntityReference = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String?): NodeList = js.noImpl
|
||||
public fun importNode(arg1: Node, arg2: Boolean): Node = js.noImpl
|
||||
public fun createElementNS(arg1: String, arg2: String): Element = js.noImpl
|
||||
public fun createAttributeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
public fun getElementById(arg1: String): Element = js.noImpl
|
||||
public fun createElementNS(arg1: String?, arg2: String?): Element = js.noImpl
|
||||
public fun createAttributeNS(arg1: String?, arg2: String?): Attr = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String?, arg2: String?): NodeList = js.noImpl
|
||||
public fun getElementById(arg1: String?): Element = js.noImpl
|
||||
public fun adoptNode(arg1: Node): Node = js.noImpl
|
||||
public fun normalizeDocument(): Unit = js.noImpl
|
||||
public fun renameNode(arg1: Node, arg2: String, arg3: String): Node = js.noImpl
|
||||
public fun renameNode(arg1: Node, arg2: String?, arg3: String?): Node = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DocumentFragment: Node {
|
||||
@@ -80,9 +80,9 @@ native public trait DocumentType: Node {
|
||||
|
||||
native public trait DOMConfiguration {
|
||||
public val parameterNames: DOMStringList
|
||||
public fun setParameter(arg1: String, arg2: Any): Unit = js.noImpl
|
||||
public fun getParameter(arg1: String): Any = js.noImpl
|
||||
public fun canSetParameter(arg1: String, arg2: Any): Boolean = js.noImpl
|
||||
public fun setParameter(arg1: String?, arg2: Any): Unit = js.noImpl
|
||||
public fun getParameter(arg1: String?): Any = js.noImpl
|
||||
public fun canSetParameter(arg1: String?, arg2: Any): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMError {
|
||||
@@ -105,10 +105,10 @@ native public trait DOMErrorHandler {
|
||||
}
|
||||
|
||||
native public trait DOMImplementation {
|
||||
public fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
public fun hasFeature(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun createDocumentType(arg1: String, arg2: String, arg3: String): DocumentType = js.noImpl
|
||||
public fun createDocument(arg1: String, arg2: String, arg3: DocumentType): Document = js.noImpl
|
||||
public fun getFeature(arg1: String?, arg2: String?): Any = js.noImpl
|
||||
public fun hasFeature(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun createDocumentType(arg1: String?, arg2: String?, arg3: String?): DocumentType = js.noImpl
|
||||
public fun createDocument(arg1: String?, arg2: String?, arg3: DocumentType?): Document = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMImplementationList {
|
||||
@@ -127,28 +127,28 @@ native public trait DOMLocator {
|
||||
|
||||
native public trait DOMStringList {
|
||||
public val length: Int
|
||||
public fun contains(arg1: String): Boolean = js.noImpl
|
||||
public fun contains(arg1: String?): Boolean = js.noImpl
|
||||
public fun item(arg1: Int): String = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Element: Node {
|
||||
public val schemaTypeInfo: TypeInfo
|
||||
public val tagName: String
|
||||
public fun getAttribute(arg1: String): String = js.noImpl
|
||||
public fun setAttribute(arg1: String, arg2: String): Unit = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
public fun removeAttribute(arg1: String): Unit = js.noImpl
|
||||
public fun getAttributeNode(arg1: String): Attr = js.noImpl
|
||||
public fun getAttribute(arg1: String?): String = js.noImpl
|
||||
public fun setAttribute(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String?): NodeList = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String?, arg2: String?): NodeList = js.noImpl
|
||||
public fun removeAttribute(arg1: String?): Unit = js.noImpl
|
||||
public fun getAttributeNode(arg1: String?): Attr = js.noImpl
|
||||
public fun removeAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun getAttributeNS(arg1: String, arg2: String): String = js.noImpl
|
||||
public fun setAttributeNS(arg1: String, arg2: String, arg3: String): Unit = js.noImpl
|
||||
public fun removeAttributeNS(arg1: String, arg2: String): Unit = js.noImpl
|
||||
public fun getAttributeNodeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
public fun hasAttribute(arg1: String): Boolean = js.noImpl
|
||||
public fun hasAttributeNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun setIdAttribute(arg1: String, arg2: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNS(arg1: String, arg2: String, arg3: Boolean): Unit = js.noImpl
|
||||
public fun getAttributeNS(arg1: String?, arg2: String?): String = js.noImpl
|
||||
public fun setAttributeNS(arg1: String?, arg2: String?, arg3: String?): Unit = js.noImpl
|
||||
public fun removeAttributeNS(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun getAttributeNodeNS(arg1: String?, arg2: String?): Attr = js.noImpl
|
||||
public fun hasAttribute(arg1: String?): Boolean = js.noImpl
|
||||
public fun hasAttributeNS(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun setIdAttribute(arg1: String?, arg2: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNS(arg1: String?, arg2: String?, arg3: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNode(arg1: Attr, arg2: Boolean): Unit = js.noImpl
|
||||
public fun setAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun setAttributeNodeNS(arg1: Attr): Attr = js.noImpl
|
||||
@@ -169,18 +169,18 @@ native public trait EntityReference: Node {
|
||||
native public trait NameList {
|
||||
public val length: Int
|
||||
public fun getName(arg1: Int): String = js.noImpl
|
||||
public fun contains(arg1: String): Boolean = js.noImpl
|
||||
public fun contains(arg1: String?): Boolean = js.noImpl
|
||||
public fun getNamespaceURI(arg1: Int): String = js.noImpl
|
||||
public fun containsNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun containsNS(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait NamedNodeMap {
|
||||
public val length: Int
|
||||
public fun item(arg1: Int): Node = js.noImpl
|
||||
public fun getNamedItem(arg1: String): Node = js.noImpl
|
||||
public fun removeNamedItem(arg1: String): Node = js.noImpl
|
||||
public fun getNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
public fun removeNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
public fun getNamedItem(arg1: String?): Node = js.noImpl
|
||||
public fun removeNamedItem(arg1: String?): Node = js.noImpl
|
||||
public fun getNamedItemNS(arg1: String?, arg2: String?): Node = js.noImpl
|
||||
public fun removeNamedItemNS(arg1: String?, arg2: String?): Node = js.noImpl
|
||||
public fun setNamedItem(arg1: Node): Node = js.noImpl
|
||||
public fun setNamedItemNS(arg1: Node): Node = js.noImpl
|
||||
}
|
||||
@@ -203,11 +203,12 @@ native public trait Node {
|
||||
public val previousSibling: Node
|
||||
public var textContent: String
|
||||
public fun normalize(): Unit = js.noImpl
|
||||
public fun isSupported(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
public fun isSupported(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun getUserData(arg1: String?): Any = js.noImpl
|
||||
public fun setUserData(arg1: String?, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
public fun getFeature(arg1: String?, arg2: String?): Any = js.noImpl
|
||||
public fun hasAttributes(): Boolean = js.noImpl
|
||||
public fun removeChild(arg1: Node): Node = js.noImpl
|
||||
public fun getUserData(arg1: String): Any = js.noImpl
|
||||
public fun replaceChild(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun insertBefore(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun appendChild(arg1: Node): Node = js.noImpl
|
||||
@@ -215,11 +216,10 @@ native public trait Node {
|
||||
public fun cloneNode(arg1: Boolean): Node = js.noImpl
|
||||
public fun compareDocumentPosition(arg1: Node): Short = js.noImpl
|
||||
public fun isSameNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun lookupPrefix(arg1: String): String = js.noImpl
|
||||
public fun isDefaultNamespace(arg1: String): Boolean = js.noImpl
|
||||
public fun lookupNamespaceURI(arg1: String): String = js.noImpl
|
||||
public fun lookupPrefix(arg1: String?): String = js.noImpl
|
||||
public fun isDefaultNamespace(arg1: String?): Boolean = js.noImpl
|
||||
public fun lookupNamespaceURI(arg1: String?): String = js.noImpl
|
||||
public fun isEqualNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun setUserData(arg1: String, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
|
||||
class object {
|
||||
public val ELEMENT_NODE: Short = 1
|
||||
@@ -262,13 +262,13 @@ native public trait Text: CharacterData {
|
||||
public val wholeText: String
|
||||
public fun splitText(arg1: Int): Text = js.noImpl
|
||||
public fun isElementContentWhitespace(): Boolean = js.noImpl
|
||||
public fun replaceWholeText(arg1: String): Text = js.noImpl
|
||||
public fun replaceWholeText(arg1: String?): Text = js.noImpl
|
||||
}
|
||||
|
||||
native public trait TypeInfo {
|
||||
public val typeName: String
|
||||
public val typeNamespace: String
|
||||
public fun isDerivedFrom(arg1: String, arg2: String, arg3: Int): Boolean = js.noImpl
|
||||
public fun isDerivedFrom(arg1: String?, arg2: String?, arg3: Int): Boolean = js.noImpl
|
||||
|
||||
class object {
|
||||
public val DERIVATION_RESTRICTION: Int = 1
|
||||
@@ -279,7 +279,7 @@ native public trait TypeInfo {
|
||||
}
|
||||
|
||||
native public trait UserDataHandler {
|
||||
public fun handle(arg1: Short, arg2: String, arg3: Any, arg4: Node, arg5: Node): Unit = js.noImpl
|
||||
public fun handle(arg1: Short, arg2: String?, arg3: Any, arg4: Node, arg5: Node): Unit = js.noImpl
|
||||
|
||||
class object {
|
||||
public val NODE_CLONED: Short = 1
|
||||
|
||||
@@ -25,6 +25,12 @@ library
|
||||
val Collections = object {
|
||||
library("collectionsMax")
|
||||
public fun max<T>(col : Collection<T>, comp : Comparator<T>) : T = js.noImpl
|
||||
|
||||
// TODO should be immutable!
|
||||
private val emptyList = ArrayList<Any>()
|
||||
|
||||
public val <T> EMPTY_LIST: List<T>
|
||||
get() = emptyList as List<T>
|
||||
}
|
||||
|
||||
library
|
||||
@@ -201,4 +207,3 @@ public class StringBuilder() {
|
||||
|
||||
library
|
||||
class NoSuchElementException() : Exception() {}
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package js
|
||||
|
||||
import java.util.List
|
||||
|
||||
native public fun String.toUpperCase() : String = js.noImpl
|
||||
|
||||
native public fun String.toLowerCase() : String = js.noImpl
|
||||
|
||||
native public fun String.indexOf(str : String) : Int = js.noImpl
|
||||
native public fun String.indexOf(str : String, fromIndex : Int) : Int = js.noImpl
|
||||
|
||||
native public fun String.lastIndexOf(str: String) : Int = js.noImpl
|
||||
native public fun String.lastIndexOf(str : String, fromIndex : Int) : Int = js.noImpl
|
||||
|
||||
native public fun String.split(regex : String) : Array<String> = js.noImpl
|
||||
|
||||
native public fun String.substring(beginIndex : Int) : String = js.noImpl
|
||||
native public fun String.substring(beginIndex : Int, endIndex : Int) : String = js.noImpl
|
||||
|
||||
native public fun String.charAt(index : Int) : Char = js.noImpl
|
||||
|
||||
native public fun String.concat(str : String) : String = js.noImpl
|
||||
|
||||
native public fun String.match(regex : String) : Array<String> = js.noImpl
|
||||
|
||||
native public fun String.trim() : String = js.noImpl
|
||||
|
||||
native public val String.length : Int
|
||||
get() = js.noImpl
|
||||
|
||||
|
||||
/*
|
||||
|
||||
native public fun String.equalsIgnoreCase(anotherString: String) : Boolean = (this as java.lang.String).equalsIgnoreCase(anotherString)
|
||||
|
||||
native public fun String.hashCode() : Int = (this as java.lang.String).hashCode()
|
||||
|
||||
native public fun String.replace(oldChar: Char, newChar : Char) : String = (this as java.lang.String).replace(oldChar, newChar).sure()
|
||||
|
||||
native public fun String.replaceAll(regex: String, replacement : String) : String = (this as java.lang.String).replaceAll(regex, replacement).sure()
|
||||
|
||||
|
||||
native public fun String.length() : Int = (this as java.lang.String).length()
|
||||
|
||||
native public fun String.getBytes() : ByteArray = (this as java.lang.String).getBytes().sure()
|
||||
|
||||
native public fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray().sure()
|
||||
|
||||
native public fun String.toCharList(): List<Char> = toCharArray().toList()
|
||||
|
||||
native public fun String.format(format : String, vararg args : Any?) : String = java.lang.String.format(format, args).sure()
|
||||
|
||||
|
||||
native public fun String.split(ch : Char) : Array<String> = (this as java.lang.String).split(java.util.regex.Pattern.quote(ch.toString())) as Array<String>
|
||||
|
||||
native public fun String.startsWith(prefix: String) : Boolean = (this as java.lang.String).startsWith(prefix)
|
||||
|
||||
native public fun String.startsWith(prefix: String, toffset: Int) : Boolean = (this as java.lang.String).startsWith(prefix, toffset)
|
||||
|
||||
native public fun String.startsWith(ch: Char) : Boolean = (this as java.lang.String).startsWith(ch.toString())
|
||||
|
||||
native public fun String.contains(seq: CharSequence) : Boolean = (this as java.lang.String).contains(seq)
|
||||
|
||||
native public fun String.endsWith(suffix: String) : Boolean = (this as java.lang.String).endsWith(suffix)
|
||||
|
||||
native public fun String.endsWith(ch: Char) : Boolean = (this as java.lang.String).endsWith(ch.toString())
|
||||
|
||||
// "constructors" for String
|
||||
|
||||
native public fun String(bytes : ByteArray, offset : Int, length : Int, charsetName : String) : String = java.lang.String(bytes, offset, length, charsetName) as String
|
||||
|
||||
native public fun String(bytes : ByteArray, offset : Int, length : Int, charset : java.nio.charset.Charset) : String = java.lang.String(bytes, offset, length, charset) as String
|
||||
|
||||
native public fun String(bytes : ByteArray, charsetName : String?) : String = java.lang.String(bytes, charsetName) as String
|
||||
|
||||
native public fun String(bytes : ByteArray, charset : java.nio.charset.Charset) : String = java.lang.String(bytes, charset) as String
|
||||
|
||||
native public fun String(bytes : ByteArray, i : Int, i1 : Int) : String = java.lang.String(bytes, i, i1) as String
|
||||
|
||||
native public fun String(bytes : ByteArray) : String = java.lang.String(bytes) as String
|
||||
|
||||
native public fun String(chars : CharArray) : String = java.lang.String(chars) as String
|
||||
|
||||
native public fun String(stringBuffer : java.lang.StringBuffer) : String = java.lang.String(stringBuffer) as String
|
||||
|
||||
native public fun String(stringBuilder : java.lang.StringBuilder) : String = java.lang.String(stringBuilder) as String
|
||||
|
||||
native public fun String.replaceFirst(regex : String, replacement : String) : String = (this as java.lang.String).replaceFirst(regex, replacement).sure()
|
||||
|
||||
|
||||
native public fun String.split(regex : String, limit : Int) : Array<String?> = (this as java.lang.String).split(regex, limit).sure()
|
||||
|
||||
native public fun String.codePointAt(index : Int) : Int = (this as java.lang.String).codePointAt(index).sure()
|
||||
|
||||
native public fun String.codePointBefore(index : Int) : Int = (this as java.lang.String).codePointBefore(index).sure()
|
||||
|
||||
native public fun String.codePointCount(beginIndex : Int, endIndex : Int) : Int = (this as java.lang.String).codePointCount(beginIndex, endIndex)
|
||||
|
||||
native public fun String.compareToIgnoreCase(str : String) : Int = (this as java.lang.String).compareToIgnoreCase(str).sure()
|
||||
|
||||
|
||||
native public fun String.contentEquals(cs : CharSequence) : Boolean = (this as java.lang.String).contentEquals(cs).sure()
|
||||
|
||||
native public fun String.contentEquals(sb : StringBuffer) : Boolean = (this as java.lang.String).contentEquals(sb).sure()
|
||||
|
||||
native public fun String.getBytes(charset : java.nio.charset.Charset) : ByteArray = (this as java.lang.String).getBytes(charset).sure()
|
||||
|
||||
native public fun String.getBytes(charsetName : String) : ByteArray = (this as java.lang.String).getBytes(charsetName).sure()
|
||||
|
||||
native public fun String.getChars(srcBegin : Int, srcEnd : Int, dst : CharArray, dstBegin : Int) : Tuple0 = (this as java.lang.String).getChars(srcBegin, srcEnd, dst, dstBegin).sure()
|
||||
|
||||
native public fun String.intern() : String = (this as java.lang.String).intern().sure()
|
||||
|
||||
native public fun String.isEmpty() : Boolean = (this as java.lang.String).isEmpty().sure()
|
||||
|
||||
|
||||
native public fun String.offsetByCodePoints(index : Int, codePointOffset : Int) : Int = (this as java.lang.String).offsetByCodePoints(index, codePointOffset).sure()
|
||||
|
||||
native public fun String.regionMatches(ignoreCase : Boolean, toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(ignoreCase, toffset, other, ooffset, len).sure()
|
||||
|
||||
native public fun String.regionMatches(toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(toffset, other, ooffset, len).sure()
|
||||
|
||||
native public fun String.replace(target : CharSequence, replacement : CharSequence) : String = (this as java.lang.String).replace(target, replacement).sure()
|
||||
|
||||
native public fun String.subSequence(beginIndex : Int, endIndex : Int) : CharSequence = (this as java.lang.String).subSequence(beginIndex, endIndex).sure()
|
||||
|
||||
native public fun String.toLowerCase(locale : java.util.Locale) : String = (this as java.lang.String).toLowerCase(locale).sure()
|
||||
|
||||
native public fun String.toUpperCase(locale : java.util.Locale) : String = (this as java.lang.String).toUpperCase(locale).sure()
|
||||
|
||||
|
||||
native public fun CharSequence.charAt(index : Int) : Char = (this as java.lang.CharSequence).charAt(index)
|
||||
|
||||
native public fun CharSequence.get(index : Int) : Char = charAt(index)
|
||||
|
||||
native public fun CharSequence.subSequence(start : Int, end : Int) : CharSequence? = (this as java.lang.CharSequence).subSequence(start, end)
|
||||
|
||||
native public fun CharSequence.get(start : Int, end : Int) : CharSequence? = subSequence(start, end)
|
||||
|
||||
native public fun CharSequence.toString() : String? = (this as java.lang.CharSequence).toString()
|
||||
|
||||
native public fun String.toByteArray(encoding: String?=null):ByteArray {
|
||||
if(encoding==null) {
|
||||
return (this as java.lang.String).getBytes().sure()
|
||||
} else {
|
||||
return (this as java.lang.String).getBytes(encoding).sure()
|
||||
}
|
||||
}
|
||||
native public fun String.toByteArray(encoding: java.nio.charset.Charset):ByteArray = (this as java.lang.String).getBytes(encoding).sure()
|
||||
|
||||
native public fun String.toBoolean() : Boolean = java.lang.Boolean.parseBoolean(this).sure()
|
||||
native public fun String.toShort() : Short = java.lang.Short.parseShort(this).sure()
|
||||
native public fun String.toInt() : Int = java.lang.Integer.parseInt(this).sure()
|
||||
native public fun String.toLong() : Long = java.lang.Long.parseLong(this).sure()
|
||||
native public fun String.toFloat() : Float = java.lang.Float.parseFloat(this).sure()
|
||||
native public fun String.toDouble() : Double = java.lang.Double.parseDouble(this).sure()
|
||||
|
||||
native public fun String.toRegex(flags: Int=0): java.util.regex.Pattern {
|
||||
return java.util.regex.Pattern.compile(this, flags).sure()
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,60 @@
|
||||
package js
|
||||
|
||||
public inline fun String.lastIndexOf(ch : Char, fromIndex : Int) : Int = lastIndexOf(ch.toString(), fromIndex)
|
||||
public inline fun String.lastIndexOf(ch: Char) : Int = lastIndexOf(ch.toString())
|
||||
|
||||
public inline fun String.indexOf(ch : Char) : Int = indexOf(ch.toString())
|
||||
public inline fun String.indexOf(ch : Char, fromIndex : Int) : Int = indexOf(ch.toString(), fromIndex)
|
||||
|
||||
public inline fun String.matches(regex : String) : Boolean {
|
||||
val result = this.match(regex)
|
||||
return result != null && result.size > 0
|
||||
}
|
||||
|
||||
public inline fun String.length(): Int = length
|
||||
|
||||
inline val String.size : Int
|
||||
get() = length
|
||||
|
||||
public inline fun String.startsWith(ch: Char): Boolean {
|
||||
return if (size > 0) charAt(0) == ch else false
|
||||
}
|
||||
|
||||
public inline fun String.endsWith(ch: Char): Boolean {
|
||||
val s = size
|
||||
return if (s > 0) charAt(s - 1) == ch else false
|
||||
}
|
||||
|
||||
public inline fun String.startsWith(text: String): Boolean {
|
||||
val size = text.length
|
||||
return if (size <= this.length) {
|
||||
substring(0, size) == text
|
||||
} else false
|
||||
}
|
||||
|
||||
public inline fun String.endsWith(text: String): Boolean {
|
||||
val matchSize = text.length
|
||||
val thisSize = this.length
|
||||
return if (matchSize <= thisSize) {
|
||||
substring(thisSize - matchSize, thisSize) == text
|
||||
} else false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a copy of this string capitalised if it is not empty or already starting with an uppper case letter, otherwise returns this
|
||||
*
|
||||
* @includeFunctionBody ../../test/StringTest.kt capitalize
|
||||
*/
|
||||
public inline fun String.capitalize(): String {
|
||||
return if (notEmpty()) substring(0, 1).toUpperCase() + substring(1) else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of this string with the first letter lower case if it is not empty or already starting with a lower case letter, otherwise returns this
|
||||
*
|
||||
* @includeFunctionBody ../../test/StringTest.kt decapitalize
|
||||
*/
|
||||
public inline fun String.decapitalize(): String {
|
||||
return if (notEmpty()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package kotlin.dom
|
||||
|
||||
import org.w3c.dom.Document
|
||||
import org.w3c.dom.Node
|
||||
|
||||
fun createDocument(): Document {
|
||||
return browser.document.implementation.createDocument(null, null, null)
|
||||
}
|
||||
|
||||
native public val Node.outerHTML: String
|
||||
get() = js.noImpl
|
||||
|
||||
/** Converts the node to an XML String */
|
||||
public fun Node.toXmlString(xmlDeclaration: Boolean = false): String {
|
||||
return this.outerHTML
|
||||
}
|
||||
Reference in New Issue
Block a user