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

This commit is contained in:
zzz
2018-10-08 12:43:58 +00:00
parent 5041bb8531
commit 524c375944
3 changed files with 0 additions and 126 deletions

View File

@ -930,88 +930,6 @@ public class DataHelper {
}
}
/** Read in a boolean as specified by the I2P data structure spec.
* A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)
* @param in stream to read from
* @throws DataFormatException if the boolean is not valid
* @throws IOException if there is an IO error reading the boolean
* @return boolean value, or null
* @deprecated unused
*/
@Deprecated
public static Boolean readBoolean(InputStream in) throws DataFormatException, IOException {
int val = in.read();
switch (val) {
case -1:
throw new EOFException("EOF reading boolean");
case 0:
return Boolean.FALSE;
case 1:
return Boolean.TRUE;
case 2:
return null;
default:
throw new DataFormatException("Uhhh.. readBoolean read a value that isn't a known ternary val (0,1,2): "
+ val);
}
}
/** Write out a boolean as specified by the I2P data structure spec.
* A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)
* @param out stream to write to
* @param bool boolean value, or null
* @throws DataFormatException if the boolean is not valid
* @throws IOException if there is an IO error writing the boolean
* @deprecated unused
*/
@Deprecated
public static void writeBoolean(OutputStream out, Boolean bool)
throws DataFormatException, IOException {
if (bool == null)
writeLong(out, 1, BOOLEAN_UNKNOWN);
else if (Boolean.TRUE.equals(bool))
writeLong(out, 1, BOOLEAN_TRUE);
else
writeLong(out, 1, BOOLEAN_FALSE);
}
/** @deprecated unused */
@Deprecated
public static Boolean fromBoolean(byte data[], int offset) {
if (data[offset] == BOOLEAN_TRUE)
return Boolean.TRUE;
else if (data[offset] == BOOLEAN_FALSE)
return Boolean.FALSE;
else
return null;
}
/** @deprecated unused */
@Deprecated
public static void toBoolean(byte data[], int offset, boolean value) {
data[offset] = (value ? BOOLEAN_TRUE : BOOLEAN_FALSE);
}
/** @deprecated unused */
@Deprecated
public static void toBoolean(byte data[], int offset, Boolean value) {
if (value == null)
data[offset] = BOOLEAN_UNKNOWN;
else
data[offset] = (value.booleanValue() ? BOOLEAN_TRUE : BOOLEAN_FALSE);
}
/** deprecated - used only in DatabaseLookupMessage */
public static final byte BOOLEAN_TRUE = 0x1;
/** deprecated - used only in DatabaseLookupMessage */
public static final byte BOOLEAN_FALSE = 0x0;
/** @deprecated unused */
@Deprecated
public static final byte BOOLEAN_UNKNOWN = 0x2;
/** @deprecated unused */
@Deprecated
public static final int BOOLEAN_LENGTH = 1;
//
// The following comparator helpers make it simpler to write consistently comparing
// functions for objects based on their value, not JVM memory address

View File

@ -1,43 +0,0 @@
package net.i2p.data;
/*
* free (adj.): unencumbered; not under the control of others
* Written by jrandom in 2003 and released into the public domain
* with no warranty of any kind, either expressed or implied.
* It probably won't make your computer catch on fire, or eat
* your children, but it might. Use at your own risk.
*
*/
import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.junit.Test;
/**
* Test harness for the boolean structure
*
* @author jrandom
*/
public class BooleanTest {
@SuppressWarnings("deprecation")
@Test
public void testBoolean() throws Exception{
byte[] temp = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataHelper.writeBoolean(baos, Boolean.TRUE);
temp = baos.toByteArray();
Boolean b = null;
ByteArrayInputStream bais = new ByteArrayInputStream(temp);
b = DataHelper.readBoolean(bais);
assertEquals(Boolean.TRUE, b);
}
}

View File

@ -6,7 +6,6 @@ import org.junit.runner.RunWith;
@RunWith(Suite.class)
@Suite.SuiteClasses({
Base64Test.class,
BooleanTest.class,
CertificateTest.class,
DataHelperTest.class,
DataStructureImplTest.class,