RAT (Release Audit Tool) results

The following document contains the results of RAT (Release Audit Tool).

*****************************************************
Summary
-------
Notes: 2
Binaries: 2
Archives: 2
Standards: 56

Apache Licensed: 22
Generated Documents: 0

JavaDocs are generated and so license header is optional
Generated files do not required license headers

34 Unknown Licenses

*******************************

Archives (+ indicates readable, $ unreadable): 

 + lib/commons-i18n-0.4.jar
 + lib/commons-xmlio-0.1pre.jar
 
*****************************************************
  Files with AL headers will be marked L
  Binary files (which do not require AL headers) will be marked B
  Compressed archives will be marked A
  Notices, licenses etc will be marked N
 !????? build.xml
  A     lib/commons-i18n-0.4.jar
  A     lib/commons-xmlio-0.1pre.jar
  N     LICENSE.txt
  N     NOTICE.txt
  AL    pom.xml
  AL    project.properties
 !????? project.xml
 !????? run_example.bat
 !????? src/config/constraints.xml
 !????? src/config/example.xml
 !????? src/config/exceptions.xml
 !????? src/config/util.xml
  AL    src/examples/org/apache/commons/contract/example/LoginProcessor.java
  AL    src/examples/org/apache/commons/contract/example/SpeedCalculator.java
  AL    src/examples/org/apache/commons/contract/example/TestLogin.java
  AL    src/examples/org/apache/commons/contract/example/TestSpeedCalculator.java
 !????? src/java/org/apache/commons/contract/constraints/ArrayConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/BooleanConstraints.java
  AL    src/java/org/apache/commons/contract/constraints/Castable.java
  AL    src/java/org/apache/commons/contract/constraints/CastException.java
  AL    src/java/org/apache/commons/contract/constraints/Constraints.java
 !????? src/java/org/apache/commons/contract/constraints/DateConstraints.java
  AL    src/java/org/apache/commons/contract/constraints/Evaluatable.java
 !????? src/java/org/apache/commons/contract/constraints/ListConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/LocaleConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/MapConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/NumberConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/StringConstraints.java
  AL    src/java/org/apache/commons/contract/constraints/TreeConstraints.java
 !????? src/java/org/apache/commons/contract/constraints/Unconstrained.java
 !????? src/java/org/apache/commons/contract/constraints/Validatable.java
  AL    src/java/org/apache/commons/contract/constraints/ValidationException.java
  AL    src/java/org/apache/commons/contract/context/VMContext.java
 !????? src/java/org/apache/commons/contract/Context.java
  AL    src/java/org/apache/commons/contract/ContractViolationException.java
 !????? src/java/org/apache/commons/contract/descriptor/Descriptor.java
 !????? src/java/org/apache/commons/contract/descriptor/ParameterDescriptor.java
  AL    src/java/org/apache/commons/contract/descriptor/ProvidedEnvironmentDescriptor.java
 !????? src/java/org/apache/commons/contract/descriptor/RequiredEnvironmentDescriptor.java
 !????? src/java/org/apache/commons/contract/descriptor/ResultDescriptor.java
 !????? src/java/org/apache/commons/contract/descriptor/ResultEntryDescriptor.java
 !????? src/java/org/apache/commons/contract/descriptor/StateDescriptor.java
  AL    src/java/org/apache/commons/contract/EnvironmentConsumer.java
  AL    src/java/org/apache/commons/contract/EnvironmentProvider.java
 !????? src/java/org/apache/commons/contract/Executor.java
 !????? src/java/org/apache/commons/contract/i18n/ParameterBundle.java
 !????? src/java/org/apache/commons/contract/Information.java
 !????? src/java/org/apache/commons/contract/Processor.java
 !????? src/java/org/apache/commons/contract/Result.java
  AL    src/java/org/apache/commons/contract/store/Environment.java
 !????? src/java/org/apache/commons/contract/Store.java
  AL    src/java/org/apache/commons/contract/StoreException.java
  AL    src/java/org/apache/commons/contract/util/InteractiveMainWrapper.java
  AL    src/java/org/apache/commons/contract/util/MainWrapper.java
  B     src/site/resources/images/contract-logo-white.png
  AL    src/site/site.xml
 !????? xdocs/downloads.xml
  B     xdocs/images/contract-logo-white.png
 !????? xdocs/index.xml
 !????? xdocs/navigation.xml
 !????? xdocs/quickstart.xml
 
 *****************************************************
 Printing headers for files without AL header...
 
 
 =======================================================================
 ==build.xml
 =======================================================================
 <?xml version="1.0"?>

<!-- <!DOCTYPE project SYSTEM "project.dtd"> -->

<!-- 
  =======================================================================
    WebDAV projector build file                                          
  ======================================================================= 
