Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:fedora.server.security.servletfilters.ldap.FilterLdap.java

private Hashtable getEnvironment(String userid, String password) {
    String m = FilterSetup.getFilterNameAbbrev(FILTER_NAME) + " getEnvironment() ";
    Hashtable env = null;

    try {//from   ww w .j  a  v  a  2  s .c  o m
        env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        if (VERSION != null && !"".equals(VERSION)) {
            log.debug(m + "ldap explicit version==" + VERSION);
            env.put(CONTEXT_VERSION_KEY, VERSION);
        }
        log.debug(m + "ldap version==" + env.get(CONTEXT_VERSION_KEY));

        env.put(Context.PROVIDER_URL, URL);
        log.debug(m + "ldap url==" + env.get(Context.PROVIDER_URL));

        if (!bindRequired()) {
            log.debug(m + "\"binding\" anonymously");
        } else {
            env.put(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);

            String userForBind = null;
            String passwordForBind = null;
            if (!individualUserBind()) {
                userForBind = SECURITY_PRINCIPAL;
                passwordForBind = SECURITY_CREDENTIALS;
                log.debug(m + "binding to protected directory");
            } else {
                passwordForBind = password;
                if (SECURITY_PRINCIPAL == null || "".equals(SECURITY_PRINCIPAL)) {
                    userForBind = userid;
                    log.debug(m + "binding for real user");
                } else {
                    //simulate test against user-bind at directory server
                    userForBind = SECURITY_PRINCIPAL;
                    log.debug(m + "binding for --test-- user");
                }
            }
            env.put(Context.SECURITY_CREDENTIALS, passwordForBind);
            String[] parms = { userForBind };
            String userFormattedForBind = applyFilter(BIND_FILTER, parms);
            env.put(Context.SECURITY_PRINCIPAL, userFormattedForBind);
        }
        log.debug(m + "bind w " + env.get(Context.SECURITY_AUTHENTICATION));
        log.debug(m + "user== " + env.get(Context.SECURITY_PRINCIPAL));
        log.debug(m + "passwd==" + env.get(Context.SECURITY_CREDENTIALS));
    } catch (Throwable th) {
        if (LOG_STACK_TRACES) {
            log.error(m + "couldn't set up env for DirContext", th);
        } else {
            log.error(m + "couldn't set up env for DirContext" + th.getMessage());
        }
    } finally {
        log.debug(m + "< " + env);
    }
    return env;
}

From source file:edu.ku.brc.specify.utilapps.DataModelClassGenerator.java

