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:edu.ku.brc.af.auth.UserAndMasterPasswordMgr.java

/**
 * Display a dialog for changing the password.
 * @return true if successful, false if in error or the user clicked on Cancel
 *///from  w  ww .  j  a v a 2 s.c o  m
public boolean changePassword() {
    loadAndPushResourceBundle("masterusrpwd");

    final ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(),
            "SystemSetup", "ChangePassword", null, getResourceString(getResourceString("CHG_PWD_TITLE")), "OK",
            null, null, true, MultiView.HIDE_SAVE_BTN | MultiView.DONT_ADD_ALL_ALTVIEWS
                    | MultiView.USE_ONLY_CREATION_MODE | MultiView.IS_EDITTING);
    dlg.setHelpContext("CHANGE_PWD");
    dlg.setWhichBtns(CustomDialog.OK_BTN | CustomDialog.CANCEL_BTN);

    dlg.setFormAdjuster(new FormPane.FormPaneAdjusterIFace() {
        @Override
        public void adjustForm(final FormViewObj fvo) {
            final ValPasswordField oldPwdVTF = fvo.getCompById("1");
            final ValPasswordField newPwdVTF = fvo.getCompById("2");
            final ValPasswordField verPwdVTF = fvo.getCompById("3");
            final PasswordStrengthUI pwdStrenthUI = fvo.getCompById("4");

            DocumentAdaptor da = new DocumentAdaptor() {
                @Override
                protected void changed(DocumentEvent e) {
                    super.changed(e);

                    // Need to invoke later so the da gets to set the enabled state last.
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            boolean enabled = dlg.getOkBtn().isEnabled();
                            String pwdStr = new String(newPwdVTF.getPassword());
                            boolean pwdOK = pwdStrenthUI.checkStrength(pwdStr);

                            dlg.getOkBtn().setEnabled(enabled && pwdOK);
                            pwdStrenthUI.repaint();
                        }
                    });
                }
            };

            oldPwdVTF.getDocument().addDocumentListener(da);
            verPwdVTF.getDocument().addDocumentListener(da);
            newPwdVTF.getDocument().addDocumentListener(da);
        }

    });
    Hashtable<String, String> valuesHash = new Hashtable<String, String>();
    dlg.setData(valuesHash);
    UIHelper.centerAndShow(dlg);

    if (!dlg.isCancelled()) {
        int pwdLen = 6;

        String oldPwd = valuesHash.get("OldPwd");
        String newPwd1 = valuesHash.get("NewPwd1");
        String newPwd2 = valuesHash.get("NewPwd2");

        if (newPwd1.equals(newPwd2)) {
            if (newPwd1.length() < pwdLen) {
                SpecifyUser spUser = AppContextMgr.getInstance().getClassObject(SpecifyUser.class);
                String spuOldPwd = spUser.getPassword();
                if (oldPwd.equals(spuOldPwd)) {
                    popResourceBundle();
                    return changePassword(oldPwd, newPwd2);
                }
                UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getResourceString("PWD_ERR_BAD")),
                        Color.RED);
            } else {
                UIRegistry.writeTimedSimpleGlassPaneMsg(
                        getFormattedResStr(getResourceString("PWD_ERR_LEN"), pwdLen), Color.RED);
            }
        } else {
            UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString(getResourceString("PWD_ERR_NOTSAME")),
                    Color.RED);
        }
    }
    popResourceBundle();
    return false;
}

From source file:edu.ku.brc.specify.tools.datamodelgenerator.DataDict.java

/**
 * @param tableDef// w w  w.  j  a v a 2  s  .com
 * @param tableInfo
 * @param okTables
 */