-->
<project name="commons-contract" default="jar" basedir=".">

	<!-- Give user a chance to override without editing this file 
  (and without typing -D each time it compiles it) -->
    <property file="build.properties"/>
	<property file=".ant.properties" />

	<property name="debug" value="true" />
	<property name="deprecation" value="true" />
	<property name="optimize" value="true" />

	<property name="version" value="20050525" />
	<property name="name" value="commons-contract" />
	<!-- 
  ===================================================================
  Set the properties related to the source tree
  =================================================================== 
  -->
	<property name="src.dir" value="src" />
	<property name="java.dir" value="${src.dir}/java" />
	<property name="examples.dir" value="${src.dir}/examples" />
	<property name="lib.dir" value="lib" />
	<property name="docs.dir" value="doc" />
	<property name="dist.dir" value="dist" />
	<property name="conf.dir" value="${src.dir}/config" />

	<!-- 
  ===================================================================
  Set the properties for the build area
  =================================================================== 
  -->
	<property name="build.dir" value="build" />
	<property name="build.classes" value="${build.dir}/classes" />
	<property name="build.lib" value="${build.dir}/lib" />
	<property name="build.javadocs" value="${docs.dir}/javadoc" />

	<path id="classpath">
		<pathelement location="${build.classes}" />
		<fileset dir="${lib.dir}" includes="*.jar" />
	</path>
	<!-- 

 =======================================================================
 ==project.xml
 =======================================================================
 <?xml version="1.0"?>
<project>
  <extend>../commons-build/sandbox-project.xml</extend>
  <name>Commons Contract</name>
  <id>commons-contract</id>
  <logo>/images/contract-logo-white.png</logo>
  <url>http://commons.apache.org/sandbox/contract/</url>
  <inceptionYear>2004</inceptionYear>
  <package>org.apache.commons.contract</package>
  <shortDescription>Commons Contract</shortDescription>
  <description>Contract based programming</description>

  <currentVersion>20050525</currentVersion>
  <versions>
  </versions>
  <branches>
  </branches>

  <developers>
    <developer>
      <name>Daniel Florey</name>
      <id>dflorey</id>
      <email>dflorey@apache.org</email>
      <organization>Apache Software Foundation</organization>
      <timezone>+1</timezone>
      <roles>
         <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <name>Oliver Zeigermann</name>
      <id>ozeigermann</id>
      <email>ozeigermann@apache.org</email>
      <organization>Apache Software Foundation</organization>
      <timezone>+1</timezone>
      <roles>
         <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  
  <dependencies>
    <dependency>
      <id>commons-i18n</id>
      <version>20050525</version>
    </dependency>
  </dependencies>

  <build>
    <unitTest>

 =======================================================================
 ==run_example.bat
 =======================================================================
 java -jar build/lib/commons-contract-examples-20050525.jar

 =======================================================================
 ==src/config/constraints.xml
 =======================================================================
 <?xml version="1.0" encoding="UTF-8" ?>
<messages>
	<!-- Verbosed constraints -->
	<!-- Date constraints -->
	<message id="unconstrainedBoolean">
		<locale language="en"> 
			<entry key="text">Boolean values ('true' or 'false') are valid.</entry>
		</locale> 
		<locale language="de"> 
			<entry key="text">Wahrheitswerte (Boolean), also 'true' oder 'false' sind erlaubt.</entry>
		</locale> 
	</message>
	<!-- Date constraints -->
	<message id="unconstrainedDate">
		<locale language="en"> 
			<entry key="text">Date values are valid.</entry>
		</locale> 
		<locale language="de"> 
			<entry key="text">Datumswerte sind erlaubt.</entry>
		</locale> 
	</message>
	<message id="constrainedDateRange">
		<locale language="en"> 
			<entry key="text">Date values between {0} and {1} are valid.</entry>
		</locale> 
		<locale language="de"> 
			<entry key="text">Datumswerte zwischen {0} sind {1} erlaubt.</entry>
		</locale> 
	</message>
	<!-- Array constraints -->
	<message id="unconstrainedArray">
		<locale language="en"> 
			<entry key="text">Array values are valid.</entry>
		</locale> 
		<locale language="de"> 
			<entry key="text">Arraywerte sind erlaubt.</entry>
		</locale> 
	</message>
	<message id="constrainedArray">
		<locale language="en"> 
			<entry key="text">All array values must match the following constraints: {0}</entry>
		</locale> 
		<locale language="de"> 
			<entry key="text">Alle Werte des Arrays müssen folgende Bedingung erfüllen: {0}</entry>
		</locale> 
	</message>
	<!-- List constraints -->
	<message id="unconstrainedList">
		<locale language="en"> 
			<entry key="text">List values are valid.</entry>

 =======================================================================
 ==src/config/example.xml
 =======================================================================
 <?xml version="1.0" encoding="UTF-8" ?>
