Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33288 > unrolled thread
| Started by | mike <mikaelpetterson@hotmail.com> |
|---|---|
| First post | 2015-12-03 03:33 -0800 |
| Last post | 2015-12-04 00:22 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
Oo questions mike <mikaelpetterson@hotmail.com> - 2015-12-03 03:33 -0800
Re: Oo questions Arne Vajhøj <arne@vajhoej.dk> - 2015-12-03 19:04 -0500
Re: Oo questions mike <mikaelpetterson@hotmail.com> - 2015-12-04 00:22 -0800
| From | mike <mikaelpetterson@hotmail.com> |
|---|---|
| Date | 2015-12-03 03:33 -0800 |
| Subject | Oo questions |
| Message-ID | <64d27264-1b2d-49cb-8492-71306709f92e@googlegroups.com> |
This is the code users have:
<code>
ObjectAttribute attr = retriever.getAttr("name");
</code>
ObjectAttribute is an abstract class with a method called getValue().
We found a fault, when we had a sequence with one element, that getAttr(String) returned wrong type for certain "name".
Before getAttr() returned ValueAttribute but so after fix we return
SequenceAttribute which is the correct type. Both ValueAttribute and SequenceAttribute are implementations of ObjectAttribute.
When this was fixed we could see that the impact for end-user would be huge so we would like to give them a grace period, since users do
<code>
attr.getValue()
</code>
which now gives a different outputformat SequenceAttribute is used.
So we created a SequenceAttributeProxy ( since SequenceAttribute is used in other libraries that don't need this) that extends SequenceAttribute and returns the old value like:
<code>
public class SequenceAttributeProxy extends SequenceAttribute {
public SequenceAttributeProxy (String name) {
super(name);
}
@Override
public String getValue() {
if (sequence.size() == 1) {
String correctFormat = getValueAsJson().toString();
String incorrectFormat = sequence.get(0).getValue();
//Do some logging
return sequence.get(0).getValue();
}
return getValueAsJson().toString();
}
}
</code>
When we checked user code we discovered that some user have done it correct:
<code>
SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
</code>
So users have both:
1. ObjectAttribute attr = retriever.getAttr("name");
2. SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
But we only want users of 1. to see logging and return the old value.
Problem is that getAttr() now returns SequenceAttribute for both 1 and 2.
And we have not found a way to distinguish between them so we can use that in our Proxy.
Any ideas?
//mike
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-12-03 19:04 -0500 |
| Message-ID | <n3qlaa$2gq$2@speranza.aioe.org> |
| In reply to | #33288 |
On 12/3/2015 6:33 AM, mike wrote:
> This is the code users have:
>
> <code>
> ObjectAttribute attr = retriever.getAttr("name");
> </code>
> ObjectAttribute is an abstract class with a method called getValue().
>
> We found a fault, when we had a sequence with one element, that
> getAttr(String) returned wrong type for certain "name".
>
> Before getAttr() returned ValueAttribute but so after fix we return
> SequenceAttribute which is the correct type. Both ValueAttribute and
> SequenceAttribute are implementations of ObjectAttribute.
>
> When this was fixed we could see that the impact for end-user would
> behuge so we would like to give them a grace period, since users do
>
> <code>
> attr.getValue()
> </code>
> which now gives a different outputformat SequenceAttribute is used.
>
> So we created a SequenceAttributeProxy ( since SequenceAttribute is
> used in other libraries that don't need this) that extends
> SequenceAttribute and returns the old value like:
> When we checked user code we discovered that some user have done it correct:
>
> <code>
> SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
> </code>
>
> So users have both:
>
> 1. ObjectAttribute attr = retriever.getAttr("name");
>
>
> 2. SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
>
>
> But we only want users of 1. to see logging and return the old value.
>
> Problem is that getAttr() now returns SequenceAttribute for both 1 and 2.
>
> And we have not found a way to distinguish between them so we can use that in our Proxy.
I don't think you can as it is.
#1 is executed as:
1) call retriever.getAttr("name")
2) assign to attr
#2 is executed as as:
1) call retriever.getAttr("name")
2) cast
3) assign to attr
You need to change something else.
Arne
[toc] | [prev] | [next] | [standalone]
| From | mike <mikaelpetterson@hotmail.com> |
|---|---|
| Date | 2015-12-04 00:22 -0800 |
| Message-ID | <4e8e3193-e3c1-412d-98ed-ca9a086671ab@googlegroups.com> |
| In reply to | #33288 |
Hi, Thx. Since to see that you got the same conclusion. There is no way to do this. br, //mike
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web