aboutsummaryrefslogtreecommitdiffstats
path: root/demos/effect/hide.html
Commit message (Expand)AuthorAgeFilesLines
* Demos: Add device-width viewport meta to all demosJörn Zaefferer2015-09-301-0/+1
* Effects: Style updatesAlexander Schmitz2015-08-211-4/+4
* Effects: Update demos to use AMDAlexander Schmitz2015-07-211-19/+2
* Effects: Remove core event/alias and deprecated module dependenciesAlexander Schmitz2015-05-201-1/+1
* Effects: RewriteMike Sherov2014-12-101-2/+4
* Effects Demos: Fix typeErrors on puff and size demosMike Sherov2014-09-101-0/+2
* Build: Reorganize external directoryScott González2014-06-241-1/+1
* Button demo: Replace anchors with more appropriate buttonsJörn Zaefferer2014-04-241-2/+1
* All: Rename jquery.js to exclude version in filenameJörn Zaefferer2014-03-051-1/+1
* All: Rename all files, removing the "jquery.ui." prefix;Rafael Xavier de Souza2014-01-241-13/+13
* Updating jQuery to 1.10.2.Bruno M. Custódio2013-07-051-1/+1
* Effects (core): Unite demos into the same single effect/ pathRafael Xavier de Souza2013-06-221-0/+95
50' href='#n150'>150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
import java.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import java.lang.reflect.*;

/**
 * test annotations on itds in various ways 
 * 1) annotated ITD
 * 2) binding of an annotation on an ITD member
 * 3) annotated ITD via declare @xxx
 * 4) binding of annotated ITD via declare
 */
public aspect AnnotationsAndITDs {

	// annotated ITD constructors
	
	@SomeAnnotation(s="hello",clazz=AnnotationsAndITDs.class)
	public ITDMe.new(String s) { this(); }
	
	@SomeAnnotation(s="goodbye",clazz=String.class)
	private ITDMe.new(int x) { this(); }

	// annotated ITD methods
	
	@SomeAnnotation(s="x",clazz=Object.class)
	private void ITDMe.foo() {}
	
	@SomeAnnotation(s="y",clazz=Integer.class)
	public void ITDMe.bar(@ParamAnnotation int x) {}

	// annotated ITD fields
	
	@SomeAnnotation(s="d",clazz=Double.class)
	public Double ITDMe.d;
	
	@SomeAnnotation(s="f",clazz=Double.class)
	private Float ITDMe.f;
	
	// declare @xxx on ITD members
	// =============================
	
	// annotated ITD constructors
	
	declare @constructor : ITDMe2.new(..) : @SomeAnnotation(s="@cons",clazz=String.class);
	
	public ITDMe2.new(String s) { this(); }	
	private ITDMe2.new(int x) { this(); }

	// annotated ITD methods
	
	declare @method : * ITDMe2.*(..) : @SomeAnnotation(s="@method",clazz=ITDMe2.class);
	
	private void ITDMe2.foo() {}	
	public void ITDMe2.bar(@ParamAnnotation int x) {}

	// annotated ITD fields
	
	declare @field : * ITDMe2.* : @SomeAnnotation(s="@field",clazz=ITDMe2.class);
	
	public Double ITDMe2.d = 2d;	
	private Float ITDMe2.f = 1.0f;
	
	declare @type : ITDMe* : @SomeAnnotation(s="@type",clazz=System.class);
	
	
	public static void main(String[] args) {
		ITDMe itdme1 = new ITDMe("foo");
		ITDMe itdme2 = new ITDMe(5);
		itdme1.foo();
		itdme1.bar(6);
		itdme1.d = 1.0d;
		itdme1.f = 1.0f;
		ITDMe2 itdme21 = new ITDMe2("foo");
		ITDMe2 itdme22 = new ITDMe2(5);
		itdme21.foo();
		itdme21.bar(6);
		itdme21.d = 1.0d;
		itdme21.f = 1.0f;
	}
}

aspect AnnotationTests {
	
	// static tests
	
	declare warning : execution(@SomeAnnotation * *(..)) : "execution(@SomeAnnotation ...)";
	
	declare warning : execution(@SomeAnnotation new(..)) : "execution(@SomeAnnotation ...new(..)";
	
	declare warning : set(@SomeAnnotation * *) : "set(@SomeAnnotation...)";
	
	declare warning : staticinitialization(@SomeAnnotation *) : "si(@SomeAnnotation...)";
	
	// binding tests
	
	before(SomeAnnotation sa) : execution(public ITDMe.new(String)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : execution(private ITDMe.new(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	before(SomeAnnotation sa) : execution(private ITDMe.new(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : execution(public void ITDMe.bar(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
//		MethodSignature sig = (MethodSignature) thisJoinPoint.getSignature(); 
//		Method meth = sig.getMethod();
//		Annotation[][] anns = meth.getParameterAnnotations();
//		System.out.println("method bar has " + anns.length + " params, first param annotation is " 
//				+ anns[0][0].toString());
	}
	
	before(SomeAnnotation sa) : set(public Double ITDMe.d) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : set(private Float ITDMe.f) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
        after(SomeAnnotation sa) returning : staticinitialization(@SomeAnnotation *) && @annotation(sa){
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	// now repeat for the @declared versions

	before(SomeAnnotation sa) : execution(public ITDMe2.new(String)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : execution(private ITDMe2.new(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	before(SomeAnnotation sa) : execution(private ITDMe2.new(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : execution(public void ITDMe2.bar(int)) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
//		MethodSignature sig = (MethodSignature) thisJoinPoint.getSignature();
//		Method meth = sig.getMethod();
//		Annotation[][] anns = meth.getParameterAnnotations();
//		System.out.println("method bar has " + anns.length + " params, first param annotation is " 
//				+ anns[0][0].toString());
	}
	
	before(SomeAnnotation sa) : set(public Double ITDMe2.d) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
	
	after(SomeAnnotation sa) : set(private Float ITDMe2.f) && @annotation(sa) {
		print(sa,thisJoinPoint.getSourceLocation().toString());
	}
		
	private void print(SomeAnnotation sa,String loc) {
		System.err.println(sa.s() + " " + sa.clazz().getName()+" ("+loc+")");
	}
}

@Retention(RetentionPolicy.RUNTIME)
@interface SomeAnnotation {
	String s();
	Class  clazz();
}

@Retention(RetentionPolicy.RUNTIME)
@interface ParamAnnotation{
	String value() default "";
}

class ITDMe {
	
	
}

class ITDMe2 {
	
	
}