[jboss-cvs] JBossAS SVN: r64409 - in projects/microcontainer/trunk/metatype/src: main/org/jboss/metatype/plugins/types and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 1 15:54:32 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-08-01 15:54:32 -0400 (Wed, 01 Aug 2007)
New Revision: 64409
Added:
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/Name.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/StringName.java
Modified:
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
Log:
Add a Name type for object references
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java 2007-08-01 19:41:42 UTC (rev 64408)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -62,6 +62,7 @@
* java.lang.Date<br>
* java.math.BigDecimal<br>
* java.math.BigInteger<br>
+ * {@link Name}<br>
* {@link SimpleValue}<br>
* {@link EnumValue}<br>
* {@link GenericValue}<br>
@@ -84,6 +85,7 @@
Date.class.getName(),
BigDecimal.class.getName(),
BigInteger.class.getName(),
+ Name.class.getName(),
SimpleValue.class.getName(),
EnumValue.class.getName(),
GenericValue.class.getName(),
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/Name.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/Name.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/Name.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.api.types;
+
+import java.io.Serializable;
+
+/**
+ * A name is a typed string representing a reference to
+ * an object.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Name extends Serializable
+{
+ public String toString();
+}
Property changes on: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/Name.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java 2007-08-01 19:41:42 UTC (rev 64408)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -83,6 +83,9 @@
/** The simple type for java.lang.String */
public static final SimpleMetaType<String> STRING;
+ /** The simple type for an object name */
+ public static final SimpleMetaType<Name> NAMEDOBJECT;
+
/** The simple type for java.lang.Void */
public static final SimpleMetaType VOID;
@@ -100,6 +103,7 @@
LONG = new SimpleMetaType<Long>(Long.class.getName());
SHORT = new SimpleMetaType<Short>(Short.class.getName());
STRING = new SimpleMetaType<String>(String.class.getName());
+ NAMEDOBJECT = new SimpleMetaType<Name>(Name.class.getName());
VOID = new SimpleMetaType(Void.class.getName());
}
@@ -156,6 +160,8 @@
return VOID;
if (className.equals(DATE.getClassName()))
return DATE;
+ if (className.equals(NAMEDOBJECT.getClassName()))
+ return NAMEDOBJECT;
return null;
}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/StringName.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/StringName.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/StringName.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.types;
+
+import org.jboss.metatype.api.types.Name;
+
+/**
+ * A simple string based Name implementation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StringName implements Name
+{
+ private static final long serialVersionUID = 1;
+ private String name;
+
+ /**
+ *
+ * @param name
+ */
+ public StringName(String name)
+ {
+ if( name == null )
+ throw new IllegalArgumentException("Name cannot be null");
+ this.name = name;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+ public boolean equals(Object obj)
+ {
+ return name.equals(obj);
+ }
+ public String toString()
+ {
+ return name;
+ }
+}
Property changes on: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/StringName.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2007-08-01 19:41:42 UTC (rev 64408)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -29,6 +29,7 @@
import junit.framework.Test;
import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.Name;
import org.jboss.metatype.api.values.ArrayValue;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.EnumValue;
@@ -74,7 +75,7 @@
public void testAllowedClasses() throws Exception
{
List<String> allowedClassNames = MetaType.ALLOWED_CLASSNAMES;
- assertEquals(19, allowedClassNames.size());
+ assertEquals(20, allowedClassNames.size());
checkMetaType(allowedClassNames, Void.class);
checkMetaType(allowedClassNames, Boolean.class);
checkMetaType(allowedClassNames, Character.class);
@@ -88,6 +89,7 @@
checkMetaType(allowedClassNames, Date.class);
checkMetaType(allowedClassNames, BigDecimal.class);
checkMetaType(allowedClassNames, BigInteger.class);
+ checkMetaType(allowedClassNames, Name.class);
checkMetaType(allowedClassNames, SimpleValue.class);
checkMetaType(allowedClassNames, EnumValue.class);
checkMetaType(allowedClassNames, GenericValue.class);
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2007-08-01 19:41:42 UTC (rev 64408)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2007-08-01 19:54:32 UTC (rev 64409)
@@ -27,9 +27,11 @@
import junit.framework.Test;
+import org.jboss.metatype.api.types.Name;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.StringName;
import org.jboss.test.metatype.AbstractMetaTypeTest;
/**
@@ -74,7 +76,8 @@
SimpleMetaType.LONG,
SimpleMetaType.SHORT,
SimpleMetaType.STRING,
- SimpleMetaType.VOID
+ SimpleMetaType.VOID,
+ SimpleMetaType.NAMEDOBJECT
};
Class[] classes = new Class[]
@@ -91,7 +94,8 @@
Long.class,
Short.class,
String.class,
- Void.class
+ Void.class,
+ Name.class
};
@SuppressWarnings("unchecked")
@@ -109,7 +113,8 @@
new SimpleValueSupport<Long>(SimpleMetaType.LONG, new Long(1)),
new SimpleValueSupport<Short>(SimpleMetaType.SHORT, new Short(Short.MAX_VALUE)),
new SimpleValueSupport<String>(SimpleMetaType.STRING, new String("hello")),
- new SimpleValueSupport(SimpleMetaType.VOID, null)
+ new SimpleValueSupport(SimpleMetaType.VOID, null),
+ new SimpleValueSupport<Name>(SimpleMetaType.NAMEDOBJECT, new StringName("objectref"))
};
@SuppressWarnings("unchecked")
@@ -127,7 +132,8 @@
new SimpleValueSupport<Long>(SimpleMetaType.LONG, null),
new SimpleValueSupport<Short>(SimpleMetaType.SHORT, null),
new SimpleValueSupport<String>(SimpleMetaType.STRING, null),
- new SimpleValueSupport(SimpleMetaType.VOID, null)
+ new SimpleValueSupport(SimpleMetaType.VOID, null),
+ new SimpleValueSupport<Name>(SimpleMetaType.NAMEDOBJECT, null)
};
/**
More information about the jboss-cvs-commits
mailing list