Stuck in HashMap + equals() behaviour

I am studying the SCJP 6, and got stuck in one example from the book.
package map583;
import java.util.*;
public class Dog {
    public Dog(String n) {
        name = n;
    public String name;
    public boolean equals(Object o) {
        if(o instanceof Dog){
            Dog dog = (Dog) o;
            if(dog.name.equalsIgnoreCase(this.name)){
                return true;
            }else{
                return false;
        } else {
            return false;
    public int hashCode() {
        return name.length();
package map583;
import java.util.*;
public class MapTest {
    public static void main(String[] args) {
        Map<Object, Object> m = new HashMap<Object, Object>();
        Dog d1 = new Dog("clover");
        m.put(d1, "Dog key");
        d1.name = "123456";
        System.out.println(m.get(d1));
}The output is "Dog Key", what I question is when changing d1.name to "123456", hashcode() returns same value, BUT equals() method compares to String values, obviously the Dog object name value in HashMap is "clover", but the d1.name value is "123456", and they are not the same.
This gives me another assumption. Is the changing of name to "123456" actually changes the dog object name value in the HashMap? Because the dog object stored in the HashMap is d1. But when I changed the code to :
        d1.name = "1234567890";
        System.out.println(m.get(d1));It outputs null now. So it proves that the dog object stored in the HashMap CANNOT be changed by changing d1.name value, so how to explain my first question?

roamer wrote:
Now same question again, then how to explain this?
d1.name = "1234567890";
System.out.println(m.get(d1));   // returns "null". #2the key in the HashMap stores the variable name d1, which points to the Dog object modified by the above statement, which name is "1234567890" now. So when searching the HashMap, the argument passed (d1) is actually referencing the SAME object as the variable in the HashMap (which is also d1), same hashcode AND returns true in equals() method.
So what the hell why this statment fails but #1 succeeded. When thinking in the same logic flow.Okay, you are REALLY missing the point here. We never get to the equals check because the hashCode is different, so it doesn't matter if it's the same object. This is what I tried to explain to you earlier: The messed up hash code might make you not even have a chanceto compare the object. With this very simple hashCode, changing the name to a different one of the same length didn't alter the hashCode, but changing it to a different length did, so we searched the wrong bucket, and therefore never had a chance to find the object.
Dog d1 = new Dog("clover"); // A
m.put(d1, "Dog key"); // B
System.out.println(m.get(d1)); // C   // returns "Dog key". ---- Yes, it is normal.
d1.name = "123456"; // D
System.out.println(m.get(d1)); // E   // returns "Dog key". #1
d1.name = "1234567890"; // F
System.out.println(m.get(d1)); // G   // returns "null". #2A: Create an instance of Dog. name = "clover", stick a reference to it in variable d1
B. Put a an entry in the map where the key is that Dog and the value is "Dog Key". The reference to the key is stored in the bucket for hashCode=6
C. Search for d1 in the map. This means 1) Get hashCode of object pointed to by d1 (6). 2) Find that bucket. 3) For each element in that bucket, check if it equals(d1) 4. When we find the Dog in that bucket that equals(d1) because its name equals(d1.name), we return the corresponding value: "Dog key"
D. Set the name of the only Dog object we've created to "123456". This does not change its bucket in the map, because hashCode() uses name.length(), which is still 6.
E. Same as C, except now we're loooking for name of "123456" instead of "clover"
F. Set the Dog object's name to "1234567890". This changes its hashcode, so it is (probably) no longer in the same bucket.
G. Search for d1 in the map. This means 1) Get hashCode of object pointed to by d1 (10). 2) Find that bucket. 3) For each element in that bucket, check if it equals(d1) 4. Since it's a different bucket, it doesn't matter if equals() is true, or even if == is true. The object is not found because we searched the wrong bucket.
Note also what would happen if we had two different Dog objects. If we change the one in the map from "clover" to "123456", we'll still search the same bucket, but we won't return anything because d1 is a different object and "clover".equals("123456") is false. The second case would still return null for the same reason it currently does--we'd never even get to search the right bucket.
Edited by: jverd on Feb 2, 2010 7:34 PM

Similar Messages

  • Stuck in HashMap

