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:edu.ku.brc.specify.ui.AttachmentIconMapper.java

/**
 * Create an instance./* ww w. ja va 2 s  .co  m*/
 */
public AttachmentIconMapper() {
    thumbnailCache = new Hashtable<Attachment, ImageIcon>();
    thumbGenStarted = new Vector<Attachment>();
}

From source file:gsn.vsensor.RVirtualSensor.java

public boolean initialize() {
    params = getVirtualSensorConfiguration().getMainClassInitialParams();

    circularBuffers = new Hashtable<String, ArrayBlockingQueue<StreamElement>>();
    // Get the parameters from the XML configuration file

    String param = null;//from   w  w  w.  j a v a 2s.  c  o  m
    param = params.get(WINDOW_SIZE);

    if (param != null) {
        windowSize = Integer.parseInt(param);
    } else {
        logger.error("The required parameter: >" + WINDOW_SIZE
                + "<+ is missing.from the virtual sensor configuration file.");
        return false;
    }

    param = params.get("script_type");
    if (param != null) {
        stype = param;
    } else {
        stype = "computation";
    }

    param = params.get(STEP_SIZE);

    if (param != null) {
        stepSize = Integer.parseInt(param);
    } else {
        logger.error("The required parameter: >" + STEP_SIZE
                + "<+ is missing.from the virtual sensor configuration file.");
        return false;
    }

    if (windowSize < stepSize) {
        logger.error(
                "The parameter " + WINDOW_SIZE + " must be greater or equal to the parameter " + STEP_SIZE);
        return false;
    }

    return true;
}

From source file:com.cyberway.issue.crawler.datamodel.ServerCache.java

/**
 * This constructor creates a ServerCache that is all memory-based using
 * Hashtables.  Used for unit testing only
 * (Use {@link #ServerCache(CrawlController)} when crawling).
 * @param sh/*w ww .j  a  v a  2  s  . c  o  m*/
 * @throws Exception
 */
public ServerCache(final SettingsHandler sh) throws Exception {
    this.settingsHandler = sh;
    this.servers = new Hashtable<String, CrawlServer>();
    this.hosts = new Hashtable<String, CrawlHost>();
}

From source file:de.ingrid.iplug.ckan.index.mapper.ScriptedDocumentMapper.java

@Override
public synchronized void map(SourceRecord record, ElasticDocument doc) throws Exception {
    if (mappingScripts == null) {
        log.error("Mapping script(s) not set!");
        throw new IllegalArgumentException("Mapping script(s) not set!");
    }/*from   ww  w  .  ja v a 2s.c  om*/
    try {
        // create utils for script
        IndexUtils idxUtils = new IndexUtils(doc);

        Map<String, Object> parameters = new Hashtable<String, Object>();
        parameters.put("sourceRecord", record.get("json"));
        parameters.put("luceneDoc", doc);
        parameters.put("log", log);
        parameters.put("IDX", idxUtils);
        parameters.put("javaVersion", System.getProperty("java.version"));

        ScriptEngine.execute(this.mappingScripts, parameters, compile);
    } catch (Exception e) {
        log.error("Error mapping source record to lucene document.", e);
        throw e;
    }
}

From source file:autohit.vm.VMLoader.java

/**
 * Default Constructor.//from   ww  w  . ja va2s . co m
 */
public VMLoader() {
    if (cache == null)
        cache = new Hashtable();
    corefactory = new VMCoreFactory();
}

From source file:edu.ku.brc.af.ui.forms.MenuSwitcherPanel.java

/**
 * @param mvParentArg//from ww  w  .j  a  va  2 s .  c o  m
 * @param viewArg
 * @param altViewArg
 * @param altViewsListArg
 */
public MenuSwitcherPanel(final MultiView mvParent, final AltViewIFace altView,
        final Vector<AltViewIFace> altViewsList) {
    super();
    setOpaque(false);

    switcherHash = new Hashtable<String, DropDownButtonStateful>();
    selectorValHash = new Hashtable<String, Vector<AltViewIFace>>();

    isSelector = StringUtils.isNotEmpty(altView.getSelectorName());

    if (isSelector) {
        setLayout(cardLayout = new CardLayout());
        for (AltViewIFace av : altViewsList) {
            Vector<AltViewIFace> avList = selectorValHash.get(av.getSelectorValue());
            if (avList == null) {
                avList = new Vector<AltViewIFace>();
                selectorValHash.put(av.getSelectorValue(), avList);
            }
            avList.add(av);
        }

        for (String selectorVal : selectorValHash.keySet()) {
            Vector<AltViewIFace> avList = selectorValHash.get(selectorVal);
            DropDownButtonStateful switcherUI = createSwitcher(mvParent, avList);
            switcherUI.setOpaque(false);
            add(switcherUI, selectorVal);
            switcherHash.put(selectorVal, switcherUI);
        }

    } else {
        setLayout(new BorderLayout());
        DropDownButtonStateful switcherUI = createSwitcher(mvParent, altViewsList);
        switcherUI.setOpaque(false);
        add(switcherUI, BorderLayout.CENTER);
        switcherHash.put("0", switcherUI);
        selectorValHash.put("0", altViewsList);
    }
}

