mcconnell 2003/11/25 16:41:41
Modified: repository/impl/src/java/org/apache/avalon/repository/impl
DefaultFactory.java DefaultRepositoryCriteria.java
repository/spi/src/java/org/apache/avalon/repository/criteria
AbstractCriteria.java Criteria.java Parameter.java
Added: repository/spi/src/java/org/apache/avalon/repository/criteria
RepositoryCriteria.java
Removed: repository/spi/src/java/org/apache/avalon/repository
RepositoryCriteria.java RepositoryFactory.java
package.html
Log:
Minor updates to criteria interfaces and code location.
Revision Changes Path
1.10 +3 -2
avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultFactory.java 24 Nov 2003 13:33:37 -0000 1.9
+++ DefaultFactory.java 26 Nov 2003 00:41:41 -0000 1.10
@@ -70,7 +70,8 @@
import org.apache.avalon.repository.Repository ;
import org.apache.avalon.repository.RepositoryException ;
import org.apache.avalon.repository.RepositoryRuntimeException;
-import org.apache.avalon.repository.RepositoryCriteria ;
+import org.apache.avalon.repository.factory.RepositoryCriteria ;
+import org.apache.avalon.repository.factory.RepositoryFactory ; // not used yet
import org.apache.avalon.repository.criteria.Factory ;
import org.apache.avalon.repository.criteria.Criteria ;
import org.apache.avalon.repository.criteria.Parameter ;
1.4 +2 -2
avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java
Index: DefaultRepositoryCriteria.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultRepositoryCriteria.java 25 Nov 2003 18:55:15 -0000 1.3
+++ DefaultRepositoryCriteria.java 26 Nov 2003 00:41:41 -0000 1.4
@@ -60,7 +60,7 @@
import java.net.MalformedURLException;
import org.apache.avalon.repository.RepositoryException;
-import org.apache.avalon.repository.RepositoryCriteria;
+import org.apache.avalon.repository.factory.RepositoryCriteria;
import org.apache.avalon.repository.criteria.Criteria;
import org.apache.avalon.repository.criteria.Parameter;
import org.apache.avalon.repository.criteria.ValidationException;
1.3 +24 -9
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/AbstractCriteria.java
Index: AbstractCriteria.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/AbstractCriteria.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractCriteria.java 25 Nov 2003 18:55:15 -0000 1.2
+++ AbstractCriteria.java 26 Nov 2003 00:41:41 -0000 1.3
@@ -110,12 +110,12 @@
//--------------------------------------------------------------
/**
- * Return the parameter associated to the criteria.
- * @return the parameters
+ * Return the set of parameter keys for the criteria.
+ * @return the keys
*/
- public Parameter[] getParameters()
+ public String[] getKeys()
{
- return m_params;
+ return m_keys;
}
/**
@@ -139,8 +139,10 @@
*/
public Object getValue( final String key )
{
- getParameter( key ); // verify key
- return m_bindings.get( key );
+ Parameter param = getParameter( key );
+ Object value = m_bindings.get( key );
+ if( null != value ) return value;
+ return param.getDefault();
}
/**
@@ -172,9 +174,22 @@
// private and protected
//--------------------------------------------------------------
- protected String[] getKeys()
+ /**
+ * Return the currently assigned value for a key.
+ * @return the assigned value
+ */
+ protected Object getValue( final Parameter param )
{
- return m_keys;
+ return getValue( param.getKey() );
+ }
+
+ /**
+ * Return the parameter associated to the criteria.
+ * @return the parameters
+ */
+ protected Parameter[] getParameters()
+ {
+ return m_params;
}
protected Parameter getParameter( final String key )
1.3 +4 -4
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Criteria.java
Index: Criteria.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Criteria.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Criteria.java 24 Nov 2003 08:19:09 -0000 1.2
+++ Criteria.java 26 Nov 2003 00:41:41 -0000 1.3
@@ -62,10 +62,10 @@
public interface Criteria
{
/**
- * Return the parameter associated to the criteria.
- * @return the parameters
+ * Return the set of parameter keys for the criteria.
+ * @return the keys
*/
- public Parameter[] getParameters();
+ public String[] getKeys();
/**
* Set a named parameter of the criteria to a value.
1.4 +32 -5
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java
Index: Parameter.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Parameter.java 24 Nov 2003 08:19:09 -0000 1.3
+++ Parameter.java 26 Nov 2003 00:41:41 -0000 1.4
@@ -60,20 +60,37 @@
private final String m_key;
private final String m_type;
private final boolean m_required;
+ private final Object m_default;
/**
- * Creation of a new parameter constraint.
+ * Creation of a new required parameter constraint.
* @param key the parameter key
* @param type the name of a class constraining assigned values
* @boolean required TRUE if the parameter is required
- * @param description a human readable parameter description
*/
public Parameter(
- final String key, final String type, boolean required )
+ final String key, final String type )
{
m_key = key;
m_type = type;
- m_required = required;
+ m_required = true;
+ m_default = null;
+ }
+
+ /**
+ * Creation of a new optional parameter constraint.
+ * @param key the parameter key
+ * @param type the name of a class constraining assigned values
+ * @param value the default value
+ * @boolean value the default value
+ */
+ public Parameter(
+ final String key, final String type, Object value )
+ {
+ m_key = key;
+ m_type = type;
+ m_required = false;
+ m_default = value;
}
/**
@@ -111,4 +128,14 @@
{
return !isRequired();
}
+
+ /**
+ * Return the default value for this parameter.
+ * @return the default value
+ */
+ public Object getDefault()
+ {
+ return m_default;
+ }
+
}
1.1
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/RepositoryCriteria.java
Index: RepositoryCriteria.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.avalon.repository.factory;
import java.net.URL;
import java.io.File;
import org.apache.avalon.repository.criteria.Criteria;
import org.apache.avalon.repository.criteria.Parameter;
/**
* A service that provides access to versioned resources.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2003/11/26 00:41:41 $
*/
public interface RepositoryCriteria extends Criteria
{
final File USER_HOME = new File( System.getProperty( "user.home" )) ;
/**
* Repository cache directory parameter descriptor.
*/
final Parameter REPOSITORY_CACHE_DIR =
new Parameter(
"avalon.home",
File.class.getName(),
new File( USER_HOME, ".avalon" ) );
/**
* Repository proxy host parameter descriptor.
*/
final Parameter REPOSITORY_PROXY_HOST =
new Parameter(
"avalon.repository.proxy.host",
String.class.getName(),
null );
/**
* Repository proxy port parameter descriptor.
*/
public static final Parameter REPOSITORY_PROXY_PORT =
new Parameter(
"avalon.repository.proxy.port",
Integer.class.getName(),
null );
/**
* Repository proxy username parameter descriptor.
*/
public static final Parameter REPOSITORY_PROXY_USERNAME =
new Parameter(
"avalon.repository.proxy.username",
String.class.getName(),
null );
/**
* Repository proxy password parameter descriptor.
*/
public static final Parameter REPOSITORY_PROXY_PASSWORD =
new Parameter(
"avalon.repository.proxy.password",
String.class.getName(),
null );
/**
* Repository proxy password parameter descriptor.
*/
final Parameter REPOSITORY_REMOTE_HOSTS =
new Parameter(
"avalon.repository.remote.url",
String[].class.getName(),
new String[0] );
/**
* The factory parameters template.
*/
final Parameter[] PARAMS = new Parameter[]{
REPOSITORY_CACHE_DIR,
REPOSITORY_PROXY_HOST,
REPOSITORY_PROXY_PORT,
REPOSITORY_PROXY_USERNAME,
REPOSITORY_PROXY_PASSWORD,
REPOSITORY_REMOTE_HOSTS };
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]