commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dflo...@apache.org
Subject cvs commit: jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/context VMContext.java
Date Tue, 07 Dec 2004 20:52:18 GMT
dflorey     2004/12/07 12:52:18

  Modified:    contract/lib commons-i18n-0.2.jar
               contract project.xml
               contract/src/java/org/apache/commons/contract/util
                        InteractiveMainWrapper.java MainWrapper.java
               contract/src/java/org/apache/commons/contract Context.java
                        Executor.java Processor.java
               contract/src/java/org/apache/commons/contract/i18n
                        ParameterMessage.java
               contract/src/java/org/apache/commons/contract/context
                        VMContext.java
  Added:       contract run_example.bat
               contract/src/java/org/apache/commons/contract
                        Information.java
  Log:
  Added information class
  
  Revision  Changes    Path
  1.3       +47 -49    jakarta-commons-sandbox/contract/lib/commons-i18n-0.2.jar
  
  	<<Binary file>>
  
  
  1.5       +1 -1      jakarta-commons-sandbox/contract/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/project.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- project.xml	3 Nov 2004 12:21:16 -0000	1.4
  +++ project.xml	7 Dec 2004 20:52:17 -0000	1.5
  @@ -8,7 +8,7 @@
     <inceptionYear>2004</inceptionYear>
     <package>org.apache.commons.contract</package>
     <shortDescription>Commons Contract</shortDescription>
  -  <description>Contract based programming core</description>
  +  <description>Contract based programming</description>
   
     <currentVersion>0.2</currentVersion>
     <versions>
  
  
  
  1.1                  jakarta-commons-sandbox/contract/run_example.bat
  
  Index: run_example.bat
  ===================================================================
  java -jar build/lib/commons-contract-example-0.2.jar
  
  
  1.2       +2 -0      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/util/InteractiveMainWrapper.java
  
  Index: InteractiveMainWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/util/InteractiveMainWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InteractiveMainWrapper.java	8 Oct 2004 09:36:20 -0000	1.1
  +++ InteractiveMainWrapper.java	7 Dec 2004 20:52:17 -0000	1.2
  @@ -65,6 +65,8 @@
               printException(exception);
               System.out.println();
               printUsage(processor);
  +        } catch ( Exception exception ) {
  +            exception.printStackTrace();
           }
           return null;
       }
  
  
  
  1.3       +2 -0      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/util/MainWrapper.java
  
  Index: MainWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/util/MainWrapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MainWrapper.java	15 Oct 2004 17:15:37 -0000	1.2
  +++ MainWrapper.java	7 Dec 2004 20:52:18 -0000	1.3
  @@ -66,6 +66,8 @@
               System.out.println();
               System.out.println();
               printUsage(processor);
  +        } catch ( Exception exception ) {
  +            exception.printStackTrace();
           }
           return null;
       }
  
  
  
  1.2       +6 -0      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Context.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Context.java	8 Oct 2004 09:36:20 -0000	1.1
  +++ Context.java	7 Dec 2004 20:52:18 -0000	1.2
  @@ -1,6 +1,12 @@
   package org.apache.commons.contract;
   
  +import java.util.List;
   
   public interface Context {
       public Store getStore(String id);
  +
  +    void addInformation(Information information);
  +
  +    public List getInformations();
  +
   }
  
  
  
  1.3       +1 -1      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Executor.java
  
  Index: Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Executor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Executor.java	15 Oct 2004 17:15:37 -0000	1.2
  +++ Executor.java	7 Dec 2004 20:52:18 -0000	1.3
  @@ -19,7 +19,7 @@
       
       public static void init() {};
       
  -    public static Result process(Processor processor, Map parameters, Context context)
throws ContractViolationException {
  +    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);
  
  
  
  1.2       +1 -1      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Processor.java
  
  Index: Processor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Processor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Processor.java	8 Oct 2004 09:36:20 -0000	1.1
  +++ Processor.java	7 Dec 2004 20:52:18 -0000	1.2
  @@ -14,7 +14,7 @@
        * @return result
        * @throws Exception 
        */
  -    public Result process(Map parameter, Context context);
  +    public Result process(Map parameter, Context context) throws Exception;
   
       // The following methods describe the behaviour of the processor
       // The parameters needed
  
  
  
  1.1                  jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/Information.java
  
  Index: Information.java
  ===================================================================
  package org.apache.commons.contract;
  
  import org.apache.commons.i18n.LocalizedError;
  
  /**
   * @version $Revision: 1.1 $
   */
  
  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 LocalizedError errorMessage;
      private String[] involvedParameters;
  
      public Information(int severity, LocalizedError 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 LocalizedError getLocalizedError() {
          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;
      }
  }
  
  
  1.2       +5 -0      jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/i18n/ParameterMessage.java
  
  Index: ParameterMessage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/i18n/ParameterMessage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParameterMessage.java	8 Oct 2004 09:36:20 -0000	1.1
  +++ ParameterMessage.java	7 Dec 2004 20:52:18 -0000	1.2
  @@ -6,6 +6,11 @@
   
   public class ParameterMessage extends LocalizedMessage {
       private final static String PROMPT = "prompt";
  +    private final static String NO_MESSAGE_AVAILABLE = "noMessageAvailable";
  +
  +    public ParameterMessage() {
  +        super(NO_MESSAGE_AVAILABLE);
  +    }
   
       public ParameterMessage(String messageId) {
           super(messageId);
  
  
  
  1.2       +18 -0     jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/context/VMContext.java
  
  Index: VMContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/contract/src/java/org/apache/commons/contract/context/VMContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VMContext.java	8 Oct 2004 09:36:20 -0000	1.1
  +++ VMContext.java	7 Dec 2004 20:52:18 -0000	1.2
  @@ -19,17 +19,35 @@
   */
   package org.apache.commons.contract.context;
   
  +import java.util.ArrayList;
  +import java.util.List;
  +
   import org.apache.commons.contract.Context;
  +import org.apache.commons.contract.Information;
   import org.apache.commons.contract.Store;
   import org.apache.commons.contract.store.Environment;
   
   public class VMContext implements Context {
       private Environment environment = new Environment();
  +    private List informations = new ArrayList();
  +    private int informationNumber = 0;
       
       public Store getStore(String id) {
           if ( id.equals(Environment.ID) ) {
               return environment;
           }
           return null;
  +    }
  +
  +    public void addInformation(Information info) {
  +        if ( !informations.contains(info) ) {
  +            informationNumber++;
  +            info.setNumber(informationNumber);
  +            informations.add(info);
  +        }
  +    }
  +
  +    public List getInformations() {
  +        return informations;
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message