You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Peter Donald <do...@apache.org> on 2001/10/29 20:52:38 UTC
Re: cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/configuration Namespace.java
Should this be per ConfigurationBuilder rather than per JVM ?
ie move it to instance variable of the Builder/Handler?
On Tue, 30 Oct 2001 03:32, bloritsch@apache.org wrote:
> bloritsch 01/10/29 08:32:50
>
> Modified: src/java/org/apache/avalon/framework/configuration
> Namespace.java
> Log:
> Globally set validation policy used for new Namespace objects.
>
> Revision Changes Path
> 1.3 +30 -6
> jakarta-avalon/src/java/org/apache/avalon/framework/configuration/Namespace
>.java
>
> Index: Namespace.java
> ===================================================================
> RCS file:
> /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration
>/Namespace.java,v retrieving revision 1.2
> retrieving revision 1.3
> diff -u -r1.2 -r1.3
> --- Namespace.java 2001/10/29 14:58:48 1.2
> +++ Namespace.java 2001/10/29 16:32:50 1.3
> @@ -18,24 +18,30 @@
> */
> public final class Namespace implements Serializable
> {
> + private static final boolean VALIDATE_PREFIX = true;
> + private static final boolean IGNORE_PREFIX = false;
> + private static volatile boolean m_policy = VALIDATE_PREFIX;
> +
> private final String m_prefix;
> private final String m_uri;
> + private final boolean m_validate_prefix;
>
> /**
> * Hide constructor so that the default factory methods must be used
> */
> private Namespace()
> {
> - this("", "");
> + this("", "", true);
> }
>
> /**
> * Create a Namespace object with a prefix and uri.
> */
> - private Namespace( final String prefix, final String uri )
> + private Namespace( final String prefix, final String uri, final
> boolean validatePrefix ) {
> this.m_prefix = prefix;
> this.m_uri = uri;
> + this.m_validate_prefix = validatePrefix;
> }
>
> /**
> @@ -71,11 +77,19 @@
> if ( check instanceof Namespace )
> {
> Namespace other = (Namespace) check;
> - isEqual = this.getPrefix().equals( other.getPrefix() );
> +
> + if ( m_validate_prefix )
> + {
> + isEqual = this.getPrefix().equals( other.getPrefix() );
>
> - if (isEqual)
> + if (isEqual)
> + {
> + isEqual = this.getURI().equals( other.getURI() );
> + }
> + }
> + else
> {
> - isEqual = this.getURI().equals( other.getURI() );
> + isEqual = this.getURI().equals( other.getURI() );
> }
> }
> else if ( check instanceof String )
> @@ -185,6 +199,16 @@
> loc = "";
> }
>
> - return new Namespace( pre, loc );
> + return new Namespace( pre, loc, true );
> + }
> +
> + public static final synchronized void setPolicy( final boolean
> prefixValidating ) + {
> + Namespace.m_policy = prefixValidating;
> + }
> +
> + public static final synchronized boolean getPolicy()
> + {
> + return Namespace.m_policy;
> }
> }
--
Cheers,
Pete
"abandon all hope , ye who enter here" - dante, inferno
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit:
jakarta-avalon/src/java/org/apache/avalon/framework/configuration
Namespace.java
Posted by Berin Loritsch <bl...@apache.org>.
Peter Donald wrote:
>
> Should this be per ConfigurationBuilder rather than per JVM ?
>
> ie move it to instance variable of the Builder/Handler?
Probably, add a parameter to the factory?
I think so.
--
"Those who would trade liberty for
temporary security deserve neither"
- Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>