Examples of BitString


Examples of org.apache.directory.api.asn1.util.BitString

     */
    @Test
    public void test33BitsBitString() throws DecoderException
    {

        BitString bitString = new BitString( 33 );

        bitString.setData( new byte[]
            { 0x07, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0x80 } );

        for ( int i = 0; i < 33; i++ )
        {
            assertEquals( true, bitString.getBit( i ) );
        }

        assertEquals( true, bitString.getBit( 32 ) );
    }
View Full Code Here

Examples of org.apache.directory.api.asn1.util.BitString

    @Test
    public void test0to128BitString() throws DecoderException
    {

        // bit number 14
        BitString bitString14 = new BitString( 14 );

        bitString14.setData( new byte[]
            { 0x02, ( byte ) 0xFF, ( byte ) 0xFC } );

        for ( int i = 0; i < 14; i++ )
        {
            assertEquals( true, bitString14.getBit( i ) );
        }

        // bit number 31
        BitString bitString31 = new BitString( 31 );

        bitString31.setData( new byte[]
            { 0x01, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFE } );

        for ( int i = 0; i < 31; i++ )
        {
            assertEquals( true, bitString31.getBit( i ) );
        }

        // bit number 128
        BitString bitString128 = new BitString( 128 );

        bitString128.setData( new byte[]
            { 0x00, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
                ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
                ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF } );

        for ( int i = 0; i < 128; i++ )
        {
            assertEquals( true, bitString128.getBit( i ) );
        }
    }
View Full Code Here

Examples of org.apache.directory.api.asn1.util.BitString


    @Test
    public void testBitStringSet()
    {
        BitString bitString = new BitString( 32 );

        byte[] bytes = new byte[]
            { 0x00, ( byte ) 0xAA, 0x11, ( byte ) 0x88, ( byte ) 0xFE };

        int[] bits = new int[]
            {
                1, 0, 1, 0, 1, 0, 1, 0,
                0, 0, 0, 1, 0, 0, 0, 1,
                1, 0, 0, 0, 1, 0, 0, 0,
                1, 1, 1, 1, 1, 1, 1, 0
        };

        for ( int i = 0; i < bits.length; i++ )
        {
            if ( bits[i] == 1 )
            {
                bitString.setBit( i );
            }
        }

        assertEquals( Asn1StringUtils.dumpBytes( bytes ), Asn1StringUtils.dumpBytes( bitString.getData() ) );
    }
View Full Code Here

Examples of org.apache.directory.api.asn1.util.BitString


    @Test
    public void testBitStringSetBit()
    {
        BitString bitString = new BitString( 32 );

        int[] bits = new int[]
            {
                1, 0, 1, 0, 1, 0, 1, 0,
                0, 0, 0, 1, 0, 0, 0, 1,
                1, 0, 0, 0, 1, 0, 0, 0, // After modification, will become 8A
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                0
        };

        for ( int i = 0; i < bits.length; i++ )
        {
            if ( bits[i] == 1 )
            {
                bitString.setBit( i );
            }
        }

        bitString.setBit( 9 );
        byte[] bytesModified = new byte[]
            { 0x00, ( byte ) 0xAA, 0x51, ( byte ) 0x88, ( byte ) 0xFE };

        assertEquals( Asn1StringUtils.dumpBytes( bytesModified ), Asn1StringUtils.dumpBytes( bitString.getData() ) );
    }
View Full Code Here

Examples of org.apache.directory.api.asn1.util.BitString


    @Test
    public void testBitStringClearBit()
    {
        BitString bitString = new BitString( 32 );

        int[] bits = new int[]
            {
                1, 0, 1, 0, 1, 0, 1, 0,
                0, 0, 0, 1, 0, 0, 0, 1,
                1, 0, 0, 0, 1, 0, 0, 0,
                1, 1, 1, 1, 1, 1, 1, 0
        };

        for ( int i = 0; i < bits.length; i++ )
        {
            if ( bits[i] == 1 )
            {
                bitString.setBit( i );
            }
        }

        bitString.clearBit( 11 );
        byte[] bytesModified = new byte[]
            { 0x00, ( byte ) 0xAA, 0x01, ( byte ) 0x88, ( byte ) 0xFE };

        assertEquals( Asn1StringUtils.dumpBytes( bytesModified ), Asn1StringUtils.dumpBytes( bitString.getData() ) );
    }
View Full Code Here

Examples of org.apache.directory.shared.asn1.util.BitString

   
    @Test
    public void testEncodeBitString()
    {
        BitString bs = new BitString( 10 );
        bs.setBit( 9 );
       
        ByteBuffer buffer = ByteBuffer.allocate( 5 );
       
        try
        {
View Full Code Here

Examples of org.apache.directory.shared.asn1.util.BitString

   
    @Test
    public void testEncodeBitString()
    {
        BitString bs = new BitString( 10 );
        bs.setBit( 9 );
       
        ByteBuffer buffer = ByteBuffer.allocate( 5 );
       
        try
        {
View Full Code Here

Examples of org.apache.harmony.security.asn1.BitString

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
View Full Code Here

Examples of org.apache.harmony.security.asn1.BitString

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

   
    // the label is not included in the conditions
    this.nbConditions = DataSet.getDataSet().getNbAttributes() - 1;
   
    weights = new double[nbConditions];
    operators = new BitString(nbConditions);
    values = new double[nbConditions];
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.