Changeset 524c375


Ignore:
Timestamp:
Oct 8, 2018 12:43:58 PM (22 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6fccfc9
Parents:
5041bb85
Message:

Data: Drop long-deprecated and unused boolean methods and related tests

Location:
core/java
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/DataHelper.java

    r5041bb85 r524c375  
    931931    }
    932932
    933     /** Read in a boolean as specified by the I2P data structure spec.
    934      * A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)
    935      * @param in stream to read from
    936      * @throws DataFormatException if the boolean is not valid
    937      * @throws IOException if there is an IO error reading the boolean
    938      * @return boolean value, or null
    939      * @deprecated unused
    940      */
    941     @Deprecated
    942     public static Boolean readBoolean(InputStream in) throws DataFormatException, IOException {
    943         int val = in.read();
    944         switch (val) {
    945         case -1:
    946             throw new EOFException("EOF reading boolean");
    947         case 0:
    948             return Boolean.FALSE;
    949         case 1:
    950             return Boolean.TRUE;
    951         case 2:
    952             return null;
    953         default:
    954             throw new DataFormatException("Uhhh.. readBoolean read a value that isn't a known ternary val (0,1,2): "
    955                                           + val);
    956         }
    957     }
    958 
    959     /** Write out a boolean as specified by the I2P data structure spec.
    960      * A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)
    961      * @param out stream to write to
    962      * @param bool boolean value, or null
    963      * @throws DataFormatException if the boolean is not valid
    964      * @throws IOException if there is an IO error writing the boolean
    965      * @deprecated unused
    966      */
    967     @Deprecated
    968     public static void writeBoolean(OutputStream out, Boolean bool)
    969         throws DataFormatException, IOException {
    970         if (bool == null)
    971             writeLong(out, 1, BOOLEAN_UNKNOWN);
    972         else if (Boolean.TRUE.equals(bool))
    973             writeLong(out, 1, BOOLEAN_TRUE);
    974         else
    975             writeLong(out, 1, BOOLEAN_FALSE);
    976     }
    977    
    978     /** @deprecated unused */
    979     @Deprecated
    980     public static Boolean fromBoolean(byte data[], int offset) {
    981         if (data[offset] == BOOLEAN_TRUE)
    982             return Boolean.TRUE;
    983         else if (data[offset] == BOOLEAN_FALSE)
    984             return Boolean.FALSE;
    985         else
    986             return null;
    987     }
    988    
    989     /** @deprecated unused */
    990     @Deprecated
    991     public static void toBoolean(byte data[], int offset, boolean value) {
    992         data[offset] = (value ? BOOLEAN_TRUE : BOOLEAN_FALSE);
    993     }
    994 
    995     /** @deprecated unused */
    996     @Deprecated
    997     public static void toBoolean(byte data[], int offset, Boolean value) {
    998         if (value == null)
    999             data[offset] = BOOLEAN_UNKNOWN;
    1000         else
    1001             data[offset] = (value.booleanValue() ? BOOLEAN_TRUE : BOOLEAN_FALSE);
    1002     }
    1003    
    1004     /** deprecated - used only in DatabaseLookupMessage */
    1005     public static final byte BOOLEAN_TRUE = 0x1;
    1006     /** deprecated - used only in DatabaseLookupMessage */
    1007     public static final byte BOOLEAN_FALSE = 0x0;
    1008     /** @deprecated unused */
    1009     @Deprecated
    1010     public static final byte BOOLEAN_UNKNOWN = 0x2;
    1011     /** @deprecated unused */
    1012     @Deprecated
    1013     public static final int BOOLEAN_LENGTH = 1;
    1014 
    1015933    //
    1016934    // The following comparator helpers make it simpler to write consistently comparing
  • core/java/test/junit/net/i2p/data/DataTestSuite.java

    r5041bb85 r524c375  
    77@Suite.SuiteClasses({
    88    Base64Test.class,
    9     BooleanTest.class,
    109    CertificateTest.class,
    1110    DataHelperTest.class,
Note: See TracChangeset for help on using the changeset viewer.