protected void compareFields(final TableDef tableDef, final DBTableInfo tableInfo,
        final Vector<String> okTables) {
    Hashtable<String, DBFieldInfo> fieldHash = new Hashtable<String, DBFieldInfo>();
    for (DBFieldInfo fi : tableInfo.getFields()) {
        fieldHash.put(fi.getName().toLowerCase(), fi);
    }

    boolean hasMissing = false;
    for (FieldDef fieldDef : tableDef.getFields()) {
        if (!fieldDef.getName().endsWith("ID")) {
            String fieldName = fieldDef.getName().toLowerCase();
            for (int i = 0; i < 2; i++) {
                DBFieldInfo fieldInfo = fieldHash.get(fieldName);
                if (fieldInfo != null) {
                    //System.err.println("["+fieldDef.getLength()+"]");
                    int fdLen = StringUtils.isNotEmpty(fieldDef.getLength())
                            && fieldDef.getLength().indexOf(',') == -1 ? Integer.parseInt(fieldDef.getLength())
                                    : -1;
                    if (fdLen != -1 && fdLen != fieldInfo.getLength() && fdLen > fieldInfo.getLength()) {
                        if (!hasMissing) {
                            System.err.println("\nComparing " + tableDef.getName());
                        }
                        System.err.println("  " + fieldDef.getName() + " Length: " + fdLen + " != "
                                + fieldInfo.getLength());
                    }
                    break;
                }
                if (i == 1) {
                    if (!hasMissing) {
                        System.err.println("\nComparing " + tableDef.getName());
                    }
                    System.err.println("  " + fieldDef.getName() + " is missing.");
                    hasMissing = true;
                }
                fieldName = "is" + fieldName;
            }
        }
    }

    if (!hasMissing) {
        okTables.add(tableDef.getName());
    }
}

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

@Override
protected void addItem(final JList list, final Vector<TaskConfigItemIFace> itemList) {
    // Hash all the names so we can figure out which forms are not used
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    ListModel model = stdPanel.getOrderModel();
    for (int i = 0; i < model.getSize(); i++) {
        DataEntryView dev = (DataEntryView) model.getElementAt(i);
        hash.put(dev.getView(), dev);/*from  w  w w .j  a v  a2 s . c om*/
    }

    model = miscPanel.getOrderModel();
    for (int i = 0; i < model.getSize(); i++) {
        DataEntryView dev = (DataEntryView) model.getElementAt(i);
        hash.put(dev.getView(), dev);
    }

    // Add only the unused forms (does NOT return internal views).
    List<String> uniqueList = new Vector<String>();
    List<ViewIFace> views = ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getAllViews();
    Hashtable<String, ViewIFace> newAvailViews = new Hashtable<String, ViewIFace>();
    for (ViewIFace view : views) {
        //System.out.println("["+view.getName()+"]["+view.getTitle()+"]");

        if (hash.get(view.getName()) == null) {
            DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(view.getClassName());
            if (ti != null) {
                if (!ti.isHidden() && !InteractionsTask.isInteractionTable(ti.getTableId())) {
                    hash.put(view.getName(), view);
                    String title = StringUtils.isNotEmpty(view.getObjTitle()) ? view.getObjTitle()
                            : ti != null ? ti.getTitle() : view.getName();
                    if (newAvailViews.get(title) != null) {
                        title = view.getName();
                    }
                    uniqueList.add(title);
                    newAvailViews.put(title, view);
                }
            } else {
                System.err.println("DBTableInfo was null for class[" + view.getClassName() + "]");
            }
        }
    }

    if (uniqueList.size() == 0) {
        JOptionPane.showMessageDialog(this, getResourceString("DET_DEV_NONE_AVAIL"),
                getResourceString("DET_DEV_NONE_AVAIL_TITLE"), JOptionPane.INFORMATION_MESSAGE);
        return;
    }

    Collections.sort(uniqueList);

    ToggleButtonChooserDlg<String> dlg = new ToggleButtonChooserDlg<String>((Frame) UIRegistry.getTopWindow(),
            "DET_AVAIL_VIEWS", uniqueList);

    dlg.setUseScrollPane(true);
    UIHelper.centerAndShow(dlg);

    if (!dlg.isCancelled()) {
        model = list.getModel();

        for (String title : dlg.getSelectedObjects()) {
            ViewIFace view = newAvailViews.get(title);
            DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(view.getClassName());

            String frmTitle = StringUtils.isNotEmpty(view.getObjTitle()) ? view.getObjTitle()
                    : ti != null ? ti.getTitle() : view.getName();
            DataEntryView dev = new DataEntryView(frmTitle, // Title 
                    view.getName(), // Name
                    ti != null ? ti.getName() : null, // Icon Name
                    view.getObjTitle(), // ToolTip
                    model.getSize(), // Order
                    true);
            dev.setTableInfo(ti);
            ((DefaultListModel) model).addElement(dev);
            itemList.add(dev);
        }
        //pack();
    }
    setHasChanged(true);
}

