Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Niall Pemberton
Sorry Frank, but I don't think you have to worry about casting at all. Say
you've collected all your values into a List (myList), as Thomas suggested -
then all you need to do is something like the following:

Class type = PropertyUtils.getPropertyType(obj, "myArray");

// Array Processing
if (type.isArray()) {

Class componentType = type.getComponentType();

// Create new instance of the array
Object myArray = Array.newInstance(componentType, myList.size());

// Get the converter
Converter converter = ConvertUtils.lookup(componentType);

// populate array values
for (int i = 0; i < myList.size(); i++) {

// Get & Convert the value
Object value = converter.convert(componentType,  myList.get(i));

// Set the value in the array
Array.set(myArray, i, value);

}

// set the beans property
BeanUtils.setProperty(obj, "myArray", myArray);

} else {

// ? handle error ?

}

- Original Message - 
From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Sent: Thursday, September 08, 2005 4:33 AM


> Yep, knew about these already... unfortunately, the one thing that would
> make this a piece of cake is not available here, or in Java t all:
> dynamic casting.  If you could do that, it would be trivial to do
> something like:
>
> Class type = PropertyUtils.getPropertyType(obj, "myArray");
> Object v = Array.newInstance(type, values.size());
> BeanUtils.setProperty(obj, "myArray", values.toArray((type.getName())v));

>
> That still assumes that getName() returned the type in a useable form,
> which of course it doesn't anyway (which complicates my above if block,
> but I digress), so my pipe dream is even more so :)




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Frank W. Zammetti

Niall Pemberton wrote:

If they're always String[] then Thomas's solution is fine - but do you want
to be able to handle other types? LazyDynaBean does something pretty similar
to this - have a look at the growIndexedProperty() method for dynamically
growing arrays and createIndexedProperty() method for instantiating new
arrays.


Actually, I spent a while trying to crack this nut and then it occurred 
to me that since these objects are configured via XML, all I'm going to 
have basically *are* Strings anyway, so Thomas's solution will do the trick.


If and when I want to support other data types, I could do something like:

String type = (PropertyUtils.getPropertyType(obj, "myArray")).getName();
if (type.equalsIgnoreCase("string")) {
  String[] o = new String[values.size()];
  BeanUtils.setProperty(obj, "myArray", values.toArray(o));
} else if (type.equalsIgnoreCase("integer")) {
  Integer[] o = new Integer[values.size()];
  BeanUtils.setProperty(obj, "myArray", values.toArray(o));
}
// ... and so on for all supported types

I wouldn't claim that's pretty code, but it would get the job done.  I 
could only support those types that BeanUtils can automatically convert 
to anyway (ignoring the possibility of custom converters), so it's not 
all that bad an answer I think.



Anyway the java.lang.reflect.Array has useful (static) methods for
manipulating arrays...

1) Instantiating an Array

 Object myArray = Array.newInstance(type.getComponentType(), arraySize);

2)  Setting a value in an array, e.g

 Array.set(myArray, index, value);

3) Finding the length of an array

 Array.getLength(myArray);

Niall


Yep, knew about these already... unfortunately, the one thing that would 
make this a piece of cake is not available here, or in Java t all: 
dynamic casting.  If you could do that, it would be trivial to do 
something like:


Class type = PropertyUtils.getPropertyType(obj, "myArray");
Object v = Array.newInstance(type, values.size());
BeanUtils.setProperty(obj, "myArray", values.toArray((type.getName())v));

That still assumes that getName() returned the type in a useable form, 
which of course it doesn't anyway (which complicates my above if block, 
but I digress), so my pipe dream is even more so :)


I think I'm good to go for now.  I can re-visit this at a later time. 
FYI, I took a look at the LazyDynaBean code... I'm not sure it would 
help from my initial reading of it, but I want to take another look and 
make sure I didn't miss something.  Thanks for pointing it out in any case!


Frank


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Niall Pemberton
If they're always String[] then Thomas's solution is fine - but do you want
to be able to handle other types? LazyDynaBean does something pretty similar
to this - have a look at the growIndexedProperty() method for dynamically
growing arrays and createIndexedProperty() method for instantiating new
arrays.

Anyway the java.lang.reflect.Array has useful (static) methods for
manipulating arrays...

1) Instantiating an Array

 Object myArray = Array.newInstance(type.getComponentType(), arraySize);

