~francis-giraldeau/noesis/xsugar-strict

« back to all changes in this revision

Viewing changes to src/dk/brics/xsugar/stylesheet/QName.java

  • Committer: Francis Giraldeau
  • Date: 2010-03-12 03:56:47 UTC
  • Revision ID: francis.giraldeau@revolutionlinux.com-20100312035647-gkvfzk22qx7urrlu
ADD toString method

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        }
66
66
        
67
67
        public boolean equals(Object o){
 
68
                boolean res = false;
68
69
                if (o instanceof QName){
69
70
                        QName other = (QName)o;
70
 
                        if ((other.getPrefix().compareTo(getPrefix())==0) && 
71
 
                                        other.getLocalname().compareTo(getLocalname())==0){
72
 
                                return true;
73
 
                        }
 
71
                        boolean samePrefix = false;
 
72
                        boolean sameLocalname = false;
 
73
                        if (other.getPrefix()!=null && this.prefix!=null){
 
74
                                if (other.getPrefix().compareTo(getPrefix())==0){
 
75
                                        samePrefix = true;
 
76
                                }
 
77
                        } else if (other.getPrefix()==null && this.prefix==null){
 
78
                                samePrefix = true;
 
79
                        }
 
80
                        if (other.getLocalname()!=null && this.localname!=null){
 
81
                                if (other.getLocalname().compareTo(getLocalname())==0){
 
82
                                        sameLocalname = true;
 
83
                                }
 
84
                        } else if (other.getPrefix()==null && this.prefix==null){
 
85
                                samePrefix = true;
 
86
                        }
 
87
                        res = samePrefix && sameLocalname;
74
88
                }
75
 
                return false;
 
89
                return res;
76
90
        }
77
91
        
78
92
        public int hashCode(){
79
 
                return this.prefix.hashCode() + this.localname.hashCode();
 
93
                int res = 0;
 
94
                if (this.prefix!=null){
 
95
                        res = res + this.prefix.hashCode();
 
96
                }
 
97
                if (this.localname!=null){
 
98
                        res = res + this.localname.hashCode();
 
99
                }
 
100
                return res;
80
101
        }
81
102
}