notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2337 - development/main/magic/core/src/main/net/dpml/magic/builder
- From: niclas AT hedhman.org
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2337 - development/main/magic/core/src/main/net/dpml/magic/builder
- Date: Wed, 20 Apr 2005 17:51:34 -0400
Author: niclas AT hedhman.org
Date: Wed Apr 20 17:51:30 2005
New Revision: 2337
Modified:
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
Log:
Breaking apart to aid in debugging.
Modified:
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
==============================================================================
---
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
(original)
+++
development/main/magic/core/src/main/net/dpml/magic/builder/XMLDefinitionBuilder.java
Wed Apr 20 17:51:30 2005
@@ -48,9 +48,8 @@
final Info info =
createInfo( home, ElementHelper.getChild( element, "info" ),
external );
final String key = getDefinitionKey( element, info );
- final ResourceRef[] resources =
- createResourceRefs(
- ElementHelper.getChild( element, "dependencies" ) );
+ final Element dependenciesElement = ElementHelper.getChild( element,
"dependencies" );
+ final ResourceRef[] resources = createResourceRefs(
dependenciesElement );
return new Resource( home, key, info, resources, uri );
}
@@ -93,17 +92,14 @@
final String file = getBuildFile( element );
- final ResourceRef[] resources =
- createResourceRefs(
- ElementHelper.getChild( element, "dependencies" ) );
-
- final ResourceRef[] plugins =
- createPluginRefs(
- ElementHelper.getChild( element, "plugins" ) );
-
- final ResourceRef[] parts =
- createResourceRefs(
- ElementHelper.getChild( element, "parts" ) );
+ final Element dependenciesElement = ElementHelper.getChild(
element, "dependencies" );
+ final ResourceRef[] resources = createResourceRefs(
dependenciesElement );
+
+ final Element pluginsElement = ElementHelper.getChild( element,
"plugins" );
+ final ResourceRef[] plugins = createPluginRefs( pluginsElement );
+
+ final Element partsElement = ElementHelper.getChild( element,
"parts" );
+ final ResourceRef[] parts = createResourceRefs( partsElement );
return new Definition(
home, key, basedir, file, path, info, resources, plugins,
parts, uri );
@@ -174,19 +170,19 @@
public static Info createInfo( Index home, final Element info, boolean
external )
{
- final String group =
- ElementHelper.getValue( ElementHelper.getChild( info, "group" ) );
- final String name =
- ElementHelper.getValue( ElementHelper.getChild( info, "name" ) );
+ final Element groupElement = ElementHelper.getChild( info, "group" );
+ final String group = ElementHelper.getValue( groupElement );
+ final Element nameElement = ElementHelper.getChild( info, "name" );
+ final String name = ElementHelper.getValue( nameElement );
- final String[] types = createTypes( info, name );
+ final String[] types = createTypes( info );
final String version = createVersion( home, info, external );
final boolean status = createSnapshotPolicy( home, info, external );
return Info.create( group, name, version, types, status );
}
- private static String[] createTypes( Element info, String name )
+ private static String[] createTypes( Element info )
{
Element types = ElementHelper.getChild( info, "types" );
if( null != types )
@@ -226,7 +222,8 @@
private static String createVersion( Index home, Element info, boolean
external )
{
- String version = ElementHelper.getValue( ElementHelper.getChild(
info, "version" ) );
+ final Element versionElement = ElementHelper.getChild( info,
"version" );
+ String version = ElementHelper.getValue( versionElement );
if( external )
{
return version;
@@ -257,9 +254,8 @@
}
else
{
- final String status =
- ElementHelper.getValue(
- ElementHelper.getChild( info, "status" ) );
+ final Element statusElement = ElementHelper.getChild( info,
"status" );
+ final String status = ElementHelper.getValue( statusElement );
return Info.SNAPSHOT.equalsIgnoreCase( status );
}
}
@@ -274,7 +270,8 @@
final Element child = children[i];
final String key = child.getAttribute( "key" );
final String scope = child.getAttribute( "scope" );
- final int tag = ResourceRef.getCategory( child.getAttribute(
"tag" ) );
+ final String tagAttribute = child.getAttribute( "tag" );
+ final int tag = ResourceRef.getCategory( tagAttribute );
final Policy policy = createPolicy( child );
refs[i] = new ResourceRef( key, policy, tag, scope );
}
@@ -290,7 +287,8 @@
{
final Element child = children[i];
final String key = child.getAttribute( "key" );
- final int tag = ResourceRef.getCategory( child.getAttribute(
"tag" ) );
+ final String tagAttribute = child.getAttribute( "tag" );
+ final int tag = ResourceRef.getCategory( tagAttribute );
final Policy policy = createPolicy( child, false );
refs[i] = new ResourceRef( key, policy, tag );
}
@@ -302,44 +300,11 @@
return createPolicy( element, true );
}
-/* Niclas: defTest was not used.
- private static Policy createPolicy(
- final Element element, final boolean defBuild, final boolean defTest )
-*/
- private static Policy createPolicy(
- final Element element, final boolean defBuild )
- {
- final boolean build =
- ElementHelper.getBooleanAttribute( element, "build", defBuild );
- final boolean test =
- ElementHelper.getBooleanAttribute( element, "test", build );
- final boolean runtime =
- ElementHelper.getBooleanAttribute( element, "runtime", test );
- return new Policy( build, test, runtime );
- }
-
- /* CODE FRAGMENT - NON FUNCTIONAL
- private Module createModule( Resource resource )
+ private static Policy createPolicy( final Element element, final boolean
defBuild )
{
- String uri = resource.getInfo().getURI();
- try
- {
- URL url = new URL( null, uri, new Handler() );
- InputStream input = url.openStream();
- Element root = ElementHelper.getRootElement( input );
- Element header = ElementHelper.getChild( root, "header" );
- Element docs = ElementHelper.getChild( header, "docs" );
- String host = ElementHelper.getAttribute( docs, "href" );
- return new Link( resource.getKey(), host );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to construct module link from resource: "
- + resource;
- throw new BuildException( error, def.getLocation() );
- }
+ boolean build = ElementHelper.getBooleanAttribute( element, "build",
defBuild );
+ boolean test = ElementHelper.getBooleanAttribute( element, "test",
build );
+ boolean runtime = ElementHelper.getBooleanAttribute( element,
"runtime", test );
+ return new Policy( build, test, runtime );
}
- */
-
}
- svn commit: r2337 - development/main/magic/core/src/main/net/dpml/magic/builder, niclas, 04/20/2005
Archive powered by MHonArc 2.6.24.