EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.value]

COVERAGE SUMMARY FOR SOURCE FILE [ValueStringFixed.java]

nameclass, %method, %block, %line, %
ValueStringFixed.java100% (1/1)100% (6/6)100% (69/69)100% (18/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ValueStringFixed100% (1/1)100% (6/6)100% (69/69)100% (18/18)
<static initializer> 100% (1/1)100% (6/6)100% (1/1)
ValueStringFixed (String): void 100% (1/1)100% (4/4)100% (2/2)
get (String): ValueStringFixed 100% (1/1)100% (24/24)100% (7/7)
getNew (String): ValueString 100% (1/1)100% (3/3)100% (1/1)
getType (): int 100% (1/1)100% (2/2)100% (1/1)
trimRight (String): String 100% (1/1)100% (30/30)100% (6/6)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.value;
7 
8import org.h2.engine.SysProperties;
9import org.h2.util.StringUtils;
10 
11/**
12 * Implementation of the CHAR data type.
13 */
14public class ValueStringFixed extends ValueString {
15 
16    private static final ValueStringFixed EMPTY = new ValueStringFixed("");
17 
18    protected ValueStringFixed(String value) {
19        super(value);
20    }
21 
22    private static String trimRight(String s) {
23        int endIndex = s.length() - 1;
24        int i = endIndex;
25        while (i >= 0 && s.charAt(i) == ' ') {
26            i--;
27        }
28        s = i == endIndex ? s : s.substring(0, i + 1);
29        return s;
30    }
31 
32    @Override
33    public int getType() {
34        return Value.STRING_FIXED;
35    }
36 
37    /**
38     * Get or create a fixed length string value for the given string.
39     * Spaces at the end of the string will be removed.
40     *
41     * @param s the string
42     * @return the value
43     */
44    public static ValueStringFixed get(String s) {
45        s = trimRight(s);
46        if (s.length() == 0) {
47            return EMPTY;
48        }
49        ValueStringFixed obj = new ValueStringFixed(StringUtils.cache(s));
50        if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) {
51            return obj;
52        }
53        return (ValueStringFixed) Value.cache(obj);
54    }
55 
56    @Override
57    protected ValueString getNew(String s) {
58        return ValueStringFixed.get(s);
59    }
60 
61}

[all classes][org.h2.value]
EMMA 2.0.5312 (C) Vladimir Roubtsov