diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/text')
30 files changed, 38 insertions, 38 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/text/AbstractUtf8Array.java b/vespajlib/src/main/java/com/yahoo/text/AbstractUtf8Array.java index 62998621181..c266a03dd8f 100644 --- a/vespajlib/src/main/java/com/yahoo/text/AbstractUtf8Array.java +++ b/vespajlib/src/main/java/com/yahoo/text/AbstractUtf8Array.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.nio.ByteBuffer; diff --git a/vespajlib/src/main/java/com/yahoo/text/Ascii.java b/vespajlib/src/main/java/com/yahoo/text/Ascii.java index 9b9f8c8df46..471368b3987 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Ascii.java +++ b/vespajlib/src/main/java/com/yahoo/text/Ascii.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.ByteArrayOutputStream; diff --git a/vespajlib/src/main/java/com/yahoo/text/Ascii7BitMatcher.java b/vespajlib/src/main/java/com/yahoo/text/Ascii7BitMatcher.java index 85ecbaf140e..2e5993e0e05 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Ascii7BitMatcher.java +++ b/vespajlib/src/main/java/com/yahoo/text/Ascii7BitMatcher.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.util.BitSet; diff --git a/vespajlib/src/main/java/com/yahoo/text/BooleanParser.java b/vespajlib/src/main/java/com/yahoo/text/BooleanParser.java index 944872777d1..8677a6cd7c1 100644 --- a/vespajlib/src/main/java/com/yahoo/text/BooleanParser.java +++ b/vespajlib/src/main/java/com/yahoo/text/BooleanParser.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/CaseInsensitiveIdentifier.java b/vespajlib/src/main/java/com/yahoo/text/CaseInsensitiveIdentifier.java index d42db0250ec..52cd35d9508 100644 --- a/vespajlib/src/main/java/com/yahoo/text/CaseInsensitiveIdentifier.java +++ b/vespajlib/src/main/java/com/yahoo/text/CaseInsensitiveIdentifier.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/DataTypeIdentifier.java b/vespajlib/src/main/java/com/yahoo/text/DataTypeIdentifier.java index 3f64993c343..90e85cbb30c 100644 --- a/vespajlib/src/main/java/com/yahoo/text/DataTypeIdentifier.java +++ b/vespajlib/src/main/java/com/yahoo/text/DataTypeIdentifier.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/ExpressionFormatter.java b/vespajlib/src/main/java/com/yahoo/text/ExpressionFormatter.java index a56b7c8edb9..bc22a2aad24 100644 --- a/vespajlib/src/main/java/com/yahoo/text/ExpressionFormatter.java +++ b/vespajlib/src/main/java/com/yahoo/text/ExpressionFormatter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/ForwardWriter.java b/vespajlib/src/main/java/com/yahoo/text/ForwardWriter.java index aedf474359b..4b15d4f3699 100644 --- a/vespajlib/src/main/java/com/yahoo/text/ForwardWriter.java +++ b/vespajlib/src/main/java/com/yahoo/text/ForwardWriter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; diff --git a/vespajlib/src/main/java/com/yahoo/text/GenericWriter.java b/vespajlib/src/main/java/com/yahoo/text/GenericWriter.java index cc867c00ee2..697272b4ab5 100644 --- a/vespajlib/src/main/java/com/yahoo/text/GenericWriter.java +++ b/vespajlib/src/main/java/com/yahoo/text/GenericWriter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; diff --git a/vespajlib/src/main/java/com/yahoo/text/HTML.java b/vespajlib/src/main/java/com/yahoo/text/HTML.java index a983df4d970..4fc3a94f773 100644 --- a/vespajlib/src/main/java/com/yahoo/text/HTML.java +++ b/vespajlib/src/main/java/com/yahoo/text/HTML.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.util.Map; diff --git a/vespajlib/src/main/java/com/yahoo/text/Identifier.java b/vespajlib/src/main/java/com/yahoo/text/Identifier.java index 3ca61368fcb..323e32cdb4e 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Identifier.java +++ b/vespajlib/src/main/java/com/yahoo/text/Identifier.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/JSON.java b/vespajlib/src/main/java/com/yahoo/text/JSON.java index 8ef66b745cc..afb24928f60 100644 --- a/vespajlib/src/main/java/com/yahoo/text/JSON.java +++ b/vespajlib/src/main/java/com/yahoo/text/JSON.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import com.yahoo.slime.Slime; diff --git a/vespajlib/src/main/java/com/yahoo/text/JSONWriter.java b/vespajlib/src/main/java/com/yahoo/text/JSONWriter.java index 30746cf016c..20e84379d72 100644 --- a/vespajlib/src/main/java/com/yahoo/text/JSONWriter.java +++ b/vespajlib/src/main/java/com/yahoo/text/JSONWriter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; diff --git a/vespajlib/src/main/java/com/yahoo/text/JavaWriterWriter.java b/vespajlib/src/main/java/com/yahoo/text/JavaWriterWriter.java index 1edc1c06400..aa42bc52c0e 100644 --- a/vespajlib/src/main/java/com/yahoo/text/JavaWriterWriter.java +++ b/vespajlib/src/main/java/com/yahoo/text/JavaWriterWriter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; diff --git a/vespajlib/src/main/java/com/yahoo/text/Lowercase.java b/vespajlib/src/main/java/com/yahoo/text/Lowercase.java index 32cc7eec102..3f9e943d2c1 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Lowercase.java +++ b/vespajlib/src/main/java/com/yahoo/text/Lowercase.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.util.Locale; diff --git a/vespajlib/src/main/java/com/yahoo/text/LowercaseIdentifier.java b/vespajlib/src/main/java/com/yahoo/text/LowercaseIdentifier.java index 9b2d57df5eb..24a8370d6fb 100644 --- a/vespajlib/src/main/java/com/yahoo/text/LowercaseIdentifier.java +++ b/vespajlib/src/main/java/com/yahoo/text/LowercaseIdentifier.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/MapParser.java b/vespajlib/src/main/java/com/yahoo/text/MapParser.java index 9b40e3d90ad..5b1d93d651b 100644 --- a/vespajlib/src/main/java/com/yahoo/text/MapParser.java +++ b/vespajlib/src/main/java/com/yahoo/text/MapParser.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.util.HashMap; diff --git a/vespajlib/src/main/java/com/yahoo/text/PositionedString.java b/vespajlib/src/main/java/com/yahoo/text/PositionedString.java index aca0b7d1259..0cd459da493 100644 --- a/vespajlib/src/main/java/com/yahoo/text/PositionedString.java +++ b/vespajlib/src/main/java/com/yahoo/text/PositionedString.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java b/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java index 6724ae51a84..5eb04c58ade 100644 --- a/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java +++ b/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java b/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java index 1ab06954b39..025eeba3998 100644 --- a/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java +++ b/vespajlib/src/main/java/com/yahoo/text/StringUtilities.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.nio.charset.Charset; diff --git a/vespajlib/src/main/java/com/yahoo/text/Text.java b/vespajlib/src/main/java/com/yahoo/text/Text.java index a2e7a696857..fe931ef34a3 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Text.java +++ b/vespajlib/src/main/java/com/yahoo/text/Text.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.util.Locale; @@ -50,13 +50,12 @@ public final class Text { return (codepoint < 0x80) ? allowedAsciiChars[codepoint] - : (codepoint < Character.MIN_SURROGATE) || isTextCharAboveMinSurrogate(codepoint); + : (codepoint < Character.MIN_SURROGATE) || isTextCharAboveMinSurrogate(codepoint); } private static boolean isTextCharAboveMinSurrogate(int codepoint) { - if (codepoint <= Character.MAX_HIGH_SURROGATE) return false; + if (codepoint <= Character.MAX_SURROGATE) return false; if (codepoint < 0xFDD0) return true; if (codepoint <= 0xFDDF) return false; - if (codepoint < 0x10000) return true; if (codepoint >= 0x10FFFE) return false; return (codepoint & 0xffff) < 0xFFFE; } @@ -75,7 +74,7 @@ public final class Text { if (Character.isHighSurrogate(string.charAt(i))) { if ( charCount == 1) { return OptionalInt.of(string.codePointAt(i)); - } else if ( !Character.isLowSurrogate(string.charAt(i+1))) { + } else if ( ! Character.isLowSurrogate(string.charAt(i+1))) { return OptionalInt.of(string.codePointAt(i+1)); } } @@ -171,15 +170,15 @@ public final class Text { } /** - * Returns a string which is never larger than the given number of characters. + * Returns a string which is never larger than the given number of code points. * If the string is longer than the given length it will be truncated. * If length is 4 or less the string will be truncated to length. * If length is longer than 4, it will be truncated at length-4 with " ..." added at the end. */ public static String truncate(String s, int length) { - if (s.length() <= length) return s; - if (length <= 4) return s.substring(0, length); - return s.substring(0, length - 4) + " ..."; + if (s.codePointCount(0, s.length()) <= length) return s; + if (length <= 4) return substringByCodepoints(s, 0, length); + return substringByCodepoints(s, 0, length - 4) + " ..."; } public static String substringByCodepoints(String s, int fromCP, int toCP) { @@ -209,4 +208,5 @@ public final class Text { public static String format(String format, Object... args) { return String.format(Locale.US, format, args); } + } diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8.java b/vespajlib/src/main/java/com/yahoo/text/Utf8.java index 3a7ecaa727a..f69603a724c 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.IOException; diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8Array.java b/vespajlib/src/main/java/com/yahoo/text/Utf8Array.java index 2d881ea2f62..3ed1c93e43f 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8Array.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8Array.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.nio.ByteBuffer; diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java b/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java index 275335d3c2b..330991c18d3 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8String.java b/vespajlib/src/main/java/com/yahoo/text/Utf8String.java index b36f2933291..97c1826ddfc 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8String.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8String.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/XML.java b/vespajlib/src/main/java/com/yahoo/text/XML.java index c2b8a0b2289..a6e36a0c3e1 100644 --- a/vespajlib/src/main/java/com/yahoo/text/XML.java +++ b/vespajlib/src/main/java/com/yahoo/text/XML.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import org.w3c.dom.Document; diff --git a/vespajlib/src/main/java/com/yahoo/text/XMLWriter.java b/vespajlib/src/main/java/com/yahoo/text/XMLWriter.java index 6f0932514e6..fa47b109af8 100644 --- a/vespajlib/src/main/java/com/yahoo/text/XMLWriter.java +++ b/vespajlib/src/main/java/com/yahoo/text/XMLWriter.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text; import java.io.Writer; diff --git a/vespajlib/src/main/java/com/yahoo/text/internal/SnippetGenerator.java b/vespajlib/src/main/java/com/yahoo/text/internal/SnippetGenerator.java index a8263b999c7..157720e479a 100644 --- a/vespajlib/src/main/java/com/yahoo/text/internal/SnippetGenerator.java +++ b/vespajlib/src/main/java/com/yahoo/text/internal/SnippetGenerator.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.text.internal; /** diff --git a/vespajlib/src/main/java/com/yahoo/text/internal/package-info.java b/vespajlib/src/main/java/com/yahoo/text/internal/package-info.java index bbbf9238528..accfae02bfd 100644 --- a/vespajlib/src/main/java/com/yahoo/text/internal/package-info.java +++ b/vespajlib/src/main/java/com/yahoo/text/internal/package-info.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * @author mpolden */ diff --git a/vespajlib/src/main/java/com/yahoo/text/package-info.java b/vespajlib/src/main/java/com/yahoo/text/package-info.java index 70b892e55ae..9a150e67fab 100644 --- a/vespajlib/src/main/java/com/yahoo/text/package-info.java +++ b/vespajlib/src/main/java/com/yahoo/text/package-info.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. @ExportPackage @PublicApi package com.yahoo.text; |