diff --git a/stdlib/ktSrc/Filter.kt b/stdlib/ktSrc/Filter.kt index 5113ab38486..c0a15369b75 100644 --- a/stdlib/ktSrc/Filter.kt +++ b/stdlib/ktSrc/Filter.kt @@ -3,14 +3,10 @@ package kotlin import java.util.* import java.lang.Iterable -/* -Filters given iterator -*/ +/** Filters given iterator */ inline fun java.util.Iterator.filter(f: (T)-> Boolean) : java.util.Iterator = FilterIterator(this, f) -/* -Create iterator filtering given java.lang.Iterable -*/ +/** Create iterator filtering given java.lang.Iterable */ /* inline fun java.lang.Iterable.filter(f: (T)->Boolean) : java.util.Iterator = (iterator() as java.util.Iterator).filter(f) */ diff --git a/stdlib/ktSrc/Iterators.kt b/stdlib/ktSrc/Iterators.kt index 76ea351421e..8350e149e34 100644 --- a/stdlib/ktSrc/Iterators.kt +++ b/stdlib/ktSrc/Iterators.kt @@ -3,36 +3,24 @@ package kotlin.util import java.util.* import java.util.Iterator -/* -Add iterated elements to given container -*/ +/** Add iterated elements to given container */ fun > java.util.Iterator.to(container: U) : U { while(hasNext()) container.add(next()) return container } -/* -Add iterated elements to java.util.ArrayList -*/ +/** Add iterated elements to java.util.ArrayList */ inline fun java.util.Iterator.toArrayList() = to(ArrayList()) -/* -Add iterated elements to java.util.LinkedList -*/ +/** Add iterated elements to java.util.LinkedList */ inline fun java.util.Iterator.toLinkedList() = to(LinkedList()) -/* -Add iterated elements to java.util.HashSet -*/ +/** Add iterated elements to java.util.HashSet */ inline fun java.util.Iterator.toHashSet() = to(HashSet()) -/* -Add iterated elements to java.util.LinkedHashSet -*/ +/** Add iterated elements to java.util.LinkedHashSet */ inline fun java.util.Iterator.toLinkedHashSet() = to(LinkedHashSet()) -/* -Add iterated elements to java.util.TreeSet -*/ +/** Add iterated elements to java.util.TreeSet */ inline fun java.util.Iterator.toTreeSet() = to(TreeSet()) diff --git a/stdlib/ktSrc/JavaIterables.kt b/stdlib/ktSrc/JavaIterables.kt index 0248153abd6..529da9d4220 100644 --- a/stdlib/ktSrc/JavaIterables.kt +++ b/stdlib/ktSrc/JavaIterables.kt @@ -147,23 +147,23 @@ inline fun java.lang.Iterable.reverse() : List { return answer } -/* Copies the collection into the given collection */ +/** Copies the collection into the given collection */ inline fun > java.lang.Iterable.to(result: C) : C { for (elem in this) result.add(elem) return result } -/* Converts the collection into a LinkedList */ +/** Converts the collection into a LinkedList */ inline fun java.lang.Iterable.toLinkedList() : LinkedList = this.to(LinkedList()) -/* Converts the collection into a List */ +/** Converts the collection into a List */ inline fun java.lang.Iterable.toList() : List = this.to(ArrayList()) -/* Converts the collection into a Set */ +/** Converts the collection into a Set */ inline fun java.lang.Iterable.toSet() : Set = this.to(HashSet()) -/* Converts the collection into a SortedSet */ +/** Converts the collection into a SortedSet */ inline fun java.lang.Iterable.toSortedSet() : SortedSet = this.to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) diff --git a/stdlib/ktSrc/Standard.kt b/stdlib/ktSrc/Standard.kt index b0dfaa84efa..c575a484de6 100644 --- a/stdlib/ktSrc/Standard.kt +++ b/stdlib/ktSrc/Standard.kt @@ -7,17 +7,17 @@ import java.util.HashSet import java.util.LinkedHashSet import java.util.TreeSet -/* +/** Helper to make jet.Iterator usable in for */ inline fun jet.Iterator.iterator() = this -/* +/** Helper to make java.util.Iterator usable in for */ inline fun java.util.Iterator.iterator() = this -/* +/** Helper to make java.util.Enumeration usable in for */ fun java.util.Enumeration.iterator(): Iterator = object: Iterator { @@ -31,7 +31,7 @@ fun java.util.Enumeration.iterator(): Iterator = object: Iterat * Extension functions on the standard Kotlin types to behave like the java.lang.* and java.util.* collections */ -/* +/** Add iterated elements to given container */ fun > Iterator.to(container: U) : U { @@ -40,32 +40,32 @@ fun > Iterator.to(container: U) : U { return container } -/* +/** Add iterated elements to java.util.ArrayList */ inline fun Iterator.toArrayList() = to(ArrayList()) -/* +/** Add iterated elements to java.util.LinkedList */ inline fun Iterator.toLinkedList() = to(LinkedList()) -/* +/** Add iterated elements to java.util.HashSet */ inline fun Iterator.toHashSet() = to(HashSet()) -/* +/** Add iterated elements to java.util.LinkedHashSet */ inline fun Iterator.toLinkedHashSet() = to(LinkedHashSet()) -/* +/** Add iterated elements to java.util.TreeSet */ inline fun Iterator.toTreeSet() = to(TreeSet()) -/* +/** Run function f */ inline fun run(f: () -> T) = f() diff --git a/stdlib/ktSrc/String.kt b/stdlib/ktSrc/String.kt index dd38871b0d8..a707b4caffb 100644 --- a/stdlib/ktSrc/String.kt +++ b/stdlib/ktSrc/String.kt @@ -99,7 +99,7 @@ inline fun String(stringBuilder : java.lang.StringBuilder) = java.lang.String(st /** Returns true if the string is not null and not empty */ inline fun String?.notEmpty() : Boolean = this != null && this.length() > 0 -/* +/** Iterator for characters of given CharSequence */ inline fun CharSequence.iterator() : CharIterator = object: jet.CharIterator() { diff --git a/stdlib/ktSrc/concurrent/Locks.kt b/stdlib/ktSrc/concurrent/Locks.kt index 36d174b7bd8..39d4609ea84 100644 --- a/stdlib/ktSrc/concurrent/Locks.kt +++ b/stdlib/ktSrc/concurrent/Locks.kt @@ -5,7 +5,7 @@ import java.util.concurrent.locks.ReadWriteLock import java.util.concurrent.locks.ReentrantReadWriteLock import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock -/* +/** Executes given calculation under lock Returns result of the calculation */ @@ -19,7 +19,7 @@ inline fun Lock.withLock(action: ()->T) : T { } } -/* +/** Executes given calculation under read lock Returns result of the calculation */ @@ -34,7 +34,7 @@ inline fun ReentrantReadWriteLock.read(action: ()->T) : T { } } -/* +/** Executes given calculation under write lock. The method does upgrade from read to write lock if needed If such write has been initiated by checking some condition, the condition must be rechecked inside the action to avoid possible races diff --git a/stdlib/ktSrc/dom/Dom.kt b/stdlib/ktSrc/dom/Dom.kt index 10316768927..e925b51d5d2 100644 --- a/stdlib/ktSrc/dom/Dom.kt +++ b/stdlib/ktSrc/dom/Dom.kt @@ -267,6 +267,7 @@ inline fun NodeList?.toElementList(): List { } } +/** Converts the node list to an XML String */ fun NodeList?.toXmlString(xmlDeclaration: Boolean = false): String { return if (this == null) "" else { @@ -353,7 +354,7 @@ fun Node.ownerDocument(doc: Document? = null): Document { } } -/* +/** Adds a newly created element which can be configured via a function */ fun Document.addElement(name: String, init: Element.()-> Unit): Element { @@ -362,7 +363,7 @@ fun Document.addElement(name: String, init: Element.()-> Unit): Element { return child } -/* +/** Adds a newly created element to an element which has an owner Document which can be configured via a function */ fun Element.addElement(name: String, doc: Document? = null, init: Element.()-> Unit): Element { @@ -371,7 +372,7 @@ fun Element.addElement(name: String, doc: Document? = null, init: Element.()-> U return child } -/* +/** Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter */ fun Element.addText(text: String?, doc: Document? = null): Element { diff --git a/stdlib/ktSrc/dom/DomJVM.kt b/stdlib/ktSrc/dom/DomJVM.kt index cd0b283a16f..31f6373e6f3 100644 --- a/stdlib/ktSrc/dom/DomJVM.kt +++ b/stdlib/ktSrc/dom/DomJVM.kt @@ -18,14 +18,17 @@ import java.lang.Iterable import java.util.List import java.util.Collection +/** Creates a new document with the given document builder*/ fun createDocument(builder: DocumentBuilder): Document { return builder.newDocument().sure() } +/** Creates a new document with an optional DocumentBuilderFactory */ fun createDocument(builderFactory: DocumentBuilderFactory = DocumentBuilderFactory.newInstance().sure()): Document { return createDocument(builderFactory.newDocumentBuilder().sure()) } +/** Creates a new TrAX transformer */ fun createTransformer(source: Source? = null, factory: TransformerFactory = TransformerFactory.newInstance().sure()): Transformer { val transformer = if (source != null) { factory.newTransformer(source) @@ -35,10 +38,12 @@ fun createTransformer(source: Source? = null, factory: TransformerFactory = Tran return transformer.sure() } +/** Converts the node to an XML String */ fun Node.toXmlString(xmlDeclaration: Boolean = this is Document): String { return nodeToXmlString(this, xmlDeclaration) } +/** Converts the collection of nodes to an XML String */ fun java.lang.Iterable.toXmlString(xmlDeclaration: Boolean = false): String { // TODO this should work... // return this.map{it.toXmlString()}.join("") @@ -56,6 +61,7 @@ fun Document.toXmlString(xmlDeclaration: Boolean = true): String { } */ +/** Converts the node to an XML String */ fun nodeToXmlString(node: Node, xmlDeclaration: Boolean): String { val transformer = createTransformer() transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, if (xmlDeclaration) "no" else "yes") diff --git a/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt b/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt index fe57720f022..6859637d6f4 100644 --- a/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt +++ b/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt @@ -150,23 +150,23 @@ inline fun Array.reverse() : List { return answer } -/* Copies the collection into the given collection */ +/** Copies the collection into the given collection */ inline fun > Array.to(result: C) : C { for (elem in this) result.add(elem) return result } -/* Converts the collection into a LinkedList */ +/** Converts the collection into a LinkedList */ inline fun Array.toLinkedList() : LinkedList = this.to(LinkedList()) -/* Converts the collection into a List */ +/** Converts the collection into a List */ inline fun Array.toList() : List = this.to(ArrayList()) -/* Converts the collection into a Set */ +/** Converts the collection into a Set */ inline fun Array.toSet() : Set = this.to(HashSet()) -/* Converts the collection into a SortedSet */ +/** Converts the collection into a SortedSet */ inline fun Array.toSortedSet() : SortedSet = this.to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) diff --git a/stdlib/ktSrc/generated/StandardFromJavaIterables.kt b/stdlib/ktSrc/generated/StandardFromJavaIterables.kt index 3e324d54c3d..478edeb0a75 100644 --- a/stdlib/ktSrc/generated/StandardFromJavaIterables.kt +++ b/stdlib/ktSrc/generated/StandardFromJavaIterables.kt @@ -150,23 +150,23 @@ inline fun Iterable.reverse() : List { return answer } -/* Copies the collection into the given collection */ +/** Copies the collection into the given collection */ inline fun > Iterable.to(result: C) : C { for (elem in this) result.add(elem) return result } -/* Converts the collection into a LinkedList */ +/** Converts the collection into a LinkedList */ inline fun Iterable.toLinkedList() : LinkedList = this.to(LinkedList()) -/* Converts the collection into a List */ +/** Converts the collection into a List */ inline fun Iterable.toList() : List = this.to(ArrayList()) -/* Converts the collection into a Set */ +/** Converts the collection into a Set */ inline fun Iterable.toSet() : Set = this.to(HashSet()) -/* Converts the collection into a SortedSet */ +/** Converts the collection into a SortedSet */ inline fun Iterable.toSortedSet() : SortedSet = this.to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :)