aboutsummaryrefslogtreecommitdiffstats
path: root/docs/dist/doc/examples/bean
diff options
context:
space:
mode:
authorehilsdal <ehilsdal>2003-04-08 21:59:39 +0000
committerehilsdal <ehilsdal>2003-04-08 21:59:39 +0000
commite2af842ae7dbf3b0315a5f73d3d5ec9b7f041556 (patch)
treea4e993a588298b0d6babdf643de8d35991a2ebd6 /docs/dist/doc/examples/bean
parentf11709f8bc26a053ff573039cc0b5ee887c005ff (diff)
downloadaspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.tar.gz
aspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.zip
folded in material from README-11.html
finally totally and completely stomped out "introduction" minor formatting changes generating better filenames for the progguide added A4 version of quick reference
Diffstat (limited to 'docs/dist/doc/examples/bean')
-rw-r--r--docs/dist/doc/examples/bean/BoundPoint.java37
-rw-r--r--docs/dist/doc/examples/bean/Demo.java79
-rw-r--r--docs/dist/doc/examples/bean/Point.java25
3 files changed, 66 insertions, 75 deletions
diff --git a/docs/dist/doc/examples/bean/BoundPoint.java b/docs/dist/doc/examples/bean/BoundPoint.java
index c247ca9cd..e5d9ab8c6 100644
--- a/docs/dist/doc/examples/bean/BoundPoint.java
+++ b/docs/dist/doc/examples/bean/BoundPoint.java
@@ -10,19 +10,20 @@
* warranty about the software, its performance or its conformity to any
* specification.
*/
+
package bean;
import java.beans.*;
import java.io.Serializable;
/*
- * Add bound properties and serialization to point objects
+ * Add bound properties and serialization to point objects
*/
aspect BoundPoint {
/*
* privately introduce a field into Point to hold the property
- * change support object. `this' is a reference to a Point object.
+ * change support object. `this' is a reference to a Point object.
*/
private PropertyChangeSupport Point.support = new PropertyChangeSupport(this);
@@ -34,13 +35,13 @@ aspect BoundPoint {
support.addPropertyChangeListener(listener);
}
- public void Point.addPropertyChangeListener(String propertyName,
+ public void Point.addPropertyChangeListener(String propertyName,
PropertyChangeListener listener){
-
+
support.addPropertyChangeListener(propertyName, listener);
}
- public void Point.removePropertyChangeListener(String propertyName,
+ public void Point.removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
support.removePropertyChangeListener(propertyName, listener);
}
@@ -63,31 +64,31 @@ aspect BoundPoint {
/**
* Advice to get the property change event fired when the
- * setters are called. It's around advice because you need
+ * setters are called. It's around advice because you need
* the old value of the property.
*/
void around(Point p): setter(p) {
- String propertyName =
+ String propertyName =
thisJoinPointStaticPart.getSignature().getName().substring("set".length());
- int oldX = p.getX();
- int oldY = p.getY();
- proceed(p);
- if (propertyName.equals("X")){
+ int oldX = p.getX();
+ int oldY = p.getY();
+ proceed(p);
+ if (propertyName.equals("X")){
firePropertyChange(p, propertyName, oldX, p.getX());
- } else {
+ } else {
firePropertyChange(p, propertyName, oldY, p.getY());
- }
+ }
}
/*
* Utility to fire the property change event.
*/
- void firePropertyChange(Point p,
- String property,
- double oldval,
+ void firePropertyChange(Point p,
+ String property,
+ double oldval,
double newval) {
- p.support.firePropertyChange(property,
- new Double(oldval),
+ p.support.firePropertyChange(property,
+ new Double(oldval),
new Double(newval));
}
}
diff --git a/docs/dist/doc/examples/bean/Demo.java b/docs/dist/doc/examples/bean/Demo.java
index 767409878..e16be245e 100644
--- a/docs/dist/doc/examples/bean/Demo.java
+++ b/docs/dist/doc/examples/bean/Demo.java
@@ -1,13 +1,12 @@
/*
-
Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export control
laws.
-
*/
+
package bean;
import java.beans.*;
@@ -22,62 +21,60 @@ public class Demo implements PropertyChangeListener {
* this method reports that a propery has changed
*/
public void propertyChange(PropertyChangeEvent e){
- System.out.println("Property " + e.getPropertyName() + " changed from " +
- e.getOldValue() + " to " + e.getNewValue() );
+ System.out.println("Property " + e.getPropertyName() + " changed from " +
+ e.getOldValue() + " to " + e.getNewValue() );
}
/**
* main: test the program
*/
public static void main(String[] args){
- Point p1 = new Point();
- p1.addPropertyChangeListener(new Demo());
- System.out.println("p1 =" + p1);
- p1.setRectangular(5,2);
- System.out.println("p1 =" + p1);
- p1.setX( 6 );
- p1.setY( 3 );
- System.out.println("p1 =" + p1);
- p1.offset(6,4);
- System.out.println("p1 =" + p1);
- save(p1, fileName);
- Point p2 = (Point) restore(fileName);
- System.out.println("Had: " + p1);
- System.out.println("Got: " + p2);
+ Point p1 = new Point();
+ p1.addPropertyChangeListener(new Demo());
+ System.out.println("p1 =" + p1);
+ p1.setRectangular(5,2);
+ System.out.println("p1 =" + p1);
+ p1.setX( 6 );
+ p1.setY( 3 );
+ System.out.println("p1 =" + p1);
+ p1.offset(6,4);
+ System.out.println("p1 =" + p1);
+ save(p1, fileName);
+ Point p2 = (Point) restore(fileName);
+ System.out.println("Had: " + p1);
+ System.out.println("Got: " + p2);
}
/**
* Save a serializable object to a file
*/
static void save(Serializable p, String fn){
- try {
- System.out.println("Writing to file: " + p);
- FileOutputStream fo = new FileOutputStream(fn);
- ObjectOutputStream so = new ObjectOutputStream(fo);
- so.writeObject(p);
- so.flush();
- } catch (Exception e) {
- System.out.println(e);
- System.exit(1);
- }
+ try {
+ System.out.println("Writing to file: " + p);
+ FileOutputStream fo = new FileOutputStream(fn);
+ ObjectOutputStream so = new ObjectOutputStream(fo);
+ so.writeObject(p);
+ so.flush();
+ } catch (Exception e) {
+ System.out.println(e);
+ System.exit(1);
+ }
}
/**
* Restore a serializable object from the file
*/
static Object restore(String fn){
- try {
- Object result;
- System.out.println("Reading from file: " + fn);
- FileInputStream fi = new FileInputStream(fn);
- ObjectInputStream si = new ObjectInputStream(fi);
- return si.readObject();
- } catch (Exception e) {
- System.out.println(e);
- System.exit(1);
- }
- return null;
+ try {
+ Object result;
+ System.out.println("Reading from file: " + fn);
+ FileInputStream fi = new FileInputStream(fn);
+ ObjectInputStream si = new ObjectInputStream(fi);
+ return si.readObject();
+ } catch (Exception e) {
+ System.out.println(e);
+ System.exit(1);
+ }
+ return null;
}
-
-
}
diff --git a/docs/dist/doc/examples/bean/Point.java b/docs/dist/doc/examples/bean/Point.java
index d5040c2bf..a6ea703cd 100644
--- a/docs/dist/doc/examples/bean/Point.java
+++ b/docs/dist/doc/examples/bean/Point.java
@@ -1,5 +1,4 @@
/*
-
Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
Use and copying of this software and preparation of derivative works based
@@ -9,7 +8,6 @@ laws.
This software is made available AS IS, and Xerox Corporation makes no warranty
about the software, its performance or its conformity to any specification.
-
*/
package bean;
@@ -23,54 +21,49 @@ class Point {
* Return the X coordinate
*/
public int getX(){
- return x;
+ return x;
}
/**
* Return the y coordinate
*/
public int getY(){
- return y;
+ return y;
}
/**
* Set the x and y coordinates
*/
public void setRectangular(int newX, int newY){
- setX(newX);
- setY(newY);
+ setX(newX);
+ setY(newY);
}
/**
* Set the X coordinate
*/
public void setX(int newX) {
- x = newX;
+ x = newX;
}
/**
* set the y coordinate
*/
public void setY(int newY) {
- y = newY;
+ y = newY;
}
-
/**
* Move the point by the specified x and y offset
*/
public void offset(int deltaX, int deltaY){
- setRectangular(x + deltaX, y + deltaY);
+ setRectangular(x + deltaX, y + deltaY);
}
-
/**
- * MAke a string of this
+ * Make a string of this
*/
public String toString(){
- return "(" + getX() + ", " + getY() + ")" ;
+ return "(" + getX() + ", " + getY() + ")" ;
}
-
-
-
}