This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit 8698e9d36ad0b1844cfb561cb82998ebde1ff88f Author: Andy Seaborne <[email protected]> AuthorDate: Tue Nov 11 16:39:03 2025 +0000 Remove deprecated classes, methods and functions (jena-base) --- .../java/org/apache/jena/atlas/io/PrintUtils.java | 29 ---- .../java/org/apache/jena/atlas/iterator/Iter.java | 12 -- .../apache/jena/atlas/iterator/NullIterator.java | 56 ------- .../main/java/org/apache/jena/atlas/lib/Cache.java | 17 --- .../org/apache/jena/atlas/lib/CacheFactory.java | 2 +- .../java/org/apache/jena/atlas/lib/ListUtils.java | 7 - .../org/apache/jena/atlas/lib/ProgressMonitor.java | 161 --------------------- .../apache/jena/atlas/lib/cache/CacheWrapper.java | 29 ++-- .../java/org/apache/jena/atlas/logging/LogCtl.java | 8 - .../tdb2/store/nodetable/ThreadBufferingCache.java | 22 --- 10 files changed, 12 insertions(+), 331 deletions(-) diff --git a/jena-base/src/main/java/org/apache/jena/atlas/io/PrintUtils.java b/jena-base/src/main/java/org/apache/jena/atlas/io/PrintUtils.java deleted file mode 100644 index 36f3535bcf..0000000000 --- a/jena-base/src/main/java/org/apache/jena/atlas/io/PrintUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.atlas.io; - -/** - * @deprecated Use {@link Printable#toString} - */ -@Deprecated(forRemoval = true) -public class PrintUtils { - public static String toString(Printable object) { - return Printable.toString(object); - } -} diff --git a/jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java b/jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java index e72c3d4608..e8ab211939 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java @@ -79,12 +79,6 @@ public class Iter<T> implements IteratorCloseable<T> { // ---- Special iterators. - /** @deprecated Use {@link #singletonIterator} */ - @Deprecated - public static <T> Iterator<T> singleton(T item) { - return singletonIterator(item); - } - public static <T> Iterator<T> singletonIterator(T item) { // There is a singleton iterator in Collections but it is not public. return new SingletonIterator<>(item); @@ -255,12 +249,6 @@ public class Iter<T> implements IteratorCloseable<T> { return filter(stream, filter.negate()); } - /** @deprecated Use {@link #filterDrop} */ - @Deprecated - public static <T> Iterator<T> notFilter(final Iterator<? extends T> stream, final Predicate<T> filter) { - return filterDrop(stream, filter); - } - // Filter-related private static final class IterFiltered<T> implements IteratorCloseable<T> { diff --git a/jena-base/src/main/java/org/apache/jena/atlas/iterator/NullIterator.java b/jena-base/src/main/java/org/apache/jena/atlas/iterator/NullIterator.java deleted file mode 100644 index cefdcd54ab..0000000000 --- a/jena-base/src/main/java/org/apache/jena/atlas/iterator/NullIterator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.atlas.iterator; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.function.Consumer; - -/** - * Null Iterator - also guaranteed shareable and immutable - * <p> - * @deprecated Use {@link Iter#nullIterator()}. - */ -@Deprecated -public class NullIterator<T> implements Iterator<T> { - - public static <X> NullIterator<X> create(){ return new NullIterator<>(); } - - private NullIterator() {} - - @Override - public boolean hasNext() { - return false; - } - - @Override - public T next() { - throw new NoSuchElementException("NullIterator.next"); - } - - @Override - public void forEachRemaining(Consumer<? super T> action) { - Objects.requireNonNull(action); - } - - @Override - public void remove() - { throw new UnsupportedOperationException("NullIterator.remove") ;} -} diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/Cache.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/Cache.java index ef6b177e93..7e97175fdd 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/Cache.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/Cache.java @@ -19,7 +19,6 @@ package org.apache.jena.atlas.lib; import java.util.Iterator ; -import java.util.concurrent.Callable ; import java.util.function.Function; import org.apache.jena.atlas.lib.cache.CacheInfo; @@ -49,22 +48,6 @@ public interface Cache<Key, Value> */ public Value getIfPresent(Key key) ; - /** Get from cache; if not present, call the {@link Callable} - * to try to fill the cache. This operation should be atomic. - * The 'key' and 'callcable' must not be null. - * @deprecated Use {@link #get(Object, Function)} - */ - @Deprecated(forRemoval = true) - public default Value getOrFill(Key key, Callable<Value> callable) { - return get(key, k->{ - try { - return callable.call(); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - } - /** * Get from cache; if not present, call the {@link Function} * to fill the cache slot. This operation should be atomic. diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/CacheFactory.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/CacheFactory.java index 6cc8ed9a1f..9d3c28abc4 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/CacheFactory.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/CacheFactory.java @@ -67,7 +67,7 @@ public class CacheFactory { * Create a null cache. * <p> * This cache never retains a value and always - * evaluates in {@link Cache#getOrFill}. + * evaluates in {@link Cache#get}. * <p> * This cache is thread-safe. */ diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java index 1eca2b5154..8c249cc442 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/ListUtils.java @@ -23,7 +23,6 @@ import static java.util.stream.Collectors.joining; import java.util.ArrayList ; import java.util.List ; -import java.util.stream.Stream; import org.apache.jena.atlas.io.IndentedWriter ; import org.apache.jena.atlas.logging.Log ; @@ -50,12 +49,6 @@ public class ListUtils return list.get(list.size()-1); } - /** @deprecated Call {@link Stream#toList} */ - @Deprecated(forRemoval = true) - public static <T> List<T> toList(Stream<T> stream) { - return stream.toList() ; - } - public static <T> String str(T[] array) { return stream(array).map(String::valueOf).collect(joining(", ", "[", "]")); } diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/ProgressMonitor.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/ProgressMonitor.java deleted file mode 100644 index c64c880897..0000000000 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/ProgressMonitor.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.atlas.lib; - -import static org.apache.jena.atlas.lib.DateTimeUtils.nowAsString ; - -import org.slf4j.Logger ; - -/** Progress monitor - output lines to show the progress of some long running operation. - * This is based on "ticks", not time. - * Once per item processed, call the {@link #tick()} operation. - * @deprecated Use RIOT's {@code org.apache.system.progress.ProgressMonitor}. - */ -@Deprecated(forRemoval = true) -public class ProgressMonitor { - @FunctionalInterface - public interface Output { - public void print(String fmt, Object... args); - } - - private final Output output; - private final long tickPoint; - private final int superTick; - private final Timer timer; - private final String label; - - private long counterBatch = 0; - private long counterTotal = 0; - - private long lastTime = 0; - - /** ProgressMonitor that outputs to a {@link Logger} */ - public static ProgressMonitor create(Logger log, String label, long tickPoint, int superTick) { - Output outputToLog = (fmt, args)-> { - if ( log != null && log.isInfoEnabled() ) { - String str = String.format(fmt, args); - log.info(str); - } - } ; - return new ProgressMonitor(label, tickPoint, superTick, outputToLog) ; - } - - /** - * @param label - * Label added to output strings. - * Usually related to the kind of things being monitored. - * e.g "tuples - * @param tickPoint - * Frequent of output messages - * @param superTick - * Frequent of "Elapsed" additional message - * @param output - * Function called to deal with progress messages. - */ - public ProgressMonitor(String label, long tickPoint, int superTick, Output output) { - this.output = output; - this.label = label; - this.tickPoint = tickPoint; - this.superTick = superTick; - this.timer = new Timer(); - } - - /** Print a start message using the label */ - public void startMessage() { - startMessage(null) ; - } - - /** Print a start message using a different string. */ - public void startMessage(String msg) { - if ( msg != null ) - output.print(msg) ; - else - output.print("Start: "+label) ; - } - - public void finishMessage() { - // Elapsed. - long timePoint = timer.getTimeInterval(); - - // *1000L is milli to second conversion - if ( timePoint != 0 ) { - double time = timePoint / 1000.0; - long runAvgRate = (counterTotal * 1000L) / timePoint; - - print("Finished: %,d %s %.2fs (Avg: %,d)", counterTotal, label, time, runAvgRate); - } else - print("Finished: %,d %s (Avg: ----)", counterTotal, label); - } - - public void start() { - timer.startTimer(); - lastTime = 0; - } - - public long finish() { - long totalTime = timer.endTimer(); - return totalTime; - } - - public long getTicks() { - return counterTotal; - } - - public void tick() { - counterBatch++; - counterTotal++; - - if ( tickPoint(counterTotal, tickPoint) ) { - long timePoint = timer.readTimer(); - long thisTime = timePoint - lastTime; - - // *1000L is milli to second conversion - if ( thisTime != 0 && timePoint != 0 ) { - long batchAvgRate = (counterBatch * 1000L) / thisTime; - long runAvgRate = (counterTotal * 1000L) / timePoint; - print("Add: %,d %s (Batch: %,d / Avg: %,d)", counterTotal, label, batchAvgRate, runAvgRate); - } else { - print("Add: %,d %s (Batch: ---- / Avg: ----)", counterTotal, label); - } - - lastTime = timePoint; - - if ( tickPoint(counterTotal, superTick * tickPoint) ) - elapsed(timePoint); - counterBatch = 0; - lastTime = timePoint; - } - } - - protected void elapsed(long timerReading) { - float elapsedSecs = timerReading / 1000F; - print(" Elapsed: %,.2f seconds [%s]", elapsedSecs, nowAsString()); - } - - /** Print a message */ - private void print(String fmt, Object... args) { - if ( output != null ) - output.print(fmt, args); - } - - static boolean tickPoint(long counter, long quantum) { - return counter % quantum == 0; - } - -} diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/cache/CacheWrapper.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/cache/CacheWrapper.java index 5dcaf2d3bd..9e7bfcb595 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/cache/CacheWrapper.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/cache/CacheWrapper.java @@ -18,49 +18,42 @@ package org.apache.jena.atlas.lib.cache; import java.util.Iterator ; -import java.util.concurrent.Callable ; import java.util.function.Function; import org.apache.jena.atlas.lib.Cache ; - - public class CacheWrapper<Key,T> implements Cache<Key,T> { - protected Cache<Key,T> cache ; + private final Cache<Key,T> cache ; public CacheWrapper(Cache<Key,T> cache) { this.cache = cache ; } + protected final Cache<Key,T> get() { return cache; } @Override - public void clear() { cache.clear(); } + public void clear() { get().clear(); } @Override - public boolean containsKey(Key key) { return cache.containsKey(key) ; } + public boolean containsKey(Key key) { return get().containsKey(key) ; } @Override - public T getIfPresent(Key key) { return cache.getIfPresent(key) ; } + public T getIfPresent(Key key) { return get().getIfPresent(key) ; } - @SuppressWarnings("removal") @Override - public T getOrFill(Key key, Callable<T> callable) { return cache.getOrFill(key, callable) ; } - - @Override - public T get(Key key, Function<Key, T> fucntion) { return cache.get(key, fucntion) ; } - + public T get(Key key, Function<Key, T> fucntion) { return get().get(key, fucntion) ; } @Override - public boolean isEmpty() { return cache.isEmpty() ; } + public boolean isEmpty() { return get().isEmpty() ; } @Override - public Iterator<Key> keys() { return cache.keys(); } + public Iterator<Key> keys() { return get().keys(); } @Override - public void put(Key key, T thing) { cache.put(key, thing) ; } + public void put(Key key, T thing) { get().put(key, thing) ; } @Override - public void remove(Key key) { cache.remove(key) ; } + public void remove(Key key) { get().remove(key) ; } @Override - public long size() { return cache.size() ; } + public long size() { return get().size() ; } } diff --git a/jena-base/src/main/java/org/apache/jena/atlas/logging/LogCtl.java b/jena-base/src/main/java/org/apache/jena/atlas/logging/LogCtl.java index 4a71107c9b..206e362b2f 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/logging/LogCtl.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/logging/LogCtl.java @@ -236,14 +236,6 @@ public class LogCtl { } } - /** - * @deprecated Use {@link #setLogging}. - */ - @Deprecated(forRemoval = true) - public static void setCmdLogging() { - setLogging(); - } - // ---- log4j2. /** The log4j2 configuration file - must be a file or URL, not a classpath java resource. */ diff --git a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/nodetable/ThreadBufferingCache.java b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/nodetable/ThreadBufferingCache.java index c1681cc2c5..3b802a6558 100644 --- a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/nodetable/ThreadBufferingCache.java +++ b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/nodetable/ThreadBufferingCache.java @@ -19,7 +19,6 @@ package org.apache.jena.tdb2.store.nodetable; import java.util.Iterator; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; @@ -136,27 +135,6 @@ public class ThreadBufferingCache<Key,Value> implements Cache<Key,Value> { return baseCache.getIfPresent(key); } - @SuppressWarnings("removal") - @Override - public Value getOrFill(Key key, Callable<Value> callable) { - if ( ! buffering() ) - return baseCache.getOrFill(key, callable); - // Not thread safe but this overlay cache is for single-thread use. - Value item = localCache().getIfPresent(key); - if ( item != null ) - return item; - item = baseCache.getIfPresent(key); - if ( item != null ) - return item; - try { - item = callable.call(); - localCache().put(key, item); - } catch (Exception ex) { - throw new TDBException("Exception filling cache", ex); - } - return item; - } - @Override public Value get(Key key, Function<Key, Value> provider) { if ( ! buffering() )