public void process() {

    String template = "";

    try {//from  w ww.  j  a v a2s . c  om
        File templateFile = new File("src/edu/ku/brc/specify/utilapps/DataModelGenTemplate.txt");
        template = FileUtils.readFileToString(templateFile);

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataModelClassGenerator.class, ex);
        ex.printStackTrace();
        return;
    }

    String className = dataClass.getSimpleName();
    String noCapClassName = className.substring(0, 1).toLowerCase() + className.substring(1);
    String idName = className.substring(0, 1).toLowerCase() + className.substring(1) + "Id";

    SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy");

    template = StringUtils.replace(template, "<!-- TableName -->", className.toLowerCase());
    template = StringUtils.replace(template, "<!-- ClassName -->", className);
    template = StringUtils.replace(template, "<!-- Id -->", idName);
    template = StringUtils.replace(template, "<!-- IdNum -->", tableIdTxt.getText());
    template = StringUtils.replace(template, "<!-- Dev -->", devTxt.getText());
    template = StringUtils.replace(template, "<!-- Date -->", sdf.format(Calendar.getInstance().getTime()));

    Hashtable<String, Boolean> duplicateClassNames = new Hashtable<String, Boolean>();
    for (Field field : dataClass.getDeclaredFields()) {
        UIRow row = fieldRowhash.get(field);
        String fieldsType = (row != null && row.getSizetxt() != null) ? row.getSizetxt().getText()
                : field.getType().getSimpleName();
        Boolean bool = duplicateClassNames.get(fieldsType);
        if (bool == null) {
            duplicateClassNames.put(fieldsType, false);
        } else if (!bool) {
            duplicateClassNames.put(fieldsType, true);
        }
    }
    StringBuilder declarationsSB = new StringBuilder();
    StringBuilder initersSB = new StringBuilder();
    StringBuilder methodsSB = new StringBuilder();

    StringBuilder osDeclarationsSB = new StringBuilder();
    StringBuilder osInitersSB = new StringBuilder();
    StringBuilder osMethodsSB = new StringBuilder();

    // Initializer
    int maxWidth = 0;
    for (Field field : dataClass.getDeclaredFields()) {
        String typeStr;
        UIRow row = fieldRowhash.get(field);
        if (row != null && row.isSet()) {
            typeStr = field.getType().getSimpleName() + "<" + row.getSizetxt().getText() + ">";
        } else {
            typeStr = field.getType().getSimpleName();
        }
        maxWidth = Math.max(maxWidth, typeStr.length());
    }

    int initerMaxWidth = 0;
    for (Field field : dataClass.getDeclaredFields()) {
        initerMaxWidth = Math.max(initerMaxWidth, field.getName().length());
    }

    String prevType = "";

    for (Field field : dataClass.getDeclaredFields()) {
        String fieldName = field.getName();
        UIRow row = fieldRowhash.get(field);
        boolean isSet = row != null && row.isSet();

        boolean isThereMoreThanOne = false;
        String othersideClassType = "";
        String othersideFieldName = "";
        String othersideMethodName = "";
        String otherSideID = "";
        boolean isFieldObj = false;
        String fieldsType;
        if (row != null) {
            fieldsType = isSet ? row.getSizetxt().getText() : field.getType().getSimpleName();
        } else {
            fieldsType = field.getType().getSimpleName();
        }
        //System.out.println("isField["+fieldsType+"]["+isFieldObj + "] " + fieldName);

        //String checkClass = "";
        if (!isSet) {
            // Check to see if the field is a basic Java type we should ignore 
            // or a Data Object we need to hook up
            isFieldObj = baseClassHash.get(fieldsType) != null;// Check to see if it is a basic type
            if (!isFieldObj) {
                othersideClassType = "Set<" + className + ">";

                isThereMoreThanOne = duplicateClassNames.get(fieldsType) != null
                        && duplicateClassNames.get(fieldsType);
                if (isThereMoreThanOne) { // OK since it isn't a basic field than it is a Set of this class
                    String fName = fieldName.substring(0, fieldName.length() - 1);
                    othersideFieldName = fName + className + "s";
                    othersideMethodName = StringUtils.capitalize(fName) + className + "s";
                    otherSideID = fName + className + "ID";
                } else {
                    othersideFieldName = noCapClassName + "s";
                    othersideMethodName = className + "s";
                    otherSideID = className + "ID";
                }
            }

        } else {
            // Since this side is a Set than the otherside will be just this class
            othersideClassType = className;

            isThereMoreThanOne = duplicateClassNames.get(fieldsType) != null
                    && duplicateClassNames.get(fieldsType);
            if (isThereMoreThanOne) {
                String fName = fieldName.substring(0, fieldName.length() - 1);
                othersideFieldName = fName + className;
                othersideMethodName = StringUtils.capitalize(fName) + className;
                otherSideID = fName + className + "ID";
            } else {
                othersideFieldName = noCapClassName;
                othersideMethodName = className;
                otherSideID = className + "ID";
            }
        }

        boolean isNewOSClassType = !fieldsType.equals(prevType);
        if (isNewOSClassType) {
            prevType = fieldsType;
        }

        boolean doOtherSide = isSet || !isFieldObj;

        //-------------------------------------
        // Declarations
        //-------------------------------------
        String typeStr;

        if (row != null && row.isSet()) {
            typeStr = field.getType().getSimpleName() + "<" + row.getSizetxt().getText() + ">";
        } else {
            typeStr = field.getType().getSimpleName();
        }
        declarationsSB.append("    protected ");
        declarationsSB.append(typeStr);
        for (int i = 0; i < (maxWidth - typeStr.length() + 1); i++) {
            declarationsSB.append(' ');
        }
        declarationsSB.append(field.getName());
        declarationsSB.append(";\n");

        if (doOtherSide) {
            if (isNewOSClassType) {
                osDeclarationsSB.append("\n\n    // Copy this Code into Class " + fieldsType + "\n\n");
            }
            // use the same width (just because)
            osDeclarationsSB.append("    protected ");
            osDeclarationsSB.append(othersideClassType);
            for (int i = 0; i < (maxWidth - typeStr.length() + 1); i++) {
                osDeclarationsSB.append(' ');
            }
            osDeclarationsSB.append(othersideFieldName);
            osDeclarationsSB.append(";\n");
        }

        //-------------------------------------
        // Initers
        //-------------------------------------
        if (row != null && row.isSet()) {
            typeStr = "new HashSet<" + row.getSizetxt().getText() + ">()";
        } else {
            typeStr = "null";
        }
        initersSB.append("        ");
        initersSB.append(field.getName());
        for (int i = 0; i < (initerMaxWidth - field.getName().length() + 1); i++) {
            initersSB.append(' ');
        }
        initersSB.append(" = ");
        initersSB.append(typeStr);
        initersSB.append(";\n");

        if (doOtherSide && !isFieldObj) {
            if (isNewOSClassType) {
                osInitersSB.append("\n\n    // Copy this Code into Class " + fieldsType + "\n\n");
            }
            osInitersSB.append("        ");
            osInitersSB.append(othersideFieldName);
            for (int i = 0; i < (initerMaxWidth - field.getName().length() + 1); i++) {
                osInitersSB.append(' ');
            }
            osInitersSB.append(" = ");
            if (othersideClassType.startsWith("Set")) {
                osInitersSB.append(
                        "new HashSet<" + (row != null ? row.getSizetxt().getText() : className) + ">()");
            } else {
                osInitersSB.append("null");
            }

            osInitersSB.append(";\n");
        }

        // Do Methods

        if (isSet) {
            typeStr = field.getType().getSimpleName() + "<" + row.getSizetxt().getText() + ">";
            isSet = true;

        } else {
            typeStr = field.getType().getSimpleName();
        }

        methodsSB.append("    /**\n");
        methodsSB.append("     *\n");
        methodsSB.append("     */\n");

        String size = "";
        if (row != null) {
            if (row.isCBXString()) {
                size = row.getSizetxt().getText();
            } else if (row.getType() != DataType.Set) {
                methodsSB.append("    @Lob\n");
            }
        } else if (field.getType() == Date.class || field.getType() == Calendar.class) {
            methodsSB.append("    @Temporal(TemporalType.DATE)\n");
        }

        if (isSet) {
            String singularFieldName = field.getName().substring(0, fieldName.length() - 1);
            methodsSB.append("    @OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = \""
                    + singularFieldName + "\")\n");

        } else if (baseClassHash.get(field.getType()) != null) {
            methodsSB.append("    @Column(name = \"" + StringUtils.capitalize(fieldName)
                    + "\", unique = false, nullable = true, insertable = true, updatable = true"
                    + (StringUtils.isNotEmpty(size) ? (", length = " + size + "") : "") + ")\n");
        } else {
            methodsSB.append("    @ManyToOne(cascade = {}, fetch = FetchType.LAZY)\n");
            methodsSB.append(
                    "    @Cascade( { CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.LOCK })\n");
            methodsSB.append("    @JoinColumn(name = \"" + className
                    + "ID\", unique = false, nullable = true, insertable = true, updatable = true)\n");
        }
        methodsSB.append("    public " + typeStr + " get" + StringUtils.capitalize(fieldName) + "()\n    {\n");
        methodsSB.append("        return this." + fieldName + ";\n");
        methodsSB.append("    }\n\n");
        methodsSB.append("    public void set" + StringUtils.capitalize(fieldName) + "(final " + typeStr + " "
                + fieldName + ")\n    {\n");
        methodsSB.append("        this." + fieldName + " = " + fieldName + ";\n");
        methodsSB.append("    }\n\n");

        if (fieldsType.startsWith("Agent")) {
            int x = 0;
            x++;
        }
        if (doOtherSide && !isFieldObj) {
            if (isNewOSClassType) {
                osMethodsSB.append("\n\n    // Copy this Code into Class " + fieldsType + "\n\n");
            }

            osMethodsSB.append("    /**\n");
            osMethodsSB.append("     *\n");
            osMethodsSB.append("     */\n");
            if (isSet) {
                osMethodsSB.append("    @OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = \""
                        + fieldName + "\")\n");

            } else {
                osMethodsSB.append("    @ManyToOne(cascade = {}, fetch = FetchType.LAZY)\n");
                osMethodsSB.append(
                        "    @Cascade( { CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.LOCK })\n");
                osMethodsSB.append("    @JoinColumn(name = \"" + otherSideID
                        + "\", unique = false, nullable = true, insertable = true, updatable = true)\n");
            }

            osMethodsSB
                    .append("    public " + othersideClassType + " get" + othersideMethodName + "()\n    {\n");
            osMethodsSB.append("        return this." + othersideFieldName + ";\n");
            osMethodsSB.append("    }\n\n");
            osMethodsSB.append("    public void set" + othersideMethodName + "(final " + othersideClassType
                    + " " + othersideFieldName + ")\n    {\n");
            osMethodsSB.append("        this." + othersideFieldName + " = " + othersideFieldName + ";\n");
            osMethodsSB.append("    }\n\n");

        }
    }
    template = StringUtils.replace(template, "<!-- Fields -->", declarationsSB.toString());
    template = StringUtils.replace(template, "<!-- Initers -->", initersSB.toString());
    template = StringUtils.replace(template, "<!-- Methods -->", methodsSB.toString());

    StringBuilder sb = new StringBuilder();
    sb.append("/* ---------------------------------------------\n");
    sb.append(osDeclarationsSB);
    sb.append(osInitersSB);
    sb.append(osMethodsSB);
    sb.append("\n*/");

    logArea.setText(template + sb.toString());

    try {
        File outFile = new File(className + ".java");
        FileUtils.writeStringToFile(outFile, template + sb.toString());

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataModelClassGenerator.class, ex);
        ex.printStackTrace();
    }

}

