[Japi-cvs] SF.net SVN: japi: [220] libs
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2006-11-26 21:40:42
|
Revision: 220
http://svn.sourceforge.net/japi/?rev=220&view=rev
Author: christianhujer
Date: 2006-11-26 13:40:38 -0800 (Sun, 26 Nov 2006)
Log Message:
-----------
Created libs-lang.
Added Paths:
-----------
libs/lang/
libs/lang/branches/
libs/lang/tags/
libs/lang/trunk/
libs/lang/trunk/libs-lang.iml
libs/lang/trunk/src/
libs/lang/trunk/src/net/
libs/lang/trunk/src/net/sf/
libs/lang/trunk/src/net/sf/japi/
libs/lang/trunk/src/net/sf/japi/lang/
libs/lang/trunk/src/net/sf/japi/lang/SuperClassIterator.java
Added: libs/lang/trunk/libs-lang.iml
===================================================================
--- libs/lang/trunk/libs-lang.iml (rev 0)
+++ libs/lang/trunk/libs-lang.iml 2006-11-26 21:40:38 UTC (rev 220)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="2" />
+ </Base>
+ </component>
+</module>
+
Property changes on: libs/lang/trunk/libs-lang.iml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ LF
Copied: libs/lang/trunk/src/net/sf/japi/lang/SuperClassIterator.java (from rev 219, historic/trunk/src/app/net/sf/japi/lang/SuperClassIterator.java)
===================================================================
--- libs/lang/trunk/src/net/sf/japi/lang/SuperClassIterator.java (rev 0)
+++ libs/lang/trunk/src/net/sf/japi/lang/SuperClassIterator.java 2006-11-26 21:40:38 UTC (rev 220)
@@ -0,0 +1,70 @@
+/* JAPI - (Yet another (hopefully) useful) Java API
+ *
+ * Copyright (C) 2004-2006 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+package net.sf.japi.lang;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import org.jetbrains.annotations.Nullable;
+
+/** An Iterator for iterating through the superclasses (subclasses to superclasses) of a class.
+ * Note: The supplied class is included in iteration. If you want to omit it, you'll have to invoke getSuperclass() once, e.g. use <code>new SuperClassIterator(clazz.getSuperClass())</code> instead of <code>new SuperClassIterator(clazz)</code>.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class SuperClassIterator implements Iterator<Class<?>>, Iterable<Class<?>> {
+
+ /** The current class. */
+ @Nullable private Class<?> nextClass;
+
+ /** Create a SuperClassIterator.
+ * @param clazz Class to create Iterator for
+ */
+ public SuperClassIterator(@Nullable final Class<?> clazz) {
+ nextClass = clazz;
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasNext() {
+ return nextClass != null;
+ }
+
+ /** {@inheritDoc} */
+ public Class<?> next() {
+ if (nextClass == null) {
+ throw new NoSuchElementException();
+ }
+ try {
+ return nextClass;
+ } finally {
+ nextClass = nextClass.getSuperclass();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public Iterator<Class<?>> iterator() {
+ return this;
+ }
+
+} // class ClassIterator
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|