<messages>
	<!-- Messages for speed calculator example -->
	<message id="computeSpeed/parameter/distance">
		<locale language="en"> 
			<entry key="title">Distance</entry>
			<entry key="text">The distance in meters</entry>
			<entry key="prompt">Enter the distance:</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">Entfernung</entry>
			<entry key="text">Die Entfernung in Metern</entry>
			<entry key="prompt">Bitte geben Sie die Entfernung an:</entry>
		</locale> 
	</message>
	<message id="computeSpeed/parameter/unit">
		<locale language="en"> 
			<entry key="title">Unit</entry>
			<entry key="text">The measuring unit for the time</entry>
			<entry key="prompt">Enter the time unit:</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">MaÃ?einheit</entry>
			<entry key="text">Die Ma�einheit für die Zeitmessung</entry>
			<entry key="prompt">Bitte geben Sie die MaÃ?einheit ein:</entry>
		</locale> 
	</message>
	<message id="computeSpeed/parameter/time">
		<locale language="en"> 
			<entry key="title">Time</entry>
			<entry key="text">The time in the chosen unit</entry>
			<entry key="prompt">Enter the time:</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">Zeit</entry>
			<entry key="text">Die Zeit in der festgelegten MaÃ?einheit</entry>
			<entry key="prompt">Bitte geben Sie die Zeit ein:</entry>
		</locale> 
	</message>

	<!-- Messages for login processor example -->
	<message id="loginProcessor/parameter/username">
		<locale language="en"> 
			<entry key="title">Username</entry>
			<entry key="text">Name of the user to log in</entry>
			<entry key="prompt">Enter the username:</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">Benutzer</entry>
			<entry key="text">Der Name des anzumeldenden Benutzers</entry>

 =======================================================================
 ==src/config/exceptions.xml
 =======================================================================
 <?xml version="1.0" encoding="UTF-8" ?>
<messages>
	<message id="stateNotDefined">
		<locale language="en"> 
			<entry key="title">Undefined return value</entry>
			<entry key="text">Return value {0} undefined.</entry>
			<entry key="summary">Return value {0} undefined.</entry>
			<entry key="details">Return value {0} undefined. Please define this return value in the running process or use one of the defined return values!</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">Undefinierter Rückgabewert</entry>
			<entry key="text">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben.</entry>
			<entry key="summary">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben.</entry>
			<entry key="details">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben. Dieser wurde im laufenden Prozess nicht definiert!</entry>
		</locale>
	</message>
		<message id="processorManager/noProcessorDescriptionAvailable">
		<locale language="de"> 
			<entry key="title">Keine Prozessorbeschreibung verfügbar</entry>
			<entry key="text">Dieser Prozessor verfügt leider über keine Beschreibung.</entry>
		</locale> 
		<locale language="en"> 
			<entry key="title">No processor description available</entry>
			<entry key="text">No description for this processor available</entry>
		</locale> 
	</message>
	<message id="stepNotFound">
		<locale language="de"> 
			<entry key="title">Arbeitsschritt nicht gefunden.</entry>
			<entry key="text">Arbeitsschritt {0} nicht gefunden.</entry>
			<entry key="summary">Arbeitsschritt {0} nicht gefunden.</entry>
			<entry key="details">Arbeitsschritt {0} nicht gefunden.</entry>
		</locale> 
		<locale language="en"> 
			<entry key="title">Step not found</entry>
			<entry key="text">Process step {0} not found</entry>
			<entry key="summary">Process step {0} not found</entry>
			<entry key="details">Process step {0} not found</entry>
		</locale> 
	</message>
	<message id="stateNotDefined">
		<locale language="de"> 
			<entry key="title">Undefinierter Rückgabewert</entry>
			<entry key="text">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben.</entry>
			<entry key="summary">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben.</entry>
			<entry key="details">Es wurde versucht, den Wert {0} als Ergebniszustand zurückzugeben. Dieser wurde im laufenden Prozess nicht definiert!</entry>
		</locale> 
		<locale language="en"> 
			<entry key="title">Undefined return value</entry>
			<entry key="text">Return value {0} undefined.</entry>

 =======================================================================
 ==src/config/util.xml
 =======================================================================
 <?xml version="1.0" encoding="UTF-8" ?>
<messages>
	<message id="usage">
		<locale language="en"> 
			<entry key="title">Usage</entry>
			<entry key="text">The application needs the following parameters:</entry>
		</locale> 
		<locale language="de"> 
			<entry key="title">Benutzung</entry>
			<entry key="text">Die folgenden Parameter werden von der Applikation erwartet:</entry>
		</locale> 
	</message>
