Example usage for java.util Hashtable Hashtable

List of usage examples for java.util Hashtable Hashtable

Introduction

In this page you can find the example usage for java.util Hashtable Hashtable.

Prototype

public Hashtable() 

Source Link

Document

Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).

Usage

From source file:algorithm.OpenStegoRandomLSBSteganographyTest.java

@Test
public void openStegoRandomLsbSteganographyAlgorithmTest() {
    try {//ww w. ja v  a 2 s  .  c  o  m
        File carrier = TestDataProvider.PNG_FILE;
        File payload = TestDataProvider.TXT_FILE;
        OpenStegoRandomLSBSteganography algorithm = new OpenStegoRandomLSBSteganography();

        // Test encapsulation:
        List<File> payloadList = new ArrayList<File>();
        payloadList.add(payload);
        File outputFile = algorithm.encapsulate(carrier, payloadList);
        assertNotNull(outputFile);
        // Test restore:
        Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>();
        for (RestoredFile file : algorithm.restore(outputFile)) {
            outputHash.put(file.getName(), file);
        }
        assertEquals(outputHash.size(), 2);
        RestoredFile restoredCarrier = outputHash.get(carrier.getName());
        RestoredFile restoredPayload = outputHash.get(payload.getName());
        assertNotNull(restoredCarrier);
        assertNotNull(restoredPayload);
        // can only restore original payload with this algorithm, not
        // carrier!
        assertEquals(FileUtils.checksumCRC32(payload), FileUtils.checksumCRC32(restoredPayload));

        // check restoration metadata:
        assertEquals("" + carrier.getAbsolutePath(), restoredCarrier.originalFilePath);
        assertEquals("" + payload.getAbsolutePath(), restoredPayload.originalFilePath);
        assertEquals(algorithm, restoredCarrier.algorithm);
        // This can't be true for steganography algorithms:
        // assertTrue(restoredCarrier.checksumValid);
        assertTrue(restoredPayload.checksumValid);
        assertTrue(restoredCarrier.wasCarrier);
        assertFalse(restoredCarrier.wasPayload);
        assertTrue(restoredPayload.wasPayload);
        assertFalse(restoredPayload.wasCarrier);
        assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload));
        assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier));
        assertTrue(restoredPayload.relatedFiles.contains(restoredCarrier));
        assertFalse(restoredPayload.relatedFiles.contains(restoredPayload));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:de.tud.inf.db.sparqlytics.bench.LDBCBenchmark.java

@BeforeClass
public static void bindRepository() throws Exception {
    SPARQLyticsParser parser = new SPARQLyticsParser(
            new InputStreamReader(LDBCBenchmark.class.getResourceAsStream("ldbc-snb-bi-repository.sparqlytics"),
                    StandardCharsets.UTF_8));
    parser.Start();//from w  w  w .j  ava 2  s.  c  o m
    Repository repository = parser.getRepository();
    Slf4jReporter.forRegistry(repository.getStatistics()).withLoggingLevel(Slf4jReporter.LoggingLevel.INFO)
            .prefixedWith("before:").build().report();
    //Set system properties Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL in pom.xml
    new InitialContext(new Hashtable<Object, Object>()).bind("ldbc", repository);
}

From source file:com.alfaariss.oa.engine.user.provisioning.translator.standard.converter.ConverterManager.java

/**
  * Creates the object.//  w w w.  j  ava  2 s. c om
 * @param oConfigurationManager the configuration manager
 * @param eConfig the configuration section with configuration of this object
 * @throws UserException if converting fails
 */
public ConverterManager(IConfigurationManager oConfigurationManager, Element eConfig) throws UserException {
    _htConverters = new Hashtable<String, IConverter>();
    try {
        _logger = LogFactory.getLog(ConverterManager.class);

        Element eConverter = oConfigurationManager.getSection(eConfig, "converter");
        if (eConverter == null) {
            _logger.error("No 'converter' section found in configuration");
            throw new UserException(SystemErrors.ERROR_CONFIG_READ);
        }

        while (eConverter != null) {
            String sConverterID = oConfigurationManager.getParam(eConverter, "id");
            if (sConverterID == null) {
                _logger.error("No 'id' parameter found in 'converter' section");
                throw new UserException(SystemErrors.ERROR_CONFIG_READ);
            }

            if (_htConverters.containsKey(sConverterID)) {
                StringBuffer sbError = new StringBuffer("The converter with id '");
                sbError.append(sConverterID);
                sbError.append("' is not unique");

                _logger.error(sbError.toString());

                throw new UserException(SystemErrors.ERROR_INIT);
            }

            String sConverterClass = oConfigurationManager.getParam(eConverter, "class");
            if (sConverterClass == null) {
                _logger.error("No 'class' parameter found in 'converter' section with id: " + sConverterID);
                throw new UserException(SystemErrors.ERROR_CONFIG_READ);
            }

            if (sConverterClass.startsWith("."))
                sConverterClass = PACKAGENAME + sConverterClass;

            Class oConverterClass = null;
            try {
                oConverterClass = Class.forName(sConverterClass);
            } catch (Exception e) {
                _logger.error("No 'class' found with name: " + sConverterClass, e);
                throw new UserException(SystemErrors.ERROR_INIT);
            }

            IConverter oConverter = null;
            try {
                oConverter = (IConverter) oConverterClass.newInstance();
            } catch (Exception e) {
                _logger.error(
                        "Could not create an 'IConverter' instance of the configured 'class' found with name: "
                                + sConverterClass,
                        e);
                throw new UserException(SystemErrors.ERROR_INIT);
            }

            oConverter.start(oConfigurationManager, eConverter);

            _htConverters.put(sConverterID, oConverter);

            eConverter = oConfigurationManager.getNextSection(eConverter);
        }
    } catch (UserException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Could not initialize object", e);
        throw new UserException(SystemErrors.ERROR_INTERNAL);
    }
}

