MCPcopy Create free account
hub / github.com/M66B/FairEmail / computePrefix

Method computePrefix

app/src/main/java/com/sun/mail/iap/Protocol.java:151–173  ·  view source on GitHub ↗

Compute the tag prefix to be used for this connection. Start with "A" - "Z", then "AA" - "ZZ", and finally "AAA" - "ZZZ". Wrap around after that.

(Properties props, String prefix)

Source from the content-addressed store, hash-verified

149 * Wrap around after that.
150 */
151 private String computePrefix(Properties props, String prefix) {
152 // XXX - in case someone depends on the tag prefix
153 if (PropUtil.getBooleanProperty(props,
154 prefix + ".reusetagprefix", false))
155 return "A";
156 // tag prefix, wrap around after three letters
157 int n = tagNum.getAndIncrement() % (26*26*26 + 26*26 + 26);
158 String tagPrefix;
159 if (n < 26)
160 tagPrefix = new String(new char[] { (char)('A' + n) });
161 else if (n < (26*26 + 26)) {
162 n -= 26;
163 tagPrefix = new String(new char[] {
164 (char)('A' + n/26), (char)('A' + n%26) });
165 } else {
166 n -= (26*26 + 26);
167 tagPrefix = new String(new char[] {
168 (char)('A' + n/(26*26)),
169 (char)('A' + (n%(26*26))/26),
170 (char)('A' + n%26) });
171 }
172 return tagPrefix;
173 }
174
175 /**
176 * Constructor for debugging.

Callers 1

ProtocolMethod · 0.95

Calls 1

getBooleanPropertyMethod · 0.95

Tested by

no test coverage detected