Example usage for java.util Hashtable keySet

List of usage examples for java.util Hashtable keySet

Introduction

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

Prototype

Set keySet

To view the source code for java.util Hashtable keySet.

Click Source Link

Document

Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested.

Usage

From source file:org.hdiv.filter.ValidatorHelperRequest.java

/**
 * Check if all required parameters are received in <code>request</code>.
 * /* ww  w  .j  a va2 s  .c  o  m*/
 * @param request
 *            HttpServletRequest to validate
 * @param state
 *            IState The restored state for this url
 * @param target
 *            Part of the url that represents the target action
 * @return valid result if all required parameters are received. False in otherwise.
 */
private ValidatorHelperResult allRequiredParametersReceived(HttpServletRequest request, IState state,
        String target) {

    Hashtable receivedParameters = new Hashtable(state.getRequiredParams());

    String currentParameter = null;
    Enumeration requestParameters = request.getParameterNames();
    while (requestParameters.hasMoreElements()) {

        currentParameter = (String) requestParameters.nextElement();
        if (receivedParameters.containsKey(currentParameter)) {
            receivedParameters.remove(currentParameter);
        }

        // If multiple parameters are received, it is possible to pass this
        // verification without checking all the request parameters.
        if (receivedParameters.size() == 0) {
            return ValidatorHelperResult.VALID;
        }
    }

    if (receivedParameters.size() > 0) {
        this.logger.log(HDIVErrorCodes.REQUIRED_PARAMETERS, target, receivedParameters.keySet().toString(),
                null);
        return new ValidatorHelperResult(HDIVErrorCodes.REQUIRED_PARAMETERS);
    }

    return ValidatorHelperResult.VALID;
}

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

/**
 * @param entries/* www.  j  a  va2 s.  c  o m*/
 * @return
 */
private Vector<String> getKeyWordsList(final Collection<RegProcEntry> entries) {
    Properties props = new Properties();
    Hashtable<String, Boolean> statKeywords = new Hashtable<String, Boolean>();
    for (RegProcEntry entry : entries) {
        props.clear();
        props.putAll(entry.getProps());

        String os = props.getProperty("os_name");
        String ver = props.getProperty("os_version");
        props.put("platform", os + " " + ver);

        for (Object keywordObj : props.keySet()) {
            statKeywords.put(keywordObj.toString(), true);
        }
    }

    String[] trackKeys = rp.getTrackKeys();

    for (String keyword : new Vector<String>(statKeywords.keySet())) {
        if (keyword.startsWith("Usage") || keyword.startsWith("num_") || keyword.endsWith("_portal")
                || keyword.endsWith("_number") || keyword.endsWith("_website") || keyword.endsWith("id")
                || keyword.endsWith("os_name") || keyword.endsWith("os_version")) {
            statKeywords.remove(keyword);

        } else {
            for (String key : trackKeys) {
                if (keyword.startsWith(key)) {
                    statKeywords.remove(keyword);
                }
            }
        }
    }

    statKeywords.remove("date");
    //statKeywords.remove("time");
    statKeywords.put("by_date", true);
    statKeywords.put("by_month", true);
    statKeywords.put("by_year", true);

    return new Vector<String>(statKeywords.keySet());
}

From source file:edu.ku.brc.specify.config.init.DataBuilder.java

/**
 * @param filename/* w  w  w  . j  a v a  2 s .  co m*/
 * @param prefix
 * @param groupMap
 */