From source file:org.mybatisorm.annotation.handler.JoinHandler.java

private Hashtable<Set<Class<?>>, LinkedList<Field[]>> getRefMap(List<Field> fields) {
    Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
    List<Field> refFields = new ArrayList<Field>();
    TableHandler handler = null;//from ww  w . j  a va2  s  . com
    for (Field field : fields) {
        Class<?> clazz = field.getType();
        if (!TableHandler.hasAnnotation(clazz))
            throw new AnnotationNotFoundException(
                    "The property class " + clazz.getName() + " has no @Table annotation.");
        classMap.put(clazz.getSimpleName(), clazz);

        handler = HandlerFactory.getHandler(clazz);
        refFields.addAll(handler.getReferenceFields());
    }

    Hashtable<Set<Class<?>>, LinkedList<Field[]>> refMap = new Hashtable<Set<Class<?>>, LinkedList<Field[]>>();
    for (Field field : refFields) {
        Class<?> clazz = field.getDeclaringClass();
        String[] ref = field.getAnnotation(Column.class).references().split("\\.");
        if (ref.length < 2)
            throw new InvalidAnnotationException(clazz.getSimpleName() + "." + field.getName()
                    + " has invalid references property in @Column annotation.");

        Class<?> refClazz = classMap.get(ref[0]);
        if (refClazz == null)
            continue;

        Set<Class<?>> pair = pair(clazz, refClazz);
        LinkedList<Field[]> list = refMap.get(pair);
        if (list == null) {
            list = new LinkedList<Field[]>();
            refMap.put(pair, list);
        }
        Field refField = null;
        try {
            refField = refClazz.getDeclaredField(ref[1]);
        } catch (Exception e) {
            throw new InvalidAnnotationException("The " + ref[0] + " class has no " + ref[1] + " property.");
        }
        list.add(new Field[] { refField, field });
    }
    return refMap;
}

