All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.eac.Flags Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
/***************************************************************/
/******    DO NOT EDIT THIS CLASS bc-java SOURCE FILE     ******/
/***************************************************************/
package org.bouncycastle.asn1.eac;

import java.util.Enumeration;
import java.util.Hashtable;


public class Flags
{

    int value = 0;

    public Flags()
    {

    }

    public Flags(int v)
    {
        value = v;
    }

    public void set(int flag)
    {
        value |= flag;
    }

    public boolean isSet(int flag)
    {
        return (value & flag) != 0;
    }

    public int getFlags()
    {
        return value;
    }

    /* Java 1.5
     String decode(Map decodeMap)
     {
         StringJoiner joiner = new StringJoiner(" ");
         for (int i : decodeMap.keySet())
         {
             if (isSet(i))
                 joiner.add(decodeMap.get(i));
         }
         return joiner.toString();
     }
     */

    String decode(Hashtable decodeMap)
    {
        StringJoiner joiner = new StringJoiner(" ");
        Enumeration e = decodeMap.keys();
        while (e.hasMoreElements())
        {
            Integer i = (Integer)e.nextElement();
            if (isSet(i.intValue()))
            {
                joiner.add((String)decodeMap.get(i));
            }
        }
        return joiner.toString();
    }

    private static class StringJoiner
    {

        String mSeparator;
        boolean First = true;
        StringBuffer b = new StringBuffer();

        public StringJoiner(String separator)
        {
            mSeparator = separator;
        }

        public void add(String str)
        {
            if (First)
            {
                First = false;
            }
            else
            {
                b.append(mSeparator);
            }

            b.append(str);
        }

        public String toString()
        {
            return b.toString();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy