Browse Source

new version of MCSUTils

Wilfried Klaas 5 years ago
parent
commit
57de9c0a83
3 changed files with 48 additions and 46 deletions
  1. 4 4
      pom.xml
  2. 16 18
      src/main/java/de/mcs/utils/SoftHashMap.java
  3. 28 24
      src/main/java/de/mcs/utils/codecs/Base64.java

+ 4 - 4
pom.xml

@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>net.sourceforge.jmeasurement2</groupId>
 	<artifactId>MCSUtils</artifactId>
-	<version>1.0.151-SNAPSHOT</version>
+	<version>1.0.152</version>
 	<name>${project.groupId}:${project.artifactId}</name>
 	<description>Assorted utils for mcs java applications</description>
 	<url>http://www.wk-music.de</url>
@@ -26,9 +26,9 @@
 	</developers>
 
 	<scm>
-		<url>https://wkla.no-ip.biz/svn/MCS/java/MCSUtils/</url>
-		<connection>scm:svn:https://wkla.no-ip.biz/svn/MCS/java/MCSUtils/</connection>
-		<developerConnection>scm:svn:https://wkla.no-ip.biz/svn/MCS/java/MCSUtils/</developerConnection>
+		<url>https://wkla.no-ip.biz/gogs/Willie/MCSUtils/</url>
+		<connection>scm:git:https://wkla.no-ip.biz/gogs/Willie/MCSUtils.git/</connection>
+		<developerConnection>scm:svn:https://wkla.no-ip.biz/gogs/Willie/MCSUtils/</developerConnection>
 	</scm>
 
 	<properties>

+ 16 - 18
src/main/java/de/mcs/utils/SoftHashMap.java

@@ -41,16 +41,16 @@ public class SoftHashMap<K, V> extends AbstractMap<K, V> {
   private ReferenceQueue q = new ReferenceQueue();
 
   /**
-   * Constructs an empty <tt>HashMap</tt> with the default initial capacity (16)
-   * and the default load factor (0.75).
+   * Constructs an empty HashMap with the default initial capacity (16) and the
+   * default load factor (0.75).
    */
   public SoftHashMap() {
     m = new HashMap<K, Reference<V>>();
   }
 
   /**
-   * Constructs an empty <tt>HashMap</tt> with the specified initial capacity
-   * and the default load factor (0.75).
+   * Constructs an empty HashMap with the specified initial capacity and the
+   * default load factor (0.75).
    * 
    * @param initialCapacity
    *          the initial capacity.
@@ -60,8 +60,8 @@ public class SoftHashMap<K, V> extends AbstractMap<K, V> {
   }
 
   /**
-   * Constructs an empty <tt>HashMap</tt> with the specified initial capacity
-   * and load factor.
+   * Constructs an empty HashMap with the specified initial capacity and load
+   * factor.
    * 
    * @param initialCapacity
    *          The initial capacity.
@@ -73,23 +73,21 @@ public class SoftHashMap<K, V> extends AbstractMap<K, V> {
   }
 
   /**
-   * Returns the value to which this map maps the specified key. Returns
-   * <tt>null</tt> if the map contains no mapping for this key. A return value
-   * of <tt>null</tt> does not <i>necessarily</i> indicate that the map contains
-   * no mapping for the key; it's also possible that the map explicitly maps the
-   * key to <tt>null</tt>. The <tt>containsKey</tt> operation may be used to
-   * distinguish these two cases.
+   * Returns the value to which this map maps the specified key. Returns null if
+   * the map contains no mapping for this key. A return value of null does not
+   * <i>necessarily</i> indicate that the map contains no mapping for the key;
+   * it's also possible that the map explicitly maps the key to null. The
+   * containsKey operation may be used to distinguish these two cases.
    * 
    * <p>
-   * More formally, if this map contains a mapping from a key <tt>k</tt> to a
-   * value <tt>v</tt> such that <tt>(key==null ? k==null :
-   * key.equals(k))</tt>, then this method returns <tt>v</tt>; otherwise it
-   * returns <tt>null</tt>. (There can be at most one such mapping.)
+   * More formally, if this map contains a mapping from a key k to a value v
+   * such that (key==null ? k==null : key.equals(k)), then this method returns
+   * v; otherwise it returns null. (There can be at most one such mapping.)
    * 
    * @param key
    *          key whose associated value is to be returned.
-   * @return the value to which this map maps the specified key, or
-   *         <tt>null</tt> if the map contains no mapping for this key.
+   * @return the value to which this map maps the specified key, or null if the
+   *         map contains no mapping for this key.
    * 
    * @see #containsKey(Object)
    */

+ 28 - 24
src/main/java/de/mcs/utils/codecs/Base64.java

@@ -33,13 +33,13 @@ package de.mcs.utils.codecs;
  * everything is more consolidated and cleaner. The code now detects when data
  * that's being decoded is gzip-compressed and will decompress it automatically.
  * Generally things are cleaner. You'll probably have to change some method
- * calls that you were making to support the new options format (<tt>int</tt>s
- * that you "OR" together).</li>
+ * calls that you were making to support the new options format (int s that you
+ * "OR" together).</li>
  * <li>v1.5.1 - Fixed bug when decompressing and decoding to a byte[] using
- * <tt>decode( String s, boolean gzipCompressed )</tt>. Added the ability to
- * "suspend" encoding in the Output Stream so you can turn on and off the
- * encoding if you need to embed base64 data in an otherwise "normal" stream
- * (like an XML file).</li>
+ * decode( String s, boolean gzipCompressed ). Added the ability to "suspend"
+ * encoding in the Output Stream so you can turn on and off the encoding if you
+ * need to embed base64 data in an otherwise "normal" stream (like an XML
+ * file).</li>
  * <li>v1.5 - Output stream pases on flush() command but doesn't do anything
  * itself. This helps when using GZIP streams. Added the ability to
  * GZip-compress objects before encoding them.</li>
@@ -282,8 +282,8 @@ public final class Base64 {
   /**
    * Serializes an object and returns the Base64-encoded version of that
    * serialized object. If the object cannot be serialized or there is another
-   * error, the method will return <tt>null</tt>. The object is not
-   * GZip-compressed before being encoded.
+   * error, the method will return null. The object is not GZip-compressed
+   * before being encoded.
    * 
    * @param serializableObject
    *          The object to encode
@@ -297,7 +297,7 @@ public final class Base64 {
   /**
    * Serializes an object and returns the Base64-encoded version of that
    * serialized object. If the object cannot be serialized or there is another
-   * error, the method will return <tt>null</tt>.
+   * error, the method will return null.
    * <p>
    * Valid options:
    * 
@@ -746,7 +746,7 @@ public final class Base64 {
 
   /**
    * Attempts to decode Base64 data and deserialize a Java Object within.
-   * Returns <tt>null</tt> if there was an error.
+   * Returns null if there was an error.
    * 
    * @param encodedObject
    *          The Base64 data to decode
@@ -793,7 +793,7 @@ public final class Base64 {
    *          byte array of data to encode in base64 form
    * @param filename
    *          Filename for saving encoded data
-   * @return <tt>true</tt> if successful, <tt>false</tt> otherwise
+   * @return true if successful, false otherwise
    * @since 2.1
    */
   public static boolean encodeToFile(final byte[] dataToEncode, final String filename) {
@@ -823,7 +823,7 @@ public final class Base64 {
    *          Base64-encoded data as a string
    * @param filename
    *          Filename for saving decoded data
-   * @return <tt>true</tt> if successful, <tt>false</tt> otherwise
+   * @return true if successful, false otherwise
    * @since 2.1
    */
   public static boolean decodeToFile(final String dataToDecode, final String filename) {
@@ -871,7 +871,8 @@ public final class Base64 {
       buffer = new byte[(int) file.length()];
 
       // Open a stream
-      bis = new Base64.Base64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE);
+      bis = new Base64.Base64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)),
+          Base64.DECODE);
 
       // Read until done
       while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
@@ -913,7 +914,8 @@ public final class Base64 {
       int numBytes = 0;
 
       // Open a stream
-      bis = new Base64.Base64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.ENCODE);
+      bis = new Base64.Base64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)),
+          Base64.ENCODE);
 
       // Read until done
       while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
