From 45e530dceda42282fae56b4c4f5fa7865f57899d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 4 Jun 2016 16:03:56 +0100 Subject: Remove dotnet (use submodule from dotnet repo instead) --- .../mammoth/internal/docx/InMemoryDocxFile.cs | 13 --- .../mammoth/internal/docx/ZippedDocxFile.cs | 30 ------ .../internal/styles/parsing/LineParseException.cs | 15 --- .../internal/styles/parsing/ParseException.cs | 8 -- .../internal/styles/parsing/StyleMapParser.cs | 22 ----- .../mammoth/internal/util/Base64Encoding.cs | 18 ---- .../Couscous/mammoth/internal/util/Casts.cs | 13 --- .../Couscous/mammoth/internal/util/Iterables.cs | 60 ----------- .../Couscous/mammoth/internal/util/Lists.cs | 97 ------------------ .../Mammoth/Couscous/mammoth/internal/util/Maps.cs | 110 --------------------- .../mammoth/internal/util/PassThroughException.cs | 29 ------ .../Couscous/mammoth/internal/util/Paths.cs | 8 -- .../Mammoth/Couscous/mammoth/internal/util/Sets.cs | 18 ---- .../Couscous/mammoth/internal/util/Strings.cs | 18 ---- .../mammoth/internal/xml/parsing/SimpleSax.cs | 42 -------- 15 files changed, 501 deletions(-) delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs (limited to 'dotnet/Mammoth/Couscous/mammoth') diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs deleted file mode 100644 index 9b7efd0..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; -using System.IO; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { - internal class InMemoryDocxFile { - internal static DocxFile fromStream(InputStream stream) { - var memoryStream = new MemoryStream(); - stream.Stream.CopyTo(memoryStream); - return new ZippedDocxFile(memoryStream); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs deleted file mode 100644 index cf39e63..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO.Compression; -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { - internal class ZippedDocxFile : DocxFile { - private readonly ZipArchive _zipFile; - - internal ZippedDocxFile(File file) { - _zipFile = ZipFile.OpenRead(file.Path); - } - - internal ZippedDocxFile(System.IO.Stream stream) { - _zipFile = new ZipArchive(stream); - } - - public Optional tryGetInputStream(string name) { - var entry = _zipFile.GetEntry(name); - if (entry == null) { - return Optional.empty(); - } else { - return Optional.of(ToJava.StreamToInputStream(entry.Open())); - } - } - - public void close() { - _zipFile.Dispose(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs deleted file mode 100644 index 6ca9381..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal class LineParseException : RuntimeException { - private readonly Token _token; - - internal LineParseException(Token token, string message) : base(message) { - _token = token; - } - - internal Token getToken() { - return _token; - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs deleted file mode 100644 index 73f349c..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal class ParseException : RuntimeException { - internal ParseException(string message) : base(message) { - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs deleted file mode 100644 index 53315f3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.styles; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal static class StyleMapParser { - internal static StyleMap parseStyleMappings(List mappings) { - return DefaultStyleMap(); - } - - internal static StyleMap parse(string styleMap) { - return DefaultStyleMap(); - } - - private static StyleMap DefaultStyleMap() { - return StyleMap.builder() - - .mapParagraph(ParagraphMatcher.styleName("Normal"), HtmlPath.element("p")) - - .build(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs deleted file mode 100644 index 24d2f9c..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Base64Encoding { - internal static string streamToBase64(SupplierWithException streamSupplier) { - using (var stream = streamSupplier.get().Stream) { - return streamToBase64(stream); - } - } - - internal static string streamToBase64(System.IO.Stream stream) { - var memoryStream = new System.IO.MemoryStream(); - stream.CopyTo(memoryStream); - return System.Convert.ToBase64String(memoryStream.ToArray()); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs deleted file mode 100644 index c342e20..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mammoth.Couscous.java.util; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Casts { - internal static Optional tryCast(System.Type type, object value) { - if (value is T) { - return new Some((T) value); - } else { - return new None(); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs deleted file mode 100644 index b1e1477..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.util.function; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Iterables - { - internal static T getFirst(Iterable iterable, T defaultValue) { - var iterator = iterable.iterator(); - if (iterator.hasNext()) { - return iterator.next(); - } else { - return defaultValue; - } - } - - internal static Optional tryFind(Iterable iterable, Predicate predicate) { - var iterator = iterable.iterator(); - while (iterator.hasNext()) { - T value = iterator.next(); - if (predicate.test(value)) { - return new Some(value); - } - } - return new None(); - } - - internal static Iterable lazyFilter(Iterable iterable, Predicate predicate) { - var enumerable = FromJava.IterableToEnumerable(iterable).Where(predicate.test); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable lazyFilter(Iterable iterable, System.Type type) { - var enumerable = FromJava.IterableToEnumerable(iterable).OfType(); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable lazyMap(Iterable iterable, Function function) { - var enumerable = FromJava.IterableToEnumerable(iterable) - .Select(function.apply); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable lazyFlatMap(Iterable iterable, Function> function) { - var enumerable = FromJava.IterableToEnumerable(iterable) - .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable lazyConcat(Iterable first, Iterable second) { - var enumerable = FromJava.IterableToEnumerable(first) - .Concat(FromJava.IterableToEnumerable(second)); - return ToJava.EnumerableToIterable(enumerable); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs deleted file mode 100644 index b914a34..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.util.function; -using System.Linq; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Lists { - internal static List list(params T[] values) { - return ToJava.ListToList(values); - } - - internal static List toList(Iterable iterable) { - return ToJava.ListToList(FromJava.IterableToEnumerable(iterable).ToList()); - } - - internal static List eagerMap(Iterable iterable, Function function) { - var result = FromJava.IterableToEnumerable(iterable) - .Select(function.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List eagerFlatMap(Iterable iterable, Function> function) { - var result = FromJava.IterableToEnumerable(iterable) - .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List cons(T head, Iterable tail) { - var result = new T[] { head } - .Concat(FromJava.IterableToEnumerable(tail)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List eagerConcat(Iterable first, Iterable second) { - var result = FromJava.IterableToEnumerable(first) - .Concat(FromJava.IterableToEnumerable(second)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List orderedBy(Iterable iterable, Function getKey) { - var result = FromJava.IterableToEnumerable(iterable) - .OrderBy(getKey.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static Optional tryGetLast(List list) { - if (list.isEmpty()) { - return new None(); - } else { - return new Some(list.get(list.size() - 1)); - } - } - - internal static Iterable reversed(List list) { - return new ReversedList(list); - } - - private class ReversedList : Iterable { - private readonly List _list; - - internal ReversedList(List list) { - _list = list; - } - - public Iterator iterator() { - return new ReverseIterator(_list); - } - } - - private class ReverseIterator : Iterator { - private readonly List _list; - private int _nextIndex; - - internal ReverseIterator(List list) { - _list = list; - _nextIndex = _list.size() - 1; - } - - public bool hasNext() { - return _nextIndex >= 0; - } - - public T next() { - if (hasNext()) { - return _list.get(_nextIndex--); - } else { - throw new NoSuchElementException(); - } - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs deleted file mode 100644 index bee2dac..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Linq; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util.function; -using Mammoth.Couscous; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Maps - { - internal static Map map() { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary()); - } - - internal static Map map(K key1, V value1) { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary { - {key1, value1} - }); - } - - internal static Map map(K key1, V value1, K key2, V value2) { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary { - {key1, value1}, - {key2, value2} - }); - } - - internal static Map toMap(Iterable iterable, Function> function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .Select(function.apply) - .ToDictionary(entry => entry.getKey(), entry => entry.getValue()); - return ToJava.DictionaryToMap(dictionary); - - } - - internal static Map toMapWithKey(Iterable iterable, Function function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .ToDictionary(function.apply); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map> toMultiMapWithKey(Iterable iterable, Function function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .GroupBy(value => function.apply(value)) - .ToDictionary( - grouping => grouping.Key, - grouping => ToJava.ListToList(grouping.ToList())); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Optional lookup(Map map, K key) { - return map._lookup(key); - } - - internal static Map eagerMapKeys(Map map, Function function) { - var dictionary = FromJava.MapToDictionary(map) - .ToDictionary( - entry => function.apply(entry.Key), - entry => entry.Value); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map eagerMapValues(Map map, Function function) { - var dictionary = FromJava.MapToDictionary(map) - .ToDictionary( - entry => entry.Key, - entry => function.apply(entry.Value)); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map__Entry entry(K key, V value) { - return new Entry(key, value); - } - - private class Entry : Map__Entry { - private readonly K _key; - private readonly V _value; - - internal Entry(K key, V value) { - this._key = key; - this._value = value; - } - - public K getKey() { - return _key; - } - - public V getValue() { - return _value; - } - } - - internal static Builder builder() { - return new Builder(); - } - - internal class Builder { - private readonly System.Collections.Generic.IDictionary _values = new System.Collections.Generic.Dictionary(); - - internal Builder put(K key, V value) { - _values[key] = value; - return this; - } - - internal Map build() { - return ToJava.DictionaryToMap(_values); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs deleted file mode 100644 index 88597e3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal class PassThroughException : RuntimeException { - internal static T wrap(SupplierWithException supplier) { - try { - return supplier.get(); - } catch (IOException exception) { - throw new PassThroughException(exception); - } - } - - internal static T unwrap(SupplierWithException supplier) { - try { - return supplier.get(); - } catch (PassThroughException exception) { - throw exception._exception; - } - } - - private readonly IOException _exception; - - internal PassThroughException(IOException exception) { - _exception = exception; - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs deleted file mode 100644 index ca876eb..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Paths { - internal static string getExtension(string path) { - int dotIndex = path.LastIndexOf('.'); - return dotIndex == -1 ? "" : path.Substring(dotIndex + 1); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs deleted file mode 100644 index bfce619..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.nio.file; -using System; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Sets { - internal static Set set(T[] values) { - return new HashSet(new System.Collections.Generic.HashSet(values)); - } - - internal static Set toSet(Iterable iterable) { - return new HashSet(new System.Collections.Generic.HashSet(FromJava.IterableToEnumerable(iterable))); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs deleted file mode 100644 index 65f5e0b..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Strings { - internal static string trimLeft(string value, int character) { - int index = 0; - while (index < value.Length && value[index] == character) { - index++; - } - return value.Substring(index); - } - - internal static bool isNullOrEmpty(string value) { - return string.IsNullOrEmpty(value); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs b/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs deleted file mode 100644 index 65f63c3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; -using System.Xml; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { - internal static class SimpleSax { - internal static void parseStream(InputStream input, SimpleSaxHandler handler) { - var reader = XmlReader.Create(input.Stream); - while (reader.Read()) { - switch (reader.NodeType) { - case XmlNodeType.Element: - var name = new ElementName(reader.NamespaceURI, reader.LocalName); - var attributes = new HashMap(); - var isEmpty = reader.IsEmptyElement; - for (int attributeIndex = 0; attributeIndex < reader.AttributeCount; attributeIndex++) { - reader.MoveToAttribute(attributeIndex); - attributes.put(new ElementName(reader.NamespaceURI, reader.LocalName), reader.Value); - } - handler.startElement(name, attributes); - if (isEmpty) { - handler.endElement(); - } - break; - case XmlNodeType.CDATA: - case XmlNodeType.Text: - case XmlNodeType.SignificantWhitespace: - handler.characters(reader.Value); - break; - case XmlNodeType.EntityReference: - throw new System.NotImplementedException(); - case XmlNodeType.EndElement: - handler.endElement(); - break; - } - } - } - - internal static void parseString(string value, SimpleSaxHandler handler) { - throw new System.NotImplementedException(); - } - } -} -- cgit v1.2.3