You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Leandro Saad <le...@ibnetwork.com.br> on 2001/07/24 19:32:58 UTC
[PATCH] for o.a.t.om.ComboKey/NumberKey
I encoutered some errors when I tried to use this constructor
o.a.t.om.ComboKey(String keys) and compare 2 different SimpleKeys
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/Attic/ComboKey.java,v
retrieving revision 1.10.10.1
diff -r1.10.10.1 ComboKey.java
187c187
< while ( indexOfSep != -1 )
---
> while ( indexOfSep != -1 )
190a191
> // key = ":X"
194a196
> // key = "X:Y"
199a202
> // key = "X:"
202c205,206
< indexOfSep = keys.indexOf(SEPARATOR);
---
> previousIndex = indexOfSep + 1;
> indexOfSep = keys.indexOf(SEPARATOR,previousIndex);
203a208,212
> if(previousIndex > 0 && tmpKeys.size() > 0)
> {
> // there is one more key do be added A:B:C ( C key)
> tmpKeys.add( keys.substring(previousIndex, keys.length()) );
> }
207,208d215
< throw new TurbineException(errMsg);
< /*
212c219,221
< this.key[i] = new SimpleKey( (String)tmpKeys.get(i) );
---
> StringKey aKey = new StringKey();
> aKey.setValue((String)tmpKeys.get(i));
> this.key[i] = aKey;
214d222
< */
222,223c230,232
< throw new TurbineException(errMsg);
< // this.key[i] = new SimpleKey(
(String)tmpKeys.get(i) );
---
> StringKey key = new StringKey();
> key.setValue((String)tmpKeys.get(i));
> this.key[i] = key;
262,263c271
< SimpleKey[] keys = (SimpleKey[])key;
< for ( int i=0; i<keys.length && isEqual; i++ )
---
> for ( int i=0; i<key.length && isEqual; i++ )
265c273
< isEqual &= keys[i] != null && keys[i].getValue() !=
null;
---
> isEqual &= key[i] != null && key[i].getValue() != null;
306c314
< else if ( keyObj instanceof ComboKey)
---
> else if ( keyObj instanceof ComboKey)
308,314c316,318
< SimpleKey[] obj = (SimpleKey[])
< ((ComboKey)keyObj).getValue();
<
< SimpleKey[] keys1 = (SimpleKey[])key;
< SimpleKey[] keys2 = (SimpleKey[])obj;
< isEqual = keys1.length == keys2.length;
< for ( int i=0; i<keys1.length && isEqual; i++)
---
> SimpleKey[] obj = (SimpleKey[])((ComboKey)keyObj).getValue();
> isEqual = key.length == obj.length;
> for ( int i=0; i<key.length && isEqual; i++)
316c320
< isEqual &= ObjectUtils.equals(keys1[i], keys2[i]);
---
> isEqual = isEqual && ObjectUtils.equals(key[i], obj[i]);
322,325c326,328
< SimpleKey[] keys1 = (SimpleKey[])key;
< SimpleKey[] keys2 = (SimpleKey[])keyObj;
< isEqual = keys1.length == keys2.length;
< for ( int i=0; i<keys1.length && isEqual; i++)
---
> SimpleKey[] obj = (SimpleKey[])keyObj;
> isEqual = key.length == obj.length;
> for ( int i=0; i<key.length && isEqual; i++)
327c330
< isEqual &= ObjectUtils.equals(keys1[i], keys2[i]);
---
> isEqual = isEqual && ObjectUtils.equals(key[i], obj[i]);
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/Attic/NumberKey.java,v
retrieving revision 1.5.4.1
diff -r1.5.4.1 NumberKey.java
156c156
< * keyObj is equal to this NumberKey if keyObj is a NumberKey or
String
---
> * keyObj is equal to this NumberKey if keyObj is a NumberKey or String or StringKey
165c165
< if (keyObj instanceof String)
---
> if (keyObj instanceof String || keyObj instanceof StringKey)
167c167
< isEqual = toString().equals(keyObj);
---
> isEqual = keyObj.toString().equals(toString());
--
Leandro Rodrigo Saad Cruz
InterBusiness tecn. e serv.
Sao Paulo - Brasil
Re: [PATCH] for o.a.t.om.ComboKey/NumberKey
Posted by John McNally <jm...@collab.net>.
Please supply a cvs diff -u, but more importantly
> 212c219,221
> < this.key[i] = new SimpleKey( (String)tmpKeys.get(i) );
> ---
> > StringKey aKey = new StringKey();
> > aKey.setValue((String)tmpKeys.get(i));
> > this.key[i] = aKey;
The line above was commented out and an exception is thrown. The reason
being that it cannot be known in some circumstances whether the key is a
String, Number, or Date and so the value cannot be set. You have
assumed it will be a StringKey which is not always the case.
john mcnally
Leandro Saad wrote:
>
> I encoutered some errors when I tried to use this constructor
> o.a.t.om.ComboKey(String keys) and compare 2 different SimpleKeys
>
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/Attic/ComboKey.java,v
> retrieving revision 1.10.10.1
> diff -r1.10.10.1 ComboKey.java
> 187c187
> < while ( indexOfSep != -1 )
> ---
> > while ( indexOfSep != -1 )
> 190a191
> > // key = ":X"
> 194a196
> > // key = "X:Y"
> 199a202
> > // key = "X:"
> 202c205,206
> < indexOfSep = keys.indexOf(SEPARATOR);
> ---
> > previousIndex = indexOfSep + 1;
> > indexOfSep = keys.indexOf(SEPARATOR,previousIndex);
> 203a208,212
> > if(previousIndex > 0 && tmpKeys.size() > 0)
> > {
> > // there is one more key do be added A:B:C ( C key)
> > tmpKeys.add( keys.substring(previousIndex, keys.length()) );
> > }
> 207,208d215
> < throw new TurbineException(errMsg);
> < /*
> 212c219,221
> < this.key[i] = new SimpleKey( (String)tmpKeys.get(i) );
> ---
> > StringKey aKey = new StringKey();
> > aKey.setValue((String)tmpKeys.get(i));
> > this.key[i] = aKey;
> 214d222
> < */
> 222,223c230,232
> < throw new TurbineException(errMsg);
> < // this.key[i] = new SimpleKey(
> (String)tmpKeys.get(i) );
> ---
> > StringKey key = new StringKey();
> > key.setValue((String)tmpKeys.get(i));
> > this.key[i] = key;
> 262,263c271
> < SimpleKey[] keys = (SimpleKey[])key;
> < for ( int i=0; i<keys.length && isEqual; i++ )
> ---
> > for ( int i=0; i<key.length && isEqual; i++ )
> 265c273
> < isEqual &= keys[i] != null && keys[i].getValue() !=
> null;
> ---
> > isEqual &= key[i] != null && key[i].getValue() != null;
> 306c314
> < else if ( keyObj instanceof ComboKey)
> ---
> > else if ( keyObj instanceof ComboKey)
> 308,314c316,318
> < SimpleKey[] obj = (SimpleKey[])
> < ((ComboKey)keyObj).getValue();
> <
> < SimpleKey[] keys1 = (SimpleKey[])key;
> < SimpleKey[] keys2 = (SimpleKey[])obj;
> < isEqual = keys1.length == keys2.length;
> < for ( int i=0; i<keys1.length && isEqual; i++)
> ---
> > SimpleKey[] obj = (SimpleKey[])((ComboKey)keyObj).getValue();
> > isEqual = key.length == obj.length;
> > for ( int i=0; i<key.length && isEqual; i++)
> 316c320
> < isEqual &= ObjectUtils.equals(keys1[i], keys2[i]);
> ---
> > isEqual = isEqual && ObjectUtils.equals(key[i], obj[i]);
> 322,325c326,328
> < SimpleKey[] keys1 = (SimpleKey[])key;
> < SimpleKey[] keys2 = (SimpleKey[])keyObj;
> < isEqual = keys1.length == keys2.length;
> < for ( int i=0; i<keys1.length && isEqual; i++)
> ---
> > SimpleKey[] obj = (SimpleKey[])keyObj;
> > isEqual = key.length == obj.length;
> > for ( int i=0; i<key.length && isEqual; i++)
> 327c330
> < isEqual &= ObjectUtils.equals(keys1[i], keys2[i]);
> ---
> > isEqual = isEqual && ObjectUtils.equals(key[i], obj[i]);
>
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/Attic/NumberKey.java,v
> retrieving revision 1.5.4.1
> diff -r1.5.4.1 NumberKey.java
> 156c156
> < * keyObj is equal to this NumberKey if keyObj is a NumberKey or
> String
> ---
> > * keyObj is equal to this NumberKey if keyObj is a NumberKey or String or StringKey
> 165c165
> < if (keyObj instanceof String)
> ---
> > if (keyObj instanceof String || keyObj instanceof StringKey)
> 167c167
> < isEqual = toString().equals(keyObj);
> ---
> > isEqual = keyObj.toString().equals(toString());
>
> --
> Leandro Rodrigo Saad Cruz
> InterBusiness tecn. e serv.
> Sao Paulo - Brasil
>
> ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org