Class Once

From Ssdlpedia

Jump to: navigation, search

Contents

[edit] Synopsis of Class Once

public class Once { 
    /*
     * Forge (1)
     */
        Once(String value); 
    /*
     * Type (1)
     */
        String toString(); 
} 



[edit] Code

// SSDLPedia
package il.ac.technion.cs.ssdl.utils;

import il.ac.technion.cs.ssdl.stereotypes.Instantiable;

/**
 * A class to manage printing a String exactly once. In the first
 * invocation of #toString(), the initial value is returned. In all
 * subsequent invocations, the empty string is returned.
 * 
 * See: Separator
 * Author: Yossi Gil
 * See:  21/08/2007
 */
@Instantiable public class Once {
    private String value;
    
    public Once(final String value) {
        this.value = Defaults.to(value, "");
    }
    
    @Override public String toString() {
        final String $ = value;
        value = null;
        return $;
    }
}

[edit] Metrics

MetricValueAcronymExplanation
LOC28Lines Of CodeTotal number of lines in the code
SCC7SemiColons CountTotal number of semicolon tokens found in the code.
NOT81Number Of TokensComments, whitespace and text which cannot be made into a token not included.
VCC569Visible Characters CountThe total number of non-white (i.e., not space, tab, newline, carriage return, form feed) characters.
CCC273Code Characters CountTotal number of non-white characters in tokens. White space characters in string and character literals are not counted.
UIC15Unique Identifiers CountThe number of different identifiers found in the code
WHC2Weighted Horizontal ComplexityA heuritistic on horizontal complexity

[edit] Statistics

StatiticValue
Average token length 3.4
Tokens/line 2.9
Visible characters/line 20
Code characters/line 9.8
Semicolons/tokens8%
Comment text percentage52%

[edit] Tokens by Kind

Token KindOccurrences
KEYWORD12
OPERATOR3
LITERAL1
ID32
PUNCTUATION33
COMMENT2
OTHER40
Personal tools