Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   PUT DATA (http://www.velocityreviews.com/forums/t957429-put-data.html)

Roedy Green 02-08-2013 10:21 PM

PUT DATA
 
In the olden days PL/I has a output mechanism called PUT DATA

Expresses Javesquely it would look like this:

out.putd ( xlow, xhigh);

It would output

xlow=23.4 xhigh=200.0

(There was also a keyword/value input method. It was mainly helpful
in debugging.)
I could see how you could implement it in a preprocessor or
amanuensis, but can you do it with a pure Java method? What if you
warp the syntax brutally to hide info with annotations?

--
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.
~ Tom Cargill Ninety-ninety Law

Arne Vajh°j 02-08-2013 10:34 PM

Re: PUT DATA
 
On 2/8/2013 5:21 PM, Roedy Green wrote:
> In the olden days PL/I has a output mechanism called PUT DATA
>
> Expresses Javesquely it would look like this:
>
> out.putd ( xlow, xhigh);
>
> It would output
>
> xlow=23.4 xhigh=200.0
>
> (There was also a keyword/value input method. It was mainly helpful
> in debugging.)
> I could see how you could implement it in a preprocessor or
> amanuensis, but can you do it with a pure Java method? What if you
> warp the syntax brutally to hide info with annotations?


xlow and xhigh seems to be variable names.

They do not even exist at runtime for local variables.

So: no - impossible.

And annotations are put on types not on instances.

Arne



Lew 02-09-2013 12:10 AM

Re: PUT DATA
 
Roedy Green wrote:
> In the olden days PL/I has a output mechanism called PUT DATA
>
> Expresses Javesquely it would look like this:
>
> out.putd ( xlow, xhigh);
>
> It would output
>
> xlow=23.4 xhigh=200.0
>
> (There was also a keyword/value input method. It was mainly helpful
> in debugging.)
>
> I could see how you could implement it in a preprocessor or
> amanuensis, but can you do it with a pure Java method?


What do you mean by "amanuensis"?

--
Lew

Lew 02-09-2013 12:13 AM

Re: PUT DATA
 
Arne Vajh°j wrote:
>> And annotations are put on types not on instances.


http://docs.oracle.com/javase/7/docs...ementType.html
contradicts you.

How else would injection work?

--
Lew

Arne Vajh°j 02-09-2013 12:18 AM

Re: PUT DATA
 
On 2/8/2013 7:13 PM, Lew wrote:
> Arne Vajh°j wrote:
>>> And annotations are put on types not on instances.

>
> http://docs.oracle.com/javase/7/docs...ementType.html
> contradicts you.
>
> How else would injection work?


????

X a;
X b;

what annotation are you suggesting that I use two distinguish between
the two X'es?

Arne


Arved Sandstrom 02-09-2013 12:44 AM

Re: PUT DATA
 
On 02/08/2013 08:18 PM, Arne Vajh°j wrote:
> On 2/8/2013 7:13 PM, Lew wrote:
>> Arne Vajh°j wrote:
>>>> And annotations are put on types not on instances.

>>
>> http://docs.oracle.com/javase/7/docs...ementType.html
>>
>> contradicts you.
>>
>> How else would injection work?

>
> ????
>
> X a;
> X b;
>
> what annotation are you suggesting that I use two distinguish between
> the two X'es?
>
> Arne
>

This suddenly got confusing. I believe we all know that we can have one
set of annotations on

X a;

and a completely different set of annotations on

X b;

Clearly the annotations must be appropriate for type 'X', but they are
separately associated to 'a' and to 'b'.

AHS

Arne Vajh°j 02-09-2013 12:52 AM

Re: PUT DATA
 
On 2/8/2013 7:44 PM, Arved Sandstrom wrote:
> On 02/08/2013 08:18 PM, Arne Vajh°j wrote:
>> On 2/8/2013 7:13 PM, Lew wrote:
>>> Arne Vajh°j wrote:
>>>>> And annotations are put on types not on instances.
>>>
>>> http://docs.oracle.com/javase/7/docs...ementType.html
>>>
>>>
>>> contradicts you.
>>>
>>> How else would injection work?

>>
>> ????
>>
>> X a;
>> X b;
>>
>> what annotation are you suggesting that I use two distinguish between
>> the two X'es?
>>

> This suddenly got confusing. I believe we all know that we can have one
> set of annotations on
>
> X a;
>
> and a completely different set of annotations on
>
> X b;
>
> Clearly the annotations must be appropriate for type 'X', but they are
> separately associated to 'a' and to 'b'.


Maybe I am the only one in the known universe that don't know.

But let us say we have:

X a = new X(aa);
X b = new X(bb);
test(a,b);

void test(X a,X b) {
}

How should the annotation look like, how should it be put on and
how do I get it in test?

I know how to put an annotation on the type X that I can get in
test. But that is the same for both a and b. Roedy needs a
different annotation (value).

I don't think I have ever seen that done with instances.

Arne



Lew 02-09-2013 01:06 AM

Re: PUT DATA
 
Arne Vajh°j wrote:
> Maybe I am the only one in the known universe that don't know.
>
> But let us say we have:
>
> X a = new X(aa);
> X b = new X(bb);
>
> test(a,b);
>
> void test(X a,X b) {
>
> }
>
> How should the annotation look like, how should it be put on and
> how do I get it in test?


I don't understand your question "How do I get it in test?"

> I know how to put an annotation on the type X that I can get in
> test. But that is the same for both a and b. Roedy needs a
> different annotation (value).
>
> I don't think I have ever seen that done with instances.


Take a look at JPA:

@Column(name="SURNAME")
private String lastName;

@Column(name="GIVENNAME")
private String firstName;

Is that not annotating a field? And annotations can annotate a local variable, too.

It's not annotating 'String'.

Is that not what you wanted?

--
Lew

Lew 02-09-2013 01:08 AM

Re: PUT DATA
 
Lew wrote:
> Arne Vajh°j wrote:
>> Maybe I am the only one in the known universe that don't know.

>
>> But let us say we have:

>
>> X a = new X(aa);
>> X b = new X(bb);

>
>> test(a,b);

>
>> void test(X a,X b) {
>> }
>>
>> How should the annotation look like, how should it be put on and
>> how do I get it in test?

>
> I don't understand your question "How do I get it in test?"
>
>> I know how to put an annotation on the type X that I can get in
>> test. But that is the same for both a and b. Roedy needs a
>> different annotation (value).

>
>> I don't think I have ever seen that done with instances.

>
> Take a look at JPA:
>
> @Column(name="SURNAME")
> private String lastName;
>
> @Column(name="GIVENNAME")
> private String firstName;
>
> Is that not annotating a field? And annotations can annotate a local variable, too.
>
> It's not annotating 'String'.
>
> Is that not what you wanted?


public void test( @Nullable Foo x, @NotNull Bar y)
{ ... }

--
Lew


Arne Vajh°j 02-09-2013 01:09 AM

Re: PUT DATA
 
On 2/8/2013 8:06 PM, Lew wrote:
> Arne Vajh°j wrote:
>> Maybe I am the only one in the known universe that don't know.
>>
>> But let us say we have:
>>
>> X a = new X(aa);
>> X b = new X(bb);
>>
>> test(a,b);
>>
>> void test(X a,X b) {
>>
>> }
>>
>> How should the annotation look like, how should it be put on and
>> how do I get it in test?

>
> I don't understand your question "How do I get it in test?"


How do I inside the test method retrieve the different
annotations on a an b?

>> I know how to put an annotation on the type X that I can get in
>> test. But that is the same for both a and b. Roedy needs a
>> different annotation (value).
>>
>> I don't think I have ever seen that done with instances.

>
> Take a look at JPA:
>
> @Column(name="SURNAME")
> private String lastName;
>
> @Column(name="GIVENNAME")
> private String firstName;
>
> Is that not annotating a field? And annotations can annotate a local variable, too.
>
> It's not annotating 'String'.
>
> Is that not what you wanted?


Not unless one can call a method with firstName and lastName and
inside that method retrieve the two column names.

Arne




All times are GMT. The time now is 02:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.