@@ -939,8 +941,8 @@ public final class Base64 {
 
   /**
    * A {@link Base64.Base64InputStream} will read data from another
-   * <tt>java.io.InputStream</tt>, given in the constructor, and encode/decode
-   * to/from Base64 notation on the fly.
+   * java.io.InputStream, given in the constructor, and encode/decode to/from
+   * Base64 notation on the fly.
    * 
    * @see Base64
    * @since 1.3
@@ -971,7 +973,7 @@ public final class Base64 {
      * Constructs a {@link Base64.Base64InputStream} in DECODE mode.
      * 
      * @param in
-     *          the <tt>java.io.InputStream</tt> from which to read data.
+     *          the java.io.InputStream from which to read data.
      * @since 1.3
      */
     public Base64InputStream(final java.io.InputStream in) {
@@ -979,7 +981,8 @@ public final class Base64 {
     } // end constructor
 
     /**
-     * Constructs a {@link Base64.Base64InputStream} in either ENCODE or DECODE mode.
+     * Constructs a {@link Base64.Base64InputStream} in either ENCODE or DECODE
+     * mode.
      * <p>
      * Valid options:
      * 
@@ -992,7 +995,7 @@ public final class Base64 {
      * Example: <code>new Base64.InputStream( in, Base64.DECODE )</code>
      * 
      * @param in
-     *          the <tt>java.io.InputStream</tt> from which to read data.
+     *          the java.io.InputStream from which to read data.
      * @param options
      *          Specified options
      * @see Base64#ENCODE
@@ -1155,8 +1158,8 @@ public final class Base64 {
 
   /**
    * A {@link Base64.Base64OutputStream} will write data to another
-   * <tt>java.io.OutputStream</tt>, given in the constructor, and encode/decode
-   * to/from Base64 notation on the fly.
+   * java.io.OutputStream, given in the constructor, and encode/decode to/from
+   * Base64 notation on the fly.
    * 
    * @see Base64
    * @since 1.3
@@ -1190,7 +1193,7 @@ public final class Base64 {
      * Constructs a {@link Base64.Base64OutputStream} in ENCODE mode.
      * 
      * @param out
-     *          the <tt>java.io.OutputStream</tt> to which data will be written.
+     *          the java.io.OutputStream to which data will be written.
      * @since 1.3
      */
     public Base64OutputStream(final java.io.OutputStream out) {
@@ -1198,7 +1201,8 @@ public final class Base64 {
     } // end constructor
 
     /**
-     * Constructs a {@link Base64.Base64OutputStream} in either ENCODE or DECODE mode.
+     * Constructs a {@link Base64.Base64OutputStream} in either ENCODE or DECODE
+     * mode.
      * <p>
      * Valid options:
      * 
@@ -1211,7 +1215,7 @@ public final class Base64 {
      * Example: <code>new Base64.OutputStream( out, Base64.ENCODE )</code>
      * 
      * @param out
-     *          the <tt>java.io.OutputStream</tt> to which data will be written.
+     *          the java.io.OutputStream to which data will be written.
      * @param options
      *          Specified options.
      * @see Base64#ENCODE