2)  Setting a value in an array, e.g

 Array.set(myArray, index, value);

3) Finding the length of an array

 Array.getLength(myArray);

Niall



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Frank W. Zammetti

Thomas Dudziak wrote:

So I take it that you either got a setter for this field, or you want
to use reflection directly (Field object).


Right... IIRC, having a getter and setter for the entire array is in the 
javabean spec anyway, so that's certainly something I can expect of any 
class that is going to be dynamically created like this.  Even if it 
isn't in the spec, it certainly isn't too much to ask :)



But why shouldn't that work ? I mean, in the end arrays are normal
objects and can be used as such.
Eg. you can do something like:




That code looks pretty much perfect to me... I was not aware that you 
could use setProperty() in that way, I've never seen it done before.  I 
don't think I even need to go the reflection route, the first example 
you posted I think will do the trick nicely.



Does that answer your question, or did I misunderstood you ?


Thanks Tom, I think that does indeed answer my question exactly.  I'll 
know for sure in a few hours when I try and implement it, but it makes 
perfect sense and I can't imagine it won't work perfectly. :)



regards,
Tom


Frank


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Thomas Dudziak
On 9/7/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:
> I can certainly explain why the above isn't valid... myArray is private
> in myBean, so I can't do the above because I simply don't have access to
> that field.  If it was public then the above would work fine and I
> wouldn't have a question :)

That much is clear :-)
 
