You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Norman Maurer (JIRA)" <se...@james.apache.org> on 2010/10/04 21:11:33 UTC
[jira] Commented: (IMAP-221) nz-numbers must be unsigned 32bit ints
[ https://issues.apache.org/jira/browse/IMAP-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917715#action_12917715 ]
Norman Maurer commented on IMAP-221:
------------------------------------
Ok so the part with parsing the command is done. But I think we should do some kind of restriction/validation in the stored too. So what about introducing a new class calling NzNumber and use it as replacement for long/Long when working with message uids. Something like:
------------------- CODE -------------
/**
* Represent a number which is >= {@link #MIN_NZ_NUMBER} and <= {@link #MAX_NZ_NUMBER}. This allows Mailbox implementations to be used
* with IMAP and POP3
*
*/
public final class NzNumber {
public static final long MAX_NZ_NUMBER = 4294967295L;
public static final long MIN_NZ_NUMBER = 1L;
private Long value;
/**
* Construct a new {@link NzNumber} which holds the given value
*
* @param value number
* @throws IllegalArgumentException thrown if the value is < {@link #MIN_NZ_NUMBER} or > {@link #MAX_NZ_NUMBER}
*/
public NzNumber(long value) {
if (isValid(value) == false) throw new IllegalArgumentException("Given value must be >= " + MIN_NZ_NUMBER + " and <=" + MAX_NZ_NUMBER);
this.value = value;
}
/**
* Return the value of the {@link NzNumber}
*
* @return value
*
*/
public long getValue() {
return value;
}
/**
* Return true if the given value is valid, which basicly means it is >= {@link #MIN_NZ_NUMBER} and <= {@link #MAX_NZ_NUMBER}
*
* @param value
* @return valid
*/
public static boolean isValid(long value) {
if (value < MIN_NZ_NUMBER || value > MAX_NZ_NUMBER) return false;
return true;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof NzNumber) {
if (getValue() == ((NzNumber) obj).getValue()) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return value.hashCode();
}
}
-----------------
WDYT ?
> nz-numbers must be unsigned 32bit ints
> --------------------------------------
>
> Key: IMAP-221
> URL: https://issues.apache.org/jira/browse/IMAP-221
> Project: JAMES Imap
> Issue Type: Bug
> Components: Parser, Protocol
> Affects Versions: 0.1
> Reporter: Norman Maurer
> Assignee: Norman Maurer
> Fix For: 0.2
>
>
> Currently we use long/Long as return type when a message uid is retrieved. Thats wrong as the RFC only allow 32-Bit numbers. We should change the methods to make this clear.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org