From source file:hd.controller.AddImageToIdeaBookServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from   w w  w  . ja  va2  s . c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html; charset=UTF-8");

    PrintWriter out = response.getWriter();
    try {
        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
        if (!isMultipart) { //to do

        } else {
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List items = null;
            try {
                items = upload.parseRequest(request);

            } catch (FileUploadException e) {
                e.printStackTrace();
            }
            Iterator iter = items.iterator();
            Hashtable params = new Hashtable();

            String fileName = null;
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField()) {
                    params.put(item.getFieldName(), item.getString("UTF-8"));

                } else if (!item.isFormField()) {
                    try {
                        long time = System.currentTimeMillis();
                        String itemName = item.getName();
                        fileName = time + itemName.substring(itemName.lastIndexOf("\\") + 1);

                        String RealPath = getServletContext().getRealPath("/") + "images\\" + fileName;

                        File savedFile = new File(RealPath);
                        item.write(savedFile);

                        String localPath = "D:\\Project\\TestHouseDecor-Merge\\web\\images\\" + fileName;
                        //                            savedFile = new File(localPath);
                        //                            item.write(savedFile);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }

            String ideaBookIdTemp = (String) params.get("txtIdeabookId");
            int ideaBookId = Integer.parseInt(ideaBookIdTemp);
            IdeaBookDAO ideabookDao = new IdeaBookDAO();

            String tilte = (String) params.get("newGalleryName");

            String description = (String) params.get("GalleryDescription");
            String url = "images/" + fileName;

            IdeaBookPhotoDAO photoDAO = new IdeaBookPhotoDAO();
            IdeaBookPhoto ideaBookPhoto = photoDAO.insertIdeaBookPhoto(tilte, description, url, ideaBookId);

            HDSystem system = new HDSystem();
            system.setNotificationIdeaBook(request);
            response.sendRedirect("MyIdeaBookDetailServlet?txtIdeabookId=" + ideaBookId);

        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        out.close();
    }
}

From source file:libra.core.kmersimilarity_m.KmerSimilarityMapper.java

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    this.libraConfig = CoreConfig.createInstance(context.getConfiguration());
    this.fileMapping = KmerMatchFileMapping.createInstance(context.getConfiguration());

    this.idCacheTable = new Hashtable<String, Integer>();

    this.reportCounter = context.getCounter("KmerSimilarity", "report");
    this.serializer = new JsonSerializer();

    this.valuesLen = this.fileMapping.getSize();
    this.scoreAccumulated = new double[this.valuesLen * this.valuesLen];
    for (int i = 0; i < this.scoreAccumulated.length; i++) {
        this.scoreAccumulated[i] = 0;
    }/*w ww.j  a  v  a  2s  . c om*/

    this.tfConsineNormBase = new double[this.valuesLen];
    for (int i = 0; i < this.tfConsineNormBase.length; i++) {
        // fill tfConsineNormBase
        String fastaFilename = this.fileMapping.getFastaFileFromID(i);
        String statisticsFilename = KmerStatisticsHelper.makeKmerStatisticsFileName(fastaFilename);
        Path statisticsPath = new Path(this.libraConfig.getKmerStatisticsPath(), statisticsFilename);
        FileSystem fs = statisticsPath.getFileSystem(context.getConfiguration());

        KmerStatistics statistics = KmerStatistics.createInstance(fs, statisticsPath);

        this.tfConsineNormBase[i] = statistics.getTFCosineNormBase();
    }
}

From source file:com.sshtools.j2ssh.util.DynamicClassLoader.java

/**
 * Creates a new DynamicClassLoader object.
 *
 * @param parent//w  w  w.  j  a v  a  2  s . com
 * @param classpath
 *
 * @throws IllegalArgumentException
 */
public DynamicClassLoader(ClassLoader parent, List classpath) throws IllegalArgumentException {
    this.parent = parent;

    // Create the cache to hold the loaded classes
    cache = new Hashtable();

    Iterator it = classpath.iterator();

    while (it.hasNext()) {
        Object obj = it.next();
        File f = null;

        if (obj instanceof String) {
            f = new File((String) obj);
        } else if (obj instanceof File) {
            f = (File) obj;
        } else {
            throw new IllegalArgumentException("Entries in classpath must be either a String or File object");
        }

        if (!f.exists()) {
            throw new IllegalArgumentException("Classpath " + f.getAbsolutePath() + " doesn't exist!");
        } else if (!f.canRead()) {
            throw new IllegalArgumentException("Don't have read access for file " + f.getAbsolutePath());
        }

        // Check that it is a directory or jar file
        if (!(f.isDirectory() || isJarArchive(f))) {
            throw new IllegalArgumentException(f.getAbsolutePath() + " is not a directory or jar file"
                    + " or if it's a jar file then it is corrupted.");
        }

        this.classpath.add(f);
    }

    // Increment and store generation counter
    this.generation = generationCounter++;
}

From source file:com.marklogic.samplestack.integration.web.LDAPIT.java

@Before
public void setup() throws NamingException {
    env = new Hashtable<String, Object>();
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    if (ldapUsername != null) {
        env.put(Context.SECURITY_PRINCIPAL, ldapUsername);
    }//from w  w  w.j  av a2 s  .com
    if (ldapPassword != null) {
        env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
    }
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, ldapServer);

    // ensures that objectSID attribute values
    // will be returned as a byte[] instead of a String
    // env.put("java.naming.ldap.attributes.binary", "uid");

    // the following is helpful in debugging errors
    //env.put("com.sun.jndi.ldap.trace.ber", System.err);

    ctx = new InitialLdapContext(env, null);

}