Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:26:06+00:00 2026-06-04T23:26:06+00:00

Can anyone suggest me why the if condition is not working in the below

  • 0

Can anyone suggest me why the if condition is not working in the below code as the record has key as SiteId.

while (!pdsxOutRecords.isEmpty()) {
PdsxRecord record = pdsxOutRecords.remove(0);
// The below if condition is not working
if(record.getAttrs().containsKey("SiteId")) {
System.out.println("Testing");
}
}

And PdsxRecord class is like this

public class PdsxRecord
{
    private String m_key;
    private Map<PdsxAttrKey, PdsxAttrValue> m_mapAttrs;

}
// constructor
    public PdsxRecord(String key, Map<PdsxAttrKey, PdsxAttrValue> mapAttrs)
    {
        m_key = key;
        m_mapAttrs = mapAttrs;
    }

    public String getKey()
    {
        return m_key;
    }

    public Map<PdsxAttrKey, PdsxAttrValue> getAttrs()
    {
        return m_mapAttrs;
    }

Below thing gets printed by using record.getAttrs()

{Gem.2036=null, Gem.2037=null, Gem.2038=com.ebay.pdsx.common.PdsxAttrValue@6b306b30, Gem.2039=null, Gem.10230=null, Gem.10117=null, Gem.10119=null, Gem.10240=null, UID=com.ebay.pdsx.common.PdsxAttrValue@1e501e50, Gem.10001=null, Gem.10002=com.ebay.pdsx.common.PdsxAttrValue@5d095d09, Gem.10003=null, Gem.10246=null, Gem.10247=null, Gem.60001=null, Gem.10007=null, Gem.10009=null, GEM_ROUTING.PartnerLastModifiedDate=null, Gem.70006=null, CGUID=com.ebay.pdsx.common.PdsxAttrValue@1e361e36, Gem.10173=null, Gem.10097=null, Gem.10131=null, Gem.10010=null, Gem.10132=null, Gem.10177=null, Gem.10178=null, Gem.10179=null, Gem.10015=null, TimeStamp=com.ebay.pdsx.common.PdsxAttrValue@1e571e57, Gem.10016=com.ebay.pdsx.common.PdsxAttrValue@645e645e, Gem.10018=null, Gem.10019=null, Gem.2025=null, SiteId=com.ebay.pdsx.common.PdsxAttrValue@1e3f1e3f, GEM_ROUTING.Partner1LastLoggedInUserId=null, GEM_ROUTING.Partner3LastLoggedInUserId=null, Gem.10181=null, Gem.10182=null, Gem.10183=null, Gem.10185=null, Gem.10187=null, Gem.10101=null, Gem.10189=null, Gem.10102=null, Gem.10026=null, PGuid=com.ebay.pdsx.common.PdsxAttrValue@1e461e46, Gem.2032=null, SGuid=null, Gem.2033=null, Gem.2034=null, Gem.2035=null}

This is the below PdsxRecord class

    public class PdsxRecord
{
    private String m_key;
    private Map<PdsxAttrKey, PdsxAttrValue> m_mapAttrs;

    // use the other constructor!
    protected PdsxRecord()
    {
    }

    // constructor
    public PdsxRecord(String key, Map<PdsxAttrKey, PdsxAttrValue> mapAttrs)
    {
        m_key = key;
        m_mapAttrs = mapAttrs;
    }

    /**
     * get Key 
     * 
     * @return
     */
    public String getKey()
    {
        return m_key;
    }

    /**
     * get attributes as a map of key=value
     * 
     * @return
     */
    public Map<PdsxAttrKey, PdsxAttrValue> getAttrs()
    {
        return m_mapAttrs;
    }

    /**
     * String -- for debugging and simple persistence
     */
    public String toString()
    {
        UnsynchronizedStringBuffer buf = new UnsynchronizedStringBuffer();
        buf.append("key=" + getKey() + "\n");
        if (getAttrs() == null || getAttrs().size() == 0) {
            return buf.toString();
        }

        for (Map.Entry<PdsxAttrKey, PdsxAttrValue> entry : getAttrs().entrySet()) {
            String key = (entry.getKey()==null ? "null" : entry.getKey().getKey());
            String value = ((entry.getValue() == null ||
                            entry.getValue().getValue() == null) ? 
                        "null" : entry.getValue().getValue().toString());
            buf.append("  " + key + "=" + value +"\n");
        }
        return buf.toString();
    }

}

Updated:- Class for PdsxAttrKey

public class PdsxAttrKey
    {
        private String m_key;

        protected PdsxAttrKey()
        {
        }

        public PdsxAttrKey(String key)
        {
            m_key = key;
        }

        public String getKey()
        {
            return m_key;
        }

        /**
         * Override the default to allow comparing with Strings 
         */
        public boolean equals(Object o)
        {
            if (o == null) {
                return false;
            }
            if (o instanceof String) {
                return o.equals(m_key);
            }
            if (o instanceof PdsxAttrKey) {
                return m_key.equals(((PdsxAttrKey)o).getKey());
            }
            return false;
        }

        /**
         * hash code implementation
         */
        public int hashCode()
        {
            return (m_key == null ? 0 : m_key.hashCode());
        }

        public String toString()
        {
            return getKey();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:26:09+00:00Added an answer on June 4, 2026 at 11:26 pm

    Maybe because you Map is consisting of PdsxAttrKey as a key, and you are checking if there’s a key which is a String with value “SiteId”.

    Here’s some code that might be useful if you do not want to change your Map definition from Map<PdsxAttrKey, PdsxAttrValue> to something like Map<String, PdsxAttrValue>:

    while (!pdsxOutRecords.isEmpty()) {
      PdsxRecord record = pdsxOutRecords.remove(0);
      if(record.getAttrs().containsKey(new PdsxAttrKey("SiteId"))) {
        System.out.println("Testing");
      }
    }
    

    Note that this assumes that you can pass a String to the PdsxAttrKey constructor, and that the class can be instantiated. Oh and of course that you have equals() and hashcode() in the class, which pretty much only check the String value for the of the PdsxAttrKey. You might ask yourself if this is really worth the hassle. That’s why I originally suggested that your change your Map definition to use Strings as keys, but of course I am not sure if this is a viable solution in your case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone suggest an easy fix for the query below? Workout.all(:joins => [:person, :schedule],
Can anyone suggest a way to shave any time off this script? var countObject
Can anyone suggest me good plugin for memory leakage which can be integrated in
Can anyone suggest a good javascript library for displaying and navigating huge images in
Can anyone suggest some fast ways to calculate the lowest common factor(excluding 1) of
Can anyone suggest a book or a tutorial on creating Charts in PHP extracting
Can anyone suggest a good solution to remove duplicates from nested lists if wanting
Can anyone suggest some best options to include charting feature in my ASP.NET pages
Can anyone suggest me a good papervision3D book to read? I know as3 pretty
Can anyone suggest where can I find good starter videos for ASP.NET MVC (other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.