Re: How to tie



On Dec 31, 9:32 am, Lew <l...@xxxxxxxxxxxxx> wrote:
Christian wrote:
Abble schrieb:
I'd like to tie a Java array to some code so when the array is
accessed my code gets run.

Is there some simple way to do this in Java?

Rather not ..
but when you use Collections instead of an array doing this becomes
rather easy.

Give us an example, Christian, or a description of how.

To the OP: You want to wrap access to your protected resource (array,
whatever) in an object that either performs the desired action on access, or
sends a notification to a listener to trigger such action.

JavaBeans have a mechanism available for notifications of property changes and
such events. You can use this to fire an event on each access of interest.

--
Lew


Thanks, Lew, but I'd like if possible to not have to wrap my array.

Here's another angle to the question: Can I dynamically declare new
array names, for instance, if I have a function that opens up a
database, can that function look up the names of the fields in the
database and make similar variables "appear"?
Something like:

OpenDB( "mydb.xyz" ); //mydb.xyz has in it a definition of arrays
A,B, C
// now at this point arrays A B C spring into existence and
populated.

D[i] = A[ i ] + B[i] + C[ i ]; // use A B c


Thanks,

.



Relevant Pages

  • Re: KirbyBase
    ... creating objects from the database records was much easier. ... Hal, I don't know if you have had a chance to take a look at the beta yet, but I basically tried to implement a uniform way to specify one-to-one links, one-to-many links, and calculated fields in the ... I suppose it would in effect be embedding an array where all the ... My first couple of attempts at adding more complexity to KirbyBase did not honor this concept. ...
    (comp.lang.ruby)
  • Re: KirbyBase
    ... I'm an Object Guy and Jamey is a Database Guy. ... That requires the table name and key field name to be specified ... I suppose it would in effect be embedding an array where all the ... that is) might compress by a factor of 10 or more. ...
    (comp.lang.ruby)
  • Re: using BLOB objects and ...
    ... while saving the array object to the database which is ok but while ... convert it back to object of 4 dimention boolean array which will be ... will let you store your 4 dimensional boolean array in it. ... You may have to modify my suggestion ...
    (comp.lang.java.programmer)
  • Re: using BLOB objects and ...
    ... - You could use Memo if you converted your boolean array into a text string. ... boolean array when you fetch it from the database. ... You might be able to put the whole array in an OLE Object, ...
    (comp.lang.java.programmer)
  • Re: Permutations - 8 columns
    ... Thanks Markos for your input. ... SQL driver to access the database, I will have to use the long way to ... > Dim TotalAccounts As Long, ... We declare and resize an array variable with the ...
    (microsoft.public.excel.programming)