> The use case here is specifically for the DependencyFilter I add in Java
> Web Parts... basically, I'm instantiating a class based on a config
> file, and then configuring it (rudimentary IoC)... It already handles
> simple properties, Lists and Maps no problem, but arrays seemingly are a
> little trickier (and maybe I'm wrong about that to begin with) because
> of one thing I want to do: I don't want to force the class to have to
> create the array itself.  I want to be able to have a list of values in
> the config file and create the array based on the number of elements,
> which of course could vary.  So, I won't know the array size until the
> object is created.

So I take it that you either got a setter for this field, or you want
to use reflection directly (Field object).
But why shouldn't that work ? I mean, in the end arrays are normal
objects and can be used as such.
Eg. you can do something like:


import java.util.ArrayList;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

public class Main
{
public static class MyBean
{
private String[] myArray;

public String[] getMyArray()
{
return myArray;
}

public void setMyArray(String[] value)
{
myArray = value;
}
}
 
   public static void main(String[] args) throws Exception
{
MyBean obj= new MyBean();
List   values = new ArrayList();

values.add("String 1");
values.add("String 2");

// it is important to give the toArray method a base array to
define its return type
BeanUtils.setProperty(obj, "myArray", values.toArray(new String[0]));

System.out.println(obj.getMyArray());
}
}


Likewise, with Reflection you can do:


import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class Main
{
public static class MyBean
{
private String[] myArray;

public String[] getMyArray()
{
return myArray;
}

public void setMyArray(String[] value)
{
myArray = value;
}
}
public static void main(String[] args) throws Exception
{
MyBean obj= new MyBean();
List   values = new ArrayList();

values.add("String 1");
values.add("String 2");

Field field = obj.getClass().getDeclaredField("myArray");

field.setAccessible(true);
field.set(obj, values.toArray(new String[0]));

System.out.println(obj.getMyArray());
}
}


Does that answer your question, or did I misunderstood you ?

regards,
Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Frank W. Zammetti

Thomas Dudziak wrote:

class mainClass {
 myBean b = new myBean();
 b.myArray = new String[5];
}

Obviously that's not valid, but pretend it would work, I need to write
*real* code that *will* work to do the equivalent of that.  I haven't seen
anything in BeanUtils that would do it, hoping I'm missing something.



Could you perhaps explain what is the problem with the above ? Perhaps
you could provide some (pseudo, hypothetical) code using BeanUtils
that shows how you would do what you want to do ?


I can certainly explain why the above isn't valid... myArray is private 
in myBean, so I can't do the above because I simply don't have access to 
that field.  If it was public then the above would work fine and I 
wouldn't have a question :)


The use case here is specifically for the DependencyFilter I add in Java 
Web Parts... basically, I'm instantiating a class based on a config 
file, and then configuring it (rudimentary IoC)... It already handles 
simple properties, Lists and Maps no problem, but arrays seemingly are a 
little trickier (and maybe I'm wrong about that to begin with) because 
of one thing I want to do: I don't want to force the class to have to 
create the array itself.  I want to be able to have a list of values in 
the config file and create the array based on the number of elements, 
which of course could vary.  So, I won't know the array size until the 
object is created.


Does that make sense?


Tom


Frank


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Frank W. Zammetti

I explained in another reply, but it's worth replying directly here...

The use case is that I'm dynamically creating instances of myBean based 
on a configuration file... this is part of the DependencyFilter I added 
to Jave Web Parts in the past few days.  It already handles simple 
properties, Maps and Lists with no problem, but arrays seem a bit 
trickier...


The thing that is making it trickier, unless I'm missing something 
simple (which is entirely possible!) is that say I read in the config 
file and find that there are 10 items to be added to a given array field 
in byBean... I don't want myBean to have to know before-hand how big the 
 array will be, nor do I want to have to arbitrarily set some high 
value.  So, I need to be able to dynamically create the array from 
OUTSIDE myBean based on the number of items found in the config file.


Since myArray is private in myBean as per my example, I can't simply 
access the field directly as I showed in the example.  Hence my question :)


Hope that makes some sense...

Frank

Niall Pemberton wrote:

LazyDynaBean does this, but I guess you don't want DynaBeans.

Whats the circumstance of you wanting to do this dynamically - rather than
just initializing it as you are in your example?

Niall

- Original Message - 
From: "Frank W. Zammetti" <[EMAIL PROTECTED]>

Sent: Wednesday, September 07, 2005 7:55 PM




I kind of assume this isn't possible based on what I've seen, but figured
I'd ask none the less...

Is it possible with BeanUtils (or otherwise) to create a new array as a
member of a bean?  What I mean is, if I have this bean:

class myBean {
 private String[] myArray;
}

Can I do the equivalent of this:

class mainClass {
 myBean b = new myBean();
 b.myArray = new String[5];
}

Obviously that's not valid, but pretend it would work, I need to write
*real* code that *will* work to do the equivalent of that.  I haven't seen
anything in BeanUtils that would do it, hoping I'm missing something.
Thanks!

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Niall Pemberton
LazyDynaBean does this, but I guess you don't want DynaBeans.

Whats the circumstance of you wanting to do this dynamically - rather than
just initializing it as you are in your example?

Niall

- Original Message - 
From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Sent: Wednesday, September 07, 2005 7:55 PM


> I kind of assume this isn't possible based on what I've seen, but figured
> I'd ask none the less...
>
> Is it possible with BeanUtils (or otherwise) to create a new array as a
> member of a bean?  What I mean is, if I have this bean:
>
> class myBean {
>   private String[] myArray;
> }
>
> Can I do the equivalent of this:
>
> class mainClass {
>   myBean b = new myBean();
>   b.myArray = new String[5];
> }
>
> Obviously that's not valid, but pretend it would work, I need to write
> *real* code that *will* work to do the equivalent of that.  I haven't seen
> anything in BeanUtils that would do it, hoping I'm missing something.
> Thanks!
>
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] Handling array creation?

2005-09-07 Thread Thomas Dudziak
On 9/7/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:

> I kind of assume this isn't possible based on what I've seen, but figured
> I'd ask none the less...
> 
> Is it possible with BeanUtils (or otherwise) to create a new array as a
> member of a bean?  What I mean is, if I have this bean:
> 
> class myBean {
>   private String[] myArray;
> }
> 
> Can I do the equivalent of this:
> 
> class mainClass {
>   myBean b = new myBean();
>   b.myArray = new String[5];
> }
> 
> Obviously that's not valid, but pretend it would work, I need to write
> *real* code that *will* work to do the equivalent of that.  I haven't seen
> anything in BeanUtils that would do it, hoping I'm missing something.

Could you perhaps explain what is the problem with the above ? Perhaps
you could provide some (pseudo, hypothetical) code using BeanUtils
that shows how you would do what you want to do ?

Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [BeanUtils] case insensitive BeanComparator?

2005-09-07 Thread Bernard, Shawn
Thanks!  That worked like a charm.

-Shawn

