notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1348 - in trunk/main: depot/library/src/main/net/dpml/library depot/library/src/main/net/dpml/library/impl depot/library/src/main/net/dpml/library/info depot/library/src/test/net/dpml/library depot/library/src/test/net/dpml/library/impl depot/library/src/test/net/dpml/library/info depot/tools/builder/src/main/net/dpml/tools/tasks lang/module/etc metro transit/core/src/main/net/dpml/util
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1348 - in trunk/main: depot/library/src/main/net/dpml/library depot/library/src/main/net/dpml/library/impl depot/library/src/main/net/dpml/library/info depot/library/src/test/net/dpml/library depot/library/src/test/net/dpml/library/impl depot/library/src/test/net/dpml/library/info depot/tools/builder/src/main/net/dpml/tools/tasks lang/module/etc metro transit/core/src/main/net/dpml/util
- Date: Mon, 10 Apr 2006 02:22:45 +0200
Author: mcconnell
Date: 2006-04-10 02:22:23 +0200 (Mon, 10 Apr 2006)
New Revision: 1348
Added:
trunk/main/depot/library/src/main/net/dpml/library/Info.java
trunk/main/depot/library/src/main/net/dpml/library/info/InfoDirective.java
trunk/main/depot/library/src/test/net/dpml/library/XMLTestCase.java
Removed:
trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java
Modified:
trunk/main/depot/library/src/main/net/dpml/library/Resource.java
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultResource.java
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryDecoder.java
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryEncoder.java
trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
trunk/main/depot/library/src/main/net/dpml/library/info/ResourceDirective.java
trunk/main/depot/library/src/test/net/dpml/library/info/ModuleDirectiveTestCase.java
trunk/main/depot/library/src/test/net/dpml/library/info/ResourceDirectiveTestCase.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
trunk/main/lang/module/etc/module.xsd
trunk/main/metro/module.xml
trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
Log:
resolve an issue in the element helper related to child element evaluation
Added: trunk/main/depot/library/src/main/net/dpml/library/Info.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Info.java
2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/depot/library/src/main/net/dpml/library/Info.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * 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.
+ */
+
+package net.dpml.library;
+
+import java.util.Properties;
+
+import net.dpml.lang.AbstractDirective;
+
+import net.dpml.library.Info;
+
+/**
+ * interface implemented by info providers.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Info
+{
+ /**
+ * Return the resource title.
+ * @return the title
+ */
+ String getTitle();
+
+
+ /**
+ * Return the resource description.
+ * @return the description
+ */
+ String getDescription();
+}
Modified: trunk/main/depot/library/src/main/net/dpml/library/Resource.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Resource.java
2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/depot/library/src/main/net/dpml/library/Resource.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -66,6 +66,12 @@
File getBaseDir();
/**
+ * Return the info block.
+ * @return the info block
+ */
+ Info getInfo();
+
+ /**
* Return the resource classifier.
* @return the classifier (LOCAL, EXTERNAL or ANONYMOUS)
*/
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -35,6 +35,7 @@
import net.dpml.library.info.DependencyDirective;
import net.dpml.library.info.ResourceDirective.Classifier;
import net.dpml.library.info.TypeDirective;
+import net.dpml.library.info.InfoDirective;
import net.dpml.library.Module;
import net.dpml.library.Resource;
import net.dpml.library.ResourceNotFoundException;
@@ -407,13 +408,15 @@
String name = getName();
String version = getVersion();
String basedir = null;
+ InfoDirective info = m_directive.getInfoDirective();
TypeDirective[] types = m_directive.getTypeDirectives();
TypeDirective[] exportedTypes = createExportedTypes( types );
Properties properties = module.getExportProperties();
return new ModuleDirective(
name, version, Classifier.EXTERNAL, basedir,
- exportedTypes, new DependencyDirective[0], directives, properties,
null );
+ info, exportedTypes, new DependencyDirective[0],
+ directives, properties, null );
}
//----------------------------------------------------------------------------
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultResource.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultResource.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultResource.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -33,11 +33,13 @@
import net.dpml.lang.Category;
+import net.dpml.library.Info;
import net.dpml.library.Filter;
import net.dpml.library.Library;
import net.dpml.library.Module;
import net.dpml.library.Resource;
import net.dpml.library.Type;
+import net.dpml.library.info.InfoDirective;
import net.dpml.library.info.TypeDirective;
import net.dpml.library.info.ResourceDirective;
import net.dpml.library.info.ResourceDirective.Classifier;
@@ -303,6 +305,15 @@
}
/**
+ * Return the info block.
+ * @return the info block
+ */
+ public Info getInfo()
+ {
+ return m_directive.getInfoDirective();
+ }
+
+ /**
* Return the expanded array of types associated with the resource.
* The returned array is a function of the types declared by a resource
* expanded relative to any types implied by processor dependencies.
@@ -599,13 +610,14 @@
String name = getName();
String version = getVersion();
String basedir = null;
+ InfoDirective info = m_directive.getInfoDirective();
TypeDirective[] types = m_directive.getTypeDirectives();
TypeDirective[] exportedTypes = createExportedTypes( types );
DependencyDirective[] dependencies = createDeps( module );
Properties properties = getExportProperties();
return new ResourceDirective(
name, version, Classifier.EXTERNAL, basedir,
- exportedTypes, dependencies, properties );
+ info, exportedTypes, dependencies, properties );
}
TypeDirective[] createExportedTypes( TypeDirective[] types )
@@ -939,13 +951,34 @@
}
catch( InvalidNameException e )
{
- final String error =
- "A dependency include referencing ["
- + ref
- + "] declared within ["
- + this
- + "] could not be resolved.";
- throw new InvalidNameException( error );
+ if( null == category )
+ {
+ final String error =
+ "A dependency include ["
+ + ref
+ + "] within ["
+ + this
+ + "] referencing ["
+ + ref
+ + "] under the scope ["
+ + scope
+ + "] is unknown.";
+ throw new InvalidNameException( error );
+ }
+ else
+ {
+ final String error =
+ "A dependency include within ["
+ + this
+ + "] referencing ["
+ + ref
+ + "] under the scope ["
+ + scope
+ + "] and category ["
+ + category
+ + "] is unknown.";
+ throw new InvalidNameException( error );
+ }
}
}
}
@@ -986,15 +1019,29 @@
private String getIncludeReference( IncludeDirective directive )
{
- if( IncludeDirective.REF.equals( directive.getMode() ) || ( null ==
m_parent ) )
+ if( null == m_parent )
{
return directive.getValue();
}
else
{
- String path = m_parent.getResourcePath();
- String key = directive.getValue();
- return path + "/" + key;
+ if( IncludeDirective.REF.equals( directive.getMode() ) )
+ {
+ return directive.getValue();
+ }
+ else
+ {
+ String path = m_parent.getResourcePath();
+ if( "".equals( path ) )
+ {
+ return directive.getValue();
+ }
+ else
+ {
+ String key = directive.getValue();
+ return path + "/" + key;
+ }
+ }
}
}
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryDecoder.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryDecoder.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryDecoder.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -28,6 +28,7 @@
import net.dpml.library.Feature;
import net.dpml.library.TypeBuilder;
+import net.dpml.library.info.InfoDirective;
import net.dpml.library.info.LibraryDirective;
import net.dpml.library.info.ImportDirective;
import net.dpml.library.info.IncludeDirective;
@@ -245,29 +246,34 @@
+ "] references a directory.";
throw new IllegalArgumentException( error );
}
- try
+ final File parent = source.getParentFile();
+ final String basedir = path;
+ final Element root = getRootElement( source );
+ final String tag = root.getTagName();
+ if( "module".equals( tag ) || "project".equals( tag ) ||
"resource".equals( tag ) )
{
- final File parent = source.getParentFile();
- final String basedir = path;
- final Element root = getRootElement( source );
- final String tag = root.getTagName();
- if( "module".equals( tag ) || "project".equals( tag ) ||
"resource".equals( tag ) )
+ try
{
return buildResourceDirectiveFromElement( parent, root,
basedir );
}
- else
+ catch( DecodingException e )
{
- throw new IllegalArgumentException( tag );
+ throw e;
}
+ catch( Throwable e )
+ {
+ final String error =
+ "An error occured while attempting to build a resource
from a local source [ "
+ + source
+ + "] from the path ["
+ + path
+ + "].";
+ throw new DecodingException( root, error, e );
+ }
}
- catch( Throwable e )
+ else
{
- final String error =
- "An error occured while attempting to build a module directive
from the source: "
- + source;
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
+ throw new IllegalArgumentException( tag );
}
}
@@ -285,68 +291,156 @@
final String elementName = element.getTagName();
if( "import".equals( elementName ) )
{
- String path = ElementHelper.getAttribute( element, "file" );
- File file = new File( base, path );
- File dir = file.getParentFile();
- String spec = getRelativePath( base, dir );
- File source = file.getCanonicalFile();
- if( !source.exists() )
+ try
{
- final String error =
- "Cannot include module ["
- + source
- + "] because the file does not exist.";
- throw new FileNotFoundException( error );
+ String path = ElementHelper.getAttribute( element, "file" );
+ File file = new File( base, path );
+ File dir = file.getParentFile();
+ String spec = getRelativePath( base, dir );
+ File source = file.getCanonicalFile();
+ if( !source.exists() )
+ {
+ final String error =
+ "Cannot include module ["
+ + source
+ + "] because the file does not exist.";
+ throw new DecodingException( element, error );
+ }
+ else
+ {
+ return buildResourceDirective( source, spec );
+ }
}
- else
+ catch( DecodingException e )
{
- return buildResourceDirective( source, spec ); // ##
+ throw e;
}
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to resolve a import
directive.";
+ throw new DecodingException( element, error, e );
+ }
}
else if( RESOURCE_ELEMENT_NAME.equals( elementName ) )
{
- return buildResourceDirective( element, offset );
+ try
+ {
+ return buildResourceDirective( element, offset );
+ }
+ catch( DecodingException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a resource
directive from an element.";
+ throw new DecodingException( element, error, e );
+ }
}
else if( PROJECT_ELEMENT_NAME.equals( elementName ) )
{
- return buildResourceDirective( element, offset );
+ try
+ {
+ return buildResourceDirective( element, offset );
+ }
+ catch( DecodingException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a project
directive from an element.";
+ throw new DecodingException( element, error, e );
+ }
}
else if( MODULE_ELEMENT_NAME.equals( elementName ) )
{
- ResourceDirective resource = buildResourceDirective( element,
offset );
- ArrayList list = new ArrayList();
- Element[] children = ElementHelper.getChildren( element );
- for( int i=0; i<children.length; i++ )
+ try
{
- Element child = children[i];
- final String tag = child.getTagName();
- if( MODULE_ELEMENT_NAME.equals( tag ) )
+ ResourceDirective resource = buildResourceDirective(
element, offset );
+ ArrayList list = new ArrayList();
+ Element[] children = ElementHelper.getChildren( element );
+ for( int i=0; i<children.length; i++ )
{
- ResourceDirective directive =
- buildResourceDirectiveFromElement( base, child, null );
- list.add( directive );
+ Element child = children[i];
+ final String tag = child.getTagName();
+ if( MODULE_ELEMENT_NAME.equals( tag ) )
+ {
+ try
+ {
+ ResourceDirective directive =
+ buildResourceDirectiveFromElement( base,
child, null );
+ list.add( directive );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a
nested module directive from an element.";
+ throw new DecodingException( child, error, e );
+ }
+ }
+ else if( IMPORT_ELEMENT_NAME.equals( tag ) )
+ {
+ try
+ {
+ ResourceDirective directive =
+ buildResourceDirectiveFromElement( base,
child, null );
+ list.add( directive );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a a
nested import directive from an element.";
+ throw new DecodingException( child, error, e );
+ }
+ }
+ else if( PROJECT_ELEMENT_NAME.equals( tag ) )
+ {
+ try
+ {
+ ResourceDirective directive =
+ buildResourceDirective( child );
+ list.add( directive );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a a
nested project directive from an element.";
+ throw new DecodingException( child, error, e );
+ }
+ }
+ else if( RESOURCE_ELEMENT_NAME.equals( tag ) )
+ {
+ try
+ {
+ ResourceDirective directive =
+ buildResourceDirective( child );
+ list.add( directive );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a a
nested resource directive from an element.";
+ throw new DecodingException( child, error, e );
+ }
+ }
}
- else if( IMPORT_ELEMENT_NAME.equals( tag ) )
- {
- ResourceDirective directive =
- buildResourceDirectiveFromElement( base, child, null );
- list.add( directive );
- }
- else if( PROJECT_ELEMENT_NAME.equals( tag ) )
- {
- ResourceDirective directive =
- buildResourceDirective( child );
- list.add( directive );
- }
- else if( RESOURCE_ELEMENT_NAME.equals( tag ) )
- {
- ResourceDirective directive =
- buildResourceDirective( child );
- list.add( directive );
- }
+ ResourceDirective[] resources = (ResourceDirective[])
list.toArray( new ResourceDirective[0] );
+ return new ModuleDirective( resource, resources );
}
- ResourceDirective[] resources = (ResourceDirective[])
list.toArray( new ResourceDirective[0] );
- return new ModuleDirective( resource, resources );
+ catch( DecodingException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to build a module
directive from an element.";
+ throw new DecodingException( element, error, e );
+ }
}
else
{
@@ -354,7 +448,7 @@
"Element ["
+ elementName
+ "] is not a module.";
- throw new IllegalArgumentException( error );
+ throw new DecodingException( element, error );
}
}
@@ -383,7 +477,7 @@
* @param element the enclosing element
* @return the array of includes
*/
- private ImportDirective[] buildImportDirectives( Element element )
+ private ImportDirective[] buildImportDirectives( Element element )
throws DecodingException
{
Element[] children = ElementHelper.getChildren( element );
ImportDirective[] includes = new ImportDirective[ children.length ];
@@ -395,28 +489,37 @@
return includes;
}
- private ImportDirective buildImportDirective( Element element )
+ private ImportDirective buildImportDirective( Element element ) throws
DecodingException
{
final String tag = element.getTagName();
final Properties properties = buildProperties( element );
if( IMPORT_ELEMENT_NAME.equals( tag ) )
{
- if( element.hasAttribute( "file" ) )
+ try
{
- final String value = ElementHelper.getAttribute( element,
"file", null );
- return new ImportDirective( ImportDirective.FILE, value,
properties );
+ if( element.hasAttribute( "file" ) )
+ {
+ final String value = ElementHelper.getAttribute(
element, "file", null );
+ return new ImportDirective( ImportDirective.FILE, value,
properties );
+ }
+ else if( element.hasAttribute( "uri" ) )
+ {
+ final String value = ElementHelper.getAttribute(
element, "uri", null );
+ return new ImportDirective( ImportDirective.URI, value,
properties );
+ }
+ else
+ {
+ final String error =
+ "Import element does not declare a 'file' or 'uri'
attribute.\n"
+ + element.toString();
+ throw new IllegalArgumentException( error );
+ }
}
- else if( element.hasAttribute( "uri" ) )
+ catch( Throwable e )
{
- final String value = ElementHelper.getAttribute( element,
"uri", null );
- return new ImportDirective( ImportDirective.URI, value,
properties );
- }
- else
- {
final String error =
- "Import element does not declare a 'file' or 'uri'
attribute.\n"
- + element.toString();
- throw new IllegalArgumentException( error );
+ "Internal error while attempting to resolve an import
directive.";
+ throw new DecodingException( element, error, e );
}
}
else
@@ -429,39 +532,47 @@
}
}
- private DependencyDirective[] buildDependencyDirectives( Element element
)
+ private DependencyDirective[] buildDependencyDirectives( Element element
) throws DecodingException
{
- final String tag = element.getTagName();
- if( DEPENDENCIES_ELEMENT_NAME.equals( tag ) )
+ if( null == element )
{
- Element[] children = ElementHelper.getChildren( element );
- DependencyDirective[] dependencies = new DependencyDirective[
children.length ];
- for( int i=0; i<children.length; i++ )
- {
- Element child = children[i];
- dependencies[i] = buildDependencyDirective( child );
- }
- return dependencies;
+ return new DependencyDirective[0];
}
else
{
- final String error =
- "Invalid dependency element name ["
- + tag
- + "].";
- throw new IllegalArgumentException( error );
+ final String tag = element.getTagName();
+ if( DEPENDENCIES_ELEMENT_NAME.equals( tag ) )
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ DependencyDirective[] dependencies = new
DependencyDirective[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ dependencies[i] = buildDependencyDirective( child );
+ }
+ return dependencies;
+ }
+ else
+ {
+ final String error =
+ "Invalid dependency element name ["
+ + tag
+ + "].";
+ throw new IllegalArgumentException( error );
+ }
}
}
- private DependencyDirective buildDependencyDirective( Element element )
+ private DependencyDirective buildDependencyDirective( Element element )
throws DecodingException
{
String name = element.getTagName();
+ Scope scope = Scope.parse( name );
IncludeDirective[] includes = buildIncludeDirectives( element );
- if( "build".equals( name ) )
+ if( Scope.BUILD.equals( scope ) )
{
return new DependencyDirective( Scope.BUILD, includes );
}
- else if( "runtime".equals( name ) )
+ else if( Scope.RUNTIME.equals( scope ) )
{
return new DependencyDirective( Scope.RUNTIME, includes );
}
@@ -476,7 +587,7 @@
* @param element the enclosing element
* @return the array of includes
*/
- private IncludeDirective[] buildIncludeDirectives( Element element )
+ private IncludeDirective[] buildIncludeDirectives( Element element )
throws DecodingException
{
Element[] children = ElementHelper.getChildren( element );
IncludeDirective[] includes = new IncludeDirective[ children.length
];
@@ -488,7 +599,7 @@
return includes;
}
- private IncludeDirective buildIncludeDirective( Element element )
+ private IncludeDirective buildIncludeDirective( Element element ) throws
DecodingException
{
final String tag = element.getTagName();
final Properties properties = buildProperties( element );
@@ -525,7 +636,7 @@
"Invalid include element name ["
+ tag
+ "].";
- throw new IllegalArgumentException( error );
+ throw new DecodingException( element, error );
}
}
@@ -556,11 +667,6 @@
}
}
- // add filter definitions
- FilterDirective[] filters = null;
- Element filtersElement = ElementHelper.getChild( element,
"filters" );
- filters = buildFilters( filtersElement );
-
if( PROJECT_ELEMENT_NAME.equals( tag ) )
{
classifier = Classifier.LOCAL;
@@ -570,7 +676,7 @@
"Missing basedir attribute on project ["
+ name
+ "].";
- throw new IllegalArgumentException( error );
+ throw new DecodingException( element, error );
}
}
else if( MODULE_ELEMENT_NAME.equals( tag ) )
@@ -589,29 +695,28 @@
classifier = Classifier.EXTERNAL;
}
- TypeDirective[] types = new TypeDirective[0];
- DependencyDirective[] dependencies = new DependencyDirective[0];
- Element[] children = ElementHelper.getChildren( element );
- Properties properties = null;
- for( int i=0; i<children.length; i++ )
- {
- Element child = children[i];
- final String childTag = child.getTagName();
- if( TYPES_ELEMENT_NAME.equals( childTag ) )
- {
- types = buildTypes( child );
- }
- else if( DEPENDENCIES_ELEMENT_NAME.equals( childTag ) )
- {
- dependencies = buildDependencyDirectives( child );
- }
- else if( PROPERTIES_ELEMENT_NAME.equals( childTag ) )
- {
- properties = buildProperties( child );
- }
- }
+ final InfoDirective info =
+ buildInfoDirective(
+ ElementHelper.getChild( element, "info" ) );
+
+ final TypeDirective[] types =
+ buildTypes(
+ ElementHelper.getChild( element, "types" ) );
+
+ final DependencyDirective[] dependencies =
+ buildDependencyDirectives(
+ ElementHelper.getChild( element, "dependencies" ) );
+
+ final FilterDirective[] filters =
+ buildFilters(
+ ElementHelper.getChild( element, "filters" ) );
+
+ final Properties properties =
+ buildProperties(
+ ElementHelper.getChild( element, "properties" ) );
+
return new ResourceDirective(
- name, version, classifier, basedir, types, dependencies,
properties, filters );
+ name, version, classifier, basedir, info, types, dependencies,
properties, filters );
}
else
{
@@ -619,10 +724,32 @@
"Invalid element name ["
+ tag
+ "].";
- throw new IllegalArgumentException( error );
+ throw new DecodingException( element, error );
}
}
+ private InfoDirective buildInfoDirective( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ Element child = ElementHelper.getChild( element, "description" );
+ if( null == child )
+ {
+ return null;
+ }
+ else
+ {
+ String title = ElementHelper.getAttribute( child, "title" );
+ String description = ElementHelper.getValue( child );
+ return new InfoDirective( title, description );
+ }
+ }
+ }
+
private FilterDirective[] buildFilters( Element element ) throws
Exception
{
if( null == element )
@@ -666,6 +793,10 @@
private TypeDirective[] buildTypes( Element element ) throws Exception
{
+ if( null == element )
+ {
+ return new TypeDirective[0];
+ }
Element[] children = ElementHelper.getChildren( element );
TypeDirective[] types = new TypeDirective[ children.length ];
for( int i=0; i<children.length; i++ )
@@ -726,7 +857,7 @@
else
{
final String error =
- "Element is not derivived from AbstractType defined under the
common namespace."
+ "Element is not derived from the schema type 'AbstractType'
defined under the common namespace."
+ "\nNamespace: " + namespace
+ "\nElement Name (from Schema Info): " + info.getTypeName();
throw new DecodingException( element, error );
@@ -735,6 +866,10 @@
private Properties buildProperties( Element element )
{
+ if( null == element )
+ {
+ return null;
+ }
Properties properties = new Properties();
Element[] children = ElementHelper.getChildren( element );
for( int i=0; i<children.length; i++ )
Modified:
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryEncoder.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryEncoder.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/impl/LibraryEncoder.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -28,6 +28,7 @@
import net.dpml.lang.Category;
+import net.dpml.library.info.InfoDirective;
import net.dpml.library.info.IncludeDirective;
import net.dpml.library.info.IncludeDirective.Mode;
import net.dpml.library.info.ModuleDirective;
@@ -85,12 +86,20 @@
+ "\n xmlns:common=\""
+ COMMON_XSD_URI
+ "\">" );
+
+ String basedir = module.getBasedir();
+ InfoDirective info = module.getInfoDirective();
Properties properties = module.getProperties();
- String basedir = module.getBasedir();
TypeDirective[] types = module.getTypeDirectives();
DependencyDirective[] dependencies =
module.getDependencyDirectives();
ResourceDirective[] resources = module.getResourceDirectives();
+
+ if( !info.isNull() )
+ {
+ writer.write( "\n" );
+ writeInfo( writer, info, " " );
+ }
if( properties.size() > 0 )
{
writer.write( "\n" );
@@ -125,6 +134,7 @@
String name = module.getName();
String version = module.getVersion();
+ InfoDirective info = module.getInfoDirective();
Properties properties = module.getProperties();
String basedir = module.getBasedir();
TypeDirective[] types = module.getTypeDirectives();
@@ -142,6 +152,11 @@
}
writer.write( ">" );
+ if( !info.isNull() )
+ {
+ writer.write( "\n" );
+ writeInfo( writer, info, lead + " " );
+ }
if( properties.size() > 0 )
{
writer.write( "\n" );
@@ -172,6 +187,7 @@
String name = resource.getName();
String version = resource.getVersion();
+ InfoDirective info = resource.getInfoDirective();
Properties properties = resource.getProperties();
String basedir = resource.getBasedir();
TypeDirective[] types = resource.getTypeDirectives();
@@ -188,6 +204,11 @@
}
writer.write( ">" );
+ if( !info.isNull() )
+ {
+ writer.write( "\n" );
+ writeInfo( writer, info, lead + " " );
+ }
if( properties.size() > 0 )
{
writeProperties( writer, properties, lead + " ", true );
@@ -203,6 +224,29 @@
writer.write( "\n" + lead + "</resource>" );
}
+ private void writeInfo(
+ Writer writer, InfoDirective info, String lead ) throws IOException
+ {
+ writer.write( "\n" + lead + "<info>" );
+ writer.write( "\n" + lead + " <description" );
+ if( null != info.getTitle() )
+ {
+ writer.write( " title\"" + info.getTitle() + "\"" );
+ }
+ String description = info.getDescription().trim();
+ if( null != info.getDescription() )
+ {
+ writer.write( ">" );
+ writer.write( "\n" + lead + " " + info.getDescription() );
+ writer.write( "\n" + lead + " </description>" );
+ }
+ else
+ {
+ writer.write( "/>" );
+ }
+ writer.write( "\n" + lead + "</info>" );
+ }
+
private void writeProperties(
Writer writer, Properties properties, String lead, boolean flag )
throws IOException
{
Added:
trunk/main/depot/library/src/main/net/dpml/library/info/InfoDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/InfoDirective.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/info/InfoDirective.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * 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.
+ */
+
+package net.dpml.library.info;
+
+import java.util.Properties;
+
+import net.dpml.lang.AbstractDirective;
+
+import net.dpml.library.Info;
+
+/**
+ * Info block descriptor.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class InfoDirective extends AbstractDirective implements Info
+{
+ private final String m_title;
+ private final String m_description;
+
+ /**
+ * Creation of a new anonymous resource directive.
+ * @param token the filter token
+ */
+ public InfoDirective( final String title, final String description )
+ {
+ m_title = title;
+ m_description = description;
+ }
+
+ /**
+ * Return the resource title.
+ * @return the title
+ */
+ public String getTitle()
+ {
+ return m_title;
+ }
+
+
+ /**
+ * Return the resource description.
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return m_description;
+ }
+
+ /**
+ * Return the null status of the info block.
+ * @return the null status
+ */
+ public boolean isNull()
+ {
+ return ( ( null == m_title ) && ( null == m_description ) );
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the other object
+ * @return true if equal
+ */
+ public boolean equals( Object other )
+ {
+ if( super.equals( other ) && ( other instanceof InfoDirective ) )
+ {
+ InfoDirective info = (InfoDirective) other;
+ if( !equals( m_title, info.m_title ) )
+ {
+ return false;
+ }
+ else
+ {
+ return equals( m_description, info.m_description );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Compute the hash value.
+ * @return the hashcode value
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= super.hashValue( m_title );
+ hash ^= super.hashValue( m_description );
+ return hash;
+ }
+}
Modified:
trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -33,7 +33,7 @@
/**
* Creation of a new module directive supporting the establishment
- * of an anonymous reesource.
+ * of an anonymous resource.
*
* @param name the module name
* @param resource resource contained within the module
@@ -41,7 +41,7 @@
public ModuleDirective( String name, ResourceDirective resource )
{
this(
- name, null, Classifier.ANONYMOUS, null,
+ name, null, Classifier.ANONYMOUS, null, null,
new TypeDirective[0], new DependencyDirective[0],
new ResourceDirective[]{resource}, null, null );
}
@@ -59,6 +59,7 @@
resource.getVersion(),
resource.getClassifier(),
resource.getBasedir(),
+ resource.getInfoDirective(),
resource.getTypeDirectives(),
resource.getDependencyDirectives(),
resources,
@@ -78,10 +79,13 @@
* @param properties suppliementary properties
*/
public ModuleDirective(
- String name, String version, Classifier classifier, String basedir,
TypeDirective[] types,
- DependencyDirective[] dependencies, ResourceDirective[] resources,
Properties properties, FilterDirective[] filters )
+ String name, String version, Classifier classifier, String basedir,
+ InfoDirective info, TypeDirective[] types,
+ DependencyDirective[] dependencies, ResourceDirective[] resources,
+ Properties properties, FilterDirective[] filters )
{
- super( name, version, classifier, basedir, types, dependencies,
properties, filters );
+ super( name, version, classifier, basedir, info, types,
dependencies, properties, filters );
+
if( null == resources )
{
throw new NullPointerException( "resources" );
Modified:
trunk/main/depot/library/src/main/net/dpml/library/info/ResourceDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ResourceDirective.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/main/net/dpml/library/info/ResourceDirective.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -54,6 +54,7 @@
private final DependencyDirective[] m_dependencies;
private final Classifier m_classifier;
private final FilterDirective[] m_filters;
+ private final InfoDirective m_info;
/**
* Creation of a new anonymous resource directive.
@@ -67,10 +68,7 @@
{
this(
name, version, Classifier.ANONYMOUS, null,
- new TypeDirective[]
- {
- new TypeDirective( type )
- },
+ null, new TypeDirective[]{new TypeDirective( type )},
new DependencyDirective[0],
properties );
}
@@ -86,10 +84,11 @@
* @param properties suppliementary properties
*/
public ResourceDirective(
- String name, String version, Classifier classifier, String basedir,
TypeDirective[] types,
+ String name, String version, Classifier classifier, String basedir,
+ InfoDirective info, TypeDirective[] types,
DependencyDirective[] dependencies, Properties properties )
{
- this( name, version, classifier, basedir, types, dependencies,
properties, null );
+ this( name, version, classifier, basedir, info, types, dependencies,
properties, null );
}
/**
@@ -104,8 +103,10 @@
* @param filters source filters
*/
public ResourceDirective(
- String name, String version, Classifier classifier, String basedir,
TypeDirective[] types,
- DependencyDirective[] dependencies, Properties properties,
FilterDirective[] filters )
+ String name, String version, Classifier classifier, String basedir,
+ InfoDirective info, TypeDirective[] types,
+ DependencyDirective[] dependencies, Properties properties,
+ FilterDirective[] filters )
{
super( properties );
@@ -125,13 +126,24 @@
{
throw new NullPointerException( "classifier" );
}
+
m_name = name;
m_version = version;
- m_types = types;
- m_dependencies = dependencies;
m_basedir = basedir;
m_classifier = classifier;
+ if( null == info )
+ {
+ m_info = new InfoDirective( null, null );
+ }
+ else
+ {
+ m_info = info;
+ }
+
+ m_types = types;
+ m_dependencies = dependencies;
+
if( null == filters )
{
m_filters = new FilterDirective[0];
@@ -170,6 +182,15 @@
}
/**
+ * Return the info descriptor.
+ * @return the info descriptor
+ */
+ public InfoDirective getInfoDirective()
+ {
+ return m_info;
+ }
+
+ /**
* Return the resource classifier.
* @return the classifier (LOCAL, EXTERNAL or ANONYMOUS)
*/
@@ -285,6 +306,10 @@
{
return false;
}
+ else if( !equals( m_info, object.m_info ) )
+ {
+ return false;
+ }
else if( !Arrays.equals( m_types, object.m_types ) )
{
return false;
@@ -314,6 +339,7 @@
hash ^= super.hashValue( m_name );
hash ^= super.hashValue( m_version );
hash ^= super.hashValue( m_basedir );
+ hash ^= super.hashValue( m_info );
hash ^= super.hashArray( m_types );
hash ^= super.hashArray( m_dependencies );
hash ^= super.hashArray( m_filters );
Copied: trunk/main/depot/library/src/test/net/dpml/library/XMLTestCase.java
(from rev 1346,
trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java)
===================================================================
--- trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java
2006-04-08 19:29:23 UTC (rev 1346)
+++ trunk/main/depot/library/src/test/net/dpml/library/XMLTestCase.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2004-2006 Stephen J. McConnell.
+ *
+ * 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.
+ */
+
+package net.dpml.library;
+
+import java.io.File;
+
+import net.dpml.library.info.LibraryDirective;
+import net.dpml.library.info.ModuleDirective;
+import net.dpml.library.info.ResourceDirective;
+import net.dpml.library.info.TypeDirective;
+
+import net.dpml.library.impl.LibraryDecoder;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Library XML test case.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class XMLTestCase extends TestCase
+{
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ }
+
+ private LibraryDecoder m_decoder;
+
+ /**
+ * Setup the library directive builder.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ m_decoder = new LibraryDecoder();
+ }
+
+ /**
+ * Test an empty library definition.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testEmptyLibrary() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-1.xml" );
+ assertEquals( "imports", 0, library.getImportDirectives().length );
+ assertEquals( "resources", 0, library.getResourceDirectives().length
);
+ assertEquals( "properties", 0,
library.getProperties().keySet().size() );
+ }
+
+ /**
+ * Test a library definition containing just properties.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testLibraryWithProperties() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-2.xml" );
+ assertEquals( "imports", 0, library.getImportDirectives().length );
+ assertEquals( "resources", 0, library.getResourceDirectives().length
);
+ assertEquals( "properties", 2,
library.getProperties().keySet().size() );
+ }
+
+ /**
+ * Test a library definition containing just a few imports.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testLibraryWithImports() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-3.xml" );
+ assertEquals( "imports", 2, library.getImportDirectives().length );
+ assertEquals( "resources", 0, library.getResourceDirectives().length
);
+ assertEquals( "properties", 0,
library.getProperties().keySet().size() );
+ }
+
+ /**
+ * Test a library definition containing just a modules imports.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testLibraryWithModules() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-4.xml" );
+ assertEquals( "imports", 2, library.getImportDirectives().length );
+ assertEquals( "resources", 3, library.getResourceDirectives().length
);
+ assertEquals( "properties", 0,
library.getProperties().keySet().size() );
+ }
+
+ /**
+ * Test a direct module name.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testModuleName() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-5.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ ResourceDirective resource = resources[0];
+ String name = resource.getName();
+ assertEquals( "name", "acme", name );
+ }
+
+ /**
+ * Test a direct module basedir.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testModuleBasedir() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-5.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ ResourceDirective resource = resources[0];
+ String basedir = resource.getBasedir();
+ assertEquals( "basedir", ".", basedir );
+ }
+
+ /**
+ * Test the properties within a module.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testModuleProperties() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-5.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ ResourceDirective resource = resources[0];
+ assertEquals( "properties", 3,
resource.getProperties().keySet().size() );
+ }
+
+ /**
+ * Test the import of a module into the <modules> element.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testModuleImport() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-6.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ assertEquals( "modules", 1, resources.length );
+ }
+
+ /**
+ * Test the import of a module into the <modules> element.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testNestedModuleImport() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-7.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ assertEquals( "resources", 1, resources.length );
+ ResourceDirective resource = resources[0];
+ if( resource instanceof ModuleDirective )
+ {
+ ModuleDirective module = (ModuleDirective) resource;
+ ResourceDirective[] ress = module.getResourceDirectives();
+ assertEquals( "resources", 1, ress.length );
+ }
+ else
+ {
+ fail( "Expecting a module - found a resource." );
+ }
+ }
+
+ /**
+ * Test the import of a module into the <modules> element.
+ * @exception Exception if an error occurs during test execution
+ */
+ public void testResourceStatement() throws Exception
+ {
+ LibraryDirective library = getDirective( "samples/example-8.xml" );
+ ResourceDirective[] resources = library.getResourceDirectives();
+ assertEquals( "resources", 1, resources.length );
+ ResourceDirective resource = resources[0];
+ if( resource instanceof ModuleDirective )
+ {
+ ModuleDirective module = (ModuleDirective) resource;
+ ResourceDirective[] ress = module.getResourceDirectives();
+ assertEquals( "resources", 1, ress.length );
+ ResourceDirective r = ress[0];
+ TypeDirective[] types = r.getTypeDirectives();
+ assertEquals( "types", 2, types.length );
+ }
+ else
+ {
+ fail( "Expecting a module - found a resource." );
+ }
+ }
+
+ private LibraryDirective getDirective( String path ) throws Exception
+ {
+ String base = System.getProperty( "project.test.dir" );
+ File test = new File( base );
+ File file = new File( test, path );
+ return m_decoder.build( file );
+ }
+}
Deleted:
trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java
===================================================================
--- trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java
2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/depot/library/src/test/net/dpml/library/impl/XMLTestCase.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -1,206 +0,0 @@
-/*
- * Copyright 2004-2006 Stephen J. McConnell.
- *
- * 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.
- */
-
-package net.dpml.library.impl;
-
-import java.io.File;
-
-import net.dpml.library.info.LibraryDirective;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.TypeDirective;
-
-import junit.framework.TestCase;
-
-
-/**
- * Library XML test case.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class XMLTestCase extends TestCase
-{
- static
- {
- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
- }
-
- private LibraryDecoder m_decoder;
-
- /**
- * Setup the library directive builder.
- * @exception Exception if an error occurs during test execution
- */
- public void setUp() throws Exception
- {
- m_decoder = new LibraryDecoder();
- }
-
- /**
- * Test an empty library definition.
- * @exception Exception if an error occurs during test execution
- */
- public void testEmptyLibrary() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-1.xml" );
- assertEquals( "imports", 0, library.getImportDirectives().length );
- assertEquals( "resources", 0, library.getResourceDirectives().length
);
- assertEquals( "properties", 0,
library.getProperties().keySet().size() );
- }
-
- /**
- * Test a library definition containing just properties.
- * @exception Exception if an error occurs during test execution
- */
- public void testLibraryWithProperties() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-2.xml" );
- assertEquals( "imports", 0, library.getImportDirectives().length );
- assertEquals( "resources", 0, library.getResourceDirectives().length
);
- assertEquals( "properties", 2,
library.getProperties().keySet().size() );
- }
-
- /**
- * Test a library definition containing just a few imports.
- * @exception Exception if an error occurs during test execution
- */
- public void testLibraryWithImports() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-3.xml" );
- assertEquals( "imports", 2, library.getImportDirectives().length );
- assertEquals( "resources", 0, library.getResourceDirectives().length
);
- assertEquals( "properties", 0,
library.getProperties().keySet().size() );
- }
-
- /**
- * Test a library definition containing just a modules imports.
- * @exception Exception if an error occurs during test execution
- */
- public void testLibraryWithModules() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-4.xml" );
- assertEquals( "imports", 2, library.getImportDirectives().length );
- assertEquals( "resources", 3, library.getResourceDirectives().length
);
- assertEquals( "properties", 0,
library.getProperties().keySet().size() );
- }
-
- /**
- * Test a direct module name.
- * @exception Exception if an error occurs during test execution
- */
- public void testModuleName() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-5.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- ResourceDirective resource = resources[0];
- String name = resource.getName();
- assertEquals( "name", "acme", name );
- }
-
- /**
- * Test a direct module basedir.
- * @exception Exception if an error occurs during test execution
- */
- public void testModuleBasedir() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-5.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- ResourceDirective resource = resources[0];
- String basedir = resource.getBasedir();
- assertEquals( "basedir", ".", basedir );
- }
-
- /**
- * Test the properties within a module.
- * @exception Exception if an error occurs during test execution
- */
- public void testModuleProperties() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-5.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- ResourceDirective resource = resources[0];
- assertEquals( "properties", 3,
resource.getProperties().keySet().size() );
- }
-
- /**
- * Test the import of a module into the <modules> element.
- * @exception Exception if an error occurs during test execution
- */
- public void testModuleImport() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-6.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- assertEquals( "modules", 1, resources.length );
- }
-
- /**
- * Test the import of a module into the <modules> element.
- * @exception Exception if an error occurs during test execution
- */
- public void testNestedModuleImport() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-7.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- assertEquals( "resources", 1, resources.length );
- ResourceDirective resource = resources[0];
- if( resource instanceof ModuleDirective )
- {
- ModuleDirective module = (ModuleDirective) resource;
- ResourceDirective[] ress = module.getResourceDirectives();
- assertEquals( "resources", 1, ress.length );
- }
- else
- {
- fail( "Expecting a module - found a resource." );
- }
- }
-
- /**
- * Test the import of a module into the <modules> element.
- * @exception Exception if an error occurs during test execution
- */
- public void testResourceStatement() throws Exception
- {
- LibraryDirective library = getDirective( "samples/example-8.xml" );
- ResourceDirective[] resources = library.getResourceDirectives();
- assertEquals( "resources", 1, resources.length );
- ResourceDirective resource = resources[0];
- if( resource instanceof ModuleDirective )
- {
- ModuleDirective module = (ModuleDirective) resource;
- ResourceDirective[] ress = module.getResourceDirectives();
- assertEquals( "resources", 1, ress.length );
- ResourceDirective r = ress[0];
- TypeDirective[] types = r.getTypeDirectives();
- assertEquals( "types", 2, types.length );
- }
- else
- {
- fail( "Expecting a module - found a resource." );
- }
- }
-
- private LibraryDirective getDirective( String path ) throws Exception
- {
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File file = new File( test, path );
- return m_decoder.build( file );
- }
-}
Modified:
trunk/main/depot/library/src/test/net/dpml/library/info/ModuleDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ModuleDirectiveTestCase.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/test/net/dpml/library/info/ModuleDirectiveTestCase.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -34,15 +34,16 @@
TypeDirective[] types = TypeDirectiveTestCase.TYPES;
DependencyDirective[] dependencies =
DependencyDirectiveTestCase.DEPENDENCIES;
ResourceDirective[] resources = ResourceDirectiveTestCase.RESOURCES;
+ InfoDirective info = new InfoDirective( "test", "test description" );
MODULES[0] = new ModuleDirective(
- "aaa", "1.1", ResourceDirective.LOCAL, ".", types,
+ "aaa", "1.1", ResourceDirective.LOCAL, ".", info, types,
dependencies, resources, PROPERTIES, null );
MODULES[1] = new ModuleDirective(
- "bbb", "1.1", ResourceDirective.LOCAL, ".", types,
+ "bbb", "1.1", ResourceDirective.LOCAL, ".", info, types,
dependencies, resources, PROPERTIES, null );
MODULES[2] = new ModuleDirective(
- "ccc", "1.1", ResourceDirective.LOCAL, ".", types,
+ "ccc", "1.1", ResourceDirective.LOCAL, ".", info, types,
dependencies, resources, PROPERTIES, null );
}
@@ -50,6 +51,7 @@
private final String m_name = "name";
private final String m_version = "1.1.1";
private final String m_basedir = ".";
+ private final InfoDirective m_info = new InfoDirective( "test", "test
description" );
private final TypeDirective[] m_types = TypeDirectiveTestCase.TYPES;
private final DependencyDirective[] m_dependencies =
DependencyDirectiveTestCase.DEPENDENCIES;
private final ResourceDirective[] m_resources =
ResourceDirectiveTestCase.RESOURCES;
@@ -65,7 +67,7 @@
{
m_module =
new ModuleDirective(
- m_name, m_version, m_classifier, "test", m_types,
m_dependencies, m_resources, PROPERTIES, m_filters );
+ m_name, m_version, m_classifier, "test", m_info, m_types,
m_dependencies, m_resources, PROPERTIES, m_filters );
}
/**
@@ -77,7 +79,7 @@
try
{
new ModuleDirective(
- null, m_version, m_classifier, "test", m_types,
m_dependencies, m_resources, PROPERTIES, m_filters );
+ null, m_version, m_classifier, "test", m_info, m_types,
m_dependencies, m_resources, PROPERTIES, m_filters );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -95,7 +97,7 @@
try
{
new ModuleDirective(
- m_name, null, m_classifier, "test", m_types, m_dependencies,
m_resources, PROPERTIES, m_filters );
+ m_name, null, m_classifier, "test", m_info, m_types,
m_dependencies, m_resources, PROPERTIES, m_filters );
}
catch( NullPointerException e )
{
@@ -112,7 +114,7 @@
try
{
new ModuleDirective(
- m_name, m_version, m_classifier, "test", m_types, null,
m_resources, PROPERTIES, m_filters );
+ m_name, m_version, m_classifier, "test", m_info, m_types,
null, m_resources, PROPERTIES, m_filters );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -130,7 +132,7 @@
try
{
new ModuleDirective(
- m_name, m_version, m_classifier, "test", m_types,
m_dependencies, null, PROPERTIES, m_filters );
+ m_name, m_version, m_classifier, "test", m_info, m_types,
m_dependencies, null, PROPERTIES, m_filters );
fail( "no-NPE" );
}
catch( NullPointerException e )
Modified:
trunk/main/depot/library/src/test/net/dpml/library/info/ResourceDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ResourceDirectiveTestCase.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/library/src/test/net/dpml/library/info/ResourceDirectiveTestCase.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -28,6 +28,7 @@
*/
public final class ResourceDirectiveTestCase extends AbstractTestCase
{
+ static final InfoDirective INFO = new InfoDirective( "test", "test
description" );
static final Classifier CLASSIFIER = ResourceDirective.LOCAL;
static final DependencyDirective[] DEPENDENCIES =
DependencyDirectiveTestCase.DEPENDENCIES;
static final TypeDirective[] TYPES = TypeDirectiveTestCase.TYPES;
@@ -37,13 +38,13 @@
{
RESOURCES[0] =
new ResourceDirective(
- "fred", null, CLASSIFIER, "example/fred", TYPES, DEPENDENCIES,
PROPERTIES );
+ "fred", null, CLASSIFIER, "example/fred", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
RESOURCES[1] =
new ResourceDirective(
- "george", "1.3.0", CLASSIFIER, "example/george", TYPES,
DEPENDENCIES, PROPERTIES );
+ "george", "1.3.0", CLASSIFIER, "example/george", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
RESOURCES[2] =
new ResourceDirective(
- "mary", "2.7", CLASSIFIER, "example/mary", TYPES, DEPENDENCIES,
PROPERTIES );
+ "mary", "2.7", CLASSIFIER, "example/mary", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
}
/**
@@ -55,7 +56,7 @@
try
{
ResourceDirective resource =
- new ResourceDirective( null, "1.0", CLASSIFIER, "test", TYPES,
DEPENDENCIES, PROPERTIES );
+ new ResourceDirective( null, "1.0", CLASSIFIER, "test", INFO,
TYPES, DEPENDENCIES, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -73,7 +74,7 @@
try
{
ResourceDirective resource =
- new ResourceDirective( "fred", "1.0", CLASSIFIER, "test",
null, DEPENDENCIES, PROPERTIES );
+ new ResourceDirective( "fred", "1.0", CLASSIFIER, "test",
INFO, null, DEPENDENCIES, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -91,7 +92,7 @@
try
{
ResourceDirective resource =
- new ResourceDirective( "fred", "1.0", CLASSIFIER, "test",
TYPES, null, PROPERTIES );
+ new ResourceDirective( "fred", "1.0", CLASSIFIER, "test",
INFO, TYPES, null, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -107,7 +108,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "name", "resource", resource.getName() );
}
@@ -118,7 +119,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "version", "2.7", resource.getVersion() );
}
@@ -129,7 +130,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "basedir", "test", resource.getBasedir() );
}
@@ -140,7 +141,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "types", 3, resource.getTypeDirectives().length );
}
@@ -151,7 +152,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "dependencies", 3,
resource.getDependencyDirectives().length );
}
@@ -162,7 +163,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
assertEquals( "properties", PROPERTIES, resource.getProperties() );
}
@@ -174,7 +175,7 @@
{
ResourceDirective resource =
new ResourceDirective(
- "resource", "2.7", CLASSIFIER, "test", TYPES, DEPENDENCIES,
PROPERTIES );
+ "resource", "2.7", CLASSIFIER, "test", INFO, TYPES,
DEPENDENCIES, PROPERTIES );
doSerializationTest( resource );
}
}
Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
2006-04-09 16:21:24 UTC (rev 1347)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -61,12 +61,12 @@
/**
* Property key used to identify the plugin title.
*/
- public static final String PLUGIN_TITLE_KEY = "project.plugin.title";
+ public static final String PLUGIN_TITLE_KEY = "project.title";
/**
* Property key used to identify the plugin description.
*/
- public static final String PLUGIN_DESCRIPTION_KEY =
"project.plugin.description";
+ public static final String PLUGIN_DESCRIPTION_KEY =
"project.description";
/**
* Property key used to identify a custom plugin handler classname.
@@ -200,8 +200,8 @@
{
Artifact artifact = resource.getArtifact( TYPE );
URI uri = artifact.toURI();
- String title = getTitle( resource );
- String description = getDescription( resource );
+ String title = resource.getInfo().getTitle();
+ String description = resource.getInfo().getDescription();
return new Info( uri, title, description );
}
Modified: trunk/main/lang/module/etc/module.xsd
===================================================================
--- trunk/main/lang/module/etc/module.xsd 2006-04-09 16:21:24 UTC (rev
1347)
+++ trunk/main/lang/module/etc/module.xsd 2006-04-10 00:22:23 UTC (rev
1348)
@@ -61,9 +61,10 @@
<complexType name="ResourceType">
<sequence>
- <element name="properties" type="this:PropertiesType" minOccurs="0"
/>
- <element name="types" type="this:TypesType" minOccurs="0"/>
- <element name="dependencies" type="this:DependenciesType"
minOccurs="0"/>
+ <element name="info" type="this:InfoType" minOccurs="0"
maxOccurs="1"/>
+ <element name="properties" type="this:PropertiesType" minOccurs="0"
maxOccurs="1"/>
+ <element name="types" type="this:TypesType" minOccurs="0"
maxOccurs="1"/>
+ <element name="dependencies" type="this:DependenciesType"
minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="name" type="string" use="required"/>
<attribute name="version" type="string"/>
@@ -74,7 +75,7 @@
<complexContent>
<extension base="this:ResourceType">
<sequence>
- <element name="filters" type="this:FiltersType" minOccurs="0"/>
+ <element name="filters" type="this:FiltersType" minOccurs="0"
maxOccurs="1"/>
</sequence>
</extension>
</complexContent>
@@ -109,7 +110,7 @@
</extension>
</complexContent>
</complexType>
-
+
<complexType name="DependenciesType">
<all>
<element name="build" type="this:BuildScope" minOccurs="0"
maxOccurs="1"/>
@@ -145,6 +146,20 @@
<attribute name="urn" type="string"/>
</complexType>
+ <complexType name="InfoType">
+ <sequence>
+ <element name="description" type="this:DescriptionType"
minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescriptionType">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="title" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
<complexType name="RuntimeIncludeType">
<complexContent>
<extension base="this:IncludeType">
Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/metro/module.xml 2006-04-10 00:22:23 UTC (rev 1348)
@@ -102,6 +102,11 @@
</project>
<project name="dpml-metro-runtime" basedir="runtime">
+ <info>
+ <description title="Metro Container Runtime">
+ DPML Component management platform runtime container.
+ </description>
+ </info>
<types>
<type id="jar"/>
<part:plugin alias="true"
class="net.dpml.metro.runtime.CompositionController">
@@ -130,6 +135,11 @@
</project>
<project name="dpml-metro-tools" basedir="tools">
+ <properties>
+ <property name="project.title" value="Metro Tools"/>
+ <property name="project.description"
+ value="DPML extensions supporting the Ant build system for component
type and deployment data management."/>
+ </properties>
<types>
<type id="jar"/>
<part:resource alias="true" urn="dpml:metro"
Modified:
trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -22,6 +22,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
/**
* Exception related to data decoding from a DOM element.
@@ -75,11 +77,10 @@
{
String message = super.getMessage();
StringBuffer buffer = new StringBuffer( message );
+ buffer.append( "\n" );
Element element = getElement();
- String tag = element.getTagName();
- buffer.append( "\nElement: <" );
- buffer.append( tag );
- buffer.append( " ...>" );
+ String listing = list( element );
+ buffer.append( listing );
Document document = element.getOwnerDocument();
String uri = document.getDocumentURI();
if( null != uri )
@@ -93,4 +94,44 @@
return super.getMessage();
}
}
+
+ public static String list( Element element )
+ {
+ return list( element, "" );
+ }
+
+ public static String list( Element element, String pad )
+ {
+ StringBuffer buffer = new StringBuffer();
+ String tag = element.getTagName();
+ buffer.append( pad + "<" );
+ buffer.append( tag );
+ NamedNodeMap map = element.getAttributes();
+ for( int i=0; i<map.getLength(); i++ )
+ {
+ Node item = map.item( i );
+ buffer.append( " " + item.getNodeName() + "=\"" );
+ buffer.append( item.getNodeValue() );
+ buffer.append( "\"" );
+ }
+
+ Element[] children = ElementHelper.getChildren( element );
+ if( children.length > 0 )
+ {
+ buffer.append( ">" );
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String listing = list( child, pad + " " );
+ String tagName = child.getTagName();
+ buffer.append( "\n" + listing );
+ }
+ buffer.append( "\n" + pad + "</" + tag + ">" );
+ }
+ else
+ {
+ buffer.append( "/>" );
+ }
+ return buffer.toString();
+ }
}
Modified: trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
2006-04-09 16:21:24 UTC (rev 1347)
+++ trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
2006-04-10 00:22:23 UTC (rev 1348)
@@ -120,13 +120,16 @@
{
return null;
}
- final NodeList list = root.getElementsByTagName( name );
- final int n = list.getLength();
- if( n < 1 )
+ Element[] children = getChildren( root );
+ for( int i=0; i<children.length; i++ )
{
- return null;
+ Element child = children[i];
+ if( name.equals( child.getTagName() ) )
+ {
+ return child;
+ }
}
- return (Element) list.item( 0 );
+ return null;
}
/**
- r1348 - in trunk/main: depot/library/src/main/net/dpml/library depot/library/src/main/net/dpml/library/impl depot/library/src/main/net/dpml/library/info depot/library/src/test/net/dpml/library depot/library/src/test/net/dpml/library/impl depot/library/src/test/net/dpml/library/info depot/tools/builder/src/main/net/dpml/tools/tasks lang/module/etc metro transit/core/src/main/net/dpml/util, mcconnell at BerliOS, 04/09/2006
Archive powered by MHonArc 2.6.24.