~ubuntu-branches/ubuntu/natty/aspectj/natty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/docs/dist/doc/examples/introduction/HashablePoint.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-10-04 16:37:23 UTC
  • mfrom: (1.1.3 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091004163723-ck4y7j7fhjxskkie
Tags: 1.6.6+dfsg-1
* New upstream release.
  - Update 02_use_gjdoc.diff patch
* Update my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (c) Xerox Corporation 1998-2002.  All rights reserved.
3
 
 
4
 
Use and copying of this software and preparation of derivative works based
5
 
upon this software are permitted.  Any distribution of this software or
6
 
derivative works must comply with all applicable United States export control
7
 
laws.
8
 
 
9
 
This software is made available AS IS, and Xerox Corporation makes no warranty
10
 
about the software, its performance or its conformity to any specification.
11
 
*/
12
 
 
13
 
package introduction;
14
 
 
15
 
import java.util.Hashtable;
16
 
 
17
 
public aspect HashablePoint {
18
 
 
19
 
   public int Point.hashCode() {
20
 
      return (int) (getX() + getY() % Integer.MAX_VALUE);
21
 
   }
22
 
 
23
 
   public boolean Point.equals(Object o) {
24
 
      if (o == this) { return true; }
25
 
      if (!(o instanceof Point)) { return false; }
26
 
      Point other = (Point)o;
27
 
      return (getX() == other.getX()) && (getY() == other.getY());
28
 
   }
29
 
 
30
 
   public static void main(String[] args) {
31
 
      Hashtable h = new Hashtable();
32
 
      Point p1 = new Point();
33
 
 
34
 
      p1.setRectangular(10, 10);
35
 
      Point p2 = new Point();
36
 
 
37
 
      p2.setRectangular(10, 10);
38
 
 
39
 
      System.out.println("p1 = " + p1);
40
 
      System.out.println("p2 = " + p2);
41
 
      System.out.println("p1.hashCode() = " + p1.hashCode());
42
 
      System.out.println("p2.hashCode() = " + p2.hashCode());
43
 
 
44
 
      h.put(p1, "P1");
45
 
      System.out.println("Got: " + h.get(p2));
46
 
   }
47
 
}