-Original Message-
From: Niall Pemberton [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07, 2005 3:47 PM
To: Jakarta Commons Users List
Subject: Re: [BeanUtils] case insensitive BeanComparator?


...or if you don't want to declare a new class

 Transformer transformer = new Transformer() {
   public Object transform(Object input) {
return ((String)input).toLowerCase();
   }
 };
 Comparator comparator = new TransformingComparator(transformer);
 Collections.sort(foobies, new BeanComparator("billingAddress.lastName",

comparator));

Niall

- Original Message - 
From: "Niall Pemberton" <[EMAIL PROTECTED]>
Sent: Wednesday, September 07, 2005 8:30 PM


> You could create an org.apache.commons.collections.Transformer 
>
> public class LowerCaseTransformer implements Transformer {
>  public Object transform(Object input) {
>   return ((String)input).toLowerCase();
>  }
> }
>
> Comparator comparator = new TransformingComparator(new
> LowerCaseTransformer());
> Collections.sort(foobies, new BeanComparator("billingAddress.lastName",
> comparator));
>
> Niall
>
> - Original Message - 
> From: "Bernard, Shawn" <[EMAIL PROTECTED]>
> Sent: Wednesday, September 07, 2005 7:15 PM
>
>
> I'm using a BeanComparator in a Collections.sort():
>
>Collections.sort(foobies, new
BeanComparator("billingAddress.lastName"));
>
> I was wondering if there was a way to make the sort case insensitive
> (without creating my own custom comparator).
>
> Thanks,
>
> Shawn
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] case insensitive BeanComparator?

2005-09-07 Thread Niall Pemberton
...or if you don't want to declare a new class

 Transformer transformer = new Transformer() {
   public Object transform(Object input) {
return ((String)input).toLowerCase();
   }
 };
 Comparator comparator = new TransformingComparator(transformer);
 Collections.sort(foobies, new BeanComparator("billingAddress.lastName",

comparator));

Niall

- Original Message - 
From: "Niall Pemberton" <[EMAIL PROTECTED]>
Sent: Wednesday, September 07, 2005 8:30 PM


> You could create an org.apache.commons.collections.Transformer 
>
> public class LowerCaseTransformer implements Transformer {
>  public Object transform(Object input) {
>   return ((String)input).toLowerCase();
>  }
> }
>
> Comparator comparator = new TransformingComparator(new
> LowerCaseTransformer());
> Collections.sort(foobies, new BeanComparator("billingAddress.lastName",
> comparator));
>
> Niall
>
> - Original Message - 
> From: "Bernard, Shawn" <[EMAIL PROTECTED]>
> Sent: Wednesday, September 07, 2005 7:15 PM
>
>
> I'm using a BeanComparator in a Collections.sort():
>
>Collections.sort(foobies, new
BeanComparator("billingAddress.lastName"));
>
> I was wondering if there was a way to make the sort case insensitive
> (without creating my own custom comparator).
>
> Thanks,
>
> Shawn
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [BeanUtils] case insensitive BeanComparator?

2005-09-07 Thread Niall Pemberton
You could create an org.apache.commons.collections.Transformer 

public class LowerCaseTransformer implements Transformer {
 public Object transform(Object input) {
  return ((String)input).toLowerCase();
 }
}

Comparator comparator = new TransformingComparator(new
LowerCaseTransformer());
Collections.sort(foobies, new BeanComparator("billingAddress.lastName",
comparator));

Niall

- Original Message - 
From: "Bernard, Shawn" <[EMAIL PROTECTED]>
Sent: Wednesday, September 07, 2005 7:15 PM


I'm using a BeanComparator in a Collections.sort():

   Collections.sort(foobies, new BeanComparator("billingAddress.lastName"));

I was wondering if there was a way to make the sort case insensitive
(without creating my own custom comparator).

Thanks,

Shawn



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[BeanUtils] Handling array creation?

2005-09-07 Thread Frank W. Zammetti
I kind of assume this isn't possible based on what I've seen, but figured
I'd ask none the less...

Is it possible with BeanUtils (or otherwise) to create a new array as a
member of a bean?  What I mean is, if I have this bean:

class myBean {
  private String[] myArray;
}

Can I do the equivalent of this:

class mainClass {
  myBean b = new myBean();
  b.myArray = new String[5];
}

Obviously that's not valid, but pretend it would work, I need to write
*real* code that *will* work to do the equivalent of that.  I haven't seen
anything in BeanUtils that would do it, hoping I'm missing something. 
Thanks!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[BeanUtils] case insensitive BeanComparator?

