StringUtil.java

Index Score
freemarker.template.utility
FreeMarker

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
LOOPSNumber of loops
COMPARISONSNumber of comparison operators
CYCLOMATICCyclomatic complexity
LOGICAL_LINESNumber of statements
OPERANDSNumber of operands
SIZESize of the file in bytes
PROGRAM_LENGTHHalstead program length
ELOCEffective lines of code
OPERATORSNumber of operators
BLOCKSNumber of blocks
LOCLines of code
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
LINESNumber of lines in the source file
JAVA0034JAVA0034 Missing braces in if statement
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0119JAVA0119 Control variable changed within body of for loop
JAVA0076JAVA0076 Use of magic number
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
INTERFACE_COMPLEXITYInterface complexity
RETURNSNumber of return points from functions
PARAMSNumber of formal parameter declarations
UNIQUE_OPERANDSNumber of unique operands
COMMENTSComment lines
DECL_COMMENTSComments in declarations
PROGRAM_VOCABHalstead program vocabulary
DOC_COMMENTNumber of javadoc comment lines
JAVA0039JAVA0039 Break statement with label
FUNCTIONSNumber of function declarations
UNIQUE_OPERATORSNumber of unique operators
JAVA0040JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0031JAVA0031 Case statement not properly closed
JAVA0067JAVA0067 Array descriptor on identifier name
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0068JAVA0068 Modifiers not declared in recommended order
EXEC_COMMENTSComments in executable code
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0145JAVA0145 Tab character used in source file
/* * Copyright (c) 2003 The Visigoth Software Society. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowledgement: * "This product includes software developed by the * Visigoth Software Society (http://www.visigoths.org/)." * Alternately, this acknowledgement may appear in the software itself, * if and wherever such third-party acknowledgements normally appear. * * 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the * project contributors may be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact visigoths@visigoths.org. * * 5. Products derived from this software may not be called "FreeMarker" or "Visigoth" * nor may "FreeMarker" or "Visigoth" appear in their names * without prior written permission of the Visigoth Software Society. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Visigoth Software Society. For more * information on the Visigoth Software Society, please see * http://www.visigoths.org/ */ package freemarker.template.utility; import java.io.UnsupportedEncodingException; import java.util.*; import freemarker.template.Template; import freemarker.core.Environment; import freemarker.core.parser.ParseException; /** * Some text related utilities. * * @version $Id: StringUtil.java,v 1.48 2005/06/01 22:39:08 ddekany Exp $ */ public class StringUtil { private static final char[] ESCAPES = createEscapes(); /* * For better performance most methods are folded down. Don't you scream... :) */ /** * HTML encoding (does not convert line breaks). * Replaces all '&gt;' '&lt;' '&amp;' and '"' with entity reference */ public static String HTMLEnc(String s) { return XMLEncNA(s); } /** * XML Encoding. * Replaces all '&gt;' '&lt;' '&amp;', "'" and '"' with entity reference */ public static String XMLEnc(String s) { return XMLOrXHTMLEnc(s, "&apos;"); } /** * XHTML Encoding. * Replaces all '&gt;' '&lt;' '&amp;', "'" and '"' with entity reference * suitable for XHTML decoding in common user agents (including legacy * user agents, which do not decode "&apos;" to "'", so "&#39;" is used * instead [see http://www.w3.org/TR/xhtml1/#C_16]) */ public static String XHTMLEnc(String s) { return XMLOrXHTMLEnc(s, "&#39;"); } private static String XMLOrXHTMLEnc(String s, String aposReplacement) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'') { StringBuilder b = new StringBuilder(s.substring(0, i)); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; case '\'': b.append(aposReplacement); break; } i++; int next = i; while (i < ln) { c = s.charAt(i); if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'') { b.append(s.substring(next, i)); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; case '\'': b.append(aposReplacement); break; } next = i + 1; } i++; } if (next < ln) b.append(s.substring(next)); s = b.toString(); break; } // if c == } // for return s; } /** * XML encoding without replacing apostrophes. * @see #XMLEnc(String) */ public static String XMLEncNA(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '<' || c == '>' || c == '&' || c == '"') { StringBuilder b = new StringBuilder(s.substring(0, i)); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; } i++; int next = i; while (i < ln) { c = s.charAt(i); if (c == '<' || c == '>' || c == '&' || c == '"') { b.append(s.substring(next, i)); switch (c) { case '<': b.append("&lt;"); break; case '>': b.append("&gt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; } next = i + 1; } i++; } if (next < ln) b.append(s.substring(next)); s = b.toString(); break; } // if c == } // for return s; } /** * XML encoding for attributes valies quoted with <tt>"</tt> (not with <tt>'</tt>!). * Also can be used for HTML attributes that are quoted with <tt>"</tt>. * @see #XMLEnc(String) */ public static String XMLEncQAttr(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '<' || c == '&' || c == '"') { StringBuilder b = new StringBuilder(s.substring(0, i)); switch (c) { case '<': b.append("&lt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; } i++; int next = i; while (i < ln) { c = s.charAt(i); if (c == '<' || c == '&' || c == '"') { b.append(s.substring(next, i)); switch (c) { case '<': b.append("&lt;"); break; case '&': b.append("&amp;"); break; case '"': b.append("&quot;"); break; } next = i + 1; } i++; } if (next < ln) { b.append(s.substring(next)); } s = b.toString(); break; } // if c == } // for return s; } /** * XML encoding without replacing apostrophes and quotation marks and greater-than signs. * @see #XMLEnc(String) */ public static String XMLEncNQG(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '<' || c == '&') { StringBuilder b = new StringBuilder(s.substring(0, i)); switch (c) { case '<': b.append("&lt;"); break; case '&': b.append("&amp;"); break; } i++; int next = i; while (i < ln) { c = s.charAt(i); if (c == '<' || c == '&') { b.append(s.substring(next, i)); switch (c) { case '<': b.append("&lt;"); break; case '&': b.append("&amp;"); break; } next = i + 1; } i++; } if (next < ln) b.append(s.substring(next)); s = b.toString(); break; } // if c == } // for return s; } /** * Rich Text Format encoding (does not replace line breaks). * Escapes all '\' '{' '}' and '"' */ public static String RTFEnc(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '\\' || c == '{' || c == '}') { StringBuilder b = new StringBuilder(s.substring(0, i)); switch (c) { case '\\': b.append("\\\\"); break; case '{': b.append("\\{"); break; case '}': b.append("\\}"); break; } i++; int next = i; while (i < ln) { c = s.charAt(i); if (c == '\\' || c == '{' || c == '}') { b.append(s.substring(next, i)); switch (c) { case '\\': b.append("\\\\"); break; case '{': b.append("\\{"); break; case '}': b.append("\\}"); break; } next = i + 1; } i++; } if (next < ln) b.append(s.substring(next)); s = b.toString(); break; } // if c == } // for return s; } /** * URL encoding (like%20this). */ public static String URLEnc(String s, String charset) throws UnsupportedEncodingException { int ln = s.length(); int i; for (i = 0; i < ln; i++) { char c = s.charAt(i); if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c == '-' || c == '.' || c == '!' || c == '~' || c >= '\'' && c <= '*')) { break; } } if (i == ln) { // Nothing to escape return s; } StringBuilder b = new StringBuilder(ln + ln / 3 + 2); b.append(s.substring(0, i)); int encstart = i; for (i++; i < ln; i++) { char c = s.charAt(i); if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c == '-' || c == '.' || c == '!' || c == '~' || c >= '\'' && c <= '*') { if (encstart != -1) { byte[] o = s.substring(encstart, i).getBytes(charset); for (int j = 0; j < o.length; j++) { b.append('%'); byte bc = o[j]; int c1 = bc & 0x0F; int c2 = (bc >> 4) & 0x0F; b.append((char) (c2 < 10 ? c2 + '0' : c2 - 10 + 'A')); b.append((char) (c1 < 10 ? c1 + '0' : c1 - 10 + 'A')); } encstart = -1; } b.append(c); } else { if (encstart == -1) { encstart = i; } } } if (encstart != -1) { byte[] o = s.substring(encstart, i).getBytes(charset); for (int j = 0; j < o.length; j++) { b.append('%'); byte bc = o[j]; int c1 = bc & 0x0F; int c2 = (bc >> 4) & 0x0F; b.append((char) (c2 < 10 ? c2 + '0' : c2 - 10 + 'A')); b.append((char) (c1 < 10 ? c1 + '0' : c1 - 10 + 'A')); } } return b.toString(); } private static char[] createEscapes() { char[] escapes = new char['\\' + 1]; for(int i = 0; i < 32; ++i) { escapes[i] = 1; } escapes['\\'] = '\\'; escapes['\''] = '\''; escapes['"'] = '"'; escapes['<'] = 'l'; escapes['>'] = 'g'; escapes['&'] = 'a'; escapes['\b'] = 'b'; escapes['\t'] = 't'; escapes['\n'] = 'n'; escapes['\f'] = 'f'; escapes['\r'] = 'r'; escapes['$'] = '$'; return escapes; } public static String FTLStringLiteralEnc(String s) { StringBuilder buf = null; int l = s.length(); int el = ESCAPES.length; for(int i = 0; i < l; i++) { char c = s.charAt(i); if(c < el) { char escape = ESCAPES[c]; switch(escape) { case 0: { if (buf != null) { buf.append(c); } break; } case 1: { if (buf == null) { buf = new StringBuilder(s.length() + 3); buf.append(s.substring(0, i)); } // hex encoding for characters below 0x20 // that have no other escape representation buf.append("\\x00"); int c2 = (c >> 4) & 0x0F; c = (char) (c & 0x0F); buf.append((char) (c2 < 10 ? c2 + '0' : c2 - 10 + 'A')); buf.append((char) (c < 10 ? c + '0' : c - 10 + 'A')); break; } default: { if (buf == null) { buf = new StringBuilder(s.length() + 2); buf.append(s.substring(0, i)); } buf.append('\\'); buf.append(escape); } } } else { if (buf != null) { buf.append(c); } } } return buf == null ? s : buf.toString(); } /** * FTL string literal decoding. * * \\, \", \', \n, \t, \r, \b and \f will be replaced according to * Java rules. In additional, it knows \g, \l, \a and \{ which are * replaced with &lt;, >, &amp; and { respectively. * \x works as hexadecimal character code escape. The character * codes are interpreted according to UCS basic plane (Unicode). * "f\x006Fo", "f\x06Fo" and "f\x6Fo" will be "foo". * "f\x006F123" will be "foo123" as the maximum number of digits is 4. * * All other \X (where X is any character not mentioned above or End-of-string) * will cause a ParseException. * * @param s String literal <em>without</em> the surrounding quotation marks * @return String with all escape sequences resolved * @throws ParseException if there string contains illegal escapes */ public static String FTLStringLiteralDec(String s) throws ParseException { int idx = s.indexOf('\\'); if (idx == -1) { return s; } int lidx = s.length() - 1; int bidx = 0; StringBuilder buf = new StringBuilder(lidx); do { buf.append(s.substring(bidx, idx)); if (idx >= lidx) { throw new ParseException("The last character of string literal is backslash", 0,0); } char c = s.charAt(idx + 1); switch (c) { case '"': buf.append('"'); bidx = idx + 2; break; case '\'': buf.append('\''); bidx = idx + 2; break; case '\\': buf.append('\\'); bidx = idx + 2; break; case 'n': buf.append('\n'); bidx = idx + 2; break; case 'r': buf.append('\r'); bidx = idx + 2; break; case 't': buf.append('\t'); bidx = idx + 2; break; case 'f': buf.append('\f'); bidx = idx + 2; break; case 'b': buf.append('\b'); bidx = idx + 2; break; case 'g': buf.append('>'); bidx = idx + 2; break; case 'l': buf.append('<'); bidx = idx + 2; break; case 'a': buf.append('&'); bidx = idx + 2; break; case '{': buf.append('{'); bidx = idx + 2; break; case 'x': { idx += 2; int x = idx; int y = 0; int z = lidx > idx + 3 ? idx + 3 : lidx; while (idx <= z) { char b = s.charAt(idx); if (b >= '0' && b <= '9') { y <<= 4; y += b - '0'; } else if (b >= 'a' && b <= 'f') { y <<= 4; y += b - 'a' + 10; } else if (b >= 'A' && b <= 'F') { y <<= 4; y += b - 'A' + 10; } else { break; } idx++; } if (x < idx) { buf.append((char) y); } else { throw new ParseException("Invalid \\x escape in a string literal",0,0); } bidx = idx; break; } default: throw new ParseException("Invalid escape sequence (\\" + c + ") in a string literal",0,0); } idx = s.indexOf('\\', bidx); } while (idx != -1); buf.append(s.substring(bidx)); return buf.toString(); } public static Locale deduceLocale(String input) { Locale locale = Locale.getDefault(); if (input.charAt(0) == '"') input = input.substring(1, input.length() -1); StringTokenizer st = new StringTokenizer(input, ",_ "); String lang = "", country = ""; if (st.hasMoreTokens()) { lang = st.nextToken(); } if (st.hasMoreTokens()) { country = st.nextToken(); } if (!st.hasMoreTokens()) { locale = new Locale(lang, country); } else { locale = new Locale(lang, country, st.nextToken()); } return locale; } public static String capitalize(String s) { StringTokenizer st = new StringTokenizer(s, " \t\r\n", true); StringBuilder buf = new StringBuilder(s.length()); while (st.hasMoreTokens()) { String tok = st.nextToken(); buf.append(tok.substring(0, 1).toUpperCase()); buf.append(tok.substring(1).toLowerCase()); } return buf.toString(); } public static boolean getYesNo(String s) { if (s.startsWith("\"")) { s = s.substring(1, s.length() -1); } if (s.equalsIgnoreCase("n") || s.equalsIgnoreCase("no") || s.equalsIgnoreCase("f") || s.equalsIgnoreCase("false")) { return false; } else if (s.equalsIgnoreCase("y") || s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("t") || s.equalsIgnoreCase("true")) { return true; } throw new IllegalArgumentException("Illegal boolean value: " + s); } /** * Splits a string at the specified character. */ public static String[] split(String s, char c) { int i, b, e; int cnt; String res[]; int ln = s.length(); i = 0; cnt = 1; while ((i = s.indexOf(c, i)) != -1) { cnt++; i++; } res = new String[cnt]; i = 0; b = 0; while (b <= ln) { e = s.indexOf(c, b); if (e == -1) e = ln; res[i++] = s.substring(b, e); b = e + 1; } return res; } /** * Splits a string at the specified string. */ public static String[] split(String s, String sep, boolean caseInsensitive) { String splitString = caseInsensitive ? sep.toLowerCase() : sep; String input = caseInsensitive ? s.toLowerCase() : s; int i, b, e; int cnt; String res[]; int ln = s.length(); int sln = sep.length(); if (sln == 0) throw new IllegalArgumentException( "The separator string has 0 length"); i = 0; cnt = 1; while ((i = input.indexOf(splitString, i)) != -1) { cnt++; i += sln; } res = new String[cnt]; i = 0; b = 0; while (b <= ln) { e = input.indexOf(splitString, b); if (e == -1) e = ln; res[i++] = s.substring(b, e); b = e + sln; } return res; } /** * Replaces all occurrences of a sub-string in a string. * @param text The string where it will replace <code>oldsub</code> with * <code>newsub</code>. * @return String The string after the replacements. */ public static String replace(String text, String oldsub, String newsub, boolean caseInsensitive, boolean firstOnly) { StringBuilder buf; int tln; int oln = oldsub.length(); if (oln == 0) { int nln = newsub.length(); if (nln == 0) { return text; } else { if (firstOnly) { return newsub + text; } else { tln = text.length(); buf = new StringBuilder(tln + (tln + 1) * nln); buf.append(newsub); for (int i = 0; i < tln; i++) { buf.append(text.charAt(i)); buf.append(newsub); } return buf.toString(); } } } else { oldsub = caseInsensitive ? oldsub.toLowerCase() : oldsub; String input = caseInsensitive ? text.toLowerCase() : text; int e = input.indexOf(oldsub); if (e == -1) { return text; } int b = 0; tln = text.length(); buf = new StringBuilder( tln + Math.max(newsub.length() - oln, 0) * 3); do { buf.append(text.substring(b, e)); buf.append(newsub); b = e + oln; e = input.indexOf(oldsub, b); } while (e != -1 && !firstOnly); buf.append(text.substring(b)); return buf.toString(); } } /** * Removes the line-break from the end of the string. */ public static String chomp(String s) { if (s.endsWith("\r\n")) return s.substring(0, s.length() - 2); if (s.endsWith("\r") || s.endsWith("\n")) return s.substring(0, s.length() - 1); return s; } /** * Quotes string as Java Language string literal. * Returns string <code>"null"</code> if <code>s</code> * is <code>null</code>. */ public static String jQuote(String s) { if (s == null) { return "null"; } int ln = s.length(); StringBuilder b = new StringBuilder(ln + 4); b.append('"'); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '"') { b.append("\\\""); } else if (c == '\\') { b.append("\\\\"); } else if (c < 0x20) { if (c == '\n') { b.append("\\n"); } else if (c == '\r') { b.append("\\r"); } else if (c == '\f') { b.append("\\f"); } else if (c == '\b') { b.append("\\b"); } else if (c == '\t') { b.append("\\t"); } else { b.append("\\u00"); int x = c / 0x10; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'A')); x = c & 0xF; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'A')); } } else { b.append(c); } } // for each characters b.append('"'); return b.toString(); } /** * Escapes the <code>String</code> with the escaping rules of Java language * string literals, so it is safe to insert the value into a string literal. * The resulting string will not be quoted. * * <p>In additional, all characters under UCS code point 0x20, that has no * dedicated escape sequence in Java language, will be replaced with UNICODE * escape (<tt>\<!-- -->u<i>XXXX</i></tt>). * * @see #jQuote(String) */ public static String javaStringEnc(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '"' || c == '\\' || c < 0x20) { StringBuilder b = new StringBuilder(ln + 4); b.append(s.substring(0, i)); while (true) { if (c == '"') { b.append("\\\""); } else if (c == '\\') { b.append("\\\\"); } else if (c < 0x20) { if (c == '\n') { b.append("\\n"); } else if (c == '\r') { b.append("\\r"); } else if (c == '\f') { b.append("\\f"); } else if (c == '\b') { b.append("\\b"); } else if (c == '\t') { b.append("\\t"); } else { b.append("\\u00"); int x = c / 0x10; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'a')); x = c & 0xF; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'a')); } } else { b.append(c); } i++; if (i >= ln) { return b.toString(); } c = s.charAt(i); } } // if has to be escaped } // for each characters return s; } /** * Escapes a <code>String</code> according the JavaScript string literal * escaping rules. The resulting string will not be quoted. * * <p>It escapes both <tt>'</tt> and <tt>"</tt>. * In additional it escapes <tt>></tt> as <tt>\></tt> (to avoid * <tt>&lt;/script></tt>). Furthermore, all characters under UCS code point * 0x20, that has no dedicated escape sequence in JavaScript language, will * be replaced with hexadecimal escape (<tt>\x<i>XX</i></tt>). */ public static String javaScriptStringEnc(String s) { int ln = s.length(); for (int i = 0; i < ln; i++) { char c = s.charAt(i); if (c == '"' || c == '\'' || c == '\\' || c == '>' || c < 0x20) { StringBuilder b = new StringBuilder(ln + 4); b.append(s.substring(0, i)); while (true) { if (c == '"') { b.append("\\\""); } else if (c == '\'') { b.append("\\'"); } else if (c == '\\') { b.append("\\\\"); } else if (c == '>') { b.append("\\>"); } else if (c < 0x20) { if (c == '\n') { b.append("\\n"); } else if (c == '\r') { b.append("\\r"); } else if (c == '\f') { b.append("\\f"); } else if (c == '\b') { b.append("\\b"); } else if (c == '\t') { b.append("\\t"); } else { b.append("\\x"); int x = c / 0x10; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'A')); x = c & 0xF; b.append((char) (x < 0xA ? x + '0' : x - 0xA + 'A')); } } else { b.append(c); } i++; if (i >= ln) { return b.toString(); } c = s.charAt(i); } } // if has to be escaped } // for each characters return s; } /** * Parses a name-value pair list, where the pairs are separated with comma, * and the name and value is separated with colon. * The keys and values can contain only letters, digits and <tt>_</tt>. They * can't be quoted. White-space around the keys and values are ignored. The * value can be omitted if <code>defaultValue</code> is not null. When a * value is omitted, then the colon after the key must be omitted as well. * The same key can't be used for multiple times. * * @param s the string to parse. * For example: <code>"strong:100, soft:900"</code>. * @param defaultValue the value used when the value is omitted in a * key-value pair. * * @return the map that contains the name-value pairs. * * @throws java.text.ParseException if the string is not a valid name-value * pair list. */ public static Map<String, String> parseNameValuePairList(String s, String defaultValue) throws java.text.ParseException { Map<String, String> map = new HashMap<String, String>(); char c = ' '; int ln = s.length(); int p = 0; int keyStart; int valueStart; String key; String value; fetchLoop: while (true) { // skip ws while (p < ln) { c = s.charAt(p); if (!Character.isWhitespace(c)) { break; } p++; } if (p == ln) { break fetchLoop; } keyStart = p; // seek key end while (p < ln) { c = s.charAt(p); if (!(Character.isLetterOrDigit(c) || c == '_')) { break; } p++; } if (keyStart == p) { throw new java.text.ParseException( "Expecting letter, digit or \"_\" " + "here, (the first character of the key) but found " + jQuote(String.valueOf(c)) + " at position " + p + ".", p); } key = s.substring(keyStart, p); // skip ws while (p < ln) { c = s.charAt(p); if (!Character.isWhitespace(c)) { break; } p++; } if (p == ln) { if (defaultValue == null) { throw new java.text.ParseException( "Expecting \":\", but reached " + "the end of the string " + " at position " + p + ".", p); } value = defaultValue; } else if (c != ':') { if (defaultValue == null || c != ',') { throw new java.text.ParseException( "Expecting \":\" here, but found " + jQuote(String.valueOf(c)) + " at position " + p + ".", p); } // skip "," p++; value = defaultValue; } else { // skip ":" p++; // skip ws while (p < ln) { c = s.charAt(p); if (!Character.isWhitespace(c)) { break; } p++; } if (p == ln) { throw new java.text.ParseException( "Expecting the value of the key " + "here, but reached the end of the string " + " at position " + p + ".", p); } valueStart = p; // seek value end while (p < ln) { c = s.charAt(p); if (!(Character.isLetterOrDigit(c) || c == '_')) { break; } p++; } if (valueStart == p) { throw new java.text.ParseException( "Expecting letter, digit or \"_\" " + "here, (the first character of the value) " + "but found " + jQuote(String.valueOf(c)) + " at position " + p + ".", p); } value = s.substring(valueStart, p); // skip ws while (p < ln) { c = s.charAt(p); if (!Character.isWhitespace(c)) { break; } p++; } // skip "," if (p < ln) { if (c != ',') { throw new java.text.ParseException( "Excpecting \",\" or the end " + "of the string here, but found " + jQuote(String.valueOf(c)) + " at position " + p + ".", p); } else { p++; } } } // store the key-value pair if (map.put(key, value) != null) { throw new java.text.ParseException( "Dublicated key: " + jQuote(key), keyStart); } } return map; } /** * @return whether the name is a valid XML tagname. * (This routine might only be 99% accurate. Should maybe REVISIT) */ static public boolean isXMLID(String name) { for (int i=0; i<name.length(); i++) { char c = name.charAt(i); if (i==0) { if (c== '-' || c=='.' || Character.isDigit(c)) return false; } if (!Character.isLetterOrDigit(c) && c != ':' && c != '_' && c != '-' && c!='.') { return false; } } return true; } /** * @return whether the qname matches the combination of nodeName, nsURI, and environment prefix settings. */ static public boolean matchesName(String qname, String nodeName, String nsURI, Environment env) { String defaultNS = env.getDefaultNS(); if ((defaultNS != null) && defaultNS.equals(nsURI)) { return qname.equals(nodeName) || qname.equals(Template.DEFAULT_NAMESPACE_PREFIX + ":" + nodeName); } if ("".equals(nsURI)) { if (defaultNS != null) { return qname.equals(Template.NO_NS_PREFIX + ":" + nodeName); } else { return qname.equals(nodeName) || qname.equals(Template.NO_NS_PREFIX + ":" + nodeName); } } String prefix = env.getPrefixForNamespace(nsURI); if (prefix == null) { return false; // Is this the right thing here??? } return qname.equals(prefix + ":" + nodeName); } /** * Pads the string at the left with spaces until it reaches the desired * length. If the string is longer than this length, then it returns the * unchanged string. * * @param s the string that will be padded. * @param minLength the length to reach. */ public static String leftPad(String s, int minLength) { return leftPad(s, minLength, ' '); } /** * Pads the string at the left with the specified character until it reaches * the desired length. If the string is longer than this length, then it * returns the unchanged string. * * @param s the string that will be padded. * @param minLength the length to reach. * @param filling the filling pattern. */ public static String leftPad(String s, int minLength, char filling) { int ln = s.length(); if (minLength <= ln) { return s; } StringBuilder res = new StringBuilder(minLength); int dif = minLength - ln; for (int i = 0; i < dif; i++) { res.append(filling); } res.append(s); return res.toString(); } /** * Pads the string at the left with a filling pattern until it reaches the * desired length. If the string is longer than this length, then it returns * the unchanged string. For example: <code>leftPad('ABC', 9, '1234')</code> * returns <code>"123412ABC"</code>. * * @param s the string that will be padded. * @param minLength the length to reach. * @param filling the filling pattern. Must be at least 1 characters long. * Can't be <code>null</code>. */ public static String leftPad(String s, int minLength, String filling) { int ln = s.length(); if (minLength <= ln) { return s; } StringBuilder res = new StringBuilder(minLength); int dif = minLength - ln; int fln = filling.length(); if (fln == 0) { throw new IllegalArgumentException( "The \"filling\" argument can't be 0 length string."); } int cnt = dif / fln; for (int i = 0; i < cnt; i++) { res.append(filling); } cnt = dif % fln; for (int i = 0; i < cnt; i++) { res.append(filling.charAt(i)); } res.append(s); return res.toString(); } /** * Pads the string at the right with spaces until it reaches the desired * length. If the string is longer than this length, then it returns the * unchanged string. * * @param s the string that will be padded. * @param minLength the length to reach. */ public static String rightPad(String s, int minLength) { return rightPad(s, minLength, ' '); } /** * Pads the string at the right with the specified character until it * reaches the desired length. If the string is longer than this length, * then it returns the unchanged string. * * @param s the string that will be padded. * @param minLength the length to reach. * @param filling the filling pattern. */ public static String rightPad(String s, int minLength, char filling) { int ln = s.length(); if (minLength <= ln) { return s; } StringBuilder res = new StringBuilder(minLength); res.append(s); int dif = minLength - ln; for (int i = 0; i < dif; i++) { res.append(filling); } return res.toString(); } /** * Pads the string at the right with a filling pattern until it reaches the * desired length. If the string is longer than this length, then it returns * the unchanged string. For example: <code>rightPad('ABC', 9, '1234')</code> * returns <code>"ABC412341"</code>. Note that the filling pattern is * started as if you overlay <code>"123412341"</code> with the left-aligned * <code>"ABC"</code>, so it starts with <code>"4"</code>. * * @param s the string that will be padded. * @param minLength the length to reach. * @param filling the filling pattern. Must be at least 1 characters long. * Can't be <code>null</code>. */ public static String rightPad(String s, int minLength, String filling) { int ln = s.length(); if (minLength <= ln) { return s; } StringBuilder res = new StringBuilder(minLength); res.append(s); int dif = minLength - ln; int fln = filling.length(); if (fln == 0) { throw new IllegalArgumentException( "The \"filling\" argument can't be 0 length string."); } int start = ln % fln; int end = fln - start <= dif ? fln : start + dif; for (int i = start; i < end; i++) { res.append(filling.charAt(i)); } dif -= end - start; int cnt = dif / fln; for (int i = 0; i < cnt; i++) { res.append(filling); } cnt = dif % fln; for (int i = 0; i < cnt; i++) { res.append(filling.charAt(i)); } return res.toString(); } /** * Is this a valid identifier in FTL? */ public static boolean isFTLIdentifier(String s) { char[] chars = s.toCharArray(); int size = chars.length; if (size == 0) { return false; } else { char firstChar = chars[0]; if (firstChar != '_' && firstChar != '@' && !Character.isLetter(firstChar)) return false; for (int i=1; i<size; i++) { char c = chars[i]; if (c != '_' && !Character.isLetterOrDigit(c)) return false; } return true; } } /** * Takes a string and puts it in quotes if it cannot * be used directly as an identifier in FTL. */ public static String quoteStringIfNecessary(String s) { if (isFTLIdentifier(s)) return s; return "\"" + FTLStringLiteralEnc(s) + "\""; } }