From source file:com.medigy.persist.model.data.EntitySeedDataPopulator.java

protected void populateCachedReferenceEntities(final Class entityClass,
        final CachedReferenceEntity[] cachedEntities, final String[] propertyList, final Object[][] data)
        throws HibernateException {
    try {/*from  w  ww.j  ava  2 s.  c o m*/
        final Hashtable pdsByName = new Hashtable();
        final BeanInfo beanInfo = Introspector.getBeanInfo(entityClass);
        final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            final PropertyDescriptor descriptor = descriptors[i];
            if (descriptor.getWriteMethod() != null)
                pdsByName.put(descriptor.getName(), descriptor.getWriteMethod());
        }

        Map entityMapByCache = new HashMap<CachedReferenceEntity, Object>();
        for (int i = 0; i < data.length; i++) {
            final Object entityObject = entityClass.newInstance();
            for (int j = 0; j < propertyList.length; j++) {
                final Method setter = (Method) pdsByName.get(propertyList[j]);
                if (setter != null && data[i][j] != null) {
                    setter.invoke(entityObject, new Object[] { data[i][j] });
                }
            }
            entityMapByCache.put(cachedEntities[i], entityObject);
            if (!useEjb)
                session.save(entityObject);
            else
                entityManager.persist(entityObject);
            cachedEntities[i].setEntity((ReferenceEntity) entityObject);
        }
    } catch (Exception e) {
        log.error(e);
        throw new HibernateException(e);
    }
}

From source file:Controller.ControllerProducts.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//w ww  .  j  a  v  a 2s. co  m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (!isMultipart) {

    } else {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        List items = null;
        try {
            items = upload.parseRequest(request);
        } catch (Exception 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());
            } else {

                try {
                    String itemName = item.getName();
                    fileName = itemName.substring(itemName.lastIndexOf("\\") + 1);
                    System.out.println("path" + fileName);
                    String RealPath = getServletContext().getRealPath("/") + "upload\\" + fileName;
                    System.out.println("Rpath" + RealPath);
                    File savedFile = new File(RealPath);
                    item.write(savedFile);
                    //System.out.println("upload\\"+fileName);
                    //insert Product
                    String code = (String) params.get("txtcode");
                    String name = (String) params.get("txtname");
                    String price = (String) params.get("txtprice");
                    Products sp = new Products();
                    sp.InsertProduct(code, name, price, "upload\\" + fileName);
                    RequestDispatcher rd = request.getRequestDispatcher("product.jsp");
                    rd.forward(request, response);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        }

    }
    //this.processRequest(request, response);
}

From source file:edu.ku.brc.specify.dbsupport.BuildFromGeonames.java

/**
 * @param row//w  ww .  j a  v a  2s  . c o  m
 * @param rankId
 * @param earthId
 * @return
 * @throws SQLException
 */