2005-09-07 Thread Bernard, Shawn
I'm using a BeanComparator in a Collections.sort():

   Collections.sort(foobies, new BeanComparator("billingAddress.lastName"));

I was wondering if there was a way to make the sort case insensitive (without 
creating my own custom comparator).

Thanks,

Shawn

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Digester] Can I do an object-create-rule within a set-properties-rule?

2005-09-07 Thread Paolo Valladolid
I am setting up Digester to parse XML in this format:
 


  
My Book
My Publisher
  

 
The rules file I have is this:
 


  


  
  


  
  
 
  

  
  
  
  

  

 
My problem is that I use Java classes generated by a tool that scans the
database.  The com.myclasses.Document class does not have a "type"
property.  Instead, it has a "doctypeid" property.  I need to
instantiate a com.myclasses.DocumentType object, set its "doctypeNm"
property to the "type" attribute (eg. "DocumentTypeA"), then use it to
retrieve the value which which I can set the Document.doctypeid
property.
 
I thought of doing an object-create-rule on a HashMap class and using
that to store attributes, then setting the Document properties out of
the HashMap object, but that seems like a clumsy workaround.
 
Any ideas?
 
Thanks,
 
Paolo Valladolid
Software Developer
DFI International
 


RE: [email] commons-email 1.0-RC8 available

2005-09-07 Thread Asleson, Ryan


I tried RC8 in WebLogic 8.1 and it now works.  Thank you very much!!

Just for historical reference, with RC5 I had tried packaging the current 
javamail and activation jars in the webapp but it made no difference.  I'm 
guessing that WebLogic had already loaded those classes into memory during 
startup, so having the newer versions in the WAR made no difference.  I was 
able to track down the source of the error, but I didn't want to do my own 
one-off custom build for maintenance reasons.  I was hoping something like this 
would be done.  Again, thank you very much!

Now I can use it throughout my app rather than writing the tedious JavaMail 
API's myself.  Right now I'm just using SimpleEmail -- can't wait to try 
HtmlEmail.


-Original Message-
From: Dion Gillard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07, 2005 7:26 AM
To: Jakarta Commons Users List
Subject: Fwd: [email] commons-email 1.0-RC8 available


FYI all.

-- Forwarded message --
From: Henning P. Schmiedehausen <[EMAIL PROTECTED]>
Date: Sep 7, 2005 10:11 PM
Subject: [email] commons-email 1.0-RC8 available
To: commons-dev@jakarta.apache.org



Due to the requests from Stephen, Niall and some remarks on the users
list about using commons-email in J2EE environments, I've applied the
patches that they contributed and verified that commons-email indeed
builds and works with JDK 1.3.x and Javamail 1.2 using both the maven
and the ant build.

I've built a new release candidate using JDK 1.3.1: commons-email-1.0-rc8

Get it (and also source and binary distributions) from

http://people.apache.org/~henning/commons-email/

I also redeployed the commons-email site; the updated docs should be
available from jakarta.apache.org in a few hours.

If there are no further objections, I think that we should restart the
vote ASAP.

Best regards
Henning


--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen  INTERMETA GmbH
[EMAIL PROTECTED]+49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

  4 - 8 - 15 - 16 - 23 - 42

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


This e-mail message is being sent solely for use by the intended recipient(s) 
and may contain confidential information.  Any unauthorized review, use, 
disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by phone or reply by e-mail, delete the 
original message and destroy all copies. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



FTPClient fails to parse file-list

2005-09-07 Thread Goebel, Martin (BREKOM)
Hi!

I have to deal with a strange behaviour of FTPClient. I don't get it.

I Connect to a ReliantUnix and want to get a FileList.

ftp = new FTPClient();
FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
conf.setServerLanguageCode("en");
ftp.configure(conf);

[...]

FTPListParseEngine engine = ftp.initiateListParsing(directory);
FTPFile[] result = engine.getFiles();

Three files of a longer Filelist can not be parsed, the resulting FTPFile is
null.

This is one of the lines that works:
-rw-rw-rw-   1 gcu  agc 3913149 Sep  7 06:00 ge05-09-07.txt
And these can not be parsed:
drwxrwxrwx   2 gcudat   gcudat96 Okt 15  2001 GCUIMPORT
-rw-r-   1 agc  agc   688128 Apr  8 10:40 SAVEGCDATA.sav
-rw-r-   1 gcuftp   other 688128 Apr  6 10:52 SAVERSfile.sav

