CVS: plexus-components/summit/src/java/org/apache/plexus/summit/resolver AbstractResolver.java,1.1.1.1,1.2 ClassicResolver.java,1.1.1.1,1.2 Resolution.java,1.1.1.1,1.2 Resolver.java,1.1.1.1,1.2 ResolverUtils.java,1.1.1.1,1.2 SimpleResolver.java,1.1.1.1,1.2
[email protected] Thu, 1 May 2003 14:28:43 -0500
| Newsgroups | gmane.comp.java.plexus.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver
In directory eng.werken.com:/tmp/cvs-serv17379/src/java/org/apache/plexus/summit/resolver
Modified Files:
AbstractResolver.java ClassicResolver.java Resolution.java
Resolver.java ResolverUtils.java SimpleResolver.java
Log Message:
o Removed the multiple View notion.
o Using a service manager instead of the components being service managers.
Index: AbstractResolver.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/AbstractResolver.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- AbstractResolver.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ AbstractResolver.java 1 May 2003 19:28:40 -0000 1.2
@@ -56,20 +56,20 @@
* ----------------------------------------------------------------------------
*/
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.commons.collections.FastArrayList;
import org.apache.plexus.summit.AbstractSummitComponent;
import org.apache.plexus.summit.module.Module;
import org.apache.plexus.summit.renderer.Renderer;
import org.apache.plexus.summit.view.DefaultView;
import org.apache.plexus.summit.view.View;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* <p>The base class from which all <code>Resolver</code>s are derived.</p>
*
@@ -82,8 +82,6 @@
extends AbstractSummitComponent
implements Resolver, Configurable, ThreadSafe
{
- private final static String ERROR_VIEW_KEY = "errorView";
-
/** * Module packages that will be searched by this resolver. */
private List modulePackages;
@@ -98,7 +96,7 @@
* The view that will be used when there is an error.
*/
private String errorView;
-
+
/**
* The name that will be searched for when a match cannot be made using the
* target's name within a <i>package</i> . This default base name is used
@@ -112,27 +110,27 @@
* Default extension to use for views.
*/
private String defaultViewExtension;
-
+
/**
* Default constructor.
*/
public AbstractResolver()
{
- modulePackages = new FastArrayList();
+ modulePackages = new ArrayList();
modulePackagesNames = new StringBuffer();
}
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
- public void configure(Configuration config) throws ConfigurationException
+ public void configure( Configuration config ) throws ConfigurationException
{
setErrorView( config.getChild( "errorView" ).getValue() );
setDefaultBaseName( config.getChild( "defaultBaseName" ).getValue() );
setDefaultViewExtension( config.getChild( "defaultViewExtension" ).getValue() );
-
+
Configuration[] packages = config.getChild( "modulePackages" ).getChildren();
-
+
// If the user does not define any modules, use the default package.
if ( packages == null || packages.length == 0 )
{
@@ -148,19 +146,15 @@
}
}
- // -------------------------------------------------------------------------
- // A C C E S S O R S
- // -------------------------------------------------------------------------
-
- /**
- * Sets the error view.
- * @param string
- */
- protected void setErrorView(String errorView)
+ // ----------------------------------------------------------------------
+ // Accessors
+ // ----------------------------------------------------------------------
+
+ protected void setErrorView( String errorView )
{
this.errorView = errorView;
}
-
+
/**
* Returns the error view.
* @see org.apache.plexus.summit.resolver.Resolver#getErrorView()
@@ -169,14 +163,14 @@
{
return errorView;
}
-
+
/**
* Set the default base name used in part to resolve <b>Modules</b> and <b>
* Views</b> .
*
* @param defaultBaseName
*/
- protected void setDefaultBaseName(String defaultBaseName)
+ protected void setDefaultBaseName( String defaultBaseName )
{
this.defaultBaseName = defaultBaseName;
}
@@ -194,10 +188,8 @@
/**
* Set the default view extension used in part to resolve <b>Views</b> .
- *
- * @param defaultBaseName
*/
- protected void setDefaultViewExtension(String defaultViewExtension)
+ protected void setDefaultViewExtension( String defaultViewExtension )
{
this.defaultViewExtension = defaultViewExtension;
}
@@ -217,7 +209,7 @@
*
* @param modulePackages
*/
- protected void setModulePackages(List modulePackages)
+ protected void setModulePackages( List modulePackages )
{
this.modulePackages = modulePackages;
}
@@ -235,12 +227,12 @@
/**
* Add a module package to the search list.
*
- * @param String module package to add to search list
+ * @param modulePackage module package to add to search list
*/
- protected void addModulePackage(String modulePackage)
+ protected void addModulePackage( String modulePackage )
{
- modulePackages.add(modulePackage);
- modulePackagesNames.append(modulePackage).append("\n");
+ modulePackages.add( modulePackage );
+ modulePackagesNames.append( modulePackage ).append( "\n" );
}
// -------------------------------------------------------------------------
@@ -250,47 +242,50 @@
/**
* Gets the view attribute of the AbstractResolver object
*/
- protected View getView(String target)
+ protected View getView( String target )
throws Exception
{
- return getView(target, null, null);
+ return getView( target, null, null );
}
/**
* Gets the view attribute of the AbstractResolver object
*/
- protected View getView(String target, String targetPrefix)
+ protected View getView( String target, String targetPrefix )
throws Exception
{
- return getView(target, targetPrefix, null);
+ return getView( target, targetPrefix, null );
}
/**
* Gets the view attribute of the AbstractResolver object
*/
- protected View getView(String target, String targetPrefix, String defaultView)
+ protected View getView( String target, String targetPrefix, String defaultView )
throws Exception
{
- List possibleViews = getPossibleViews(target, targetPrefix);
- Renderer renderer = ( Renderer ) getServiceBroker().lookup( Renderer.ROLE );
-
- if (defaultView != null && defaultView.length() > 0)
+ List possibleViews = getPossibleViews( target, targetPrefix );
+
+ System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!! " + getServiceManager() );
+
+ Renderer renderer = (Renderer) getServiceManager().lookup( Renderer.ROLE );
+
+ if ( defaultView != null && defaultView.length() > 0 )
{
- possibleViews.add(defaultView);
+ possibleViews.add( defaultView );
}
- for (Iterator i = possibleViews.iterator(); i.hasNext(); )
+ for ( Iterator i = possibleViews.iterator(); i.hasNext(); )
{
String view = (String) i.next();
-
- getLogger().info("Looking for view: " + view);
-
- if (getServiceBroker() != null && renderer.viewExists(view))
+
+ getLogger().info( "Looking for view: " + view );
+
+ if ( getServiceManager() != null && renderer.viewExists( view ) )
{
- getLogger().info("Found view: " + view);
+ getLogger().info( "Found view: " + view );
// We should use a view factory.
- return new DefaultView(view);
- }
+ return new DefaultView( view );
+ }
}
return null;
@@ -298,18 +293,18 @@
/**
*/
- protected List getPossibleViews(String target, String targetPrefix)
+ protected List getPossibleViews( String target, String targetPrefix )
throws Exception
{
- FastArrayList views = new FastArrayList();
- List possibleViews = ResolverUtils.getPossibleViews(target, getDefaultBaseName());
+ ArrayList views = new ArrayList();
+ List possibleViews = ResolverUtils.getPossibleViews( target, getDefaultBaseName() );
- for (Iterator i = possibleViews.iterator(); i.hasNext(); )
+ for ( Iterator i = possibleViews.iterator(); i.hasNext(); )
{
String view;
String possibleView = (String) i.next();
- if (targetPrefix != null && targetPrefix.length() > 0)
+ if ( targetPrefix != null && targetPrefix.length() > 0 )
{
view = targetPrefix + "/" + possibleView;
}
@@ -319,7 +314,7 @@
}
view = view + "." + getDefaultViewExtension();
- views.add(view);
+ views.add( view );
}
return views;
@@ -339,9 +334,9 @@
int size = modulePackages.size();
- for (int i = 0; i < size; i++)
+ for ( int i = 0; i < size; i++ )
{
- modulePackages.remove(0);
+ modulePackages.remove( 0 );
}
}
@@ -353,10 +348,10 @@
* @return The desired <code>Module</code>, or <code>null</code> if not
* found..
*/
- protected Module getModule(String target)
+ protected Module getModule( String target )
throws Exception
{
- return getModule(target, null, null);
+ return getModule( target, null, null );
}
/**
@@ -368,10 +363,10 @@
* @return The desired <code>Module</code>, or <code>null</code> if not
* found..
*/
- protected Module getModule(String target, String targetPrefix)
+ protected Module getModule( String target, String targetPrefix )
throws Exception
{
- return getModule(target, targetPrefix, null);
+ return getModule( target, targetPrefix, null );
}
/**
@@ -385,37 +380,37 @@
* @return The desired <code>Module</code>, or <code>null</code> if not
* found..
*/
- protected Module getModule(String target, String targetPrefix, String defaultModule)
+ protected Module getModule( String target, String targetPrefix, String defaultModule )
throws Exception
{
Module module = null;
// a cache implementation could go here.
- List possibleModules = getPossibleModules(target, targetPrefix);
+ List possibleModules = getPossibleModules( target, targetPrefix );
- if (defaultModule != null && defaultModule.length() > 0)
+ if ( defaultModule != null && defaultModule.length() > 0 )
{
- possibleModules.add(defaultModule);
+ possibleModules.add( defaultModule );
}
- for (Iterator i = possibleModules.iterator(); i.hasNext(); )
+ for ( Iterator i = possibleModules.iterator(); i.hasNext(); )
{
String moduleClass = (String) i.next();
try
{
- getLogger().debug("[Resolver] Looking for " + moduleClass);
- module = (Module) Class.forName(moduleClass).newInstance();
- getLogger().debug("[Resolver] " + target + " => " + moduleClass);
+ getLogger().debug( "[Resolver] Looking for " + moduleClass );
+ module = (Module) Class.forName( moduleClass ).newInstance();
+ getLogger().debug( "[Resolver] " + target + " => " + moduleClass );
break;
}
- catch (Exception ignored)
+ catch ( Exception ignored )
{
// Likely a non-existant class name combination.
}
}
-
+
/*
if (module == null)
{
@@ -423,7 +418,7 @@
"Can't find module for " + target + " in " + modulePackagesNames);
}
*/
-
+
// We will return null for the time being. We will propagate a
// ModuleNotFoundException
@@ -432,23 +427,23 @@
/**
*/
- protected List getPossibleModules(String target, String targetPrefix)
+ protected List getPossibleModules( String target, String targetPrefix )
throws Exception
{
- FastArrayList modules = new FastArrayList();
+ ArrayList modules = new ArrayList();
List moduleSuffixes =
- ResolverUtils.getPossibleModuleSuffixes(target, getDefaultBaseName());
+ ResolverUtils.getPossibleModuleSuffixes( target, getDefaultBaseName() );
- for (Iterator i = modulePackages.iterator(); i.hasNext(); )
+ for ( Iterator i = modulePackages.iterator(); i.hasNext(); )
{
String modulePackage = (String) i.next();
- for (Iterator j = moduleSuffixes.iterator(); j.hasNext(); )
+ for ( Iterator j = moduleSuffixes.iterator(); j.hasNext(); )
{
String module;
- if (targetPrefix != null && targetPrefix.length() > 0)
+ if ( targetPrefix != null && targetPrefix.length() > 0 )
{
module = modulePackage + "." + targetPrefix + "." + j.next();
}
@@ -457,7 +452,7 @@
module = modulePackage + "." + j.next();
}
- modules.add(module);
+ modules.add( module );
}
}
Index: ClassicResolver.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/ClassicResolver.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ClassicResolver.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ ClassicResolver.java 1 May 2003 19:28:40 -0000 1.2
@@ -81,26 +81,26 @@
* @version $Id$
*/
public class ClassicResolver
- extends AbstractResolver
-{
+ extends AbstractResolver
+{
/** Default layout module */
public final static String DEFAULT_LAYOUT_MODULE = "Default";
-
+
/** Key to retrieve the default layout module from the configuration */
public final static String DEFAULT_LAYOUT_MODULE_KEY = "defaultLayoutModule";
-
+
/** Default navigation module */
public final static String DEFAULT_NAV_MODULE = "Default";
-
+
/** Key to retrieve the default navigation module from the configuration */
public final static String DEFAULT_NAV_MODULE_KEY = "defaultLayoutModule";
-
+
/** Default screen module */
public final static String DEFAULT_SCREEN_MODULE = "Default";
-
+
/** Key to retrieve the default screen module from the configuration */
public final static String DEFAULT_SCREEN_MODULE_KEY = "defaultLayoutModule";
-
+
/** Tag for the layout module in the resolution. */
public final static String LAYOUT_MODULE = "layoutModule";
@@ -121,16 +121,16 @@
/** Tag for the layouts directory. */
private final static String LAYOUT_TARGET_PREFIX = "layouts";
-
+
/** Tag for the navigations directory. */
private final static String NAVIGATION_TARGET_PREFIX = "navigations";
-
+
/** Tag for the screens directory. */
private final static String SCREEN_TARGET_PREFIX = "screens";
- /**
- * The layout module to use when no match is found using
- * the target's name.
+ /**
+ * The layout module to use when no match is found using
+ * the target's name.
*/
private String defaultLayoutModule;
@@ -141,11 +141,11 @@
private String defaultNavigationModule;
/**
- * The screen module to use when no match is found using the
+ * The screen module to use when no match is found using the
* target's name.
*/
private String defaultScreenModule;
-
+
// -------------------------------------------------------------------------
// A C C E S S O R S
// -------------------------------------------------------------------------
@@ -157,7 +157,7 @@
* @param defaultLayoutModule Default layout module to use when a layout
* module cannot be resolved.
*/
- public void setDefaultLayoutModule(String defaultLayoutModule)
+ public void setDefaultLayoutModule( String defaultLayoutModule )
{
this.defaultLayoutModule = defaultLayoutModule;
}
@@ -179,7 +179,7 @@
* @param defaultNavigationModule Default navigation module to use when a
* navigation module cannot be resolved.
*/
- public void setDefaultNavigationModule(String defaultNavigationModule)
+ public void setDefaultNavigationModule( String defaultNavigationModule )
{
this.defaultNavigationModule = defaultNavigationModule;
}
@@ -201,7 +201,7 @@
* @param defaultScreenModule Default screen module to use when a screen
* module cannot be resolved.
*/
- public void setDefaultScreenModule(String defaultScreenModule)
+ public void setDefaultScreenModule( String defaultScreenModule )
{
this.defaultScreenModule = defaultScreenModule;
}
@@ -223,7 +223,7 @@
/**
* Description of the Method
*/
- public Resolution resolve(String target)
+ public Resolution resolve( String target )
throws Exception
{
Resolution resolution = new Resolution();
@@ -231,35 +231,35 @@
// ---------------------------------------------------------------
// L A Y O U T
// ---------------------------------------------------------------
- Module layoutModule = getLayoutModule(target);
- resolution.put(LAYOUT_MODULE, layoutModule);
- getLogger().info("Layout Module: " + layoutModule);
-
- View layoutView = getView(target, LAYOUT_TARGET_PREFIX);
- resolution.put(LAYOUT_VIEW, layoutView);
- getLogger().info("Layout View: " + layoutView);
+ Module layoutModule = getLayoutModule( target );
+ resolution.put( LAYOUT_MODULE, layoutModule );
+ getLogger().info( "Layout Module: " + layoutModule );
+
+ View layoutView = getView( target, LAYOUT_TARGET_PREFIX );
+ resolution.put( LAYOUT_VIEW, layoutView );
+ getLogger().info( "Layout View: " + layoutView );
// ---------------------------------------------------------------
// N A V I G A T I O N
// ---------------------------------------------------------------
- Module navigationModule = getNavigationModule(target);
- resolution.put(NAVIGATION_MODULE, navigationModule);
- getLogger().info("Navigation Module: " + navigationModule);
+ Module navigationModule = getNavigationModule( target );
+ resolution.put( NAVIGATION_MODULE, navigationModule );
+ getLogger().info( "Navigation Module: " + navigationModule );
- View navigationView = getView(target, NAVIGATION_TARGET_PREFIX);
- resolution.put(NAVIGATION_VIEW, navigationView);
- getLogger().info("Navigation View: " + navigationView);
+ View navigationView = getView( target, NAVIGATION_TARGET_PREFIX );
+ resolution.put( NAVIGATION_VIEW, navigationView );
+ getLogger().info( "Navigation View: " + navigationView );
// ---------------------------------------------------------------
// S C R E E N
// ---------------------------------------------------------------
- Module screenModule = getScreenModule(target);
- resolution.put(SCREEN_MODULE, screenModule);
- getLogger().info("Screen Module: " + screenModule);
+ Module screenModule = getScreenModule( target );
+ resolution.put( SCREEN_MODULE, screenModule );
+ getLogger().info( "Screen Module: " + screenModule );
- View screenView = getView(target, SCREEN_TARGET_PREFIX);
- resolution.put(SCREEN_VIEW, screenView);
- getLogger().info("Screen View: " + screenView);
+ View screenView = getView( target, SCREEN_TARGET_PREFIX );
+ resolution.put( SCREEN_VIEW, screenView );
+ getLogger().info( "Screen View: " + screenView );
return resolution;
}
@@ -271,10 +271,10 @@
* @param target
* @return Module
*/
- protected Module getLayoutModule(String target)
+ protected Module getLayoutModule( String target )
throws Exception
{
- return getModule(target, LAYOUT_TARGET_PREFIX, getDefaultLayoutModule());
+ return getModule( target, LAYOUT_TARGET_PREFIX, getDefaultLayoutModule() );
}
/**
@@ -284,10 +284,10 @@
* @param target
* @return Module
*/
- protected Module getNavigationModule(String target)
+ protected Module getNavigationModule( String target )
throws Exception
{
- return getModule(target, NAVIGATION_TARGET_PREFIX, getDefaultNavigationModule());
+ return getModule( target, NAVIGATION_TARGET_PREFIX, getDefaultNavigationModule() );
}
/**
@@ -297,27 +297,27 @@
* @param target
* @return Module
*/
- protected Module getScreenModule(String target)
+ protected Module getScreenModule( String target )
throws Exception
{
- return getModule(target, SCREEN_TARGET_PREFIX, getDefaultScreenModule());
+ return getModule( target, SCREEN_TARGET_PREFIX, getDefaultScreenModule() );
}
-
+
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
- public void configure(Configuration config) throws ConfigurationException
+ public void configure( Configuration config ) throws ConfigurationException
{
super.configure( config );
-
- setDefaultLayoutModule(
+
+ setDefaultLayoutModule(
config.getChild( DEFAULT_LAYOUT_MODULE_KEY )
- .getValue( DEFAULT_LAYOUT_MODULE_KEY ));
- setDefaultNavigationModule(
+ .getValue( DEFAULT_LAYOUT_MODULE_KEY ) );
+ setDefaultNavigationModule(
config.getChild( DEFAULT_NAV_MODULE_KEY )
- .getValue( DEFAULT_NAV_MODULE_KEY ));
- setDefaultScreenModule(
+ .getValue( DEFAULT_NAV_MODULE_KEY ) );
+ setDefaultScreenModule(
config.getChild( DEFAULT_SCREEN_MODULE_KEY )
- .getValue( DEFAULT_SCREEN_MODULE_KEY ));
+ .getValue( DEFAULT_SCREEN_MODULE_KEY ) );
}
}
Index: Resolution.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/Resolution.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Resolution.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ Resolution.java 1 May 2003 19:28:40 -0000 1.2
@@ -57,8 +57,8 @@
*/
import java.util.Map;
+import java.util.HashMap;
-import org.apache.commons.collections.FastHashMap;
import org.apache.plexus.summit.module.Module;
import org.apache.plexus.summit.view.View;
@@ -71,7 +71,7 @@
*/
public class Resolution
{
- /**
+ /**
* The collection of <code>Views</code> and <code>Modules</code>
* that have been computed by a <code>Resolver</code>. </p>
*/
@@ -80,7 +80,7 @@
/** Constructor for the Resolution object */
public Resolution()
{
- resolution = new FastHashMap();
+ resolution = new HashMap();
}
/**
@@ -89,9 +89,9 @@
* @param key
* @param value
*/
- public void put(Object key, Object value)
+ public void put( Object key, Object value )
{
- resolution.put(key, value);
+ resolution.put( key, value );
}
/**
@@ -100,24 +100,24 @@
* @param key
* @return Object
*/
- public Object get(Object key)
+ public Object get( Object key )
{
- return resolution.get(key);
+ return resolution.get( key );
}
/**
* Gets the module attribute of the Resolution object
*/
- public Module getModule(String key)
+ public Module getModule( String key )
{
- return (Module) get(key);
+ return (Module) get( key );
}
/**
* Gets the view attribute of the Resolution object
*/
- public View getView(String key)
+ public View getView( String key )
{
- return (View) get(key);
+ return (View) get( key );
}
}
Index: Resolver.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/Resolver.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Resolver.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ Resolver.java 1 May 2003 19:28:40 -0000 1.2
@@ -68,26 +68,26 @@
public interface Resolver
{
public final static String ROLE = Resolver.class.getName();
-
+
/**
* Resolve the target view.
*
* @param view Target view.
* @return Resolution
*/
- Resolution resolve(String view)
+ Resolution resolve( String view )
throws Exception;
/**
* <p>Return the default view.</p>
- *
+ *
* @return String the view
*/
String getDefaultView();
/**
* <p>Return the view that should be used upon an error.</p>
- *
+ *
* @return String the view
*/
String getErrorView();
Index: ResolverUtils.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/ResolverUtils.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ResolverUtils.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ ResolverUtils.java 1 May 2003 19:28:40 -0000 1.2
@@ -60,10 +60,8 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.collections.FastArrayList;
-
/**
- * A set of utilities that help with fulling resolving a
+ * A set of utilities that help with fulling resolving a
* target view.
*
* @author <a href="mailto:[email protected]">Jason van Zyl</a>
@@ -77,28 +75,28 @@
* @param target The target name.
* @param defaultBaseName The module type key.
* @return The parsed module name.
- * @exception Exception, a generaic exception.
+ * @exception Exception a generaic exception.
*/
- public static List getPossibleViews(String target, String defaultBaseName)
+ public static List getPossibleViews( String target, String defaultBaseName )
throws Exception
{
List views = new ArrayList();
StringBuffer view = new StringBuffer();
- int i = parseTargetPath(target, view);
+ int i = parseTargetPath( target, view );
// Remove leading slash if present
- if (view.charAt(0) == '/')
+ if ( view.charAt( 0 ) == '/' )
{
- view.deleteCharAt(0);
+ view.deleteCharAt( 0 );
i--;
}
// Remove a possible file extension.
- for (int j = i + 1; j < view.length(); j++)
+ for ( int j = i + 1; j < view.length(); j++ )
{
- if (view.charAt(j) == '.')
+ if ( view.charAt( j ) == '.' )
{
- view.delete(j, view.length());
+ view.delete( j, view.length() );
break;
}
}
@@ -108,30 +106,30 @@
// views to find a default module named Default.
int j = 9999;
String module;
- while (j-- > 0)
+ while ( j-- > 0 )
{
module = view.toString();
- views.add(module);
- view.setLength(i + 1);
+ views.add( module );
+ view.setLength( i + 1 );
- if (i > 0)
+ if ( i > 0 )
{
// We have still views to traverse.
- for (i = view.length() - 2; i >= 0; i--)
+ for ( i = view.length() - 2; i >= 0; i-- )
{
- if (view.charAt(i) == '/')
+ if ( view.charAt( i ) == '/' )
{
break;
}
}
}
- else if (j > 0)
+ else if ( j > 0 )
{
// Only the main level left.
j = 1;
}
- view.append(defaultBaseName);
+ view.append( defaultBaseName );
}
// Not found, return the default module name.
@@ -141,15 +139,15 @@
/**
* Gets the possibleModules attribute of the ResolverUtils class
*/
- public static List getPossibleModules(List views)
+ public static List getPossibleModules( List views )
throws Exception
{
List modules = new ArrayList();
- for (Iterator i = views.iterator(); i.hasNext(); )
+ for ( Iterator i = views.iterator(); i.hasNext(); )
{
String view = (String) i.next();
- modules.add(viewToClassName(view));
+ modules.add( viewToClassName( view ) );
}
return modules;
@@ -167,34 +165,34 @@
* @return The index of the separator between the path and the name.
* @exception Exception Malformed template name.
*/
- public static int parseTargetPath(String target, StringBuffer buffer)
+ public static int parseTargetPath( String target, StringBuffer buffer )
throws Exception
{
char c;
int j = 0;
int index = -1;
- buffer.setLength(0);
- buffer.append(target);
+ buffer.setLength( 0 );
+ buffer.append( target );
int len = buffer.length();
- while (j < len)
+ while ( j < len )
{
- c = buffer.charAt(j);
- if (c == ',')
+ c = buffer.charAt( j );
+ if ( c == ',' )
{
c = '/';
- buffer.setCharAt(j, c);
+ buffer.setCharAt( j, c );
}
- if (c == '/')
+ if ( c == '/' )
{
index = j;
- if (j < (len - 1))
+ if ( j < ( len - 1 ) )
{
- c = buffer.charAt(j + 1);
- if ((c == '/') ||
- (c == ','))
+ c = buffer.charAt( j + 1 );
+ if ( ( c == '/' ) ||
+ ( c == ',' ) )
{
- buffer.deleteCharAt(j);
+ buffer.deleteCharAt( j );
len--;
continue;
}
@@ -202,11 +200,11 @@
}
j++;
}
- if ((len == 0) ||
- (index >= (len - 1)))
+ if ( ( len == 0 ) ||
+ ( index >= ( len - 1 ) ) )
{
throw new Exception(
- "Syntax error in template name '" + target + '\'');
+ "Syntax error in template name '" + target + '\'' );
}
return index;
}
@@ -218,20 +216,20 @@
* @param view View to convert to a class name
* @return String The class name produced
*/
- public static String viewToClassName(String view)
+ public static String viewToClassName( String view )
{
- StringBuffer sb = new StringBuffer(view);
+ StringBuffer sb = new StringBuffer( view );
- if (sb.charAt(0) == '/')
+ if ( sb.charAt( 0 ) == '/' )
{
- sb.deleteCharAt(0);
+ sb.deleteCharAt( 0 );
}
- for (int j = 0; j < sb.length(); j++)
+ for ( int j = 0; j < sb.length(); j++ )
{
- if (sb.charAt(j) == '/')
+ if ( sb.charAt( j ) == '/' )
{
- sb.setCharAt(j, '.');
+ sb.setCharAt( j, '.' );
}
}
@@ -244,18 +242,18 @@
* be used to produce the possible list of fully qualified modules class
* names.
*/
- public static List getPossibleModuleSuffixes(String target, String defaultBaseName)
+ public static List getPossibleModuleSuffixes( String target, String defaultBaseName )
throws Exception
{
- List views = ResolverUtils.getPossibleViews(target, defaultBaseName);
+ List views = ResolverUtils.getPossibleViews( target, defaultBaseName );
// Now what we have is a set of views which look like paths so we need
// to convert these into elements that look like classes in order to
// create a list of possible modules.
- List modules = new FastArrayList();
- for (Iterator i = views.iterator(); i.hasNext(); )
+ List modules = new ArrayList();
+ for ( Iterator i = views.iterator(); i.hasNext(); )
{
- modules.add(ResolverUtils.viewToClassName((String) i.next()));
+ modules.add( ResolverUtils.viewToClassName( (String) i.next() ) );
}
return modules;
@@ -264,8 +262,8 @@
/**
* Description of the Method
*/
- public boolean targetHasExtension(String target)
+ public boolean targetHasExtension( String target )
{
- return target.indexOf(".") > 0;
+ return target.indexOf( "." ) > 0;
}
}
Index: SimpleResolver.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/resolver/SimpleResolver.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SimpleResolver.java 15 Feb 2003 03:55:54 -0000 1.1.1.1
+++ SimpleResolver.java 1 May 2003 19:28:40 -0000 1.2
@@ -79,7 +79,7 @@
/** Tag for the default screen module configuration key */
public final static String DEFAULT_SCREEN_MODULE_KEY = "defaultScreenModule";
-
+
/** Tag for the screen module in the resolution. */
public final static String DEFAULT_SCREEN_MODULE = "Default";
@@ -90,7 +90,7 @@
public SimpleResolver()
{
}
-
+
// -------------------------------------------------------------------------
// A C C E S S O R S
// -------------------------------------------------------------------------
@@ -102,7 +102,7 @@
* @param defaultScreenModule Default screen module to use when a screen
* module cannot be resolved.
*/
- public void setDefaultScreenModule(String defaultScreenModule)
+ public void setDefaultScreenModule( String defaultScreenModule )
{
this.defaultScreenModule = defaultScreenModule;
}
@@ -124,20 +124,20 @@
/**
* Description of the Method
*/
- public Resolution resolve(String target)
+ public Resolution resolve( String target )
throws Exception
{
Resolution resolution = new Resolution();
-
+
// Find the screen module
- Module screenModule = getScreenModule(target);
- resolution.put(SCREEN_MODULE, screenModule);
- getLogger().info("Found screen module: " + screenModule);
-
+ Module screenModule = getScreenModule( target );
+ resolution.put( SCREEN_MODULE, screenModule );
+ getLogger().info( "Found screen module: " + screenModule );
+
// Find the screen view
- View screenView = getView(target);
- resolution.put(SCREEN_VIEW, screenView);
- getLogger().info("Found screen view: " + screenView);
+ View screenView = getView( target );
+ resolution.put( SCREEN_VIEW, screenView );
+ getLogger().info( "Found screen view: " + screenView );
return resolution;
}
@@ -149,21 +149,21 @@
* @param target
* @return Module
*/
- protected Module getScreenModule(String target)
+ protected Module getScreenModule( String target )
throws Exception
{
return getModule( target, null, getDefaultScreenModule() );
}
-
+
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
- public void configure(Configuration config) throws ConfigurationException
+ public void configure( Configuration config ) throws ConfigurationException
{
super.configure( config );
-
- setDefaultScreenModule(
+
+ setDefaultScreenModule(
config.getChild( DEFAULT_SCREEN_MODULE_KEY )
- .getValue( DEFAULT_SCREEN_MODULE ));
+ .getValue( DEFAULT_SCREEN_MODULE ) );
}
}