private boolean buildInsert(final List<Object> row, final int rankId, final int earthId) throws SQLException {

    GeographyTreeDefItem item = geoDef.getDefItemByRank(rankId);
    int geoDefItemId = item.getId();

    String nameStr = row.get(0).toString().trim();

    Integer parentId = null;
    String abbrev = null;
    String isoCode = null;

    if (rankId == 100) // Continent
    {
        parentId = earthId;
        abbrev = row.get(3).toString();
        isoCode = abbrev;

    } else if (rankId == 200) // Country
    {
        String countryCode = row.get(3).toString();
        String continentCode = countryToContHash.get(countryCode);

        isoCode = (String) row.get(row.size() - 1);
        abbrev = countryCode;

        if (continentCode != null) {
            parentId = contToIdHash.get(continentCode);
            if (parentId == null) {
                log.error("No Continent Id for Name  continentCode[" + continentCode + "]   Country[" + nameStr
                        + "]");
            }
        } else {
            StringBuilder sb = new StringBuilder("No Continent Code [" + continentCode + "]:\n");
            for (int i = 0; i < row.size(); i++) {
                sb.append(i + " - " + row.get(i) + "\n");
            }
            log.error(sb.toString());
        }

    } else if (rankId == 300) // State
    {
        String countryCode = row.get(3).toString();
        abbrev = row.get(4).toString();
        isoCode = (String) row.get(row.size() - 1);

        parentId = countryCodeToIdHash.get(countryCode);
        if (parentId == null) {
            log.error("No Country Code Id for [" + countryCode + "][" + nameStr + "]");
        }

    } else if (rankId == 400) // County
    {
        String stateCode = row.get(4).toString();
        String countryCode = row.get(3).toString();

        abbrev = row.get(3).toString();
        isoCode = (String) row.get(row.size() - 1);

        Hashtable<String, Integer> stateToIdHash = countryStateCodeToIdHash.get(countryCode);
        if (stateToIdHash != null) {
            parentId = stateToIdHash.get(stateCode);
            if (parentId == null) {
                log.error("No State Id for CC[" + countryCode + "]  stateCode[" + stateCode + "] County["
                        + nameStr + "]");
            }
        } else {
            log.error(
                    "No State Hash for CC[" + countryCode + "]  State[" + stateCode + "] Name: " + row.get(1));
        }
    }

    if (nameStr.length() > 64) {
        log.error("Name[" + nameStr + " is too long " + nameStr.length() + "truncating.");
        nameStr = nameStr.substring(0, 64);
    }

    if (parentId != null) {
        Double lat = row.get(1) != null ? ((BigDecimal) row.get(1)).doubleValue() : null;
        Double lon = row.get(2) != null ? ((BigDecimal) row.get(2)).doubleValue() : null;

        pStmt.setString(1, nameStr);
        pStmt.setInt(2, rankId);
        pStmt.setInt(3, parentId);
        pStmt.setBoolean(4, true);
        pStmt.setBoolean(5, true);
        pStmt.setInt(6, geoDef.getId());
        pStmt.setInt(7, geoDefItemId);
        pStmt.setInt(8, createdByAgent == null ? 1 : createdByAgent.getId());
        pStmt.setBigDecimal(9, lat > -181 ? new BigDecimal(lat) : null); // Lat
        pStmt.setBigDecimal(10, lon > -181 ? new BigDecimal(lon) : null); // Lon

        pStmt.setString(11, StringUtils.isNotEmpty(abbrev) ? abbrev : null); // Abbrev
        pStmt.setTimestamp(12, now);
        pStmt.setTimestamp(13, now);
        pStmt.setInt(14, 0);
        pStmt.setString(15, isoCode);

        return true;
    }
    return false;
}

From source file:edu.ku.brc.specify.tools.AppendHelp.java

/**
 * /*  w w  w . j  a va  2s . c o m*/
 */