I can not see the significant difference!?!

To track down the problem, I called the parser directly with the content and
it works, like this:

UnixFTPEntryParser parse = new UnixFTPEntryParser();
ftpFile = parse.parseFTPEntry("-rw-r-   1 agc  agc   688128 Apr
8 10:40 SAVEGCDATA.sav");
System.out.println(ftpFile.getName());

If I adjust my FTPClient to SYST_UNIX, isn't that the used parser?

If then, I use the FTPFileEntryParser, it fails, on all my entrys.

This is the output, of the method, that revealed the Problem:

i=69/75 -rw-rw-rw-   1 gcu  agc  4176135 Sep  6 06:00 ge05-09-06.txt
i=70/75 -rw-rw-rw-   1 gcu  agc  3913149 Sep  7 06:00 ge05-09-07.txt
i=71/75 -rw-r--r--   1 root other   2221 Jul 29  2002 pg
Can't read File-List java.lang.NullPointerException

This is the next line on wich it fails:
drwxrwxrwx   2 gcudat   gcudat96 Okt 15  2001 GCUIMPORT


Any ideas? thanks...

Bye, mago

 


RE: [email] commons-email 1.0-RC8 available

2005-09-07 Thread Asleson, Ryan


Excellent!!  Thank you!!

-Original Message-
From: Dion Gillard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07, 2005 7:26 AM
To: Jakarta Commons Users List
Subject: Fwd: [email] commons-email 1.0-RC8 available


FYI all.

-- Forwarded message --
From: Henning P. Schmiedehausen <[EMAIL PROTECTED]>
Date: Sep 7, 2005 10:11 PM
Subject: [email] commons-email 1.0-RC8 available
To: commons-dev@jakarta.apache.org



Due to the requests from Stephen, Niall and some remarks on the users
list about using commons-email in J2EE environments, I've applied the
patches that they contributed and verified that commons-email indeed
builds and works with JDK 1.3.x and Javamail 1.2 using both the maven
and the ant build.

I've built a new release candidate using JDK 1.3.1: commons-email-1.0-rc8

Get it (and also source and binary distributions) from

http://people.apache.org/~henning/commons-email/

I also redeployed the commons-email site; the updated docs should be
available from jakarta.apache.org in a few hours.

If there are no further objections, I think that we should restart the
vote ASAP.

Best regards
Henning


--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen  INTERMETA GmbH
[EMAIL PROTECTED]+49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

  4 - 8 - 15 - 16 - 23 - 42

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


This e-mail message is being sent solely for use by the intended recipient(s) 
and may contain confidential information.  Any unauthorized review, use, 
disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by phone or reply by e-mail, delete the 
original message and destroy all copies. Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Fwd: [email] commons-email 1.0-RC8 available

2005-09-07 Thread Henning P. Schmiedehausen
Dion Gillard <[EMAIL PROTECTED]> writes:

>FYI all.

Thanks Dion.

[...]

>builds and works with JDK 1.3.x and Javamail 1.2 using both the maven
>and the ant build.

I'd especially interested in hearing a success/failure report from the guy
who tried c-e in a J2EE 1.3 environment (Weblogic 8.1 I think) and ran into
the "InternetAddress.validate() - Method not found" problem.

Best regards
Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen  INTERMETA GmbH
[EMAIL PROTECTED]+49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

  4 - 8 - 15 - 16 - 23 - 42

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Commons-Email -- not J2EE 1.3?

2005-09-07 Thread Henning P. Schmiedehausen
"Asleson, Ryan" <[EMAIL PROTECTED]> writes:

>--_=_NextPart_001_01C5B313.D15644AC
>Content-Type: text/plain;
>   charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable


>Hello,

>I just tried using Commons-Email RC5 on WebLogic 8.1. When
>using the Email.addTo method, I receive a NoSuchMethodError.

> It appears that the Email class is attempting to use
> InternetAddress.validate() , which is part of J2EE 1.4, not 1.3.
> Since I'm using WebLogic 8.1, which is only J2EE 1.3, it looks like
> I'm stuck.

> Is there any way around this?

Is it possible for you to deploy the javamail-1.3.x with your
application? The method call that you've mentioned is part of the 
1.2 -> 1.3 enhancements listed on
http://java.sun.com/products/javamail/JavaMail-1.3-changes.txt

I've used commons-email in its development stages (and before as part
of Turbine) on a number of JDKs in the 1.3-1.4.2 range and it worked
everywhere. I'd think that if you deploy the javamail jar together
with your application, this should work.