public static void createDefaultPermissions(final Session sessionArg, final String filename,
        final String prefix, final Map<String, SpPrincipal> groupMap,
        final List<SecurityOptionIFace> additionalSecOpts) {
    Hashtable<String, Hashtable<String, PermissionOptionPersist>> mainHash = BaseTask
            .readDefaultPermsFromXML(filename);
    for (String permName : mainHash.keySet()) {
        String userType = "LimitedAccess";
        Hashtable<String, PermissionOptionPersist> hash = mainHash.get(permName);
        if (hash.get(userType) == null) {
            PermissionOptionPersist permOpts = hash.get("Manager");
            PermissionOptionPersist newPermOpts = new PermissionOptionPersist(permOpts.getTaskName(), userType,
                    permOpts.isCanView(), permOpts.isCanModify(), permOpts.isCanDel(), permOpts.isCanAdd());
            hash.put(userType, newPermOpts);
        }

        userType = "FullAccess";
        hash = mainHash.get(permName);
        if (hash.get(userType) == null) {
            PermissionOptionPersist permOpts = hash.get("Manager");
            PermissionOptionPersist newPermOpts = new PermissionOptionPersist(permOpts.getTaskName(), userType,
                    permOpts.isCanView(), permOpts.isCanModify(), permOpts.isCanDel(), permOpts.isCanAdd());
            hash.put(userType, newPermOpts);
        }
    }

    if (additionalSecOpts != null) {
        for (SecurityOptionIFace aso : additionalSecOpts) {
            Hashtable<String, PermissionOptionPersist> hash = mainHash.get(aso.getPermissionName());
            if (hash == null) {
                hash = new Hashtable<String, PermissionOptionPersist>();
                mainHash.put(aso.getPermissionName(), hash);
            }
            for (SpecifyUserTypes.UserType userType : SpecifyUserTypes.UserType.values()) {
                PermissionIFace asoPerm = aso.getDefaultPermissions(userType.toString());
                if (asoPerm != null) {
                    PermissionOptionPersist newPermOpts = new PermissionOptionPersist(aso.getPermissionName(),
                            userType.toString(), asoPerm.canView(), asoPerm.canModify(), asoPerm.canDelete(),
                            asoPerm.canAdd());
                    hash.put(userType.toString(), newPermOpts);
                }
            }
        }
    }
    writePerms(mainHash, filename);

    for (SpPrincipal p : groupMap.values()) {
        persist(p);
    }

    for (String permName : mainHash.keySet()) {
        Hashtable<String, PermissionOptionPersist> hash = mainHash.get(permName);
        for (String userType : hash.keySet()) {
            PermissionOptionPersist tp = hash.get(userType);
            SpPermission perm = tp.getSpPermission();
            sessionArg.saveOrUpdate(perm);

            Set<SpPrincipal> groupSet = new HashSet<SpPrincipal>();
            groupSet.add(groupMap.get(userType));
            perm.setPrincipals(groupSet);
            perm.setName(prefix + permName);
        }
    }
}

From source file:net.rim.ejde.internal.packaging.PackagingManager.java

private Vector<String> getProtectionOptions(boolean forMakefile) {
    Vector<String> v = new Vector<String>();
    Hashtable<String, String> classProtection, packageProtection;
    classProtection = _bbProject.getProperties()._hiddenProperties.getClassProtection();
    packageProtection = _bbProject.getProperties()._hiddenProperties.getPackageProtection();
    Object keys[] = packageProtection.keySet().toArray();
    for (int i = 0; i < keys.length; ++i) {
        v.addElement("package:" + Util.doubleDollar(keys[i].toString()) + "="
                + stripPath(packageProtection.get(keys[i])));
    }//from  ww w. ja v  a  2  s  . c om
    keys = classProtection.keySet().toArray();
    for (int i = 0; i < keys.length; ++i) {
        if (forMakefile) {
            v.addElement("class:" + Util.doubleDollar(keys[i].toString()) + "="
                    + stripPath(classProtection.get(keys[i])));
        } else {
            // When we are not creating a makefile don't add double $$ to rapc cmd line
            v.addElement("class:" + keys[i].toString() + "=" + stripPath(classProtection.get(keys[i])));
        }
    }
    return v;
}

From source file:edu.ku.brc.specify.config.init.DataBuilder.java

/**
 * @param filename//from  ww  w  .j a v  a 2  s  .com
 * @param prefix
 * @param groupMap
 */
