|
Thanks, makes a lot of sense. Whenever I cast something I feel like I'm
breaking a rule. And probably am.
By typed vectors I assume you mean something like:
Vector myClass = new MyClass() (or is it the other way.. it's friday, my
brain is oo'd out).
That would automatically create a vector of MyClass() objects. I would like
to see the same thing.
As for using my own class instead of a vector, that means I need to make my
own size() and get() methods for it, correct? That's what I've been doing.
For example:
public int size()
{
return this.myList.size();
}
Thanks again.
Brad
> -----Original Message-----
> From: Joe Pluta [mailto:joepluta@plutabrothers.com]
> Sent: Friday, March 16, 2001 1:05 PM
> To: JAVA400-L@midrange.com
> Subject: RE: Header and Detail
>
>
> It depends on the access. If you access by ordinal position,
> then leaving something a Vector is "okay", except that you
> always have to cast it. I usually start with Vectors for
> those kind of collections, and then eventually replace the
> Vectors with my own class (I keep waiting for Java to support
> typed Vectors as an integral part of the language).
>
> So, iscmControlList is probably okay to leave as a Vector for
> now. However, what iscmControlList returns (let's call it
> FieldRow) is a collection of FieldDefinitions that you have
> to access by key. This is definitely NOT a Vector. In fact,
> you may want to consider subclassing Hashtable instead of
> Vector, because Hashtables provide keyed access. In any
> case, the code that you have in FieldFormatter that pulls an
> individual FieldDefinition out of a FieldRow definitely has
> no business in FieldFormatter, it should instead be a method
> in FieldRow.
>
> HTH
>
>
> ---------- Original Message ----------------------------------
> From: "Stone, Brad V (TC)" <bvstone@taylorcorp.com>
> Reply-To: JAVA400-L@midrange.com
> Date: Fri, 16 Mar 2001 12:18:51 -0600
>
> >sendID =iscmControlList.getRecord(i).getField("SND_ID").data();
>
> Using this (which makes sense) my getRecord method for
> icsmControlList will
> have to return something other than a vector object, right?
> I'd have to
> make my own class (FieldRow or something) that it would
> return. Then write
> my own getField method for the FieldRow class.
>
> But in this case, FieldRow is nothing more than a vector (or
> fields). So is
> there an advatange to this, or is this just not right to begin with?
>
> (My comparable code)
> sendID =
> FieldListFormatter.getField((Vector)icsmControlList.get(i),"SN
> D_ID").data;
> +---
> | This is the JAVA/400 Mailing List!
> | To submit a new message, send your mail to JAVA400-L@midrange.com.
> | To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> JAVA400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner: joe@zappie.net
> +---
>
> +---
> | This is the JAVA/400 Mailing List!
> | To submit a new message, send your mail to JAVA400-L@midrange.com.
> | To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> JAVA400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner: joe@zappie.net
> +---
>
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.