DateValue.java

Index Score
net.sf.saxon.value
Saxon

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
JAVA0034JAVA0034 Missing braces in if statement
JAVA0076JAVA0076 Use of magic number
DECL_COMMENTSComments in declarations
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
RETURNSNumber of return points from functions
INTERFACE_COMPLEXITYInterface complexity
CYCLOMATICCyclomatic complexity
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
COMPARISONSNumber of comparison operators
SIZESize of the file in bytes
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
PARAMSNumber of formal parameter declarations
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
OPERANDSNumber of operands
BLOCKSNumber of blocks
LOGICAL_LINESNumber of statements
EXITSProcedure exits
ELOCEffective lines of code
LINESNumber of lines in the source file
LINE_COMMENTNumber of line comments
DOC_COMMENTNumber of javadoc comment lines
LOCLines of code
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
FUNCTIONSNumber of function declarations
UNIQUE_OPERATORSNumber of unique operators
COMMENTSComment lines
JAVA0264JAVA0264 Integer math in long context - check for overflow
JAVA0031JAVA0031 Case statement not properly closed
JAVA0266JAVA0266 Use of System.out
JAVA0084JAVA0084 Should use compound assignment operator
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0130JAVA0130 Non-static method does not use instance fields
LOOPSNumber of loops
JAVA0145JAVA0145 Tab character used in source file
package net.sf.saxon.value; import net.sf.saxon.Configuration; import net.sf.saxon.Err; import net.sf.saxon.sort.ComparisonKey; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.functions.Component; import net.sf.saxon.om.FastStringBuffer; import net.sf.saxon.trans.DynamicError; import net.sf.saxon.trans.XPathException; import net.sf.saxon.type.*; import java.util.*; /** * A value of type Date. Note that a Date may include a TimeZone. */ public class DateValue extends CalendarValue { protected int year; // unlike the lexical representation, includes a year zero protected byte month; protected byte day; /** * Default constructor needed for subtyping */ protected DateValue() {} /** * Constructor given a year, month, and day. Performs no validation. * @param year The year as held internally (note that the year before 1AD is 0) * @param month The month, 1-12 * @param day The day 1-31 */ public DateValue(int year, byte month, byte day) { this.year = year; this.month = month; this.day = day; } /** * Constructor given a year, month, and day, and timezone. Performs no validation. * @param year The year as held internally (note that the year before 1AD is 0) * @param month The month, 1-12 * @param day The day 1-31 * @param tz the timezone displacement in minutes from UTC. Supply the value * {@link CalendarValue#NO_TIMEZONE} if there is no timezone component. */ public DateValue(int year, byte month, byte day, int tz) { this.year = year; this.month = month; this.day = day; setTimezoneInMinutes(tz); } /** * Constructor: create a dateTime value from a supplied string, in * ISO 8601 format */ public DateValue(CharSequence s) throws XPathException { setLexicalValue(s); } /** * Create a DateValue * @param calendar the absolute date/time value * @param tz The timezone offset from GMT in minutes, positive or negative; or the special * value NO_TIMEZONE indicating that the value is not in a timezone */ public DateValue(GregorianCalendar calendar, int tz) { // Note: this constructor is not used by Saxon itself, but might be used by applications int era = calendar.get(GregorianCalendar.ERA); year = calendar.get(Calendar.YEAR); if (era == GregorianCalendar.BC) { year = 1-year; } month = (byte)(calendar.get(Calendar.MONTH)+1); day = (byte)(calendar.get(Calendar.DATE)); setTimezoneInMinutes(tz); } /** * Initialize the DateValue using a character string in the format yyyy-mm-dd and an optional time zone. * Input must have format [-]yyyy-mm-dd[([+|-]hh:mm | Z)] * @param s the supplied string value * @throws net.sf.saxon.trans.XPathException */ public void setLexicalValue(CharSequence s) throws XPathException { StringTokenizer tok = new StringTokenizer(Whitespace.trimWhitespace(s).toString(), "-:+Z", true); try { if (!tok.hasMoreElements()) badDate("Too short", s); String part = (String)tok.nextElement(); int era = +1; if ("+".equals(part)) { badDate("Date may not start with '+' sign", s); } else if ("-".equals(part)) { era = -1; part = (String)tok.nextElement(); } if (part.length() < 4) { badDate("Year is less than four digits", s); } if (part.length() > 4 && part.charAt(0) == '0') { badDate("When year exceeds 4 digits, leading zeroes are not allowed", s); } year = Integer.parseInt(part) * era; if (year==0) { badDate("Year zero is not allowed", s); } if (era < 0) { year++; // internal representation allows a year zero. } if (!tok.hasMoreElements()) badDate("Too short", s); if (!"-".equals(tok.nextElement())) badDate("Wrong delimiter after year", s); if (!tok.hasMoreElements()) badDate("Too short", s); part = (String)tok.nextElement(); if (part.length() != 2) badDate("Month must be two digits", s); month = (byte)Integer.parseInt(part); if (month < 1 || month > 12) badDate("Month is out of range", s); if (!tok.hasMoreElements()) badDate("Too short", s); if (!"-".equals(tok.nextElement())) badDate("Wrong delimiter after month", s); if (!tok.hasMoreElements()) badDate("Too short", s); part = (String)tok.nextElement(); if (part.length() != 2) badDate("Day must be two digits", s); day = (byte)Integer.parseInt(part); if (day < 1 || day > 31) badDate("Day is out of range", s); int tzOffset; if (tok.hasMoreElements()) { String delim = (String)tok.nextElement(); if ("Z".equals(delim)) { tzOffset = 0; if (tok.hasMoreElements()) badDate("Continues after 'Z'", s); setTimezoneInMinutes(tzOffset); } else if (!(!"+".equals(delim) && !"-".equals(delim))) { if (!tok.hasMoreElements()) badDate("Missing timezone", s); part = (String)tok.nextElement(); int tzhour = Integer.parseInt(part); if (part.length() != 2) badDate("Timezone hour must be two digits", s); if (tzhour > 14) badDate("Timezone hour is out of range", s); //if (tzhour > 12) badDate("Because of Java limitations, Saxon currently limits the timezone to +/- 12 hours", s); if (!tok.hasMoreElements()) badDate("No minutes in timezone", s); if (!":".equals(tok.nextElement())) badDate("Wrong delimiter after timezone hour", s); if (!tok.hasMoreElements()) badDate("No minutes in timezone", s); part = (String)tok.nextElement(); int tzminute = Integer.parseInt(part); if (part.length() != 2) badDate("Timezone minute must be two digits", s); if (tzminute > 59) badDate("Timezone minute is out of range", s); if (tok.hasMoreElements()) badDate("Continues after timezone", s); tzOffset = (tzhour*60 + tzminute); if ("-".equals(delim)) tzOffset = -tzOffset; setTimezoneInMinutes(tzOffset); } else { badDate("Timezone format is incorrect", s); } } if (!isValidDate(year, month, day)) { badDate("Non-existent date", s); } } catch (NumberFormatException err) { badDate("Non-numeric component", s); } } private void badDate(String msg, CharSequence value) throws ValidationException { ValidationException err = new ValidationException( "Invalid date " + Err.wrap(value, Err.VALUE) + " (" + msg + ")"); err.setErrorCode("FORG0001"); throw err; } /** * Get the year component of the date (in local form) */ public int getYear() { return year; } /** * Get the month component of the date (in local form) */ public byte getMonth() { return month; } /** * Get the day component of the date (in local form) */ public byte getDay() { return day; } /** * Test whether a candidate date is actually a valid date in the proleptic Gregorian calendar */ private static byte[] daysPerMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; public static boolean isValidDate(int year, int month, int day) { if (month > 0 && month <= 12 && day > 0 && day <= daysPerMonth[month-1]) { return true; } if (month == 2 && day == 29) { return isLeapYear(year); } return false; } /** * Test whether a year is a leap year */ public static boolean isLeapYear(int year) { return (year % 4 == 0) && !(year % 100 == 0 && !(year % 400 == 0)); } /** * Get the date that immediately follows a given date * @return a new DateValue with no timezone information */ public static DateValue tomorrow(int year, byte month, byte day) { if (DateValue.isValidDate(year, month, day+1)) { return new DateValue(year, month, (byte)(day+1)); } else if (month < 12) { return new DateValue(year, (byte)(month+1), (byte)1); } else { return new DateValue(year+1, (byte)1, (byte)1); } } /** * Get the date that immediately precedes a given date * @return a new DateValue with no timezone information */ public static DateValue yesterday(int year, byte month, byte day) { if (day > 1) { return new DateValue(year, month, (byte)(day-1)); } else if (month > 1) { if (month == 3 && isLeapYear(year)) { return new DateValue(year, (byte)2, (byte)29); } else { return new DateValue(year, (byte)(month-1), daysPerMonth[month-2]); } } else { return new DateValue(year-1, (byte)12, (byte)31); } } /** * Convert to target data type * @param requiredType an integer identifying the required atomic type * @param context * @return an AtomicValue, a value of the required type; or an ErrorValue */ public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context) { switch(requiredType.getPrimitiveType()) { case Type.DATE: case Type.ANY_ATOMIC: case Type.ITEM: return this; case Type.DATE_TIME: return toDateTime(); case Type.STRING: return new StringValue(getStringValueCS()); case Type.UNTYPED_ATOMIC: return new UntypedAtomicValue(getStringValueCS()); case Type.G_YEAR: { return new GYearValue(year, getTimezoneInMinutes()); } case Type.G_YEAR_MONTH: { return new GYearMonthValue(year, month, getTimezoneInMinutes()); } case Type.G_MONTH: { return new GMonthValue(month, getTimezoneInMinutes()); } case Type.G_MONTH_DAY: { return new GMonthDayValue(month, day, getTimezoneInMinutes()); } case Type.G_DAY:{ return new GDayValue(day, getTimezoneInMinutes()); } default: ValidationException err = new ValidationException("Cannot convert date to " + requiredType.getDisplayName()); err.setErrorCode("XPTY0004"); err.setIsTypeError(true); return new ValidationErrorValue(err); } } /** * Convert to DateTime */ public DateTimeValue toDateTime() { return new DateTimeValue(year, month, day, (byte)0, (byte)0, (byte)0, 0, getTimezoneInMinutes()); } /** * Convert to string * @return ISO 8601 representation. */ public CharSequence getStringValueCS() { FastStringBuffer sb = new FastStringBuffer(16); int yr = year; if (year <= 0) { sb.append('-'); yr = -yr +1; // no year zero in lexical space } appendString(sb, yr, (yr>9999 ? (yr+"").length() : 4)); sb.append('-'); appendTwoDigits(sb, month); sb.append('-'); appendTwoDigits(sb, day); if (hasTimezone()) { appendTimezone(sb); } return sb; } public GregorianCalendar getCalendar() { int tz = (hasTimezone() ? getTimezoneInMinutes() : 0); TimeZone zone = new SimpleTimeZone(tz*60000, "LLL"); GregorianCalendar calendar = new GregorianCalendar(zone); calendar.setGregorianChange(new Date(Long.MIN_VALUE)); calendar.clear(); calendar.setLenient(false); int yr = year; if (year <= 0) { yr = 1-year; calendar.set(Calendar.ERA, GregorianCalendar.BC); } calendar.set(yr, month-1, day); calendar.set(Calendar.ZONE_OFFSET, tz*60000); calendar.set(Calendar.DST_OFFSET, 0); calendar.getTime(); return calendar; } /** * Determine the data type of the expression * @return Type.DATE_TYPE, * @param th */ public ItemType getItemType(TypeHierarchy th) { return Type.DATE_TYPE; } /** * Make a copy of this date, time, or dateTime value */ public CalendarValue copy() { return new DateValue(year, month, day, getTimezoneInMinutes()); } /** * Return a new date with the same normalized value, but * in a different timezone. This is called only for a DateValue that has an explicit timezone * @param timezone the new timezone offset, in minutes * @return the time in the new timezone. This will be a new TimeValue unless no change * was required to the original value */ public CalendarValue adjustTimezone(int timezone) { DateTimeValue dt = (DateTimeValue)toDateTime().adjustTimezone(timezone); return new DateValue(dt.getYear(), dt.getMonth(), dt.getDay(), dt.getTimezoneInMinutes()); } /** * Convert to Java object (for passing to external functions) */ public Object convertToJava(Class target, XPathContext context) throws XPathException { if (target.isAssignableFrom(Date.class)) { return getCalendar().getTime(); } else if (target.isAssignableFrom(GregorianCalendar.class)) { return getCalendar(); } else if (target.isAssignableFrom(DateValue.class)) { return this; } else if (target==String.class) { return getStringValue(); } else if (target.isAssignableFrom(CharSequence.class)) { return getStringValueCS(); } else if (target==Object.class) { return getStringValue(); } else { Object o = super.convertToJava(target, context); if (o == null) { throw new DynamicError("Conversion of date to " + target.getName() + " is not supported"); } return o; } } /** * Get a component of the value. Returns null if the timezone component is * requested and is not present. */ public AtomicValue getComponent(int component) throws XPathException { switch (component) { case Component.YEAR: return new IntegerValue((year > 0 ? year : year-1)); case Component.MONTH: return new IntegerValue(month); case Component.DAY: return new IntegerValue(day); case Component.TIMEZONE: if (hasTimezone()) { return SecondsDurationValue.fromMilliseconds(getTimezoneInMinutes()*60000); } else { return null; } default: throw new IllegalArgumentException("Unknown component for date: " + component); } } /** * Compare the value to another date value. This method is used only during schema processing, * and uses XML Schema semantics rather than XPath semantics. * @param other The other date value. Must be an object of class DateValue. * @return negative value if this one is the earlier, 0 if they are chronologically equal, * positive value if this one is the later. For this purpose, dateTime values with an unknown * timezone are considered to be UTC values (the Comparable interface requires * a total ordering). * @throws ClassCastException if the other value is not a DateValue (the parameter * is declared as Object to satisfy the Comparable interface) */ public int compareTo(Object other) { if (other instanceof AtomicValue) { other = ((AtomicValue)other).getPrimitiveValue(); } if (!(other instanceof DateValue)) { throw new ClassCastException("Date values are not comparable to " + other.getClass()); } return compareTo((DateValue)other, new Configuration()); } /** * Compare this value to another value of the same type, using the supplied context object * to get the implicit timezone if required. This method implements the XPath comparison semantics. */ public int compareTo(CalendarValue other, Configuration config) { final TypeHierarchy th = config.getTypeHierarchy(); if (this.getItemType(th).getPrimitiveType() != other.getItemType(th).getPrimitiveType()) { throw new ClassCastException("Cannot compare values of different types"); // covers, for example, comparing a gYear to a gYearMonth } // This code allows comparison of a gYear (etc) to a date, but this is prevented at a higher level return toDateTime().compareTo(other.toDateTime(), config); } /** * Get a comparison key for this value. Two values are equal if and only if they their comparison * keys are equal */ public ComparisonKey getComparisonKey(Configuration config) { return new ComparisonKey(Type.DATE, toDateTime().normalize(config)); } public boolean equals(Object other) { return compareTo(other) == 0; } public int hashCode() { // Equality must imply same hashcode, but not vice-versa return getCalendar().getTime().hashCode() + getTimezoneInMinutes(); } /** * Add a duration to a date * @param duration the duration to be added (may be negative) * @return the new date * @throws net.sf.saxon.trans.XPathException if the duration is an xs:duration, as distinct from * a subclass thereof */ public CalendarValue add(DurationValue duration) throws XPathException { if (duration instanceof SecondsDurationValue) { long microseconds = ((SecondsDurationValue)duration).getLengthInMicroseconds(); boolean negative = (microseconds < 0); microseconds = Math.abs(microseconds); int days = (int)Math.floor((double)microseconds / (1000000L*60L*60L*24L)); boolean partDay = (microseconds % (1000000L*60L*60L*24L)) > 0; int julian = getJulianDayNumber(year, month, day); DateValue d = dateFromJulianDayNumber(julian + (negative ? -days : days)); if (partDay) { if (negative) { d = yesterday(d.year, d.month, d.day); } } d.setTimezoneInMinutes(getTimezoneInMinutes()); return d; } else if (duration instanceof MonthDurationValue) { int months = ((MonthDurationValue)duration).getLengthInMonths(); int m = (month-1) + months; int y = year + m / 12; m = m % 12; if (m < 0) { m += 12; y -= 1; } m++; int d = day; while (!isValidDate(y, m, d)) { d -= 1; } return new DateValue(y, (byte)m, (byte)d, getTimezoneInMinutes()); } else { DynamicError err = new DynamicError( "Date arithmetic is not supported on xs:duration, only on its subtypes"); err.setIsTypeError(true); err.setErrorCode("XPTY0004"); throw err; } } /** * Determine the difference between two points in time, as a duration * @param other the other point in time * @param context * @return the duration as an xdt:dayTimeDuration * @throws net.sf.saxon.trans.XPathException for example if one value is a date and the other is a time */ public SecondsDurationValue subtract(CalendarValue other, XPathContext context) throws XPathException { if (!(other instanceof DateValue)) { DynamicError err = new DynamicError( "First operand of '-' is a date, but the second is not"); err.setIsTypeError(true); err.setErrorCode("XPTY0004"); throw err; } return super.subtract(other, context); } /** * Calculate the Julian day number at 00:00 on a given date. This algorithm is taken from * http://vsg.cape.com/~pbaum/date/jdalg.htm and * http://vsg.cape.com/~pbaum/date/jdalg2.htm * (adjusted to handle BC dates correctly) */ public static int getJulianDayNumber(int year, int month, int day) { int z = year - (month<3 ? 1 : 0); short f = monthData[month-1]; if (z >= 0) { return day + f + 365*z + z/4 - z/100 + z/400 + 1721118; } else { // for negative years, add 12000 years and then subtract the days! z += 12000; int j = day + f + 365*z + z/4 - z/100 + z/400 + 1721118; return j - (365*12000 + 12000/4 - 12000/100 + 12000/400); // number of leap years in 12000 years } } /** * Get the Gregorian date corresponding to a particular Julian day number. The algorithm * is taken from http://www.hermetic.ch/cal_stud/jdn.htm#comp * @return a DateValue with no timezone information set */ public static DateValue dateFromJulianDayNumber(int julianDayNumber) { if (julianDayNumber >= 0) { int L = julianDayNumber + 68569 + 1; // +1 adjustment for days starting at noon int n = ( 4 * L ) / 146097; L = L - ( 146097 * n + 3 ) / 4; int i = ( 4000 * ( L + 1 ) ) / 1461001; L = L - ( 1461 * i ) / 4 + 31; int j = ( 80 * L ) / 2447; int d = L - ( 2447 * j ) / 80; L = j / 11; int m = j + 2 - ( 12 * L ); int y = 100 * ( n - 49 ) + i + L; return new DateValue(y, (byte)m, (byte)d); } else { // add 12000 years and subtract them again... DateValue dt = dateFromJulianDayNumber(julianDayNumber + (365*12000 + 12000/4 - 12000/100 + 12000/400)); dt.year -= 12000; return dt; } } private static final short[] monthData = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; /** * Get the ordinal day number within the year (1 Jan = 1, 1 Feb = 32, etc) */ public static final int getDayWithinYear(int year, int month, int day) { int j = getJulianDayNumber(year, month, day); int k = getJulianDayNumber(year, 1, 1); return j - k + 1; } /** * Get the day of the week. The days of the week are numbered from * 1 (Monday) to 7 (Sunday) */ public static final int getDayOfWeek(int year, int month, int day) { int d = getJulianDayNumber(year, month, day); d -= 2378500; // 1800-01-05 - any Monday would do while (d <= 0) { d += 70000000; // any sufficiently-high multiple of 7 would do } return (d-1)%7 + 1; } /** * Get the ISO week number for a given date. The days of the week are numbered from * 1 (Monday) to 7 (Sunday), and week 1 in any calendar year is the week (from Monday to Sunday) * that includes the first Thursday of that year */ public static final int getWeekNumber(int year, int month, int day) { int d = getDayWithinYear(year, month, day); int firstDay = getDayOfWeek(year, 1, 1); if (firstDay > 4 && (firstDay + d) <= 8) { // days before week one are part of the last week of the previous year (52 or 53) return getWeekNumber(year-1, 12, 31); } int inc = (firstDay < 5 ? 1 : 0); // implements the First Thursday rule return ((d + firstDay - 2) / 7) + inc; } /** * Get the week number within a month. This is required for the XSLT format-date() function, * and the rules are not entirely clear. The days of the week are numbered from * 1 (Monday) to 7 (Sunday), and by analogy with the ISO week number, we consider that week 1 * in any calendar month is the week (from Monday to Sunday) that includes the first Thursday * of that month. Unlike the ISO week number, we put the previous days in week zero. */ public static final int getWeekNumberWithinMonth(int year, int month, int day) { int firstDay = getDayOfWeek(year, month, 1); int inc = (firstDay < 5 ? 1 : 0); // implements the First Thursday rule return ((day + firstDay - 2) / 7) + inc; } /** * Temporary test rig */ public static void main(String[] args) throws Exception { DateValue date = new DateValue(args[0]); System.out.println(date.getStringValue()); int jd = getJulianDayNumber(date.year, date.month, date.day); System.out.println(jd); System.out.println(dateFromJulianDayNumber(jd).getStringValue()); } } // // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); // you may not use this file except in compliance with the License. You may obtain a copy of the // License at http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. // See the License for the specific language governing rights and limitations under the License. // // The Original Code is: all this file. // // The Initial Developer of the Original Code is Michael H. Kay // // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. // // Contributor(s): none. //

The table below shows all metrics for DateValue.java.

MetricValueDescription
BLOCKS96.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS185.00Comment lines
COMMENT_DENSITY 0.53Comment density
COMPARISONS91.00Number of comparison operators
CYCLOMATIC139.00Cyclomatic complexity
DECL_COMMENTS51.00Comments in declarations
DOC_COMMENT160.00Number of javadoc comment lines
ELOC350.00Effective lines of code
EXEC_COMMENTS 8.00Comments in executable code
EXITS66.00Procedure exits
FUNCTIONS37.00Number of function declarations
HALSTEAD_DIFFICULTY102.62Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY159.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 1.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003422.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 1.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA007673.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 2.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 1.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA010825.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011015.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 4.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 1.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 1.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 1.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 1.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 1.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 2.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 3.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES712.00Number of lines in the source file
LINE_COMMENT25.00Number of line comments
LOC428.00Lines of code
LOGICAL_LINES233.00Number of statements
LOOPS 2.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1238.00Number of operands
OPERATORS2423.00Number of operators
PARAMS56.00Number of formal parameter declarations
PROGRAM_LENGTH3661.00Halstead program length
PROGRAM_VOCAB443.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS103.00Number of return points from functions
SIZE26953.00Size of the file in bytes
UNIQUE_OPERANDS380.00Number of unique operands
UNIQUE_OPERATORS63.00Number of unique operators
WHITESPACE99.00Number of whitespace lines