Regards
Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen  INTERMETA GmbH
[EMAIL PROTECTED]+49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

  4 - 8 - 15 - 16 - 23 - 42

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Fwd: [email] commons-email 1.0-RC8 available

2005-09-07 Thread Dion Gillard
FYI all.

-- Forwarded message --
From: Henning P. Schmiedehausen <[EMAIL PROTECTED]>
Date: Sep 7, 2005 10:11 PM
Subject: [email] commons-email 1.0-RC8 available
To: commons-dev@jakarta.apache.org



Due to the requests from Stephen, Niall and some remarks on the users
list about using commons-email in J2EE environments, I've applied the
patches that they contributed and verified that commons-email indeed
builds and works with JDK 1.3.x and Javamail 1.2 using both the maven
and the ant build.

I've built a new release candidate using JDK 1.3.1: commons-email-1.0-rc8

Get it (and also source and binary distributions) from

http://people.apache.org/~henning/commons-email/

I also redeployed the commons-email site; the updated docs should be
available from jakarta.apache.org in a few hours.

If there are no further objections, I think that we should restart the
vote ASAP.

Best regards
Henning


--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen  INTERMETA GmbH
[EMAIL PROTECTED]+49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

  4 - 8 - 15 - 16 - 23 - 42

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DIGESTER -- how to handle embedded HTML

2005-09-07 Thread Catalin Grigoroscuta

Hi,

IMO you shoud use CDATA sections in your xml to put HTML code.
I do not think this will affect your DTD.

Regards,
Catalin

Pitts, Nathan wrote:


Hi all,



I have a question that I'm sure is very simple, but I haven't seen any
docs on it.  This is my first time using digester.  Let's say I have an
XML document (which is generated so I don't have control of it) that may
include HTML inside the XML elements.  Sometimes the HTML is not xml
compliant - like using a  without a Currently, my I am
getting null values for that element, although the other elements
(without embedded HTML) work fine.



Example:





   This is a book

   This book is good.This book has embedded HTML
inside the summary. 






Does this mean I need to come up with a dtd that lists summary contents
as CDATA?



Tia,



-nathan




 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jelly] How to create maps

2005-09-07 Thread Adrian Herscu



Adrian Herscu wrote:

Thought that there is some special JEXL syntax that allows the creation 
of collections, arrays and lists.


So instead of:




one could write:





Another idea:

  
  


But JEXL syntax is better since it allows the definition of collections 
in properties files.



Dion Gillard wrote:


Using the new tag?
http://jakarta.apache.org/commons/jelly/tags.html#core:new

On 9/7/05, Adrian Herscu <[EMAIL PROTECTED]> wrote:


Hi all,

I know how to access a map in Jelly.


${iter.key} = ${iter.value}


But, how can I create a map using Jelly syntax?

Thanks,
Adrian.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]









-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jelly] How to create maps

2005-09-07 Thread Adrian Herscu
Thought that there is some special JEXL syntax that allows the creation 
of collections, arrays and lists.


So instead of:




one could write:



Dion Gillard wrote:

Using the new tag?
http://jakarta.apache.org/commons/jelly/tags.html#core:new

On 9/7/05, Adrian Herscu <[EMAIL PROTECTED]> wrote:


Hi all,

I know how to access a map in Jelly.


${iter.key} = ${iter.value}


But, how can I create a map using Jelly syntax?

Thanks,
Adrian.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]









-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Basic questions about VFS

2005-09-07 Thread Mario Ivankovits

Jon Blower wrote:

However, there must be some underlying libraries (e.g. the
FTP libraries?) that understand file permissions.

FTP do not support permission, the protocol itself didnt support it.

I am not sure, but I think the only library with "ACL" support is 
webdav/slide.



Regards,
Mario


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Basic questions about VFS

2005-09-07 Thread Stephen Colebourne
--- Mario Ivankovits <[EMAIL PROTECTED]> wrote:
> The main problem is the lack of support in the
> underlaying libraries.
> Even for local files we might need a native library
> (I hate native 
> libraries) to set permissions as there is no real
> support in java.io.file.

