From 77ea92d5d62830dee0fa4189171aa637bab1d444 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Fri, 11 Mar 2011 11:08:36 +0100 Subject: [PATCH] some support for events --- .../JavaSupport/CS2JRunTimeException.java | 28 +++++++++++++ .../JavaSupport/language/EventArgs.java | 24 +++++++++++ .../JavaSupport/language/EventCollection.java | 42 +++++++++++++++++++ .../language/IEventCollection.java | 29 +++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 CS2JLibrary/src/CS2JNet/JavaSupport/CS2JRunTimeException.java create mode 100644 CS2JLibrary/src/CS2JNet/JavaSupport/language/EventArgs.java create mode 100644 CS2JLibrary/src/CS2JNet/JavaSupport/language/EventCollection.java create mode 100644 CS2JLibrary/src/CS2JNet/JavaSupport/language/IEventCollection.java diff --git a/CS2JLibrary/src/CS2JNet/JavaSupport/CS2JRunTimeException.java b/CS2JLibrary/src/CS2JNet/JavaSupport/CS2JRunTimeException.java new file mode 100644 index 0000000..b018fa3 --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/JavaSupport/CS2JRunTimeException.java @@ -0,0 +1,28 @@ +/* + Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author(s): + + Kevin Glynn (kevin.glynn@twigletsoftware.com) +*/ +package CS2JNet.JavaSupport; + +public class CS2JRunTimeException extends Exception { + + public CS2JRunTimeException(String msg) { + super(msg); + } + +} diff --git a/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventArgs.java b/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventArgs.java new file mode 100644 index 0000000..8efa648 --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventArgs.java @@ -0,0 +1,24 @@ +/* + Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author(s): + + Kevin Glynn (kevin.glynn@twigletsoftware.com) +*/ +package CS2JNet.JavaSupport.language; + +public class EventArgs { + +} diff --git a/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventCollection.java b/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventCollection.java new file mode 100644 index 0000000..77ff08b --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/JavaSupport/language/EventCollection.java @@ -0,0 +1,42 @@ +/* + Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author(s): + + Kevin Glynn (kevin.glynn@twigletsoftware.com) +*/ +package CS2JNet.JavaSupport.language; + +import java.util.List; + +import CS2JNet.JavaSupport.CS2JRunTimeException; + +// TODO: T should implement a delegate type +public class EventCollection implements IEventCollection { + + List listeners = null; + + /* (non-Javadoc) + * @see CS2JNet.JavaSupport.language.IEventCollection#Invoke(java.lang.Object, CS2JNet.JavaSupport.language.EventArgs) + */ + @Override + public void Invoke(Object cause, EventArgs e) throws CS2JRunTimeException { + if (listeners != null) { + // do something here + throw new CS2JRunTimeException("Events are not yet implemented"); + } + } + +} diff --git a/CS2JLibrary/src/CS2JNet/JavaSupport/language/IEventCollection.java b/CS2JLibrary/src/CS2JNet/JavaSupport/language/IEventCollection.java new file mode 100644 index 0000000..8dc6bce --- /dev/null +++ b/CS2JLibrary/src/CS2JNet/JavaSupport/language/IEventCollection.java @@ -0,0 +1,29 @@ +/* + Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author(s): + + Kevin Glynn (kevin.glynn@twigletsoftware.com) +*/ +package CS2JNet.JavaSupport.language; + +import CS2JNet.JavaSupport.CS2JRunTimeException; + +public interface IEventCollection { + + public abstract void Invoke(Object cause, EventArgs e) + throws CS2JRunTimeException; + +} \ No newline at end of file