[Clirr-devel] CVS: clirr/src/java/net/sf/clirr/event ApiDifference.java,1.11,1.12
Status: Alpha
Brought to you by:
lkuehne
From: Simon K. <s_k...@us...> - 2004-06-28 06:53:10
|
Update of /cvsroot/clirr/clirr/src/java/net/sf/clirr/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3709/src/java/net/sf/clirr/event Modified Files: ApiDifference.java Log Message: Changes to support new Message framework (all backwards-compatible). Index: ApiDifference.java =================================================================== RCS file: /cvsroot/clirr/clirr/src/java/net/sf/clirr/event/ApiDifference.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ApiDifference.java 27 Jun 2004 14:21:35 -0000 1.11 +++ ApiDifference.java 28 Jun 2004 06:53:00 -0000 1.12 @@ -29,6 +29,12 @@ { private static final int HASHCODE_MAGIC = 29; + /** + * Object representing the message text to be output (or null if + * the constructor which takes a message string directly is used). + */ + private Message message = null; + /** human readable change report. */ private String report; @@ -118,6 +124,78 @@ this.affectedMethod = method; } + /** + * Invokes the two-severity-level version of this constructor. + */ + public ApiDifference( + Message message, + Severity severity, + String clazz, + String method, + String field, + String[] args) + { + this(message, severity, severity, clazz, method, field, args); + } + + /** + * Create a new API difference representation. + * + * @param message is the key of a human readable string describing the + * change that was made. + * + * @param binarySeverity the severity in terms of binary compatibility, + * must be non-null. + * + * @param sourceSeverity the severity in terms of source code compatibility, + * must be non-null. + * + * @param clazz is the fully-qualified name of the class in which the + * change occurred. + * + * @param method the method signature of the method that changed, + * <code>null</code> if no method was affected. + * + * @param field the field name where the change occured, <code>null</code> + * if no field was affected. + * + * @param args is a set of additional change-specific strings which are + * made available for the message description string to reference via + * the standard {n} syntax. + */ + public ApiDifference( + Message message, + Severity binarySeverity, + Severity sourceSeverity, + String clazz, + String method, + String field, + String[] args) + { + String desc = MessageManager.getInstance().getDesc(message); + int nArgs = 0; + if (args != null) + { + nArgs = args.length; + } + String[] strings = new String[nArgs + 3]; + strings[0] = clazz; + strings[1] = method; + strings[2] = field; + for (int i = 0; i < nArgs; ++i) + { + strings[i + 3] = args[i]; + } + + this.message = message; + this.report = java.text.MessageFormat.format(desc, strings); + this.binaryCompatibilitySeverity = binarySeverity; + this.sourceCompatibilitySeverity = sourceSeverity; + this.affectedClass = clazz; + this.affectedField = field; + this.affectedMethod = method; + } + private void checkNonNull(Object o) { if (o == null) @@ -156,6 +234,9 @@ return sourceCompatibilitySeverity; } + /** + * Return the maximum of the binary and source compatibility severities. + */ public Severity getMaximumSeverity() { final Severity src = getSourceCompatibilitySeverity(); |