From 12b0ce03d0029bb96bb23cc288ea351a8a1bec75 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 07 Dec 2007 17:36:12 +0000
Subject: [PATCH] This relates to issue 2661 "public APIs must not reference private classes".
---
opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java | 16 +-
/dev/null | 49 -------
opends/build.xml | 10 -
opends/src/messages/src/org/opends/messages/Severity.java | 11 +
opends/resource/Messages.java.stub | 18 ++
opends/src/messages/src/org/opends/messages/Message.java | 20 +-
opends/src/messages/src/org/opends/messages/MessageDescriptor.java | 214 ++++++++++++++++++++++++++----
opends/src/messages/src/org/opends/messages/package-info.java | 2
opends/src/messages/src/org/opends/messages/Category.java | 7
opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java | 18 +-
opends/src/messages/src/org/opends/messages/MessageBuilder.java | 17 +
11 files changed, 255 insertions(+), 127 deletions(-)
diff --git a/opends/build.xml b/opends/build.xml
index 2baace5..20f4d79 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -238,15 +238,9 @@
<genmsg sourceProps="${msg.prop.dir}/task.properties"
destJava="${msg.javagen.dir}/org/opends/messages/TaskMessages.java">
</genmsg>
- <genmsg sourceProps="${msg.prop.dir}/third_party.properties"
- destJava="${msg.javagen.dir}/org/opends/messages/ThirdPartyMessages.java">
- </genmsg>
<genmsg sourceProps="${msg.prop.dir}/tools.properties"
destJava="${msg.javagen.dir}/org/opends/messages/ToolMessages.java">
</genmsg>
- <genmsg sourceProps="${msg.prop.dir}/user_defined.properties"
- destJava="${msg.javagen.dir}/org/opends/messages/UserDefinedMessages.java">
- </genmsg>
<genmsg sourceProps="${msg.prop.dir}/utility.properties"
destJava="${msg.javagen.dir}/org/opends/messages/UtilityMessages.java">
</genmsg>
@@ -1839,7 +1833,9 @@
org/opends/messages/Category.java,
org/opends/messages/Message.java,
org/opends/messages/MessagePropertyKey.java,
- org/opends/messages/MessageDescriptor.java"
+ org/opends/messages/MessageDescriptor.java,
+ org/opends/server/types/PublicAPI.java,
+ org/opends/server/types/StabilityLevel.java"
debug="on" debuglevel="${build.debuglevel}" source="1.5"
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}"/>
diff --git a/opends/resource/Messages.java.stub b/opends/resource/Messages.java.stub
index 95dc265..9a2c76d 100644
--- a/opends/resource/Messages.java.stub
+++ b/opends/resource/Messages.java.stub
@@ -36,12 +36,22 @@
* Directory Server source. It was dynamically generated as part of the
* Directory Server build process and should not be edited directly.
*/
-public class ${CLASS_NAME} {
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.PRIVATE,
+ mayInstantiate=false,
+ mayExtend=false,
+ mayInvoke=true)
+public final class ${CLASS_NAME} {
/** Base property for resource bundle containing messages */
- static private final String BASE = "${BASE}";
+ private static final String BASE = "${BASE}";
- static private ClassLoader webstartClassLoader;
+ private static ClassLoader webstartClassLoader;
+
+ // Prevent instantiation.
+ private ${CLASS_NAME}() {
+ // Do nothing.
+ }
${MESSAGES}
@@ -64,7 +74,7 @@
{
try
{
- Class c = Class.forName("${PACKAGE}.${CLASS_NAME}");
+ Class<?> c = Class.forName("${PACKAGE}.${CLASS_NAME}");
java.net.URL[] urls = new java.net.URL[] {
c.getProtectionDomain().getCodeSource().getLocation()
diff --git a/opends/src/messages/messages/third_party.properties b/opends/src/messages/messages/third_party.properties
deleted file mode 100644
index 6723819..0000000
--- a/opends/src/messages/messages/third_party.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at
-# trunk/opends/resource/legal-notices/OpenDS.LICENSE
-# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at
-# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
-# add the following below this CDDL HEADER, with the fields enclosed
-# by brackets "[]" replaced with your own identifying information:
-# Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Portions Copyright 2006-2007 Sun Microsystems, Inc.
-
-
-
-#
-# Global directives
-#
-global.category=THIRD_PARTY
-
-#
-# Format string definitions
-#
-# Keys must be formatted as follows:
-#
-# [SEVERITY]_[DESCRIPTION]_[ORDINAL]
-#
-# where:
-#
-# SEVERITY is one of:
-# [INFO, MILD_WARN, SEVERE_WARN, MILD_ERR, SEVERE_ERR, FATAL_ERR, DEBUG, NOTICE]
-#
-# DESCRIPTION is an upper case string providing a hint as to the context of
-# the message in upper case with the underscore ('_') character serving as
-# word separator
-#
-# ORDINAL is an integer unique among other ordinals in this file
-#
diff --git a/opends/src/messages/messages/user_defined.properties b/opends/src/messages/messages/user_defined.properties
deleted file mode 100644
index 4b4827d..0000000
--- a/opends/src/messages/messages/user_defined.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at
-# trunk/opends/resource/legal-notices/OpenDS.LICENSE
-# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at
-# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
-# add the following below this CDDL HEADER, with the fields enclosed
-# by brackets "[]" replaced with your own identifying information:
-# Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Portions Copyright 2006-2007 Sun Microsystems, Inc.
-
-
-
-#
-# Global directives
-#
-global.category=USER_DEFINED
-
-#
-# Format string definitions
-#
-# Keys must be formatted as follows:
-#
-# [SEVERITY]_[DESCRIPTION]_[ORDINAL]
-#
-# where:
-#
-# SEVERITY is one of:
-# [INFO, MILD_WARN, SEVERE_WARN, MILD_ERR, SEVERE_ERR, FATAL_ERR, DEBUG, NOTICE]
-#
-# DESCRIPTION is an upper case string providing a hint as to the context of
-# the message in upper case with the underscore ('_') character serving as
-# word separator
-#
-# ORDINAL is an integer unique among other ordinals in this file
-#
diff --git a/opends/src/messages/src/org/opends/messages/Category.java b/opends/src/messages/src/org/opends/messages/Category.java
index c5046e4..b2d33c2 100644
--- a/opends/src/messages/src/org/opends/messages/Category.java
+++ b/opends/src/messages/src/org/opends/messages/Category.java
@@ -36,6 +36,11 @@
* server components. Categories contain an in value that can be
* used as a mask for bitwise operations.
*/
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=false,
+ mayExtend=false,
+ mayInvoke=true)
public enum Category {
/**
@@ -186,7 +191,7 @@
return MASK_VALUE_MAP.get(mask);
}
- private int mask;
+ private final int mask;
/**
* Gets the mask value associated with this category.
diff --git a/opends/src/messages/src/org/opends/messages/Message.java b/opends/src/messages/src/org/opends/messages/Message.java
index 7240bea..e060b6f 100644
--- a/opends/src/messages/src/org/opends/messages/Message.java
+++ b/opends/src/messages/src/org/opends/messages/Message.java
@@ -45,7 +45,13 @@
*
* @see org.opends.messages.MessageDescriptor
*/
-public class Message implements CharSequence, Formattable, Comparable {
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+public final class Message implements CharSequence, Formattable,
+ Comparable<Message> {
/** Represents an empty message string. */
public static final Message EMPTY = Message.raw("");
@@ -149,10 +155,10 @@
}
/** Descriptor of this message. */
- protected MessageDescriptor descriptor;
+ private final MessageDescriptor descriptor;
/** Values used to replace argument specifiers in the format string. */
- protected Object[] args;
+ private final Object[] args;
/**
* Gets the string representation of this message.
@@ -387,13 +393,9 @@
* @param o the object to be compared.
* @return a negative integer, zero, or a positive integer as this object
* is less than, equal to, or greater than the specified object.
- *
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this object.
*/
- public int compareTo(Object o) throws ClassCastException {
- Message thatMessage = (Message)o;
- return toString().compareTo(thatMessage.toString());
+ public int compareTo(Message o) {
+ return toString().compareTo(o.toString());
}
/**
diff --git a/opends/src/messages/src/org/opends/messages/MessageBuilder.java b/opends/src/messages/src/org/opends/messages/MessageBuilder.java
index e412c2f..e462f2d 100644
--- a/opends/src/messages/src/org/opends/messages/MessageBuilder.java
+++ b/opends/src/messages/src/org/opends/messages/MessageBuilder.java
@@ -48,20 +48,25 @@
* a change to reformat the message for a particular locale if
* necessary.
*/
-public class MessageBuilder implements Appendable, CharSequence,
- Serializable
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+public final class MessageBuilder implements Appendable, CharSequence,
+ Serializable
{
private static final long serialVersionUID = -3292823563904285315L;
/** Used internally to store appended messages. */
- StringBuilder sb = new StringBuilder();
+ private final StringBuilder sb = new StringBuilder();
/** Used internally to store appended messages. */
- List<Message> messages = new LinkedList<Message>();
+ private final List<Message> messages = new LinkedList<Message>();
/** Used to render the string representation of appended messages. */
- Locale locale;
+ private final Locale locale;
/**
* Constructs an instance that will build messages
@@ -78,6 +83,7 @@
* @param message initial message
*/
public MessageBuilder(Message message) {
+ this(Locale.getDefault());
append(message);
}
@@ -88,6 +94,7 @@
* @param message initial message
*/
public MessageBuilder(String message) {
+ this(Locale.getDefault());
append(message);
}
diff --git a/opends/src/messages/src/org/opends/messages/MessageDescriptor.java b/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
index 9e39e19..24b5755 100644
--- a/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
+++ b/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
@@ -35,6 +35,11 @@
/**
* Base class for all Message descriptor classes.
*/
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=false,
+ mayExtend=false,
+ mayInvoke=true)
public abstract class MessageDescriptor {
/**
@@ -61,7 +66,12 @@
/**
* Subclass for creating messages with no arguments.
*/
- static public class Arg0 extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg0 extends MessageDescriptor {
/**
* Cached copy of the message created by this descriptor. We can
@@ -122,8 +132,14 @@
/**
* Subclass for creating messages with one argument.
+ * @param <T1> The type of the first message argument.
*/
- static public class Arg1<T1> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg1<T1> extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -175,8 +191,15 @@
/**
* Subclass for creating messages with two arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
*/
- static public class Arg2<T1, T2> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg2<T1, T2> extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -229,8 +252,16 @@
/**
* Subclass for creating messages with three arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
*/
- static public class Arg3<T1, T2, T3> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg3<T1, T2, T3> extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -284,8 +315,17 @@
/**
* Subclass for creating messages with four arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
*/
- static public class Arg4<T1, T2, T3, T4> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg4<T1, T2, T3, T4> extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -340,8 +380,18 @@
/**
* Subclass for creating messages with five arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
*/
- static public class Arg5<T1, T2, T3, T4, T5> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg5<T1, T2, T3, T4, T5> extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -397,8 +447,20 @@
/**
* Subclass for creating messages with six arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
*/
- static public class Arg6<T1, T2, T3, T4, T5, T6> extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg6<T1, T2, T3, T4, T5, T6> extends
+ MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -455,8 +517,20 @@
/**
* Subclass for creating messages with seven arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
+ * @param <T7> The type of the seventh message argument.
*/
- static public class Arg7<T1, T2, T3, T4, T5, T6, T7>
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg7<T1, T2, T3, T4, T5, T6, T7>
extends MessageDescriptor
{
@@ -516,8 +590,21 @@
/**
* Subclass for creating messages with eight arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
+ * @param <T7> The type of the seventh message argument.
+ * @param <T8> The type of the eighth message argument.
*/
- static public class Arg8<T1, T2, T3, T4, T5, T6, T7, T8>
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg8<T1, T2, T3, T4, T5, T6, T7, T8>
extends MessageDescriptor
{
@@ -579,8 +666,22 @@
/**
* Subclass for creating messages with nine arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
+ * @param <T7> The type of the seventh message argument.
+ * @param <T8> The type of the eighth message argument.
+ * @param <T9> The type of the ninth message argument.
*/
- static public class Arg9<T1, T2, T3, T4, T5, T6, T7, T8, T9>
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg9<T1, T2, T3, T4, T5, T6, T7, T8, T9>
extends MessageDescriptor {
/**
@@ -642,8 +743,23 @@
/**
* Subclass for creating messages with ten arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
+ * @param <T7> The type of the seventh message argument.
+ * @param <T8> The type of the eighth message argument.
+ * @param <T9> The type of the ninth message argument.
+ * @param <T10> The type of the tenth message argument.
*/
- static public class Arg10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
extends MessageDescriptor {
/**
@@ -706,8 +822,24 @@
/**
* Subclass for creating messages with eleven arguments.
+ * @param <T1> The type of the first message argument.
+ * @param <T2> The type of the second message argument.
+ * @param <T3> The type of the third message argument.
+ * @param <T4> The type of the fourth message argument.
+ * @param <T5> The type of the fifth message argument.
+ * @param <T6> The type of the sixth message argument.
+ * @param <T7> The type of the seventh message argument.
+ * @param <T8> The type of the eighth message argument.
+ * @param <T9> The type of the ninth message argument.
+ * @param <T10> The type of the tenth message argument.
+ * @param <T11> The type of the eleventh message argument.
*/
- static public class Arg11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class Arg11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
extends MessageDescriptor
{
@@ -776,7 +908,12 @@
* defined with more arguments that can be handled with the current
* number of subclasses
*/
- static public class ArgN extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=true,
+ mayExtend=false,
+ mayInvoke=true)
+ static public final class ArgN extends MessageDescriptor {
/**
* Creates a parameterized instance.
@@ -832,7 +969,10 @@
* plugins may want to use the mechanism to create messages without
* storing their strings in resource bundles.
*/
- static class Raw extends MessageDescriptor {
+ @org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.PRIVATE
+ )
+ static final class Raw extends MessageDescriptor {
private String formatString;
@@ -903,13 +1043,13 @@
}
/** String for accessing backing resource bundle. */
- protected String rbBase;
+ private final String rbBase;
/** Used for accessing format string from the resource bundle. */
- protected String key;
+ private final String key;
/** Category for messages created by this descriptor. */
- protected Category category;
+ private final Category category;
/**
* Custom mask associated with messages created by this
@@ -917,35 +1057,35 @@
* to indicate that the mask should come from
* <code>category</code>.
*/
- protected Integer mask;
+ private final Integer mask;
/**
* The severity associated with messages created by this
* descriptor.
*/
- protected Severity severity;
+ private final Severity severity;
/**
* The value that makes a message unique among other messages
* having the same severity and category. May be null for
* raw messages.
*/
- protected Integer ordinal;
+ private final Integer ordinal;
/**
* The class loader to be used to retrieve the ResourceBundle. If null
* the default class loader will be used.
*/
- protected ClassLoader classLoader;
+ private final ClassLoader classLoader;
- private Map<Locale,String> formatStrMap = new HashMap<Locale,String>();
+ private final Map<Locale,String> formatStrMap = new HashMap<Locale,String>();
/**
* Obtains the category of this descriptor. Gauranteed not to be null.
* @return Category of this message
*/
- public Category getCategory() {
+ public final Category getCategory() {
return this.category;
}
@@ -953,7 +1093,7 @@
* Obtains the severity of this descriptor. Gauranteed not to be null.
* @return Category of this message
*/
- public Severity getSeverity() {
+ public final Severity getSeverity() {
return this.severity;
}
@@ -962,7 +1102,7 @@
* unique among messages defined with the same category and severity.
* @return int ordinal value
*/
- public int getOrdinal() {
+ public final int getOrdinal() {
if (this.ordinal == null)
return 0;
else
@@ -973,7 +1113,7 @@
* Returns the ID unique to all OpenDS messages.
* @return unique ID
*/
- public int getId() {
+ public final int getId() {
if (this.ordinal == null) { // ordinal may be null for raw messages
return NULL_ID;
} else {
@@ -987,7 +1127,7 @@
* explicitly set in the constructor.
* @return Integer mask value
*/
- public int getMask() {
+ public final int getMask() {
if (this.mask != null) {
return this.mask;
} else {
@@ -1000,7 +1140,7 @@
* May be null for raw messages.
* @return key of this message
*/
- public String getKey() {
+ public final String getKey() {
return this.key;
}
@@ -1010,7 +1150,7 @@
* May be null for raw messages.
* @return string base
*/
- public String getBase() {
+ public final String getBase() {
return this.rbBase;
}
@@ -1028,7 +1168,7 @@
* locale.
* @return format string
*/
- String getFormatString() {
+ final String getFormatString() {
return getFormatString(Locale.getDefault());
}
@@ -1058,7 +1198,7 @@
* @return boolean where true indicates that the format
* string requires formatting
*/
- protected boolean containsArgumentLiterals(String s) {
+ protected final boolean containsArgumentLiterals(String s) {
return s.matches(".*%[n|%].*"); // match Formatter literals
}
@@ -1100,6 +1240,7 @@
this.severity = severity;
this.ordinal = ordinal;
this.classLoader = classLoader;
+ this.mask = null;
}
/**
@@ -1116,7 +1257,16 @@
private MessageDescriptor(String rbBase, String key, int mask,
Severity severity, Integer ordinal,
ClassLoader classLoader) {
- this(rbBase, key, Category.USER_DEFINED, severity, ordinal, classLoader);
+ if (severity == null) {
+ throw new NullPointerException("Null Severity value for message " +
+ "descriptor with key " + key);
+ }
+ this.rbBase = rbBase;
+ this.key = key;
+ this.category = Category.USER_DEFINED;
+ this.severity = severity;
+ this.ordinal = ordinal;
+ this.classLoader = classLoader;
this.mask = mask;
}
diff --git a/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java b/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
index 0a2306b..af6c205 100644
--- a/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
+++ b/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
@@ -46,20 +46,22 @@
* descriptors are stored in the text file "descriptors.reg" which is
* generated during the OpenDS build process.
*/
-public class MessageDescriptorRegistry {
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.PRIVATE)
+final class MessageDescriptorRegistry {
private static final String REGISTRY_FILE = "descriptors.reg";
- private static final Set<Class> REGISTERED_MESSAGE_CLASSES =
- new HashSet<Class>();
+ private static final Set<Class<?>> REGISTERED_MESSAGE_CLASSES =
+ new HashSet<Class<?>>();
private static final Map<Integer, MessageDescriptor>
ID_TO_DESCRIPTORS =
new HashMap<Integer,MessageDescriptor>();
- private static final Map<Class, List<MessageDescriptor>>
+ private static final Map<Class<?>, List<MessageDescriptor>>
CLASS_TO_DESCRIPTORS =
- new HashMap<Class,List<MessageDescriptor>>();
+ new HashMap<Class<?>,List<MessageDescriptor>>();
static {
@@ -71,7 +73,7 @@
try {
while (null != (line = reader.readLine())) {
String descClassName = line.trim();
- Class descClass;
+ Class<?> descClass;
try {
descClass = Class.forName(descClassName);
List<MessageDescriptor> mdList = new LinkedList<MessageDescriptor>();
@@ -125,7 +127,7 @@
*/
public static List<MessageDescriptor> getMessageDescriptorsForClass(
- Class mdClass)
+ Class<?> mdClass)
{
return Collections.unmodifiableList(CLASS_TO_DESCRIPTORS.get(mdClass));
}
@@ -136,7 +138,7 @@
*
* @return list of classes
*/
- public static Set<Class> getRegisteredClasses() {
+ public static Set<Class<?>> getRegisteredClasses() {
return Collections.unmodifiableSet(REGISTERED_MESSAGE_CLASSES);
}
diff --git a/opends/src/messages/src/org/opends/messages/Severity.java b/opends/src/messages/src/org/opends/messages/Severity.java
index df75775..820b01a 100644
--- a/opends/src/messages/src/org/opends/messages/Severity.java
+++ b/opends/src/messages/src/org/opends/messages/Severity.java
@@ -39,6 +39,11 @@
* integer value that can be used for bitwise operations as well
* as a short abbreviated string form of each value.
*/
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
+ mayInstantiate=false,
+ mayExtend=false,
+ mayInvoke=true)
public enum Severity {
/**
@@ -153,9 +158,9 @@
return parseMask(msgId & 0x000F0000);
}
- private int mask;
- private String propertyKeyForm;
- private String messageDescriptorForm;
+ private final int mask;
+ private final String propertyKeyForm;
+ private final String messageDescriptorForm;
/**
* Returns the mask associated with this <code>Severity</code>.
diff --git a/opends/src/messages/src/org/opends/messages/package-info.java b/opends/src/messages/src/org/opends/messages/package-info.java
index db6e11e..968345e 100644
--- a/opends/src/messages/src/org/opends/messages/package-info.java
+++ b/opends/src/messages/src/org/opends/messages/package-info.java
@@ -39,5 +39,7 @@
* specifiers that are used to parameterize messages according to the rules of
* <code>java.util.Formatter</code>.
*/
+@org.opends.server.types.PublicAPI(
+ stability=org.opends.server.types.StabilityLevel.VOLATILE)
package org.opends.messages;
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
index aebf0ad..bb04715 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
@@ -31,8 +31,6 @@
import org.testng.annotations.*;
import java.util.Set;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
@@ -63,8 +61,8 @@
@DataProvider(name = "message classes")
public Object[][] getMessageClasses() {
- Set<Class> mdClasses = MessageDescriptorRegistry.getRegisteredClasses();
- List<Class> classesToTest = new ArrayList<Class>(mdClasses);
+ Set<Class<?>> mdClasses = MessageDescriptorRegistry.getRegisteredClasses();
+ List<Class<?>> classesToTest = new ArrayList<Class<?>>(mdClasses);
// These newer message files don't comply
classesToTest.remove(AdminToolMessages.class);
@@ -86,7 +84,7 @@
* class through reflection
*/
@Test(dataProvider = "message classes")
- public void testFormatStringsDontEndWithPeriod(Class messagesClass)
+ public void testFormatStringsDontEndWithPeriod(Class<?> messagesClass)
throws IllegalAccessException
{
Field[] fa = messagesClass.getFields();
@@ -115,10 +113,10 @@
*/
@Test
public void testCategoriesDontSpanFiles() {
- Map<Category,Class> categoriesToClass = new HashMap<Category,Class>();
- Set categories = EnumSet.allOf(Category.class);
- Set<Class> msgClasses = MessageDescriptorRegistry.getRegisteredClasses();
- for (Class msgClass : msgClasses) {
+ Map<Category,Class<?>> categoriesToClass = new HashMap<Category,Class<?>>();
+ Set<?> categories = EnumSet.allOf(Category.class);
+ Set<Class<?>> msgClasses = MessageDescriptorRegistry.getRegisteredClasses();
+ for (Class<?> msgClass : msgClasses) {
List<MessageDescriptor> mds =
MessageDescriptorRegistry.getMessageDescriptorsForClass(msgClass);
Category currentCategory = null;
--
Gitblit v1.10.0