    Thank you for your reply. I have re-worked my code and only issue I have in the compiler is with the displayMap method. I have no idea if this is going to work after I fix this issue. However, I'm reposting the requirements and my classes to see if you can spot my errors. It's such a shame that books and tutorials are so weak in such an important subject and I can't seem to find someone to talk to and to guide me on HashMaps. I do understand perfectly what it is suppose to do, but can't seem to grasp the concepts to implement them. Thank you again for your assistance.
    Requirement 1: Implement your author tracking application. You do not have to read the book information from a file. You may enter it from the keyboard. You'll need to enter author last name and book title. No duplicate entries for an author last name should be stored; therefore be sure to use the appropriate collection class to store your author names. No book titles will be stored.
    Requirement 2: Create an Author class that stores author's name and total royalties. Create an AuthorCode hashmap to store an author id and Author class. Use author id as the key and Author Class as the value.
    Test application: Your test application should print the list of authors sorted alphabetically when done inputing authors and titles (tests implementation of requirement 1). Be sure to test multiple books for the same author to ensure you are not storing duplicates. To test requirement 2, your test application will prompt you for an author ID and using method(s) on HashMap, provide you a readable output of the Author's information for the entered author id.
    Hint: You may want to look into overriding toString() method to provide a readable string representation of Author object. - with the help of NetBean and my revisions, this method was created.
    First you need to take the author information read in and store in an author class. - Hopefully, I have done this step.
    Call the constructor for your Author class with the author/book information you read in:
    new Author(authorNameReadInString, bookTitleReadInString) - This one is not clear for me at all.
    You'll want to put this in the map. Create an author id for the key. TO do this you can just increment i each time you add an author. Be sure to initialize i.
    int i = 0;
    map.put(i, new Author(authorNameReadInString, bookTitleReadInString); - when I do this step with variables, I get multiple errors.  This method took the call to my class AuthorRoyal and most of the erros were gone.
    I didn't provide perfect syntax but hopefully this sheds some light.
    I'm having to post my code in separate sections because of the forums' length limitation.

    Oops the other class was my AuthorRoyal class. Here is the main class
    import java.util.StringTokenizer;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Set;
    import java.util.TreeSet;
    import java.util.Scanner;
    public class AuthorMapMain {
      private Map < Integer, AuthorRoyal> authorcode;
      private Scanner scanner;
      int i = 0;
      public AuthorMapMain()
         authorcode = new HashMap< Integer, AuthorRoyal > (); // create HashMap
         scanner = new Scanner( System.in ); // create scanner
         createMap(); // create map based on user input
         displayMap(); // display map content
      // method to create map from user input
      private void createMap()
        System.out.println( "Enter author fist name, last name, and book title:"); // prompt for user input
        String a = scanner.nextLine( ); // reads user input following the prompt
          // create StringTokenizer for input
          StringTokenizer tokenizer = new StringTokenizer( a );
          // processing input text
          while ( tokenizer.hasMoreTokens() ) // while more input
             // if the map contains the word
                String authorid = tokenizer.nextToken(); // get author
             if ( authorcode.containsKey( authorid ) ) // is key in map
                 authorcode.put(i, new AuthorRoyal());
               } // end if
            // else
              //     authorcode.put ( );
              // add new word with a count of 1 to map
           } // end while
         // display map content
       private void displayMap()
          // sort keys
          Set< Integer > keys = authorcode.keySet(); // get keys
          TreeSet< String > sortedKeys = new TreeSet< String >( keys ); // ERROR after new TreeSet appears in NetBean underlined
          System.out.println( "Map contains:\nKey\t\tValue" );
          // generate output for each key in map
          for ( String key : sortedKeys )
             System.out.printf( "%-10s%10s%10s%n", key, authorcode.get( key ) );
          System.out.printf(
             "%nsize:%d%nisEmpty:%b%n", authorcode.size(), authorcode.isEmpty() );
       } // end method displayMap
        public static void main(String[] args) {
         // new AuthorRoyal();
          new AuthorMapMain();
    }

  • Why am I getting == instead of equals() behaviour when I add to a HashSet?

    I want to maintain a set of ordered pairs. I have created a generic class OrderedPair<K,V>, and given it the following equals method:
        public boolean equals (OrderedPair<K,V> otherGuy) {
         return otherGuy != null && this.key.equals(otherGuy.key) && this.value.equals(otherGuy.value);
        }Now I want to create a set (say HashSet) of OrderedPairs of Strings that (obviously!) will not add a pair p if there is already a pair p1 in the set such that p.equals(p1).
        OrderedPair<String,String> p1 = mkPair ("tea", "biscuits");
        OrderedPair<String,String> p2 = mkPair ("tea", "biscuits");
        HashSet<OrderedPair<String,String>> s =  new HashSet<OrderedPair<String,String>>();
        s.add(p1);
        s.add(p1); // doesn't add a second copy
        s.add(p2) // now there are two pairs in the set, but they are "equal"If I add p1 or p2 multiple times, only the first attempt succeeds for each object tried, so the impl seems to be cheking reference identity rather than the equals method I so lovingly designed for OrderedPair.
    So what, conceptually, am I missing here?
    Thanks.
    -- Mike

    OK, thanks everyone. In hindsight, it's completely obvious, isn't it.
    So I've written the equals(Object) below in the naive way and I'm getting warnings about unsafe cast at line (a) and an unsafe assignemtn at line (b). I understand why this is a problem, but I'm not sure what the best solution is.
    How does one ask about instanceof for the otherObject, and how does one cast an Object to an OrderedPair<K,V> in a safe way?
        public boolean equals (Object otherObject) {
         if (otherObject == null || ! (otherObject instanceof OrderedPair<K,V>)) {    //line (a)
             return false;
         } else {
             OrderedPair<K,V> otherPair = (OrderedPair<K,V>) otherObject;      // line (b)
                return this.key.equals(otherPair.key)  && this.value.equals(otherPair.value);

  • Same query giving different results

    Hi
    I m surprised to see the behaviour of oracle. I have two different sessions for same scheema on same server. In both sessions same query returns different results. The query involves some calculations like sum and divisions on number field.
    I have imported this data from another server using export / import utility available with 9i server. Before export every thing was going fine. Is there some problem with this utility.
    I m using Developer 6i as the front end for my client server application. The behaviour of my application is very surprizing as once it shows the correct data and if I close the screen and reopen, it shows wrong data.
    I m really stucked with the abnormal behaviour. Please tell me the possiblities and corrective action for these conditions.
    Regards
    Asad.

    There is nothing uncommitted in both the sessions. But still different results are returned.
    I m sending u the exact query and result returned in both sessions.
    Session 1:
    SQL> rollback;
    Rollback complete.
    SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
    2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
    3 WHERE G.COURSE_CDE=CC.COURSE_CDE
    4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
    5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
    6 /
    CREDIT_HRS GRADE_PTS
    3 4
    4 3.33
    4 3.33
    3 4
    3 4
    3 4
    3 4
    7 rows selected.
    SQL>
    SESSION 2:
    SQL> rollback;
    Rollback complete.
    SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
    2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
    3 WHERE G.COURSE_CDE=CC.COURSE_CDE
    4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
    5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
    6 /
    CREDIT_HRS GRADE_PTS
    3 4
    4 3.33
    3 4
    3 4
    3 4
    3 4
    6 rows selected.
    SQL>
    U can see in session 1, seven rows are returned while in session 2 six rows are returned. I have issued a rollback before query to be sure that data in both sessions is same.

  • Cannot prevent ExtendScript debugging while running scripts from After Effects

    Hi,
    I am facing this issue while running scripts from within After Effects. Whenever I am trying to run a script in After Effects, the script opens up in ESTK in the debug mode. The execution waits at the starting point of the script as if there is breakpoint even though there is none. I am not sure whether what I am missing, whether some debug flag needs to be reset etc. I am using After Effects CC on Windows 7 OS. Any help would be highly appreciated.
    Thanks.

    I tried running the script after removing all $.writeln() statements, but unfortunately that does not resolve the problem. For testing the issue, I am trying with the simple script given below :
    var window = new Window ("palette", "My Window", undefined);
    var panel = window.add("panel", undefined, "Panel");
    var text = panel.add("statictext", undefined, "Testing AE");
    window.show();
    But executing even this one from AE opens up ESTK. I am absolutely stuck with this odd behaviour .

  • TDD JUnit

    Hi, I have been trying to use Test driven development and work back from test cases. So far I have these test cases:
    package poly;
    import static org.junit.Assert.*;
    import org.junit.Test;
    public class ConEqTest {
         private int min = Integer.MIN_VALUE;
         private int max = Integer.MAX_VALUE;
          * Testing the constructor
          * Values for coefficient: min -7 0 7 max Values for exponent: -1 0 9 max
          * Combinations for test cases: con1 (min,9) ok con2 (-7,9) ok con3 (0,9) ok
          * con4 (7,9) ok con5 (max,9) ok con6 (7, -1) NegativeExponent con7 (7,0) ok
          * con8 (7,9) ok con9 (7,max) ok
         @Test
         public void con1() throws TError {
              new Term(min, 9);
         @Test
         public void con2() throws TError {
              new Term(-7, 9);
         @Test
         public void con3() throws TError {
              new Term(0, 9);
         @Test
         public void con4() throws TError {
              new Term(7, 9);
         @Test
         public void con5() throws TError {
              new Term(max, 9);
         @Test(expected = NegativeExponent.class)
         public void con6() throws TError {
              new Term(7, -1);
         @Test
         public void con7() throws TError {
              new Term(7, 0);
         @Test
         public void con8() throws TError {
              new Term(7, 9);
         @Test
         public void con9() throws TError {
              new Term(7, max);
          * Valid terms that are equivalent: eq01 (-10,0) (-10,0) => true eq02 (0,0)
          * (0,0) => true eq03 (0,0) (0,2) => true eq04 (10,0) (10,0) => true eq05
          * (-10,2) (-10,2) => true eq06 (0,2) (0,0) => true eq07 (0,2) (0,2) => true
          * eq08 (10,2) (10,2) => true
          * Valid terms that are not equivalent eq09 (-10,0) (0,0) => false eq10
          * (-10,0) (10,0) => false eq11 (0,0) (-10,0) => false eq12 (0,0) (10,0) =>
          * false eq13 (10,0) (-10,0) => false eq14 (10,0) (0,0) => false eq15
          * (-10,0) (-10,2) => false eq16 (10,0) (10,2) => false
          * Invalid objects eq17 (10,2) null => false eq18 (10,2) "junk" => false
          * eq19 (10,2) (10,-2) => NegativeExponent eq20 (0,0) null => false
          * Testing Zero eq21 Test.Zero (0,1) => true eq22 Test.Zero (0,0) => true
         @Test
         public void eq01() throws TError {
              assertTrue(new Term(-10, 0).equals(new Term(-10, 0)));
         @Test
         public void eq02() throws TError {
              assertTrue(new Term(0, 0).equals(new Term(0, 0)));
         @Test
         public void eq03() throws TError {
              assertTrue(new Term(0, 0).equals(new Term(0, 2)));
         @Test
         public void eq04() throws TError {
              assertTrue(new Term(10, 0).equals(new Term(10, 0)));
         @Test
         public void eq05() throws TError {
              assertTrue(new Term(-10, 2).equals(new Term(-10, 2)));
         @Test
         public void eq06() throws TError {
              assertTrue(new Term(0, 2).equals(new Term(0, 0)));
         @Test
         public void eq07() throws TError {
              assertTrue(new Term(0, 2).equals(new Term(0, 2)));
         @Test
         public void eq08() throws TError {
              assertTrue(new Term(10, 2).equals(new Term(10, 2)));
         @Test
         public void eq09() throws TError {
              assertFalse(new Term(-10, 0).equals(new Term(0, 0)));
         @Test
         public void eq10() throws TError {
              assertFalse(new Term(-10, 0).equals(new Term(10, 0)));
         @Test
         public void eq11() throws TError {
              assertFalse(new Term(0, 0).equals(new Term(-10, 0)));
         @Test
         public void eq12() throws TError {
              assertFalse(new Term(0, 0).equals(new Term(10, 0)));
         @Test
         public void eq13() throws TError {
              assertFalse(new Term(10, 0).equals(new Term(-10, 0)));
         @Test
         public void eq14() throws TError {
              assertFalse(new Term(10, 0).equals(new Term(0, 0)));
         @Test
         public void eq15() throws TError {
              assertFalse(new Term(-10, 0).equals(new Term(-10, 2)));
         @Test
         public void eq16() throws TError {
              assertFalse(new Term(10, 0).equals(new Term(10, 2)));
         @Test
         public void eq17() throws TError {
              assertFalse(new Term(10, 2).equals(null));
         @Test
         public void eq18() throws TError {
              assertFalse(new Term(10, 2).equals("junk"));
         @Test(expected = NegativeExponent.class)
         public void eq19() throws TError {
              assertFalse(new Term(10, 2).equals(new Term(10, -2)));
         @Test
         public void eq20() throws TError {
              assertFalse(new Term(0, 0).equals(null));
         @Test
         public void eq21() throws TError {
              assertEquals(Term.Zero, new Term(0, 1));
         @Test
         public void eq22() throws TError {
              assertEquals(Term.Zero, new Term(0, 0));
          * Check the predicate functions
          * zero1 isZero(zero) => true zero2 isZero(unit) => false zero3
          * isZero((0,5)) => true zero4 isZero((5,0)) => false
         @Test
         public void zero1() throws TError {
              assertTrue(Term.Zero.isZero());
         @Test
         public void zero2() throws TError {
              assertFalse(Term.Unit.isZero());
         @Test
         public void zero3() throws TError {
              assertTrue(new Term(0, 5).isZero());
         @Test
         public void zero4() throws TError {
              assertFalse(new Term(5, 0).isZero());
          * neg1 isNegative(zero) => false neg2 isNegative(unit) => false neg3
          * isNegative(-1,0) => true neg4 isNegative(min,2) => true neg5
          * isNegative(max,2) => false
         @Test
         public void neg1() throws TError {
              assertFalse(Term.Zero.isNegative());
         @Test
         public void neg2() throws TError {
              assertFalse(Term.Unit.isNegative());
         @Test
         public void neg3() throws TError {     
              assertTrue(new Term(-1, 2).isNegative());
         @Test
         public void neg4() throws TError {
              assertTrue(new Term(Integer.MIN_VALUE, 2).isNegative());
         @Test
         public void neg5() throws TError {
              assertFalse(new Term(Integer.MAX_VALUE, 2).isNegative());
          * const1 isConstant(zero) => true const2 isConstant(unit) => true const3
          * isConstant(0,5) => true const4 isConstant(5,1) => false
         @Test
         public void const1() throws TError {
              assertTrue(Term.Zero.isConstant());
         @Test
         public void const2() throws TError {
              assertTrue(Term.Unit.isConstant());
         @Test
         public void const3() throws TError {
              assertTrue(new Term(0, 5).isConstant());
         @Test
         public void const4() throws TError {
              assertFalse(new Term(5, 1).isConstant());
    }and my term class so far is:
    package poly;
    public class Term {
         public Term(int c, int e) throws NegativeExponent {
         public boolean isConstant() {
         public boolean isZero() {
         public boolean isNegative() {
         public String toString() {
         public boolean equals(Object that) {
         public Term negate() throws CoefficientOverflow {
         public Term scale(int m) throws CoefficientOverflow {
         public Term times(Term that) throws CoefficientOverflow, ExponentOverflow {
         public Term add(Term that) throws CoefficientOverflow, IncompatibleTerms {
    }I have a version where I can get about 50% of the tests to work, but I am not sure I am even doing it correctly. If someone could advise me, it would be really helpful. I am mainly stuck on the "equals" function and the "isZero" function.
    Thank you!
    Edited by: 968077 on 28-Oct-2012 08:12
    Edited by: 968077 on 28-Oct-2012 08:13

    Hi my term class is:
    package poly;
    public class Term
         final private int coef;
         final private int expo;
         private static Term zero, unit;
         static     {     try {      zero = new Term(0,0);          // the number zero
                                  unit = new Term(1,0);          // the number one
                        catch (Exception e) {
                             // constructor will not throw an exception here anyway
          * @param c The coefficient of the new term
          * @param e The exponent of the new term (must be non-negative)
          * @throws NegativeExponent
         public Term(int c, int e) throws NegativeExponent {
              if (e <= 0) throw new NegativeExponent();
              coef = c;
              expo = (coef == 0) ? 1 : e;
         final public static Term Zero = zero;
         final public static Term Unit = unit;
          * Tests to see if the term represents a constant value
          * @return true if the term has a zero coefficient
         public boolean isConstant() {
              return false;  // unimplemented - default value false is only a placeholder
          * Tests to see if the term is equal to zero
          * @return true if the term is equal to zero
         public boolean isZero() {
              return false;  // unimplemented - default value false is only a placeholder
          * Tests to see if the term is negative
          * @return true if the coefficient is less than
         public boolean isNegative() {
              return false;  // unimplemented - default value false is only a placeholder
          * Represents a term as a string in a standard form: specification by example:
          * (An underscore represents any value)
          * (-7,0)          =>     "-7"
          * (-7,1)          =>     "-7x"
          * (-7,2)          =>     "-7^2"
          * (-1,0)          =>     "-1"
          * (-1,1)          =>     "-x"
          * (-1,2)          =>     "-x^2"
          * (0, _)          =>     "0"
          * (1,0)          =>     "1"
          * (1,1)          =>     "x"
          * (1,2)          =>     "x^2"
          * (7,0)          =>     "7"
          * (7,1)          =>     "7x"
          * (7,2)          =>     "7^2"
         @Override
         public String toString() {
              return null;  // unimplemented - default value null is only a placeholder
         @Override
         public boolean equals(Object other) {
              return false;  // unimplemented - default value false is only a placeholder
          * Negates a term
          * @return a new term with the original coefficient negated
          * @throws CoefficientOverflow
         public Term negate() throws CoefficientOverflow {
              return null;  // unimplemented - default value null is only a placeholder
          * Multiplies a term by a scalar amount
          * @param m The value to multiply by
          * @return a new Term whose coefficient is the original coefficient multiplied by scale
          * @throws CoefficientOverflow
         public Term scale(int m) throws CoefficientOverflow {
              return null;  // unimplemented - default value null is only a placeholder
          * Multiplies two terms together
          * @param that represents the term to be multiplied by
          * @return a new Term whose coefficient is the product of the two terms, and whose exponent is the sum of the two terms
          * @throws CoefficientOverflow
          * @throws ExponentOverflow
         public Term times(Term that) throws CoefficientOverflow, ExponentOverflow {
              return null;  // unimplemented - default value null is only a placeholder
          * Adds two terms together
          * Precondition: The two exponents must be equal for this to be valid
          * @param thats represent the term to be added
          * @return a new Term whose coefficient is the sum of the two original coefficients
          * @throws CoefficientOverflow
          * @throws IncompatibleTerms
         public Term add(Term that) throws CoefficientOverflow, IncompatibleTerms {
              return null;  // unimplemented - default value null is only a placeholder
    }Thank you for the link, I will definitely check it out!

  • DocumentBuilderFactory.newInstance() only works after garbage collection

    Hi all,
    I am stucked with a strange behaviour of "DocumentBuilderFactory.newInstance()".
    I use the DocumentBuilderFactory in an applet
    to parse an xml-file.
    My applet starts ok until the line 5 (newInstance) gets called.
    At this time it seems that nothing happens anymore and that
    the applet fails to continue.
    But when I open up the java console and hit
    g (garbage collection) the xml parsing continues immediatly
    and my applet completes loading and runs ok.
    1 private void genarteDomNodes() {
    2 try {
    3 // ---- Parse XML file ----
    4 DocumentBuilderFactory factory =
    5 DocumentBuilderFactory.newInstance();
    6 DocumentBuilder builder =
    7 factory.newDocumentBuilder();
    8 Document document = builder.parse(
    9 new URL(this.myModules_xml).openStream() );
    10 // ---- Get list of nodes to given element tag name ----
    11 NodeList ndList =
    12 document.getElementsByTagName("meter-group");
    13 printNodesFromList( ndList );
    14 } catch( SAXParseException spe ) {
    15 ...
    16 } catch( SAXException sxe ) {
    17 ...
    18 } catch( ParserConfigurationException pce ) {
    19 ...
    20 } catch( IOException ioe ) {
    21 ...
    22 }
    23 }

    I am still stucked with this problem. But I found out how to enable JAXP debug output for applets (setting system properties isn't allowed for applets).
    This puts somemore output to the java console. It might help someone to understand my problem. I also printed some debug messages to track down my problem.
    Following is the console output of my applet:
    URL of XML to parse = "http://10.110.132.195/c8000-modules.xml"
    entering "genarteDomNodes"
    just before calling "DocumentBuilderFactory.newInstance()"
    JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
    !!! at this time the applet "hangs" and nothing happens;
    until I hit the "g" button. Then applet continues immediatly and prints:
    JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
    JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: sun.plugin.security.PluginClassLoader@32060c
    After invoking the garbage collector the applet continue to parse the xml file and runs as expected.
    Can someone help me please.

  • Mail Rules suddenly stop working - at least some of them!

    I have successfully created a number of Rules in Mail that have worked wonderfully for many months (years!) with no problem.
    Suddenly about a week ago the following happened.
    1. Some messages (with valid rules) just stayed in the In Box and wouldn't transfer automatically to the folder identified in my rules.
    2. Applying Rules to the errant messages sometimes works but others just stubbornly refuse to move
    3. Some messages for which there are valid rules actually end up in mail's Junk folder! And all of these refuse to move when subject to the Apply Rules command.
    I've checked the addresses and they are all valid but for some reason the Rules just don't work in every case. Lots of the other rules work fine.
    I've even deleted the rule in some cases and created a new one using the errant message's address - but I'm still stuck with the same behaviour.
    To add insult to injury of the errant mails (all with the same address)
    a) some stay in the In Box
    b) some transfer to the proper box (in accordance with the Rule) and
    c) some go into junk!
    Weird or what?
    Any ideas?
    MalcW

    OKAY. Did the entire list over again. After reboot and importing all 21273 messages those in orange for junk were still orange. Interestingly, I enabled one mailbox that had been disabled for several days and none of those were orange.
    After thinking this over, here's how a way was found to get all of messages changed from orange to black:
    Open each mail box; hi-light all messages, click format, Click on show fonts and/or click on show colors. Click on black. The go back to the mailbox where All messages are selected and click on that and everything in the box becomes black. Now go back to the color window and with that other "all"
    window selected, chose WHITE and then go to the mailbox and click and all messages are now black.
    Mail has been closed and re-opened several times after that, and all messages in each of the six mailboxes are now the proper color.
    Obviously I will need to set up new rules. Here's where I started:
    Open Mail Preferences, Select Junk Mail, Click to enable junk mail filtering
    and click on When Junk Mail arrives "leave it in my inbox, but indicate it's junk
    and click on each of the following
    Exempt from junk mail filtering
    Sender is in my address book
    Sender is in my previous recipients.
    And as a result, if I click on the ADVANCED option at the bottom the following
    Junk Mail window comes up:
    Description JUNK
    If ALL of following conditions are met:
    sender is not in my previous recipients
    sender is not in my address book
    message is Junk Mail
    Perform the following actions:
    set color of text (box shows orange).
    That's it. I hope that's the best way to 'teach it correctly'!!
    I appreciate the help and hope this assists others.

  • JSSE restriction problem

    Hi
    I am trying to use SSL related code which tried to establish secure connection with HTTPS site and exchanges data with it. This code run fine on Oracle 10g R3 jvm on windows but on AIX the JVM throws Exception Export Restriction: JSSE implementation not pluggable. Currenly i have solve the issue by setting java.protocol.handler.pkgs=com.ibm.net.ssl.internal.www.protocol instead of com.sun.net.ssl.internal.www.protocol but need to know if this is Oracle 10g R3 issue on AIX.
    Thank you

    Try using Socket.setEnabledProtocols() in
    JDK 1.4. Doesn't exist in JSSE 1.0.2, you're
    stuck with the default behaviour.
    (TLS hello wrapped in a SSLv2 format hello)

  • Strange bug, cannot resolve it

    Here is some code with a corresponding test case, but the results here are astonishing, since two of the entries in the probe map are not present there...
    Someone helps ?
    Thank you.
    public final class Matrix {
        private Map<Integer, Map<Index, Value>> valueMatrix;
        public void putValueRange(Integer rank, Index from, Index to, Value value){
         int fromIndex = from.ordinal();
         int toIndex = to.ordinal();
         if(fromIndex > toIndex){
             throw new IllegalArgumentException("FROM must be lower than TO");
         Index[] indices= Index.values();
         Map<Index, Value> range = new HashMap<Index, Value>();
         for(int i = fromIndex; i <= toIndex; i++){
             range.put(indices, value);
         valueMatrix.put(rank, range);
    @Test
    public void putValueRange() {
         Integer rank = 9;
         Index from = Index.SEVEN;
         Index to = Index.FOURTEEN;
         Value value= Value.X;
         Matrix matrix = new Matrix();
         matrix.putValueRange(rank, from, to, value);
         Map<Index, Value> probe = new HashMap<Index, Value>();
         probe.put(Index.SEVEN, value);
         probe.put(Index.EIGHT, value);
         probe.put(Index.NINE, value);
         probe.put(Index.TEN, value);
         probe.put(Index.ELEVEN, value);
         probe.put(Index.TWELVE, value);
         probe.put(Index.THIRTEEN, value);
         probe.put(Index.FOURTEEN, value);
         assertTrue(matrix.getValueMatrix().get(rank).size() == 8);
         assertTrue(matrix.getValueMatrix().get(rank).equals(probe));
    Edited by: javaUserMuser on May 21, 2009 5:19 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    javaUserMuser wrote:
    Well, does the hashmap.equals method take into account the ordering of the entries ?I never said it did!
    >
    >
    anyway, here is the code:
    public enum Index {
    TWO,
    THREE,
    FOUR,
    FIVE,
    SIX,
    SEVEN,
    EIGHT,
    NINE,
    TEN,
    ELEVEN,
    TWELVE,
    THIRTEEN,
    FOURTEEN;
    }Edited by: javaUserMuser on May 21, 2009 8:38 AMThat is not the class name in the OP.

  • Stuck with making my event structure examine if two arrays are equal

    Hi there, I'm new to labview. I'm trying to write an event structure; examining if one array equals another array. The program will carry on if they are equal, otherwise it will continue checking... Any help is appreciated.
    My program is attached.. It is eventually going to be a memory game when I get it working..
    Sequence 1, case structure 10 is were I'm stuck with the case structure.
    Thank you in advance
    Attachments:
    attempt 2.vi ‏18 KB

    Seems to me like you should implement a true State Machine.  This way you can repeat states and/or jump states as needed.
    State Machine
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • STUCK thread equals elevated CPU

    Agile PLM 9.3.0.1
    Weblogic 10.0
    Solaris 10
    Recently installed Agile 9301 in production. Three times in the week since go-live CPU has elevated up to 100% (twice on one managed host, once on the other), forcing me to kill Agile on that managed host and restart. We sure did not see anything like this on the development environment.
    * I'd like to know why this is happening.
    * Obviously I'd like to make it stop.
    * If I can't do that I can take steps to make the problem less deadly to the system.
    Installed VisualVM to look inside the JVM. I've got a STUCK thread that seems to be elevating the CPU past 25% (baseline appears to be around 10%). Now I have more data to confuse myself with. Here are the snipped bits relating to this thread from the thread dump.
    * Does this mean anything to anyone?
    * Any advice on how to track down a problem like this?
    Thread Dump snip with the STUCK threads
    "[STUCK] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)'" - Thread t@101
    java.lang.Thread.State: RUNNABLE
    at java.util.HashMap.get(HashMap.java:303)
    at com.agile.ui.web.action.ClientSession.getAttribute(ClientSession.java:154)
    at com.agile.ui.web.action.ActionContext.getAttribute(ActionContext.java:385)
    at com.agile.ui.pcm.common.model.AbstractDataModel.saveContext(AbstractDataModel.java:1701)
    at com.agile.ui.pcm.common.CMBaseModuleHandler.removeAll(CMBaseModuleHandler.java:153)
    at com.agile.ui.pcm.common.CMBaseModuleHandler.tabContextChanged(CMBaseModuleHandler.java:136)
    at com.agile.ui.web.action.ActionServlet.raiseRequestEvents(ActionServlet.java:1240)
    at com.agile.ui.web.action.ActionServlet.handleRequest(ActionServlet.java:658)
    at com.agile.ui.web.action.ActionServlet.doPost(ActionServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.RemoteFSRequestFilter.doFilter(RemoteFSRequestFilter.java:148)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.web.filter.LoggingFilter.doFilter(LoggingFilter.java:108)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.WebClientLog.doFilter(WebClientLog.java:78)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.jspbook.GZIPFilter.doFilter(GZIPFilter.java:21)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.SSOTicketFilter.doFilter(SSOTicketFilter.java:84)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Locked ownable synchronizers:
    - None
    "[STUCK] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" - Thread t@14
    java.lang.Thread.State: RUNNABLE
    at java.util.HashMap.get(HashMap.java:303)
    at com.agile.ui.web.action.ClientSession.getAttribute(ClientSession.java:154)
    at com.agile.ui.web.action.ActionContext.getAttribute(ActionContext.java:385)
    at com.agile.ui.pcm.common.ObjectViewHandler.setGridPage(ObjectViewHandler.java:20617)
    at sun.reflect.GeneratedMethodAccessor231.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.agile.ui.web.action.ActionServlet.invokeMethod(ActionServlet.java:1062)
    at com.agile.ui.web.action.ActionServlet.handleRequest(ActionServlet.java:667)
    at com.agile.ui.web.action.ActionServlet.doPost(ActionServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.RemoteFSRequestFilter.doFilter(RemoteFSRequestFilter.java:148)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.web.filter.LoggingFilter.doFilter(LoggingFilter.java:108)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.WebClientLog.doFilter(WebClientLog.java:78)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.jspbook.GZIPFilter.doFilter(GZIPFilter.java:21)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.agile.ui.pcm.common.filter.SSOTicketFilter.doFilter(SSOTicketFilter.java:84)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Locked ownable synchronizers:
    - None

    Did you take multiple thread dumps to see if the thread is always in the same place? It seems that a "Runnable" thread is making progress and not blocked on any locks.
    There is additional troubleshooting steps at support.oracle.com with a document called Oracle WebLogic Server Core Server / JVM / Memory Issues Support Patterns - Unexpected High CPU Usage with WLS
    Document ID 874292.1 in the Knowledge Base
    The article is a bit old, but the approach should still be sound. I'm not sure if VisualVM gives you CPU by thread or not, but I know it has a profiler.

  • logic:equal + hashmap

    hi
    i have a bean in jsp which has a HashMap like this
    <bean:define name="actionFormSample" id="sampleBean" property="myHashMap" type="java.util.HashMap"/>.
    Now i have to use <logic:equal>tags to compare value of a key in the hashmap
    only if it is YES i have to show a particular text box.
    can anybody tell how to use logic equal on a hashMap.
    Note: i dont want to use javascript here

    Hi,
    You can use "history.go(0)" to refresh/reload the current page. You need to call "history.go(0)" when ever any changes occoured. For more information visit http://www.htmlgoodies.com/tutorials/getting_started/article.php/3479551.
    Thanks.

  • Comparing 2 HashMap with the equals method

    Hi,
    I�m trying to compare 2 HashMap with the equls method like this:
    saveAnyWayMap.equals(keysMap)
    The 2 HashMaps contains the following values and keys:
    saveAnyWayMap: {P_PERSON.PA_TIDPKT=null, P_PERSON.P_PXXX92=xxx, P_PERSON.P_P
    XXX91=xx, P_PERSON.P_PXXX90=xxx}
    keysMap: {P_PERSON.PA_TIDPKT=null, P_PERSON.P_PXXX92=xxx, P_PERSON.P_PXXX91=
    xx, P_PERSON.P_PXXX90=xxx}
    Why dose the equals method return false?
    When P_PERSON.PA_TIDPKT is not null the equals method returns true. Can�t the values be null if you want to compare HashMaps or what is wrong?
    Can someone please help?
    Thanks!
    /Lisa

    Works fine when I use null objects in a hashmap. Are you sure it is the null values that gives you the problem? And is the key in both maps?
    What if the only key-value pair you have is P_PERSON.PA_TIDPKT and null?
    Do you use string objects as keys?

  • Stuck with clear behaviour

    Hello all,
    Please see http://www.thewharfhouse.co.uk/press-and-media.html - I'm stuck trying to get the <h3 class="pressmedia"> headings to work as desired. I have set a clear:left in the style sheet, and applied a margin-top:30px in order to add some distance between whatever's above, but it's not working.
    Actually, I think the first 'Exterior images' one is working in terms of the space above it, but all the others below haven't loaded with the margin-top as desired.
    Any ideas what I'm doing wrong?
    Thanks in advance

    First things first - you can only use a given ID value once on any given page.  You have used pressmedia_container many times, for example -
    <div id="pressmedia_container"><a href="Images/press-media-full-size/TheWharfHouse-Exterior/The Wharf House exterior 01.JPG" target="_blank"><img src="Images/press-media-small/TheWharfHouse-Exterior/The Wharf House exterior 01.JPG" width="180" height="135" border="0" class="pressmedia_container" /></a>
    </div>
    <div id="pressmedia_container"> <a href="Images/press-media-full-size/TheWharfHouse-Exterior/The Wharf House exterior 02.JPG" target="_blank"><img src="Images/press-media-small/TheWharfHouse-Exterior/The Wharf House exterior 02.JPG" width="101" height="135" border="0" class="pressmedia_container" /></a>
    </div>
    Before doing anything else you should change that.  If you want to re-use a selector like this, it needs to be a class not an ID value.

Maybe you are looking for

  • Communication Language Polish

    When creating new users for Poland the default communication language is set to Polish. But not possible to select it in the drop down box. Now we start to the fine-tuning for Poland and activate the language Polish (and Chinese) and still the same.

  • Maximum Content Size

    Dear all what is maximum of content size allowed in the request and is there any way to increase th size of the request content size. because iam doing one application which allows users to enter unlimited size of charecters,if the enter very large n

  • Different task in UWL than Business Workplace

    Hi, I have problem with tasks. Why in Business Workplace (R/3) I have only tasks "In Progress"? But in UWL in SAP Portal I have all of status tasks? What must I do? I want the same tasks in <i>UWL</i> and in <i>Business Workplace</i>. <b>thanks,</b>

  • Oracle 8i/OAS on laptop

    Greetings: Has anyone ever gotten an 8i database (8.1.6 for NT) with OAS (4.0.8.2.1 for NT ) to run on a laptop. I'm trying to run an application standalone on my laptop with Windows 2000 professional (P3 700, 384 MB RAM). My problem is that if I'm n

  • Longevity of Photoshop CS6

    I  don't know if I am at the right place or not, but how long will Adobe support Photoshop cs6? At the end of the day, somewhere down the road will I wake up and Adobe says they no longer support Photoshop CS6...that you will have to rent the "progra