From source file:hd.controller.AddImageToProductServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from  w  w  w  . j  a  v a 2s.  c  o m*/
 *
 * @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);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }
            String productID = (String) params.get("txtProductId");
            System.out.println(productID);
            String tilte = (String) params.get("newGalleryName");
            String description = (String) params.get("GalleryDescription");
            String url = "images/" + fileName;
            ProductDAO productDao = new ProductDAO();
            ProductPhoto productPhoto = productDao.insertProductPhoto(tilte, description, url, productID);

            response.sendRedirect("MyProductDetailServlet?action=showDetail&txtProductID=" + productID);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        out.close();
    }
}

From source file:io.card.development.recording.ManifestEntry.java

public ManifestEntry(String manifestDirName, JSONObject data, Hashtable<String, byte[]> recordingData)
        throws JSONException {
    yFilename = data.getString("y_filename");
    cbFilename = data.getString("cb_filename");
    crFilename = data.getString("cr_filename");
    fallbackFocusScore = data.getDouble("fallback_focus_score");
    temporalMotion = data.getInt("temporal_motion");
    exposureLimitsReached = data.getInt("exposure_limits_reached") > 0;
    currentOrientation = data.getInt("current_orientation");
    timestamp = data.getDouble("timestamp");

    if (data.has("overall_luma")) {
        overallLuma = data.getInt("overall_luma");
    }//  w  w  w .  j a v a 2  s  .  c  o  m

    if (data.has("focus_position")) {
        focusPosition = data.getInt("focus_position");
    }

    JSONArray focusScoresData = data.getJSONArray("focus_scores");
    focusScores = new int[focusScoresData.length()];
    for (int i = 0; i < focusScoresData.length(); i++) {
        focusScores[i] = focusScoresData.getInt(i);
    }

    yImage = recordingData.get(manifestDirName + "/" + yFilename);
    cbImage = recordingData.get(manifestDirName + "/" + cbFilename);
    crImage = recordingData.get(manifestDirName + "/" + crFilename);
}

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