From source file:org.eclipse.virgo.ide.runtime.internal.core.command.AbstractJmxServerCommand.java

private JMXConnector getJmxConnector() throws IOException {
    Hashtable<String, Object> h = new Hashtable<String, Object>();
    //      String username = behaviour.getDmServer().getDeployerUsername();
    //      String password = behaviour.getDmServer().getDeployerPassword();
    //      if (StringUtils.hasText(username)) {
    //         String[] credentials = new String[] { username, password };
    //         h.put(JMX_REMOTE_CREDENTIALS, credentials);
    //      }/*ww w. j a  v a  2 s .c  o m*/
    Server server = ServerUtils.getServer(serverBehaviour);

    if (serverBehaviour.getMBeanServerIp() == null) {
        throw new IOException("MBean server not open for connection");
    }
    String connectorUrl = String.format(JMX_CONNECTOR_URL, serverBehaviour.getMBeanServerIp(),
            server.getMBeanServerPort());
    return JMXConnectorFactory.connect(new JMXServiceURL(connectorUrl), h);
}

From source file:com.alfaariss.oa.engine.idp.storage.configuration.AbstractConfigurationStorage.java

/**
 * Constructor. //from   w ww. j  ava2  s .co m
 */
public AbstractConfigurationStorage() {
    _htIDPs = new Hashtable<String, IDP>();
    _listIDPs = new Vector<IIDP>();
}

From source file:algorithm.ZipPackagingTest.java

@Test
public void zipPackagingTest() {
    try {/* w ww  . j  a  v  a  2 s .c o m*/
        File carrier = TestDataProvider.TXT_FILE;
        File payload1 = TestDataProvider.TXT_FILE_2;
        File payload2 = TestDataProvider.XML_FILE;
        List<File> payloadList = new ArrayList<File>();
        payloadList.add(payload1);
        payloadList.add(payload2);

        ZipPackaging algorithm = new ZipPackaging();
        // Test encapsulation:
        File outputFile = algorithm.encapsulate(carrier, payloadList);
        assertNotNull(outputFile);
        // Test restore:
        Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>();
        for (RestoredFile file : algorithm.restore(outputFile)) {
            outputHash.put(file.getName(), file);
        }
        assertEquals(3, outputHash.size());
        RestoredFile restoredCarrier = outputHash.get(carrier.getName());
        RestoredFile restoredPayload1 = outputHash.get(payload1.getName());
        RestoredFile restoredPayload2 = outputHash.get(payload2.getName());
        assertNotNull(restoredCarrier);
        assertNotNull(restoredPayload1);
        assertNotNull(restoredPayload2);
        assertEquals(FileUtils.checksumCRC32(carrier), FileUtils.checksumCRC32(restoredCarrier));
        assertEquals(FileUtils.checksumCRC32(payload1), FileUtils.checksumCRC32(restoredPayload1));
        assertEquals(FileUtils.checksumCRC32(payload2), FileUtils.checksumCRC32(restoredPayload2));

        // check restoration metadata:
        // (algorithm doesn't save original file paths)
        assertEquals(algorithm, restoredCarrier.algorithm);
        assertTrue(restoredCarrier.checksumValid);
        assertTrue(restoredPayload1.checksumValid);
        assertTrue(restoredPayload2.checksumValid);
        // every file in a zip package is payload!:
        assertTrue(restoredCarrier.wasPayload);
        assertFalse(restoredCarrier.wasCarrier);
        assertTrue(restoredPayload1.wasPayload);
        assertFalse(restoredPayload1.wasCarrier);
        assertTrue(restoredPayload2.wasPayload);
        assertFalse(restoredPayload2.wasCarrier);
        assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload1));
        assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload2));
        assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier));
        assertTrue(restoredPayload1.relatedFiles.contains(restoredCarrier));
        assertTrue(restoredPayload1.relatedFiles.contains(restoredPayload2));
        assertFalse(restoredPayload1.relatedFiles.contains(restoredPayload1));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.alfaariss.oa.authentication.password.AbstractPasswordHandler.java

/**
 * Constructor. Must be called by its children.
 *///from   ww w  .j  a v  a  2s .  co  m
public AbstractPasswordHandler() {
    _resourceHandlers = new Hashtable<String, IResourceHandler>();
    _logger = LogFactory.getLog(this.getClass());
}

From source file:com.panet.imeta.trans.steps.exceloutput.ExcelOutputData.java

/**
 * //from w  ww  .  ja  v a 2s .  co  m
 */
public ExcelOutputData() {
    super();

    formats = new Hashtable<String, WritableCellFormat>();
    oneFileOpened = false;
    file = null;
    realSheetname = null;
    headerWrote = false;
}

From source file:com.alfaariss.oa.engine.core.idp.IDPStorageManager.java

/**
 * Default constructor. 
 */
public IDPStorageManager() {
    _htStorages = new Hashtable<String, IIDPStorage>();
}

From source file:io.pivotal.poc.gemfire.gtx.jndi.SimpleNamingContext.java

/**
 * Create a new naming context with the given naming root.
 */// ww  w  . j  a va2 s . c o  m
public SimpleNamingContext(String root) {
    this.root = root;
    this.boundObjects = new Hashtable<String, Object>();
}