Discussion:
[jira] [Created] (DIRAPI-328) Fix inconsistency in Attribute and Value
Stefan Seelmann (JIRA)
2018-11-25 13:17:00 UTC
Permalink
Stefan Seelmann created DIRAPI-328:
--------------------------------------

Summary: Fix inconsistency in Attribute and Value
Key: DIRAPI-328
URL: https://issues.apache.org/jira/browse/DIRAPI-328
Project: Directory Client API
Issue Type: Improvement
Reporter: Stefan Seelmann
Assignee: Stefan Seelmann
Fix For: 2.0.0.AM3


Inconsistent method names:
* Attribute: getString() and getBytes()
* Value: getValue() and getBytes()
* Proposal: Rename Value.getValue() to Value.getString()

Inconsistent and wrong documented error handling:
* Attribute: getString() and getBytes() check for isHumanReadable and throw LdapInvalidAttributeValueException
* Value: getValue()/getString() tries to UTF-8 encode bytes if not human readable, which doesn't work always, and javadoc says "returns null"
* Value: getBytes() doesn't check if is human readable
* Proposal: Make Value behave like Attribute, i.e. throw LdapInvalidAttributeValueException

Opinions?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Emmanuel Lecharny (JIRA)
2018-11-26 04:37:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/DIRAPI-328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16698468#comment-16698468 ]

Emmanuel Lecharny commented on DIRAPI-328:
------------------------------------------

+1 to rename the {{Value.getValue()}} to {{Valu.getString()}}

+1 to hav the {{Value.getString()}} throwing a {{LdapInvalidAttributeValueException}} instead of returning a empty string.

{{Value.getBytes()}} has a special purpose : return the {{byte[]}} representing the value, even if the value is a String. This is mainly use when we encode a message. In a sense, it will always work, because the interned value is computed when the String is stored :

{code:java}
public Value( String upValue )
{
this.upValue = upValue;

// We can't normalize the value, we store it as is
normValue = upValue;

if ( upValue != null )
{
bytes = Strings.getBytesUtf8( upValue ); <---- Here
}

hashCode();
}
{code}
Post by Stefan Seelmann (JIRA)
Fix inconsistency in Attribute and Value
----------------------------------------
Key: DIRAPI-328
URL: https://issues.apache.org/jira/browse/DIRAPI-328
Project: Directory Client API
Issue Type: Improvement
Reporter: Stefan Seelmann
Assignee: Stefan Seelmann
Priority: Major
Fix For: 2.0.0.AM3
* Attribute: getString() and getBytes()
* Value: getValue() and getBytes()
* Proposal: Rename Value.getValue() to Value.getString()
* Attribute: getString() and getBytes() check for isHumanReadable and throw LdapInvalidAttributeValueException
* Value: getValue()/getString() tries to UTF-8 encode bytes if not human readable, which doesn't work always, and javadoc says "returns null"
* Value: getBytes() doesn't check if is human readable
* Proposal: Make Value behave like Attribute, i.e. throw LdapInvalidAttributeValueException
Opinions?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
Emmanuel Lecharny (JIRA)
2018-11-26 07:31:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/DIRAPI-328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16698561#comment-16698561 ]

Emmanuel Lecharny commented on DIRAPI-328:
------------------------------------------

Rthinking about it, it may be a good idea to have a {{getUtf8()}} method that is distinct from the {{getBytes()}} method, as they semantically differ.
Post by Stefan Seelmann (JIRA)
Fix inconsistency in Attribute and Value
----------------------------------------
Key: DIRAPI-328
URL: https://issues.apache.org/jira/browse/DIRAPI-328
Project: Directory Client API
Issue Type: Improvement
Reporter: Stefan Seelmann
Assignee: Stefan Seelmann
Priority: Major
Fix For: 2.0.0.AM3
* Attribute: getString() and getBytes()
* Value: getValue() and getBytes()
* Proposal: Rename Value.getValue() to Value.getString()
* Attribute: getString() and getBytes() check for isHumanReadable and throw LdapInvalidAttributeValueException
* Value: getValue()/getString() tries to UTF-8 encode bytes if not human readable, which doesn't work always, and javadoc says "returns null"
* Value: getBytes() doesn't check if is human readable
* Proposal: Make Value behave like Attribute, i.e. throw LdapInvalidAttributeValueException
Opinions?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Loading...