/**
 * Fill the Vector with all the views from the DOM document
 * @param doc the DOM document conforming to form.xsd
 * @param viewDefs the list to be filled
 * @param doMapDefinitions tells it to map and clone the definitions for formtables (use false for the FormEditor)
 * @return the viewset name//from  w  w w .j av a  2s  .  com
 * @throws Exception for duplicate view set names or if a ViewDef name is not unique
 */
public static String getViewDefs(final Element doc, final Hashtable<String, ViewDefIFace> viewDefs,
        @SuppressWarnings("unused") final Hashtable<String, ViewIFace> views, final boolean doMapDefinitions)
        throws Exception {
    colDefType = AppPreferences.getLocalPrefs().get("ui.formatting.formtype", UIHelper.getOSTypeAsStr());

    instance.viewSetName = doc.attributeValue(NAME);

    Element viewDefsElement = (Element) doc.selectSingleNode("viewdefs");
    if (viewDefsElement != null) {
        for (Iterator<?> i = viewDefsElement.elementIterator("viewdef"); i.hasNext();) {
            Element element = (Element) i.next(); // assume element is NOT null, if it is null it will cause an exception
            ViewDef viewDef = createViewDef(element);
            if (viewDef != null) {
                if (viewDefs.get(viewDef.getName()) == null) {
                    viewDefs.put(viewDef.getName(), viewDef);

                } else {
                    String msg = "View Set [" + instance.viewSetName + "] the View Def Name ["
                            + viewDef.getName() + "] is not unique.";
                    log.error(msg);
                    FormDevHelper.appendFormDevError(msg);
                }
            }
        }

        if (doMapDefinitions) {
            mapDefinitionViewDefs(viewDefs);
        }
    }

    return instance.viewSetName;
}

From source file:com.apatar.flickr.function.DownloadPhotoFlickrTable.java

public List<KeyInsensitiveMap> execute(FlickrNode node, Hashtable<String, Object> values, String strApi,
        String strSecret) throws IOException, XmlRpcException {
    FlickrTable table = FlickrTableList.getTableByName("flickr.photos.getSizes");
    if (table == null)
        return null;

    List<KeyInsensitiveMap> list = new ArrayList<KeyInsensitiveMap>();
    KeyInsensitiveMap map = new KeyInsensitiveMap();
    list.add(map);/*  www.  ja va  2 s .  c o m*/
    try {
        Element element = table.getResponse(node, values, strApi, strSecret);
        for (Object obj : element.getChild("sizes").getChildren("size")) {
            Element child = (Element) obj;
            if (child.getAttributeValue("label").equalsIgnoreCase("Medium")) {
                GetMethod getMethod = new GetMethod(child.getAttributeValue("source"));
                HttpClient client = new HttpClient();
                client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
                client.executeMethod(getMethod);
                map.put("photo", getMethod.getResponseBody());
                map.put("photo_id", values.get("photo_id"));
            }
        }
    } catch (JDOMException e) {
        e.printStackTrace();
    }

    return list;
}

From source file:ca.queensu.cs.sail.mailboxmina2.main.modules.ThreadsModule.java

/**
 * This method stores the root associations of a roots table into the database
 * @param roots a list of roots associations
 * @throws SQLException/*from  w ww .  ja va  2 s .  c  om*/
 */
