commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject cvs commit: jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql StorageBeanBase.java
Date Thu, 02 Jan 2003 19:45:26 GMT
husted      2003/01/02 11:45:26

  Modified:    scaffold/src/java/org/apache/commons/scaffold/sql
                        StorageBeanBase.java
  Log:
  + Tweaks.
  
  Revision  Changes    Path
  1.17      +50 -17    jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java
  
  Index: StorageBeanBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StorageBeanBase.java	23 Nov 2002 19:06:11 -0000	1.16
  +++ StorageBeanBase.java	2 Jan 2003 19:45:26 -0000	1.17
  @@ -108,13 +108,19 @@
   
   
       /**
  -     * Convenience method to check for null, empty String,
  -     * or "0" String.
  +     * Convenience method to check for null, empty String.
        */
       protected boolean blank(String s) {
           return ConvertUtils.blank(s);
       }
   
  +    /**
  +     * Convenience method to check for null, empty String,
  +     * or "0" String.
  +     */
  +    protected boolean blankValue(String s) {
  +        return ConvertUtils.blankValue(s);
  +    }
   
       /**
        * Returns true if null or zero.
  @@ -156,7 +162,8 @@
       protected String lookup(String key)
           throws PropertiesException {
   
  -        if (null==commands) throw new PropertiesException();
  +        if (null==commands) throw new PropertiesException(
  +            PropertiesException.MESSAGE + key);
   
           String command = null;
           String prefix = getPrefix();
  @@ -178,7 +185,8 @@
       protected String lookupRoot(String key)
           throws PropertiesException {
   
  -        if (null==commands) throw new PropertiesException();
  +        if (null==commands) throw new PropertiesException(
  +            PropertiesException.MESSAGE + key);
   
           return commands.getProperty(key);
   
  @@ -306,10 +314,11 @@
           String paramToken = command + PARAMS;        
           String params = lookup(paramToken);
   
  -        // :HMMM: On null, silently return an empty list?
  -        if (null==params) return new Object[0];
  +        if (null==params) { 
  +            throw new PropertiesException(
  +                PropertiesException.MESSAGE + paramToken);
  +        } 
           else {
  -
               String[] tokens = ConvertUtils.tokensToArray(params,PARAM_SEP);
               Object[] values = new Object[tokens.length];
               try {
  @@ -318,7 +327,8 @@
                   }
               }
               catch (Exception e) {
  -                throw new PropertiesException();
  +                throw new PropertiesException(
  +                    PropertiesException.MESSAGE + params);
               }
               
               return values;
  @@ -391,8 +401,11 @@
           // Lookup parameters for command ( * + .params)        
           String paramToken = command + PARAMS;        
           String params = lookup(paramToken);
  -        // :HMMM: On null, silently return an empty list?
  -        if (null!=params) {           
  +        if (null==params) {
  +            throw new PropertiesException(
  +                PropertiesException.MESSAGE + paramToken);
  +        }
  +        else {           
               // Tokenize into list/iterator (:TODO: Cache?) (:FIXME: List better than array?)
               Iterator tokens = ConvertUtils.tokensToList(params,PARAM_SEP).iterator();
               // Get the runtime property for each parameter (token)
  @@ -402,7 +415,8 @@
                   }
               }
               catch (Exception e) {
  -                throw new PropertiesException();
  +                throw new PropertiesException(
  +                    PropertiesException.MESSAGE + params);
               }
           }
          return values;
  @@ -468,7 +482,7 @@
           try {
   
                int result = StatementUtils.executeUpdate(
  -                 null,lookup(command));
  +                 null,lookup(command),getParameters(command));
   
           }
           catch (SQLException e) {
  @@ -761,6 +775,11 @@
   // --------------------------------------------------------------------- store
   
   
  +    /**
  +     * If timestamp is null (or ConvertUtils.NULL_TIMESTAMP), 
  +     * set our modified property to the current time. 
  +     * This emulates how MySQL treats the first null Timestamp in a record.
  +     */
      public void fixModified() {   
          Timestamp modified = getModified();
          if ((null==modified) || (ConvertUtils.NULL_TIMESTAMP==modified)) {
  @@ -807,7 +826,7 @@
       }
   
   
  -    public Object elementResult(String command) throws Exception {
  +    public ProcessResult elementResult(String command) throws Exception {
   
           boolean found = false;
           try {
  @@ -836,7 +855,14 @@
       }
   
   
  -        // see interface for Javadoc
  +    /**
  +     * Retrieve an element (record) from storage.
  +     * The element is retrieved is determined by what command 
  +     * has been set to the parameter property.
  +     * <P>
  +     * This signature is designed for compatibilty with
  +     * the Executable interface.
  +     */
       public Object element(Object command) throws Exception {
   
           populate((Map) command);
  @@ -867,7 +893,14 @@
       }
   
           
  -        // see interface for Javadoc
  +    /**
  +     * Retrieve a collection of objects from storage.
  +     * The objects retrieved is determined by what command 
  +     * has been set to the parameter property.
  +     * <P>
  +     * This signature is designed for compatibilty with
  +     * the Executable interface.
  +     */
       public Object collection(Object parameters) throws Exception {
   
           populate((Map) parameters);
  @@ -893,7 +926,7 @@
           // See interface for JavaDoc
       public boolean isNew() {
           Object key = getStorageKey();
  -        return ((null==key) || (blank(key.toString())));
  +        return ((null==key) || (blankValue(key.toString())));
       }
   
   
  
  
  

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


Mime
View raw message