Project

Profile

Help

Revision 145ccaa0

Added by Michael Kay almost 3 years ago

Support code for alphacode type representation in XX compiler

View differences:

latest9.9/hej/net/sf/saxon/type/BuiltInAtomicType.java
19 19
import net.sf.saxon.value.*;
20 20

  
21 21
import java.util.Collections;
22
import java.util.HashMap;
23
import java.util.Map;
22 24
import java.util.Set;
23 25

  
24 26
import static net.sf.saxon.type.SchemaComponent.ValidationStatus.VALIDATED;
......
42 44
    private SequenceType _zeroOrOne;
43 45
    private SequenceType _zeroOrMore;
44 46

  
47
    /**
48
     * Table of all built in atomic types, indexed by the alphacode, eg. ADI = integer
49
     */
50

  
51
    private static Map<String, BuiltInAtomicType> lookupByAlphaCode = new HashMap<>(100);
52

  
45 53
    public final static BuiltInAtomicType ANY_ATOMIC =
46 54
            makeAtomicType(StandardNames.XS_ANY_ATOMIC_TYPE, AnySimpleType.getInstance(), "A", true);
47 55

  
......
1177 1185
        t.ordered = ordered;
1178 1186
        t.alphaCode = code;
1179 1187
        BuiltInType.register(fingerprint, t);
1188
        lookupByAlphaCode.put(code, t);
1180 1189
        return t;
1181 1190
    }
1182 1191

  
1192
    public static BuiltInAtomicType getTypeWithAlphaCode(String alphaCode) {
1193
        return lookupByAlphaCode.get(alphaCode);
1194
    }
1195

  
1183 1196
    /**
1184 1197
     * Apply any pre-lexical facets, other than whitespace. At the moment the only such
1185 1198
     * facet is saxon:preprocess
latest9.9/hej/net/sf/saxon/type/BuiltInType.java
26 26
     * Table of all built in types, indexed by fingerprint
27 27
     */
28 28

  
29
    private static IntHashMap<SchemaType> lookup = new IntHashMap<SchemaType>(100);
29
    private static IntHashMap<SchemaType> lookup = new IntHashMap<>(100);
30 30

  
31 31
    /**
32 32
     * Table of all built in types, indexed by local name
33 33
     */
34 34

  
35
    private static Map<String, SchemaType> lookupByLocalName = new HashMap<String, SchemaType>(100);
35
    private static Map<String, SchemaType> lookupByLocalName = new HashMap<>(100);
36 36

  
37 37
    /**
38 38
     * Class is never instantiated
latest9.9/hej/net/sf/saxon/value/Cardinality.java
209 209
    }
210 210

  
211 211
    /**
212
     * Get the occurence indicator representing the cardinality
212
     * Get the occurrence indicator representing the cardinality
213 213
     *
214 214
     * @param cardinality the cardinality value
215 215
     * @return the occurrence indicator, for example "*", "+", "?", "".
......
236 236
        }
237 237
    }
238 238

  
239
    /**
240
     * Get the cardinality code from an occurrence indicator
241
     *
242
     * @param cardinality the cardinality value
243
     * @return the occurrence indicator, for example "*", "+", "?", "".
244
     */
245

  
246
    /*@NotNull*/
247
    public static int fromOccurrenceIndicator(char cardinality) {
248
        switch (cardinality) {
249
            case '?':
250
            return StaticProperty.ALLOWS_ZERO_OR_ONE;
251
            case '1': return StaticProperty.EXACTLY_ONE;
252
            case '*': return StaticProperty.ALLOWS_ZERO_OR_MORE;
253
            case '+': return StaticProperty.ALLOWS_ONE_OR_MORE;
254
            case '\u00B0': return StaticProperty.ALLOWS_ZERO;
255
            default:
256
                throw new AssertionError();
257
        }
258
    }
259

  
260

  
239 261
    /**
240 262
     * Generate Javascript code to check whether a number satisfies the cardinality property.
241 263
     *

Also available in: Unified diff