private void storeRoots(Hashtable<String, String> roots, Connection connection) throws SQLException {
    // Use StringBuilders to create big insertion queries

    StringBuilder rootQueryBuilder = new StringBuilder();

    // Queries use the pgpsql functions
    // merge_parent(int msg_uid, int parent_uid)
    // merge_root(int msg_uid, int root_uid)
    // that take care of insertion / update automatically

    rootQueryBuilder.append("PREPARE rootplan (int, int) AS SELECT merge_root($1, $2);");
    // Genereate the roots query
    int i = 0;
    for (String key : roots.keySet()) {
        rootQueryBuilder.append("EXECUTE rootplan (" + key + ", " + roots.get(key) + ");"
                + System.getProperty("line.separator"));
        i++;
        if ((i % 1000) == 0) {
            i = 0;
            rootQueryBuilder.append("DEALLOCATE rootplan;" + System.getProperty("line.separator"));
            String sqlstr = rootQueryBuilder.toString();
            Statement statement = connection.createStatement();
            statement.execute(sqlstr);
            statement.close();
            rootQueryBuilder.delete(0, rootQueryBuilder.length());
            rootQueryBuilder.append("PREPARE rootplan (int, int) AS SELECT merge_root($1, $2);");
            Main.getLogger().debug(4, "Stored 1000 root relations!");
        }
    }
    if (i > 0) {
        rootQueryBuilder.append("DEALLOCATE rootplan;" + System.getProperty("line.separator"));
        String sqlstr = rootQueryBuilder.toString();
        Statement statement = connection.createStatement();
        statement.execute(sqlstr);
        statement.close();
        Main.getLogger().debug(4, "Stored " + i + " root relations!");
    }
}

From source file:com.stimulus.archiva.extraction.MessageExtraction.java

protected String extractMessage(Email message) throws MessageExtractionException {

    if (message == null)
        throw new MessageExtractionException("assertion failure: null message", logger);

    logger.debug("extracted message {" + message + "}");

    Hashtable<String, Part> att = new Hashtable<String, Part>();
    Hashtable<String, String> inl = new Hashtable<String, String>();
    Hashtable<String, String> imgs = new Hashtable<String, String>();
    Hashtable<String, String> nonImgs = new Hashtable<String, String>();
    Hashtable<String, String> ready = new Hashtable<String, String>();
    ArrayList<String> mimeTypes = new ArrayList<String>();
    String viewFileName;/*from w  w  w  .j  av  a 2  s  . c o  m*/
    try {
        dumpPart(message, att, inl, imgs, nonImgs, mimeTypes, message.getSubject());
        for (String attachFileName : att.keySet()) {
            Part p = (Part) att.get(attachFileName);
            writeAttachment(p, attachFileName);
            ready.put(attachFileName, attachFileName);
            //if (!imgs.containsKey(attachFileName) && !nonImgs.containsKey(attachFileName))
            addAttachment(attachFileName, p);
        }

        if (inl.containsKey("text/html")) {
            viewFileName = prepareHTMLMessage(baseURL, inl, imgs, nonImgs, ready, mimeTypes);
        } else if (inl.containsKey("text/plain")) {
            viewFileName = preparePlaintextMessage(inl, imgs, nonImgs, ready, mimeTypes);
        } else {
            logger.debug(
                    "unable to extract message since the content type is unsupported. returning empty message body.");
            return writeTempMessage("<html><head><META http-equiv=Content-Type content=\"text/html; charset="
                    + serverEncoding + "\"></head><body></body></html>", ".html");
        }
    } catch (Exception ex) {
        throw new MessageExtractionException(ex.getMessage(), ex, logger);
    }
    logger.debug("message successfully extracted {filename='" + fileName + "' " + message + "}");
    return viewFileName;
}

From source file:edu.ku.brc.specify.tasks.PluginsTask.java

/**
 * @param table/*from   ww  w  . j a v a 2  s.  c o m*/
 */
protected void exportTable(final JTable table) {
    Hashtable<String, String> values = new Hashtable<String, String>();
    ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(), "SystemSetup",
            "ExcelExportInfo", null, getResourceString("EXCEL_EXPORT_INFO_TITLE"), getResourceString("Export"),
            null, // className,
            null, // idFieldName,
            true, // isEdit,
            0);
    dlg.setData(values);
    dlg.setModal(true);
    dlg.setVisible(true);
    if (dlg.getBtnPressed() == ViewBasedDisplayIFace.OK_BTN) {
        dlg.getMultiView().getDataFromUI();
        File file = new File(values.get("FilePath"));
        TableModel2Excel.convertToExcel(file, values.get("Title"), table.getModel());
    }
}