</messages>

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/ArrayConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class ArrayConstraints implements Constraints {
    public static final ArrayConstraints UNCONSTRAINED = new ArrayConstraints();

    protected Constraints entryValueDescriptor;

    public ArrayConstraints() {
        entryValueDescriptor = Unconstrained.UNCONSTRAINED;
    }

    public ArrayConstraints(Constraints entryValueDescriptor) {
        this.entryValueDescriptor = entryValueDescriptor;
    }

    public void setEntryValueDescriptor(Constraints entryValueDescriptor) {
        this.entryValueDescriptor = entryValueDescriptor;
    }

    public Constraints getEntryValueDescriptor() {
        return entryValueDescriptor;
    }

    public Object cast(Object value, Context context) throws CastException {
    	Object[] array = null;
    	if ( value instanceof String[] ) {
    		array = new Object[((String[])value).length];
    		for ( int i = 0; i < array.length; i++ ) {
    			array[i] = entryValueDescriptor.cast(((String [])value)[i], context);
    		}
    	} else if ( value instanceof List ) {
        	array = new Object[((List)value).size()];
    		int counter = 0;
    		for ( Iterator i = ((List)value).iterator(); i.hasNext(); ) {
    			Object entry = i.next();
                if ( entry instanceof Evaluatable ) {
                    try {
                        entry = ((Evaluatable)entry).evaluate(context);
                    } catch (Exception e) {
                        throw new CastException(new ErrorBundle("evaluatingAnyFailed"), e);
                    }
                }

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/BooleanConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class BooleanConstraints implements Constraints {
	public final static String TRUE = Boolean.toString(true);
    public final static String FALSE = Boolean.toString(false);

    public Object cast(Object value, Context context) throws CastException {
        if ( value instanceof Boolean) {
            return value;
        } 
        try {
            return Boolean.valueOf(StringConstraints.UNCONSTRAINED.cast(value, null).toString());
        } catch ( CastException exception ) {
            throw new CastException(new ErrorBundle("uncastableBooleanValue", new Object[] { value }));
        }
    }
    
    public void validate(Object value, Context context) throws ValidationException {
    }
    
    public TextBundle verboseConstraints() {
        return new TextBundle("unconstrainedBoolean");
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/DateConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class DateConstraints implements Constraints {
    public static final DateConstraints UNCONSTRAINED = new DateConstraints();

    protected boolean constrained;
    protected List allowedValues = new ArrayList();
    protected Date earliest, latest;
    protected String formatPattern;

    public DateConstraints() {
        this.constrained = false;
    }

    public DateConstraints(String formatPattern) {
        this.constrained = false;
        this.formatPattern = formatPattern;
    }

    public DateConstraints(Date earliest, Date latest) {
        constrained = true;
        this.earliest = earliest;
        this.latest = latest;
    }

    public boolean isConstrained() {
        return constrained;
    }

    public void setEarliest(Date earliest) {
        this.earliest = earliest;
    }

    public void setLatest(Date latest) {
        this.latest = latest;
    }

    public void setFormatPattern(String dateFormat) {
        this.formatPattern = dateFormat;

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/ListConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class ListConstraints implements Constraints {
	protected Constraints entryValueDescriptor;

    public ListConstraints() {
        entryValueDescriptor = Unconstrained.UNCONSTRAINED;
    }

    public ListConstraints(Constraints entryValueDescriptor) {
        this.entryValueDescriptor = entryValueDescriptor;
    }

    public void setEntryValueDescriptor(Constraints entryValueDescriptor) {
        this.entryValueDescriptor = entryValueDescriptor;
    }

    public Constraints getEntryValueDescriptor() {
        return entryValueDescriptor;
    }

    public Object cast(Object value, Context context) throws CastException {
    	List list = new ArrayList();
    	if ( value instanceof String[] ) {
    		for ( int i = 0; i < ((String[])value).length; i++ ) {
    			list.add(entryValueDescriptor.cast(((String [])value)[i], context));
    		}
    	} else if ( value instanceof List ) {
    		for ( Iterator i = ((List)value).iterator(); i.hasNext(); ) {
    			Object entry = i.next();
                if ( entry instanceof Evaluatable ) {
                    try {
                        entry = ((Evaluatable)entry).evaluate(context);
                    } catch (Exception e) {
                        throw new CastException(new ErrorBundle("evaluatingAnyFailed"), e);
                    }
                }
    			list.add(entryValueDescriptor.cast(entry, context));
    		}
        } else if ( value instanceof Object[] ) {
    		for ( int i = 0; i < ((Object [])value).length; i++ ) {

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/LocaleConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.util.Locale;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class LocaleConstraints implements Constraints {
	public static final LocaleConstraints UNCONSTRAINED = new LocaleConstraints();

    public void validate(Object value, Context context) throws ValidationException {
	}
	
	public Object cast(Object value, Context context) throws CastException {
		if ( value instanceof Locale) {
            return (Locale)value;
		} 
		try {
			return new Locale(StringConstraints.UNCONSTRAINED.cast(value, null).toString());
		} catch ( CastException exception ) {
			throw new CastException(new ErrorBundle("uncastableLocale", new Object[] { value }));
		}
	}
    
    public TextBundle verboseConstraints() {
        return new TextBundle("unconstrainedLocale");
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/MapConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.contract.Context;
import org.apache.commons.contract.descriptor.ParameterDescriptor;
import org.apache.commons.contract.i18n.ParameterBundle;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class MapConstraints implements Constraints {
    public final static MapConstraints UNCONSTRAINED = new MapConstraints(new ParameterDescriptor(MapConstraints.ALL, new ParameterBundle("mapEntry/any"), Unconstrained.UNCONSTRAINED)); 
    public final static String ALL = "*";
	
	protected List entryConstraints = new ArrayList();

	public MapConstraints() {
	}
	
    public MapConstraints(List entryDescriptors) {
        this.entryConstraints = entryDescriptors;
    }

    public MapConstraints(ParameterDescriptor parameterDescriptor) {
    	entryConstraints.add(parameterDescriptor);
    }

    public MapConstraints(ParameterDescriptor[] parameterDescriptors) {
        for ( int i = 0; i < parameterDescriptors.length; i++ ) {
            entryConstraints.add(parameterDescriptors[i]);
        }
    }

    public void addEntryDescriptor(ParameterDescriptor parameterDescriptor) {
        entryConstraints.add(parameterDescriptor);
    }

    public List getEntryDescriptors() {
    	return entryConstraints;
    }
    
    public Object cast(Object value, Context context) throws CastException {
        if ( entryConstraints.isEmpty() ) {
        	throw new CastException(new ErrorBundle("noMapEntryDescriptorsFound"));
        }
        if ( value instanceof Map ) {

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/NumberConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class NumberConstraints implements Constraints {
    public final static NumberConstraints UNCONSTRAINED = new NumberConstraints();
    public final static NumberConstraints POSITIVE = new NumberConstraints(new Integer(0), null, false);
    public final static NumberConstraints NEGATIVE = new NumberConstraints(null, new Integer(0), false);
    
	protected boolean constrained, inclusive;
    protected List allowedValues = new ArrayList();
    protected Number minimum, maximum;
    
    public NumberConstraints() {
        this.constrained = false;
    }

    public NumberConstraints(Number minimum, Number maximum) {
        this(minimum, maximum, true);
    }

    public NumberConstraints(Number minimum, Number maximum, boolean inclusive) {
        constrained = true;
        this.minimum = minimum;
        this.maximum = maximum;
        this.inclusive = inclusive;
    }

    public NumberConstraints(Number[] allowedValues) {
        this.constrained = true;
        this.allowedValues = new ArrayList(Arrays.asList(allowedValues));
    }

    public boolean isConstrained() {
        return constrained;
    }

    public void addAllowedValue(Number value) {
        allowedValues.add(value);
    }

    public Number[] getAllowedValues() {

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/StringConstraints.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class StringConstraints implements Constraints, Castable {
    public final static StringConstraints UNCONSTRAINED = new StringConstraints();
    public final static StringConstraints EMPTY = new StringConstraints(0);
    public final static StringConstraints NOT_EMPTY = new StringConstraints(1,Integer.MAX_VALUE);
    
    protected boolean constrained;
    protected List allowedValues = new ArrayList();
    protected int minimumLength = -1, maximumLength =-1;
    protected Object defaultValue;

    public StringConstraints() {
        this.constrained = false;
    }

    public StringConstraints(String[] allowedValues) {
        this.constrained = true;
        this.allowedValues = new ArrayList(Arrays.asList(allowedValues));
    }

    public StringConstraints(int maximumLength) {
        this.maximumLength = maximumLength;
        this.constrained = true;
    }

    public StringConstraints(int minimumLength, int maximumLength) {
        this.minimumLength = minimumLength;
        this.maximumLength = maximumLength;
        this.constrained = true;
    }

    public int getMinimumLength() {
        return minimumLength;
    }

    public void setMinimumLength(int minimumLength) {
        this.minimumLength = minimumLength;
        constrained = true;
    }


 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/Unconstrained.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import org.apache.commons.contract.Context;
import org.apache.commons.i18n.bundles.ErrorBundle;
import org.apache.commons.i18n.bundles.TextBundle;

public class Unconstrained implements Constraints {
    public final static Unconstrained UNCONSTRAINED = new Unconstrained();

    private Class clazz;
    
    public Unconstrained() {
        this.clazz = null;
    }
    
    public Unconstrained(Class clazz) {
        this.clazz = clazz;
    }
    
    public Object cast(Object value, Context context) throws CastException {
        return value;
    }
    
    public void validate(Object value, Context context) throws ValidationException {
        if ( clazz != null && !clazz.isInstance(value) ) {
            throw new ValidationException(new ErrorBundle("invalidObjectType", new Object[] { clazz, value }));
        }
    }
    
    public TextBundle verboseConstraints() {
        if ( clazz == null ) {
            return new TextBundle("unconstrained");
        } else {
            return new TextBundle("constrainedUnconstrained");
        }
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/constraints/Validatable.java
 =======================================================================
 package org.apache.commons.contract.constraints;

import org.apache.commons.contract.Context;

public interface Validatable {
    public void validate(Object value, Context context) throws ValidationException;
}

 =======================================================================
 ==src/java/org/apache/commons/contract/Context.java
 =======================================================================
 package org.apache.commons.contract;

import java.util.List;

public interface Context {
    public Store getStore(String id);

    void addInformation(Information information);

    public List getInformations();

}

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/Descriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

import org.apache.commons.i18n.bundles.MessageBundle;

public class Descriptor {
    protected String name;
    protected MessageBundle description;

    public Descriptor(String name, MessageBundle description) {
        this.name = name;
        this.description = description;
    }

    public String getName() {
        return name;
    }

    public MessageBundle getDescription() {
        return description;
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/ParameterDescriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

import org.apache.commons.contract.constraints.Constraints;
import org.apache.commons.contract.i18n.ParameterBundle;

public class ParameterDescriptor extends Descriptor {
	public final static ParameterDescriptor[] NO_PARAMETERS = new ParameterDescriptor[0];
	
    protected Constraints constraints;
    protected Object defaultValue;
    protected boolean required;

    public ParameterDescriptor(String name, ParameterBundle description, Constraints valueDescriptor) {
        super(name, description);
        this.constraints = valueDescriptor;
        this.required = true;
    }

    public ParameterDescriptor(String name, ParameterBundle description, Constraints valueDescriptor, Object defaultValue) {
        super(name, description);
        this.constraints = valueDescriptor;
        this.defaultValue  = defaultValue;
        this.required = false;
    }

    public boolean isRequired() {
        return required;
    }

    public void setConstraints(Constraints valueDescriptor) {
        this.constraints = valueDescriptor;
    }

    public Constraints getConstraints() {
        return constraints;
    }

    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
        this.required = true;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }
    
    public boolean equals(Object o) {
    	if ( o instanceof ParameterDescriptor && ((ParameterDescriptor)o).getName().equals(getName())) return true;
    	return false;
    }

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/RequiredEnvironmentDescriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

import org.apache.commons.contract.constraints.Constraints;
import org.apache.commons.contract.i18n.ParameterBundle;

public class RequiredEnvironmentDescriptor extends ParameterDescriptor {
    protected String store;

    public RequiredEnvironmentDescriptor(String name, String store, ParameterBundle description, Constraints valueDescriptor) {
        super(name, description, valueDescriptor);
        this.store = store;
    }

    public RequiredEnvironmentDescriptor(String name, String store, ParameterBundle description, Constraints valueDescriptor, Object defaultValue) {
        super(name, description, valueDescriptor, defaultValue);
        this.store = store;
    }

    public String getStore() {
        return store;
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/ResultDescriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

public class ResultDescriptor {
	public final static ResultDescriptor OK = new ResultDescriptor(StateDescriptor.OK_DESCRIPTOR); 
		
	protected StateDescriptor stateDescriptor;
    protected ResultEntryDescriptor[] resultEntryDescriptors;

    public ResultDescriptor(StateDescriptor stateDescriptor, ResultEntryDescriptor[] resultEntryDescriptors) {
        this.stateDescriptor = stateDescriptor;
        this.resultEntryDescriptors = resultEntryDescriptors;
    }

    public ResultDescriptor(StateDescriptor stateDescriptor) {
        this.stateDescriptor = stateDescriptor;
        this.resultEntryDescriptors = new ResultEntryDescriptor[0];
    }

    public StateDescriptor getStateDescriptor() {
        return stateDescriptor;
    }

    public ResultEntryDescriptor[] getResultEntryDescriptors() {
        return resultEntryDescriptors;
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/ResultEntryDescriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

import org.apache.commons.contract.constraints.Constraints;
import org.apache.commons.i18n.bundles.MessageBundle;

public class ResultEntryDescriptor extends Descriptor {
    protected Constraints constraints;

    public ResultEntryDescriptor(String name, MessageBundle description, Constraints constraints) {
        super(name, description);
        this.constraints = constraints;
    }

    public Constraints getConstraints() {
        return constraints;
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/descriptor/StateDescriptor.java
 =======================================================================
 package org.apache.commons.contract.descriptor;

import org.apache.commons.i18n.bundles.MessageBundle;

public class StateDescriptor extends Descriptor {
	public final static String OK = "ok";
	public final static StateDescriptor OK_DESCRIPTOR = new StateDescriptor(OK, new MessageBundle("state/ok"));

	public StateDescriptor(String state, MessageBundle description) {
		super(state, description);
	}

	public String getState() {
		return getName();
	}
}

 =======================================================================
 ==src/java/org/apache/commons/contract/Executor.java
 =======================================================================
 package org.apache.commons.contract;

import java.util.Map;

import org.apache.commons.contract.constraints.Constraints;
import org.apache.commons.contract.constraints.ValidationException;
import org.apache.commons.contract.descriptor.ParameterDescriptor;
import org.apache.commons.contract.descriptor.RequiredEnvironmentDescriptor;
import org.apache.commons.contract.descriptor.ResultDescriptor;
import org.apache.commons.contract.descriptor.ResultEntryDescriptor;
import org.apache.commons.i18n.XMLMessageProvider;
import org.apache.commons.i18n.bundles.ErrorBundle;

public class Executor {
    static {
        // FIXME - install() method has been removed
        //XMLMessageProvider.install("contract/exceptions", Thread.currentThread().getContextClassLoader().getResourceAsStream("exceptions.xml"));
        //XMLMessageProvider.install("contract/constraints", Thread.currentThread().getContextClassLoader().getResourceAsStream("constraints.xml"));
    }
    
    public static void init() {};
    
    public static Result process(Processor processor, Map parameters, Context context) throws Exception {
    	prepareValues(processor.getParameterDescriptors(), parameters, context);
        if ( processor instanceof EnvironmentConsumer ) {
            checkRequirements((EnvironmentConsumer)processor, context);
        }
    	Result result = processor.process(parameters, context);
        validateResult(processor.getResultDescriptors(), result, context);
        return result;
    }
    
    public static void prepareValues(ParameterDescriptor[] parameterDescriptors, Map parameters, Context context) throws ContractViolationException {
    	for ( int i = 0; i < parameterDescriptors.length; i++ ) {
    		String parameterName = parameterDescriptors[i].getName();
    		Object parameterValue = parameters.get(parameterName);
    		Object preparedValue = prepareValue(parameterDescriptors[i], parameterValue, context);
    		parameters.put(parameterName, preparedValue);
    	}
    }
    
    public static Object prepareValue(ParameterDescriptor parameterDescriptor, Object value, Context context) throws ContractViolationException {
    	Object preparedValue;
    	if ( value == null ) {
            if ( parameterDescriptor.isRequired() ) {
                throw new ContractViolationException(new ErrorBundle("requiredParameterMissing", new String[] { parameterDescriptor.getName() }));
            } else {
                preparedValue = parameterDescriptor.getDefaultValue();
            }
    	} else {

 =======================================================================
 ==src/java/org/apache/commons/contract/i18n/ParameterBundle.java
 =======================================================================
 package org.apache.commons.contract.i18n;

import java.util.Locale;

import org.apache.commons.i18n.bundles.MessageBundle;

public class ParameterBundle extends MessageBundle {
    private final static String PROMPT = "prompt";
    private final static String NO_MESSAGE_AVAILABLE = "noMessageAvailable";

    public ParameterBundle() {
        super(NO_MESSAGE_AVAILABLE);
    }

    public ParameterBundle(String messageId) {
        super(messageId);
    }

    public ParameterBundle(String messageId, Object[] arguments) {
        super(messageId, arguments);
    }

    public String getPrompt(Locale locale) {
        return getEntry(PROMPT, locale);
    }

    public String getPrompt(Locale locale, String defaultPrompt) {
        return getEntry(PROMPT, locale, defaultPrompt);
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/Information.java
 =======================================================================
 package org.apache.commons.contract;

import org.apache.commons.i18n.bundles.ErrorBundle;

/**
 * @version $Revision: 155440 $
 */

public class Information {
    public final static int DEBUG = 0;
    public final static int INFO = 1;
    public final static int WARNING = 2;
    public final static int ERROR = 3;

    private int severity, number;
    private ErrorBundle errorMessage;
    private String[] involvedParameters;

    public Information(int severity, ErrorBundle errorMessage, String[] involvedParameters) {
        this.severity = severity;
        this.errorMessage = errorMessage;
        this.involvedParameters = involvedParameters;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public int getNumber() {
        return number;
    }

    public int getSeverity() {
        return severity;
    }

    public ErrorBundle getErrorBundle() {
        return errorMessage;
    }

    public String[] getInvolvedParameters() {
        return involvedParameters;
    }

    public boolean isParameterInvolved(String paramterName) {
        for ( int i = 0; i < involvedParameters.length; i++ ) {
            if ( involvedParameters[i].equals(paramterName) ) return true;
        }
        return false;
    }

 =======================================================================
 ==src/java/org/apache/commons/contract/Processor.java
 =======================================================================
 package org.apache.commons.contract;

import java.util.Map;

import org.apache.commons.contract.descriptor.ParameterDescriptor;
import org.apache.commons.contract.descriptor.ResultDescriptor;

public interface Processor {
    /**
     * Implement this method to provide the logic of the processor
     * 
     * @param parameter a map containing the parameters for this process call.
     *                  
     * @return result
     * @throws Exception 
     */
    public Result process(Map parameter, Context context) throws Exception;

    // The following methods describe the behaviour of the processor
    // The parameters needed
    public ParameterDescriptor[] getParameterDescriptors();

    // The states/results that this renderer generates
    public ResultDescriptor[] getResultDescriptors();
}

 =======================================================================
 ==src/java/org/apache/commons/contract/Result.java
 =======================================================================
 package org.apache.commons.contract;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.contract.descriptor.StateDescriptor;

public class Result {
    public final static Result OK = new Result(StateDescriptor.OK);

    protected String state;
    protected Map resultEntries;

    public Result(String state) {
        this.state = state;
        resultEntries = new HashMap();
    }

    public Result(String state, String key, Object value) {
        this(state);
        addResultEntry(key, value);
    }

    public Result(String state, Map resultEntries) {
        this.state = state;
        this.resultEntries = resultEntries;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public Map getResultEntries() {
        return resultEntries;
    }

    public void addResultEntry(String key, Object value) {
        resultEntries.put(key, value);
    }
}

 =======================================================================
 ==src/java/org/apache/commons/contract/Store.java
 =======================================================================
 package org.apache.commons.contract;

public interface Store {
    String getId();
    
    void put(String key, Object value, Context context) throws StoreException;

    Object get(String key, Context context) throws StoreException;

    void dispose(String key, Context context) throws StoreException;
}

 =======================================================================
 ==xdocs/downloads.xml
 =======================================================================
 <?xml version="1.0"?>
<document>
   <properties>
      <title>Downloads</title>
      <author email="dev@commons.apache.org">Commons Documentation Team</author>
      <revision>$Id: downloads.xml 561366 2007-07-31 15:58:29Z rahul $</revision>
   </properties>

   <body>
      <section name="Releases">
         <p>There are no releases available.</p>

<!--
         <p>The following releases are available:</p>
         <ul>
           <li>Version 1.1 - 20 October 2003</li>
           <li>Version 1.0 - 12 August 2002</li>
         </ul>
         <br/>
         <p>
            The latest binary release is always available on the 
            <a href="http://jakarta.apache.org/site/binindex.cgi#commons-transaction">
            Jakarta Binary Downloads page</a>,
            its source is available from 
            <a href="http://jakarta.apache.org/site/sourceindex.cgi#commons-transaction">
            Jakarta Source Downloads page</a>.
         </p>
         <p>
            Older releases are retained by the Apache Software Foundation but are 
            moved into a
            <a href="http://archive.apache.org/dist/jakarta/commons/transaction/">
            special archive area</a>.
         </p>
         <p>
           <a href="http://cvs.apache.org/builds/jakarta-commons/nightly/commons-transaction/">
           Nightly source and binary drops</a> are available.
         </p>
-->
         <p>
            Access to the source tree to see the latest and greatest code is possible
            through <a href="cvs-usage.html">anonymous SVN access</a>.
         </p>
      </section>

<!--
      <section name="Release Candidate">
         <p>
            Release candidates for the upcoming 1.1 release can be downloaded 
            <a href="http://cvs.apache.org/~dirkv/builds/">here</a>.
         </p>

 =======================================================================
 ==xdocs/index.xml
 =======================================================================
 <?xml version="1.0"?>

<document>

 <properties>
  <title>Overview</title>
  <author email="dev@commons.apache.org">Commons Documentation Team</author>
 </properties>

 <body>

<section name="The Contract Component">
<p>
The contract component delivers the contract based programming core that is currently used
in the Slide Projector project.
</p>
<p>
This component makes all the nice features available to the java programming language that
come along with contract based programming. To get started go <a href="quickstart.html">here</a>.
</p>
</section>

<section name="Releases">
    <p>
       See the <a href="downloads.html">downloads</a> page for information on obtaining releases.
    </p>
</section>

<section name="Documentation">
  <p>
     The <a href="apidocs/index.html">JavaDoc API documents</a> are available online.
  </p>
</section>

</body>
</document>

 =======================================================================
 ==xdocs/navigation.xml
 =======================================================================
 <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE org.apache.commons.menus SYSTEM '../../commons-build/menus/menus.dtd'>
<project name="Commons&#xA0;Contract">
    <title>Commons&#xA0;Contrac</title>
    <body>
        <menu name="Commons&#xA0;Contract">
            <item name="Overview" href="/index.html" />
            <item name="Getting started" href="/quickstart.html" />	
            <item name="Downloads"                     href="/downloads.html"/>
        </menu>
        &common-menus;
    </body>
</project>

 =======================================================================
 ==xdocs/quickstart.xml
 =======================================================================
 <?xml version="1.0"?>

<document>

 <properties>
  <title>Getting started</title>
  <author email="dev@commons.apache.org">Commons Documentation Team</author>
 </properties>

 <body>

<section name="Getting started">
<p>In order to get an impression of how this component works, we will start with an
	example showing the capabilities of this package.</p>
<p>To get started you need at least the jar of this component and the dependent i18n.jar in your classpath.</p>
</section>
<section name="What is contract based programming?">
<p>You already know contract based programming if you've ever implemented a java method: You specify
a contract that defines which types of parameters are accepted by your method and you specify the 
type of tbe return value. This is how a method might look like that calcalutes speed:</p>
<source>
	public float calculateSpeed(float distance, float time, String timeUnit) {
		float speed;
        if (timeUnit.equals("s")) speed = distance / time;
        else if (timeUnit.equals("min")) speed = distance*60 / time;
        else speed = distance*3600 / time;
		return speed;
	}
</source>
<p>So your method will accept two floats that pass the distance and the time to the method. Additionally
	the method requires the unit in which the time was measured. You can tell this by using the appropriated
	types, that reflect the desired values.</p>
<p>This example is incomplete, as no error handling is done. What happens if the method will be called
	with time=0? What if the user enters an invalid unit? As this part is not much fun, many programmers
	don't care much about handling errors in an appropriate way and by doing so cause much pain.</p>
<p>In the java world, you cannot declare which value ranges are valid for the parameters of your method.
	You might only accept values larger than zero for the time and only "s", "min" and "h" for the
	measuring unit.</p>
	<p>Imagine that you want to provide a simple program, that allows the user to enter
	these three parameters and you want to provide the calculated speed. To calculate the speed is
	the very easy task, but as you might already know it is a lot more work to handle all possible errors,
	to display the user in a localized way which values are accepted and so on.</p>
</section>
<section name="The speed calculator example">
	<p>This is the moment where the contract component comes into play! You have to declare the possible
		values that are accepted by your method and the result that will be provided. This additional effort 
		will be donated by handling all the rest. Let's have a look at the sources of the SpeedCalculator that
		is provided as an example in the sources of this component:</p>
		<source>
public class SpeedCalculator implements Processor {