@SuppressWarnings({ "unchecked" })
public AppendHelp() {
    super();

    StringBuilder sb = new StringBuilder();

    String path = "help/SpecifyHelp";

    File spHelpDir = new File(path);
    getMapEntries(spHelpDir);

    sb.append(
            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
    //sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
    sb.append("<head>\n");
    //sb.append("<base href=\"help/SpecifyHelp/Workbench\">\n");
    sb.append("<style>body { font-family: sans-serif; }</style>\n");
    sb.append("<link href=\"../../main.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\"></link>\n");
    sb.append("<title>Specify Help</title>\n");
    sb.append("</head>\n");
    sb.append("<body bgcolor=\"#ffffff\">\n");
    sb.append("<H1>");
    sb.append("Specify Help");
    sb.append("</H1>\n");

    try {
        List<TOCItem> tocList = getTOCList(spHelpDir, sb);

        Vector<String> fileNameList = new Vector<String>();
        Hashtable<String, Boolean> fileNameHash = new Hashtable<String, Boolean>();
        for (TOCItem item : tocList) {
            String fName = targetToUrlHash.get(item.getTarget());
            if (fName != null) {
                if (fName.indexOf('#') > -1) {
                    String[] toks = StringUtils.split(fName, "#");
                    item.setFileName("help/" + toks[0]);
                    item.setAnchor(toks[1]);

                } else {
                    item.setFileName("help/" + fName);
                }

                String fullName = item.getFileName();
                if (fileNameHash.get(fullName) == null) {
                    fileNameList.add(fullName);
                    fileNameHash.put(fullName, false);
                }
                //sb.append(getContents(new File(fileName), p.first, toks.length > 1 ? toks[1] : null));
            }
        }

        int i = 0;
        for (TOCItem item : tocList) {
            if (item.getFileName() != null) {
                System.out.println(item.getTarget() + "  " + item.getFileName());
                Boolean used = fileNameHash.get(item.getFileName());
                if (used != null && !used) {
                    if (i > 0) {
                        sb.append("<HR>\n");
                    }

                    sb.append(getContents(new File(item.getFileName()), item.getTarget(), null));
                    fileNameHash.put(item.getFileName(), true);
                    i++;
                }
            } else {
                System.err.println("File Name is null for target[" + item.getTarget() + "]");
            }
        }

        Hashtable<String, Boolean> fNameHash = new Hashtable<String, Boolean>();
        for (String url : urlToTargetHash.keySet()) {
            fNameHash.put(FilenameUtils.getName(url), true);
        }

        for (File file : (Collection<File>) FileUtils.listFiles(new File(path), new String[] { "html" },
                true)) {
            try {
                String fName = FilenameUtils.getName(file.getAbsolutePath());
                if (fNameHash.get(fName) == null) {
                    if (i > 0) {
                        sb.append("<HR>\n");
                    }
                    sb.append(getContents(file, fName, null));
                    i++;
                }

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

        sb.append("</body></html>");
        FileUtils.writeStringToFile(new File("SpecifyHelp.html"), sb.toString());

    } catch (IOException ex) {
        ex.printStackTrace();
    }

}

From source file:com.icesoft.faces.webapp.parser.JspPageToDocument.java

/**
 * @param input/*from  w w w . j  a v a 2  s . c o m*/
 * @return String
 */
public static String transform(String input) {
    String result = input;

    Pattern jspDeclarationPattern = Pattern.compile(JSP_DECL_PATTERN, Pattern.DOTALL);
    Matcher jspDeclarationMatcher = jspDeclarationPattern.matcher(result);
    if (!jspDeclarationMatcher.find()) {
        //no JSP declarations, must be a JSP Document, not a page
        return (preprocessJspDocument(result));
    }

    result = performStaticInclude(STATIC_INCLUDE_PATTERN, input);

    result = toLowerHTML(result);

    Pattern jspTaglibPattern = Pattern.compile(JSP_TAGLIB_PATTERN, Pattern.DOTALL);
    Pattern openTagPattern = Pattern.compile(OPEN_TAG_PATTERN, Pattern.DOTALL);
    Pattern attributePattern = Pattern.compile(ATTRIBUTE_PATTERN, Pattern.DOTALL);
    Pattern prefixPattern = Pattern.compile(PREFIX_PATTERN, Pattern.DOTALL);
    Pattern uriPattern = Pattern.compile(URI_PATTERN, Pattern.DOTALL);

    Hashtable declarationsTable = new Hashtable();
    Matcher jspTaglibMatcher = jspTaglibPattern.matcher(result);
    declarationsTable.put("xmlns:jsp", "jsp");
    declarationsTable.put("xmlns:icefaces", "http://www.icesoft.com/icefaces");

    while (jspTaglibMatcher.find()) {
        String attributes = jspTaglibMatcher.group(1);
        Matcher prefixMatcher = prefixPattern.matcher(attributes);
        Matcher uriMatcher = uriPattern.matcher(attributes);
        prefixMatcher.find();
        uriMatcher.find();
        String prefix = prefixMatcher.group(1);
        String url = uriMatcher.group(1);
        declarationsTable.put("xmlns:" + prefix, url);
    }

    Matcher openTagMatcher = openTagPattern.matcher(result);
    openTagMatcher.find();
    String tag = openTagMatcher.group(1);
    String attributes = openTagMatcher.group(2);

    Matcher attributeMatcher = attributePattern.matcher(attributes);
    while (attributeMatcher.find()) {
        String name = attributeMatcher.group(1);
        String value = attributeMatcher.group(2);
        declarationsTable.put(name, value);
    }

    Enumeration declarations = declarationsTable.keys();
    String namespaceDeclarations = "";
    while (declarations.hasMoreElements()) {
        String prefix = (String) declarations.nextElement();
        String url = (String) declarationsTable.get(prefix);
        namespaceDeclarations += prefix + "=\"" + url + "\" ";
    }

    jspDeclarationMatcher = jspDeclarationPattern.matcher(result);
    result = jspDeclarationMatcher.replaceAll("");

    //ensure single root tag for all JSPs as per bug 361
    result = "<icefaces:root " + namespaceDeclarations + ">" + result + "</icefaces:root>";

    Pattern jspIncludePattern = Pattern.compile(JSP_INCLUDE_PATTERN);
    Matcher jspIncludeMatcher = jspIncludePattern.matcher(result);
    StringBuffer jspIncludeBuf = new StringBuffer();
    while (jspIncludeMatcher.find()) {
        String args = jspIncludeMatcher.group(1);
        jspIncludeMatcher.appendReplacement(jspIncludeBuf,
                "<icefaces:include" + args + " isDynamic=\"#{true}\" />");
    }
    jspIncludeMatcher.appendTail(jspIncludeBuf);
    result = jspIncludeBuf.toString();

    //Fix HTML
    result = toSingletonTag(P_TAG_PATTERN, result);
    result = toSingletonTag(LINK_TAG_PATTERN, result);
    result = toSingletonTag(META_TAG_PATTERN, result);
    result = toSingletonTag(IMG_TAG_PATTERN, result);
    result = toSingletonTag(INPUT_TAG_PATTERN, result);

    Pattern brTagPattern = Pattern.compile(BR_TAG_PATTERN);
    Matcher brTagMatcher = brTagPattern.matcher(result);
    result = brTagMatcher.replaceAll("<br/>");

    Pattern hrTagPattern = Pattern.compile(HR_TAG_PATTERN);
    Matcher hrTagMatcher = hrTagPattern.matcher(result);
    result = hrTagMatcher.replaceAll("<hr/>");

    Pattern nbspEntityPattern = Pattern.compile(NBSP_ENTITY_PATTERN);
    Matcher nbspEntityMatcher = nbspEntityPattern.matcher(result);
    //  result = nbspEntityMatcher.replaceAll("&nbsp;");
    result = nbspEntityMatcher.replaceAll("&amp;nbsp");

    Pattern copyEntityPattern = Pattern.compile(COPY_ENTITY_PATTERN);
    Matcher copyEntityMatcher = copyEntityPattern.matcher(result);
    result = copyEntityMatcher.replaceAll("&#169;");

    Pattern docDeclPattern = Pattern.compile(DOC_DECL_PATTERN);
    Matcher docDeclMatcher = docDeclPattern.matcher(result);
    result = docDeclMatcher.replaceAll("");

    result = unescapeBackslash(result);

    return result;
}

From source file:com.medigy.persist.model.data.EntitySeedDataPopulator.java

protected void populateCachedCustomReferenceEntities(final Class entityClass,
        final CachedCustomReferenceEntity[] cachedEntities, final String[] propertyList, final Object[][] data)
        throws HibernateException {
    try {/* www .j  a  va  2 s . c om*/
        final Hashtable pdsByName = new Hashtable();
        final BeanInfo beanInfo = Introspector.getBeanInfo(entityClass);
        final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            final PropertyDescriptor descriptor = descriptors[i];
            if (descriptor.getWriteMethod() != null)
                pdsByName.put(descriptor.getName(), descriptor.getWriteMethod());
        }

        Map entityMapByCache = new HashMap<CachedCustomReferenceEntity, Object>();
        for (int i = 0; i < data.length; i++) {
            final Object entityObject = entityClass.newInstance();
            for (int j = 0; j < propertyList.length; j++) {
                final Method setter = (Method) pdsByName.get(propertyList[j]);
                if (setter != null && data[i][j] != null) {
                    if (data[i][j] instanceof CachedCustomHierarchyReferenceEntity) {
                        setter.invoke(entityObject, new Object[] { entityMapByCache.get(data[i][j]) });
                    } else
                        setter.invoke(entityObject, new Object[] { data[i][j] });
                }
            }
            entityMapByCache.put(cachedEntities[i], entityObject);
            if (!useEjb)
                session.save(entityObject);
            else
                entityManager.persist(entityObject);
            cachedEntities[i].setEntity((CustomReferenceEntity) entityObject);
        }
    } catch (Exception e) {
        log.error(ExceptionUtils.getStackTrace(e));
        throw new HibernateException(e);
    }
}

From source file:oscar.dms.actions.DmsInboxManageAction.java

private void setQueueDocsInSession(ArrayList<EDoc> privatedocs, HttpServletRequest request) {
    // docs according to queue name
    Hashtable queueDocs = new Hashtable();
    QueueDao queueDao = (QueueDao) SpringUtils.getBean("queueDao");
    List<Hashtable> queues = queueDao.getQueues();
    for (int i = 0; i < queues.size(); i++) {
        Hashtable ht = queues.get(i);
        List<EDoc> EDocs = new ArrayList<EDoc>();
        String queueId = (String) ht.get("id");
        queueDocs.put(queueId, EDocs);/*from www .j  av a2 s  . c o m*/
    }
    logger.debug("queueDocs=" + queueDocs);
    for (int i = 0; i < privatedocs.size(); i++) {
        EDoc eDoc = privatedocs.get(i);
        String docIdStr = eDoc.getDocId();
        Integer docId = -1;
        if (docIdStr != null && !docIdStr.equalsIgnoreCase("")) {
            docId = Integer.parseInt(docIdStr);
        }
        List<QueueDocumentLink> queueDocLinkList = queueDocumentLinkDAO.getQueueFromDocument(docId);

        for (QueueDocumentLink qdl : queueDocLinkList) {
            Integer qidInt = qdl.getQueueId();
            String qidStr = qidInt.toString();
            logger.debug("qid in link=" + qidStr);
            if (queueDocs.containsKey(qidStr)) {
                List<EDoc> EDocs = new ArrayList<EDoc>();
                EDocs = (List<EDoc>) queueDocs.get(qidStr);
                EDocs.add(eDoc);
                logger.debug("add edoc id to queue id=" + eDoc.getDocId());
                queueDocs.put(qidStr, EDocs);
            }
        }
    }

    // remove queues which has no docs linked to
    Enumeration queueIds = queueDocs.keys();
    while (queueIds.hasMoreElements()) {
        String queueId = (String) queueIds.nextElement();
        List<EDoc> eDocs = new ArrayList<EDoc>();
        eDocs = (List<EDoc>) queueDocs.get(queueId);
        if (eDocs == null || eDocs.size() == 0) {
            queueDocs.remove(queueId);
            logger.debug("removed queueId=" + queueId);
        }
    }

    request.getSession().setAttribute("queueDocs", queueDocs);
}