The table below shows all metrics for StringUtil.java.

MetricValueDescription
BLOCKS200.00Number of blocks
BLOCK_COMMENT54.00Number of block comment lines
COMMENTS257.00Comment lines
COMMENT_DENSITY 0.32Comment density
COMPARISONS271.00Number of comparison operators
CYCLOMATIC336.00Cyclomatic complexity
DECL_COMMENTS30.00Comments in declarations
DOC_COMMENT190.00Number of javadoc comment lines
ELOC802.00Effective lines of code
EXEC_COMMENTS12.00Comments in executable code
EXITS39.00Procedure exits
FUNCTIONS33.00Number of function declarations
HALSTEAD_DIFFICULTY193.09Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY130.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.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 1.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
JAVA003210.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003414.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 1.00JAVA0039 Break statement with label
JAVA0040 1.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'
JAVA004912.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 0.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 1.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 2.00JAVA0067 Array descriptor on identifier name
JAVA0068 2.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
JAVA007643.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 0.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 0.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
JAVA010829.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011022.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 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 4.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA011912.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 0.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 0.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 0.00JAVA0144 Line exceeds maximum M characters
JAVA014525.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
JAVA017717.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 0.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 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 2.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
LINES1308.00Number of lines in the source file
LINE_COMMENT13.00Number of line comments
LOC969.00Lines of code
LOGICAL_LINES577.00Number of statements
LOOPS46.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS2376.00Number of operands
OPERATORS4291.00Number of operators
PARAMS55.00Number of formal parameter declarations
PROGRAM_LENGTH6667.00Halstead program length
PROGRAM_VOCAB422.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS75.00Number of return points from functions
SIZE46030.00Size of the file in bytes
UNIQUE_OPERANDS363.00Number of unique operands
UNIQUE_OPERATORS59.00Number of unique operators
WHITESPACE82.00Number of whitespace lines