See [io] FileSystemUtils for an example of using the
command line from Java to get the free space on the
drive. You could extend this [io] class to add file
permissions.

Stephen

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Basic questions about VFS

2005-09-07 Thread Jon Blower
Hi Mario,

Yes, I see the problem and I agree that native libraries would not be a
good solution.  However, there must be some underlying libraries (e.g. the
FTP libraries?) that understand file permissions.  Even if it weren't
available in VFS files that are underlain by java.io.File, perhaps it
would still be useful to have support in VFS for filesystems that do
support permissions in pure Java?  VFS could detect whether permissions
were supported and allow manipulation accordingly.

Cheers, Jon


--
Dr Jon Blower  Tel: +44 118 378 5213 (direct line)
Technical Director Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre   Fax: +44 118 378 6413
ESSC   Email: [EMAIL PROTECTED]
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--


On Wed, 7 Sep 2005, Mario Ivankovits wrote:

> Hi!
> >Perhaps there could be a "hasPosixPermissions" Capability, and if a file
> >has that capability, its permissions can be set and read?
> >
> The main problem is the lack of support in the underlaying libraries.
> Even for local files we might need a native library (I hate native
> libraries) to set permissions as there is no real support in java.io.file.
>
> And we have to figure out how to abstract the various different
> permission systems.
> For windows/unix this document might help:
> http://docs.hp.com/en/B8725-90053/ch03s02.html
>
> Maybe this might happen, though I cant promise it.
>
> Ciao,
> Mario
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Basic questions about VFS

2005-09-07 Thread Mario Ivankovits

Hi!

Perhaps there could be a "hasPosixPermissions" Capability, and if a file
has that capability, its permissions can be set and read?
 

The main problem is the lack of support in the underlaying libraries.
Even for local files we might need a native library (I hate native 
libraries) to set permissions as there is no real support in java.io.file.


And we have to figure out how to abstract the various different 
permission systems.
For windows/unix this document might help: 
http://docs.hp.com/en/B8725-90053/ch03s02.html


Maybe this might happen, though I cant promise it.

Ciao,
Mario


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Basic questions about VFS

2005-09-07 Thread Jon Blower
Hi Mario,

Thanks very much for all this information.  The lack of file permissions
support could be a problem for me.  I understand why it's not there, as
many systems don't use permissions, but I was wondering if there could at
least be a system for setting and getting file permissions (if the correct
Capability is set) and for creating files and folders with given
permissions?

Perhaps there could be a "hasPosixPermissions" Capability, and if a file
has that capability, its permissions can be set and read?

As for the asynchronous I/O, that would be very useful too.  I might be
able to contribute something when I've understood VFS a bit better.

Regards, Jon

--
Dr Jon Blower  Tel: +44 118 378 5213 (direct line)
Technical Director Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre   Fax: +44 118 378 6413
ESSC   Email: [EMAIL PROTECTED]
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--


On Tue, 6 Sep 2005, Mario Ivankovits wrote:

> Hi!
> >1) What is the status of the VFS project?
> We are close before a 1.0 release.
> >Is it still actively being developed?
> Currently I am the only active committer, but there is a active user
> base and some contributors.
> >Is it planned to be a key part of any important Apache projects?
> Not that I am aware of. From our internal logs (those which other
> projects fail if I made a mistake) I can see its used in
> cocoon, excalibur, forrest and log4j-chainsaw (log viewer), though I
> know of some other people who use vfs
> as part of their productive system.
> >2) When is a formal release planned?
> see above
> >At the moment is the only way to get the software via the nightly builds?
> Yes - and svn head.
> >The SVN repository (http://svn.apache.org/viewcvs.cgi/) seems to say that 
> >the Commons project
> >is closing - is this true, or has the SVN repository moved somewhere else?
> >
> You must dive into jakarta/commons not the top level commons.
> >3) Are there any GUI apps (e.g. file system browsers) that interact with
> >VFS resources?
> >
> log4j-chainsaw
> >4) How does VFS deal with file permissions?
> VFS do not deal with file permissions, its up to the used library and in
> fact at last by the operating system if a system is read-/writeable.
> VFS do not have a api to change/set file permissions.
> >5) Is asynchronous I/O supported?  I.e. can I send a message to write data
> >to a file and provide a callback for when the data are written?
> >
> Currently not, but might be a great addition.
>
> Do not hesitate to ask further questions.
>
> ---
> Mario
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]