public static void mergeDefaultPermissions(final String filename, final String prefix,
        final Map<String, List<Integer>> groupMap) {
    Hashtable<String, Hashtable<String, PermissionOptionPersist>> mainHash = BaseTask
            .readDefaultPermsFromXML(filename);
    for (String permName : mainHash.keySet()) {
        String userType = "LimitedAccess";
        Hashtable<String, PermissionOptionPersist> hash = mainHash.get(permName);
        if (hash.get(userType) == null) {
            PermissionOptionPersist permOpts = hash.get("Manager");
            PermissionOptionPersist newPermOpts = new PermissionOptionPersist(permOpts.getTaskName(), userType,
                    permOpts.isCanView(), permOpts.isCanModify(), permOpts.isCanDel(), permOpts.isCanAdd());
            hash.put(userType, newPermOpts);
        }

        userType = "FullAccess";
        hash = mainHash.get(permName);
        if (hash.get(userType) == null) {
            PermissionOptionPersist permOpts = hash.get("Manager");
            PermissionOptionPersist newPermOpts = new PermissionOptionPersist(permOpts.getTaskName(), userType,
                    permOpts.isCanView(), permOpts.isCanModify(), permOpts.isCanDel(), permOpts.isCanAdd());
            hash.put(userType, newPermOpts);
        }
    }

    /*if (additionalSecOpts != null)
    {
    for (SpecifyUserTypes.UserType userType : SpecifyUserTypes.UserType.values())
    {
        System.out.println(userType.toString()+" --------------------------------------");
        for (SecurityOptionIFace aso : additionalSecOpts)
        {
            PermissionIFace asoPerm = aso.getDefaultPermissions(userType.toString());
            if (asoPerm != null)
            {
                System.out.println("  "+prefix+aso.getPermissionName()+"  "+asoPerm.getOptions());
            }
        }
    }
    }*/

    HashMap<SpPermission, List<Integer>> prinPermHash = new HashMap<SpPermission, List<Integer>>();
    for (String permName : mainHash.keySet()) {
        String fullPermName = prefix + permName;

        Hashtable<String, PermissionOptionPersist> hash = mainHash.get(permName);
        for (String userType : hash.keySet()) {
            PermissionOptionPersist tp = hash.get(userType);
            SpPermission perm = tp.getSpPermission();

            for (Integer id : groupMap.get(userType)) {
                String str = "SELECT p.SpPermissionID FROM sppermission AS p Inner Join spprincipal_sppermission AS pp ON p.SpPermissionID = pp.SpPermissionID "
                        + "WHERE p.Name = '%s' AND pp.SpPrincipalID = %d";
                String sql = String.format(str, fullPermName, id);
                Integer permId = BasicSQLUtils.getCount(sql);
                if (permId == null) {
                    System.out.println(String.format("Going to create %s for Prin: %d", fullPermName, id));
                    List<Integer> list = prinPermHash.get(perm);
                    if (list == null) {
                        perm.setName(fullPermName);
                        list = new ArrayList<Integer>();
                        prinPermHash.put(perm, list);
                    }
                    list.add(id);
                }
            }
        }
    }

    if (prinPermHash.size() > 0) {
        Connection conn = null;
        PreparedStatement pstmt1 = null;
        PreparedStatement pstmt2 = null;
        try {
            conn = DatabaseService.getInstance().getConnection();
            pstmt1 = conn.prepareStatement(
                    "INSERT INTO sppermission (Actions, Name, PermissionClass) VALUES (?, ?, ?)", //$NON-NLS-1$
                    Statement.RETURN_GENERATED_KEYS);
            pstmt2 = conn.prepareStatement(
                    "INSERT INTO spprincipal_sppermission (SpPermissionID, SpPrincipalID) VALUES (?, ?)"); //$NON-NLS-1$
            for (SpPermission spPerm : prinPermHash.keySet()) {
                for (Integer prinId : prinPermHash.get(spPerm)) {
                    pstmt1.setString(1, spPerm.getActions());
                    pstmt1.setString(2, spPerm.getName());
                    pstmt1.setString(3, spPerm.getClass().getName());
                    pstmt1.setString(3, BasicSpPermission.class.getCanonicalName());
                    pstmt1.executeUpdate();

                    Integer newPermId = BasicSQLUtils.getInsertedId(pstmt1);
                    pstmt2.setInt(1, newPermId);
                    pstmt2.setInt(2, prinId);
                    pstmt2.executeUpdate();
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PermissionService.class, e);
        } finally {
            try {
                if (pstmt1 != null)
                    pstmt1.close();
                if (pstmt2 != null)
                    pstmt2.close();
                if (conn != null)
                    conn.close();

            } catch (SQLException e) {
                e.printStackTrace();
                edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PermissionService.class, e);
            }
        }
    }
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.MobileServiceFeaturesTests.java

public void testFeaturesToStringConversion() {
    Hashtable<EnumSet<MobileServiceFeatures>, String> cases;
    cases = new Hashtable<EnumSet<MobileServiceFeatures>, String>();
    for (MobileServiceFeatures feature : MobileServiceFeatures.class.getEnumConstants()) {
        cases.put(EnumSet.of(feature), feature.getValue());
    }/*from  w ww  .  jav a 2  s.c o m*/
    cases.put(EnumSet.of(MobileServiceFeatures.TypedTable, MobileServiceFeatures.AdditionalQueryParameters),
            "QS,TT");
    cases.put(EnumSet.of(MobileServiceFeatures.UntypedTable, MobileServiceFeatures.AdditionalQueryParameters),
            "QS,TU");
    cases.put(EnumSet.of(MobileServiceFeatures.TypedTable, MobileServiceFeatures.Offline), "OL,TT");
    cases.put(EnumSet.of(MobileServiceFeatures.UntypedTable, MobileServiceFeatures.Offline), "OL,TU");
    cases.put(EnumSet.of(MobileServiceFeatures.TypedApiCall, MobileServiceFeatures.AdditionalQueryParameters),
            "AT,QS");
    cases.put(EnumSet.of(MobileServiceFeatures.JsonApiCall, MobileServiceFeatures.AdditionalQueryParameters),
            "AJ,QS");
    cases.put(EnumSet.of(MobileServiceFeatures.OpportunisticConcurrency, MobileServiceFeatures.Offline,
            MobileServiceFeatures.UntypedTable), "OC,OL,TU");

    for (EnumSet<MobileServiceFeatures> features : cases.keySet()) {
        String expected = cases.get(features);
        String actual = MobileServiceFeatures.featuresToString(features);
        assertEquals(expected, actual);
    }
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void applyStyles(Element inputSrcElement, Element out) {
    String type = out.getAttribute("type");
    String id = "Android" + type + (styleIndex++);
    String selId = id + ".sel";
    String unselId = id;/*  w  w  w .  j ava2  s . c o  m*/
    String pressedId = id + ".press";
    String disabledId = id + ".dis";

    outputResources.setThemeProperty(themeName, unselId + ".derive", type);
    outputResources.setThemeProperty(themeName, selId + "#derive", type + ".sel");
    outputResources.setThemeProperty(themeName, pressedId + "#derive", type + ".press");
    outputResources.setThemeProperty(themeName, disabledId + "#derive", type + ".dis");
    out.setAttribute("uiid", id);

    // If there is a width/height specified, we will use 3 piece borders to 
    // force preserved space.
    if ((getNS(inputSrcElement, "width", null) != null || getNS(inputSrcElement, "height", null) != null
            || getNS(inputSrcElement, "minHeight", null) != null
            || getNS(inputSrcElement, "minWidth", null) != null)
            && getNS(inputSrcElement, "background", null) == null) {
        // Removing this for now, because using border images just to ensure width is
        // crazy heavy and really shouldn't be necessary... will find a better way.
        /*
        String minWidth = getNS(inputSrcElement, "minWidth", getNS(inputSrcElement, "width", "5dp"));
        String minHeight = getNS(inputSrcElement, "minHeight", getNS(inputSrcElement, "height", "5dp"));
        System.out.println("Creating border with width "+minWidth+" and height "+minHeight+" for id "+id);
        Border border = Border.createHorizonalImageBorder(createBlankImage(minWidth, minHeight), createBlankImage("1dp", minHeight), createBlankImage("1dp", minHeight));
                
        setAllStyles(id, "border", border);
            */
    }

    if (getNS(inputSrcElement, "paddingTop", null) != null
            || getNS(inputSrcElement, "paddingBottom", null) != null
            || getNS(inputSrcElement, "paddingLeft", null) != null
            || getNS(inputSrcElement, "paddingRight", null) != null) {
        String padding = parseNumber(getNS(inputSrcElement, "paddingTop", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingBottom", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingLeft", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingRight", "0")).value;

        byte[] paddingUnits = new byte[] { parseNumber(get(inputSrcElement, "paddingTop", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingRight", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingBottom", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingLeft", "0")).unit };
        //System.out.println("Setting padding: "+padding);
        setAllStyles(id, "padding", padding);
        setAllStyles(id, "padUnit", paddingUnits);
    }

    if (getNS(inputSrcElement, "marginTop", null) != null
            || getNS(inputSrcElement, "marginBottom", null) != null
            || getNS(inputSrcElement, "marginLeft", null) != null
            || getNS(inputSrcElement, "marginRight", null) != null) {
        String margin = parseNumber(get(inputSrcElement, "marginTop", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginBottom", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginLeft", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginRight", "0")).value;

        byte[] marginUnits = new byte[] { parseNumber(get(inputSrcElement, "marginTop", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginRight", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginBottom", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginLeft", "0")).unit };
        //System.out.println("Setting margin "+margin);
        setAllStyles(id, "margin", margin);
        setAllStyles(id, "marUnit", marginUnits);
    }

    if (get(inputSrcElement, "background", null) != null) {
        // We have a custom background
        String backgroundStr = getNS(inputSrcElement, "background", null);
        if (backgroundStr.startsWith("@drawable/")) {
            try {
                backgroundStr = backgroundStr.substring(backgroundStr.indexOf("/") + 1);
                List<Element> items = getSelectorElementsForDrawable(backgroundStr);

                // 

                if (items != null) {
                    String defaultBackground = null;
                    String pressedBackground = null;
                    String disabledBackground = null;
                    String selectedBackground = null;
                    for (Element item : items) {

                        if (item.hasAttributeNS(NS_ANDROID, "drawable")) {
                            String itemDrawableStr = item.getAttributeNS(NS_ANDROID, "drawable");
                            if (itemDrawableStr.startsWith("@drawable/")) {
                                itemDrawableStr = itemDrawableStr.substring(itemDrawableStr.indexOf("/") + 1);
                            }
                            File itemDrawable = findDrawableResource(itemDrawableStr);
                            if (itemDrawable == null || (!itemDrawable.getName().endsWith(".png")
                                    && !itemDrawable.getName().endsWith(".jpg"))) {
                                // Let's not support nested xml drawables just yet...
                                // we'll skip this
                                continue;
                            }
                            if (!outputResources.containsResource(itemDrawable.getName())) {
                                // If the resource file hasn't imported the image yet, we won't set it here
                                continue;
                            }

                            if (item.hasAttributeNS(NS_ANDROID, "state_pressed")
                                    && "true".equals(item.getAttributeNS(NS_ANDROID, "state_pressed"))) {
                                pressedBackground = itemDrawable.getName();
                                //outputResources.setThemeProperty(themeName, pressedId+"#border", createImageBorder(itemDrawable.getName()));
                            } else if (item.hasAttributeNS(NS_ANDROID, "state_enabled")
                                    && "false".equals(item.getAttributeNS(NS_ANDROID, "state_enabled"))) {
                                //outputResources.setThemeProperty(themeName, disabledId+"#border", createImageBorder(itemDrawable.getName()));
                                disabledBackground = itemDrawable.getName();
                            } else if (item.hasAttributeNS(NS_ANDROID, "state_focused")
                                    && "true".equals(item.getAttributeNS(NS_ANDROID, "state_focused"))) {
                                selectedBackground = itemDrawable.getName();
                            } else {
                                defaultBackground = itemDrawable.getName();
                                //outputResources.setThemeProperty(themeName, id+".border", createImageBorder(itemDrawable.getName()));
                            }
                        }
                    }

                    if (defaultBackground != null) {
                        if (pressedBackground == null)
                            pressedBackground = defaultBackground;
                        if (selectedBackground == null)
                            selectedBackground = defaultBackground;
                        if (disabledBackground == null)
                            disabledBackground = defaultBackground;
                    }

                    if (defaultBackground != null) {
                        outputResources.setThemeProperty(themeName, id + ".border",
                                createImageBorder(defaultBackground));
                    }
                    if (pressedBackground != null) {
                        outputResources.setThemeProperty(themeName, pressedId + "#border",
                                createImageBorder(pressedBackground));
                    }
                    if (selectedBackground != null) {
                        outputResources.setThemeProperty(themeName, selId + "#border",
                                createImageBorder(pressedBackground));
                    }
                    if (disabledBackground != null) {
                        outputResources.setThemeProperty(themeName, disabledId + "#border",
                                createImageBorder(disabledBackground));
                    }
                }
            } catch (SAXException ex) {
                Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    if (false && (get(inputSrcElement, "drawable", null) != null
            || get(inputSrcElement, "drawableTop", null) != null
            || get(inputSrcElement, "drawableRight", null) != null
            || get(inputSrcElement, "drawableBottom", null) != null
            || get(inputSrcElement, "drawableLeft", null) != null)) {
        String iconDrawableStr = null;
        int iconPosition = -1;
        if (inputSrcElement.hasAttributeNS(NS_ANDROID, "drawableLeft")) {
            iconDrawableStr = get(inputSrcElement, "drawableLeft", null);
            iconPosition = Component.LEFT;
        } else if (get(inputSrcElement, "drawableRight", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableRight", null);
            iconPosition = Component.RIGHT;
        } else if (get(inputSrcElement, "drawableTop", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableTop", null);
            iconPosition = Component.TOP;
        } else if (get(inputSrcElement, "drawableBottom", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableBottom", null);
            iconPosition = Component.BOTTOM;
        }

        if (iconPosition >= 0) {
            switch (iconPosition) {
            case Component.TOP:
                out.setAttribute("textPosition", String.valueOf(Component.BOTTOM));
                break;
            case Component.BOTTOM:
                out.setAttribute("textPosition", String.valueOf(Component.TOP));
                break;
            case Component.LEFT:
                out.setAttribute("textPosition", String.valueOf(Component.RIGHT));
                break;
            case Component.RIGHT:
                out.setAttribute("textPosition", String.valueOf(Component.LEFT));
                break;
            }
            String backgroundStr = iconDrawableStr;
            if (backgroundStr.startsWith("@drawable/")) {
                try {
                    backgroundStr = backgroundStr.substring(backgroundStr.indexOf("/") + 1);
                    List<Element> items = getSelectorElementsForDrawable(backgroundStr);
                    if (items != null) {
                        for (Element item : items) {

                            if (item.hasAttributeNS(NS_ANDROID, "drawable")) {
                                String itemDrawableStr = item.getAttributeNS(NS_ANDROID, "drawable");
                                if (itemDrawableStr.startsWith("@drawable/")) {
                                    itemDrawableStr = itemDrawableStr
                                            .substring(itemDrawableStr.indexOf("/") + 1);
                                }
                                File itemDrawable = findDrawableResource(itemDrawableStr);
                                if (itemDrawable == null || (!itemDrawable.getName().endsWith(".png")
                                        && !itemDrawable.getName().endsWith(".jpg"))) {
                                    // Let's not support nested xml drawables just yet...
                                    // we'll skip this
                                    continue;
                                }
                                if (!outputResources.containsResource(itemDrawable.getName())) {
                                    // If the resource file hasn't imported the image yet, we won't set it here
                                    continue;
                                }
                                if (item.hasAttributeNS(NS_ANDROID, "state_pressed")
                                        && "true".equals(item.getAttributeNS(NS_ANDROID, "state_pressed"))) {
                                    out.setAttribute("pressedIcon", itemDrawableStr);
                                } else if (item.hasAttributeNS(NS_ANDROID, "state_enabled")
                                        && "false".equals(item.getAttributeNS(NS_ANDROID, "state_enabled"))) {

                                    out.setAttribute("disabledIcon", itemDrawableStr);
                                } else {
                                    out.setAttribute("icon", itemDrawableStr);
                                }
                            }
                        }
                    }
                } catch (SAXException ex) {
                    Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }

    // Try to find an existing style that we can merge
    Hashtable<String, Object> theme = outputResources.getTheme(themeName);

    String matchingId = findMatchingId(id, theme);
    if (matchingId != null) {
        //System.out.println("Found UIID with identical styles to "+id+".  Removing "+id+" and just using "+matchingId);
        // There is already a UIID that is identical to this one, so let's just
        // use that.
        out.setAttribute("uiid", matchingId);

        Set<String> keysToRemove = new HashSet<String>();
        String prefix = id + ".";
        for (String key : theme.keySet()) {
            if (key.startsWith(prefix)) {
                keysToRemove.add(key);
            }
        }
        for (String key : keysToRemove) {
            theme.remove(key);
        }
        outputResources.setTheme(themeName, theme);
    }
}

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

/**
 * @param clsHash/*from w  ww .  j av  a2s  . c o m*/
 */
private void showClassList(final Hashtable<String, Boolean> clsHash) {
    boolean wasVisible = false;
    boolean wasCreated = false;
    if (classFrame == null) {
        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g"));

        classList = new JList(new DefaultListModel());
        //pb.add(UIHelper.createLabel("Unused Classes"), cc.xy(1,1));
        pb.add(UIHelper.createScrollPane(classList), cc.xy(1, 1));

        pb.setDefaultDialogBorder();

        classFrame = new CustomFrame("Used Classes", CustomFrame.OK_BTN, pb.getPanel());
        classFrame.setOkLabel("Close");
        classFrame.createUI();
        wasCreated = true;

    } else {
        wasVisible = classFrame.isVisible();
    }

    Hashtable<String, Boolean> allClassesHash = new Hashtable<String, Boolean>();
    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        allClassesHash.put(ti.getShortClassName(), true);
    }

    for (String key : clsHash.keySet()) {
        allClassesHash.remove(key);
    }

    ((DefaultListModel) classList.getModel()).clear();
    TreeSet<String> keys = new TreeSet<String>(allClassesHash.keySet());
    for (String key : keys) {
        ((DefaultListModel) classList.getModel()).addElement(key);
    }

    // Can't believe I have to do this
    Rectangle r = classFrame.getBounds();
    r.height++;
    classFrame.setBounds(r);
    r.height--;
    //----
    classFrame.setBounds(r);

    if (wasCreated) {
        classFrame.pack();
    }

    if (!wasVisible) {
        UIHelper.centerAndShow(classFrame);
    }
}

From source file:com.pmarlen.model.controller.EntityJPAToPlainPojoTransformer.java

public static void copyPlainValues(Entity entity, Object plain) {
    final Class entityClass;
    entityClass = entity.getClass();//from w  w  w. jav a  2s .  c  o  m
    final String entityClassName = entityClass.getName();
    Hashtable<String, Object> propertiesToCopy = new Hashtable<String, Object>();
    Hashtable<String, Object> propertiesM2MToCopy = new Hashtable<String, Object>();
    List<String> propertiesWithNULLValueToCopy = new ArrayList<String>();
    List<String> propertiesKey = new ArrayList<String>();
    try {
        final Field[] declaredFields = entityClass.getDeclaredFields();
        for (Field f : declaredFields) {
            logger.trace("->create: \tcopy: " + entityClassName + "." + f.getName() + " accesible ? "
                    + (f.isAccessible()));
            if (!f.isAccessible()) {

                if (f.isAnnotationPresent(javax.persistence.Id.class)) {
                    propertiesKey.add(f.getName());
                }
                if (f.isAnnotationPresent(javax.persistence.Id.class)
                        && !f.isAnnotationPresent(javax.persistence.GeneratedValue.class)
                        && !Modifier.isStatic(f.getModifiers())) {

                    Object valueCopyed = PropertyUtils.getProperty(entity, f.getName());
                    if (valueCopyed != null) {
                        propertiesToCopy.put(f.getName(), valueCopyed);
                    } else {
                        propertiesWithNULLValueToCopy.add(f.getName());
                    }
                    logger.trace("->create:\t\t ID elegible 2 be copied, added to copy list: " + f.getName()
                            + " = " + valueCopyed + ", is really null?" + (valueCopyed == null));
                } else if (!f.isAnnotationPresent(javax.persistence.Id.class)
                        && !f.isAnnotationPresent(javax.persistence.OneToMany.class)
                        && !f.isAnnotationPresent(javax.persistence.ManyToMany.class)
                        && !Modifier.isStatic(f.getModifiers())) {

                    Object valueCopyed = PropertyUtils.getProperty(entity, f.getName());
                    if (valueCopyed != null) {
                        propertiesToCopy.put(f.getName(), valueCopyed);
                    } else {
                        propertiesWithNULLValueToCopy.add(f.getName());
                    }
                    logger.trace("->create:\t\t elegible 2 be copied, added to copy list: " + f.getName()
                            + " = " + valueCopyed + ", is really null?" + (valueCopyed == null));
                } else if (!f.isAnnotationPresent(javax.persistence.Id.class)
                        && f.isAnnotationPresent(javax.persistence.ManyToMany.class)) {

                    Object valueCopyed = PropertyUtils.getProperty(entity, f.getName());
                    if (valueCopyed != null) {
                        propertiesM2MToCopy.put(f.getName(), valueCopyed);
                    } else {
                        propertiesWithNULLValueToCopy.add(f.getName());
                    }
                    logger.trace("->create:\t\t M2M elegible 2 be copied, added to copy list: " + f.getName()
                            + " = " + valueCopyed + ", is really null?" + (valueCopyed == null));
                }
            }
        }
        logger.trace("->create:copy values ?");
        for (String p2c : propertiesToCopy.keySet()) {
            Object valueCopyed = propertiesToCopy.get(p2c);
            logger.trace("->create:\t\t copy value with SpringUtils: " + p2c + " = " + valueCopyed
                    + ", is null?" + (valueCopyed == null));
            BeanUtils.copyProperty(plain, p2c, valueCopyed);
        }
        for (String p2c : propertiesWithNULLValueToCopy) {
            logger.trace("->create:\t\t copy null with SpringUtils");
            BeanUtils.copyProperty(plain, p2c, null);
        }
    } catch (Exception e) {
        logger.error("..in copy", e);
    }
}

From source file:edu.ku.brc.ui.IconManager.java

/**
 * Loads icons from config file/*from ww w  .  ja va 2s .c om*/
 *
 */
public static void loadIcons(final File iconFile) {
    try {
        Element root = XMLHelper.readFileToDOM4J(iconFile);
        if (root != null) {
            Hashtable<String, String> aliases = new Hashtable<String, String>();
            Element iconsNode = (Element) root.selectSingleNode("/icons");
            String type = XMLHelper.getAttr(iconsNode, "type", null);
            String subdir = XMLHelper.getAttr(iconsNode, "subdir", null);
            if (StringUtils.isNotEmpty(type)) {
                if (instance.iconSets.get(type) == null) {
                    instance.iconListForType = new Vector<String>();
                    instance.iconSets.put(type, instance.iconListForType);
                } else {
                    log.debug("Type [" + type + "] has already been loaded.");
                }
            }

            if (StringUtils.isNotEmpty(subdir)) {
                subdirPath = subdir + "/";
            } else {
                subdirPath = null;
            }

            List<?> boxes = root.selectNodes("/icons/icon");
            for (Iterator<?> iter = boxes.iterator(); iter.hasNext();) {
                org.dom4j.Element iconElement = (org.dom4j.Element) iter.next();

                String name = iconElement.attributeValue("name");
                String sizes = iconElement.attributeValue("sizes");
                String file = iconElement.attributeValue("file");
                String alias = iconElement.attributeValue("alias");

                if (StringUtils.isNotEmpty(alias)) {
                    aliases.put(name, alias);

                } else if (sizes == null || sizes.length() == 0 || sizes.toLowerCase().equals("all")) {

                    //log.info("["+name+"]["+sizes+"]["+file+"]");
                    //this is the cache of the icons, i want to just cache filename
                    /*IconEntry entry = register(name, file, IconManager.IconSize.Std32);
                    if (entry != null)
                    {
                       entry.addScaled( IconSize.Std32, IconSize.Std24);
                       entry.addScaled( IconSize.Std32, IconSize.Std16); 
                    }*/
                    //---------do not need to addScaled, the image will scale when it is needed

                    register(name, file, IconManager.IconSize.Std32);

                } else if (sizes.toLowerCase().equals("nonstd")) {
                    register(name, file, IconSize.NonStd);

                } else {
                    StringTokenizer st = new StringTokenizer(sizes, ",");
                    while (st.hasMoreTokens()) {
                        String sz = st.nextToken();
                        register(name, file, getSizeFromInt(Integer.parseInt(sz)));
                    }
                }
            }

            for (String name : aliases.keySet()) {
                IconEntry entry = instance.defaultEntries.get(aliases.get(name));
                if (entry != null) {
                    instance.defaultEntries.put(name, entry);
                }
                //makeAlias(aliases.get(name), name);
            }
        } else {
            log.debug("Couldn't open icons.xml");
        }
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(IconManager.class, ex);
        ex.printStackTrace();
        log.error(ex);
    }

    subdirPath = null;
    instance.iconListForType = null;
}