MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / IonValueLite

Class IonValueLite

src/main/java/com/amazon/ion/impl/lite/IonValueLite.java:34–1406  ·  view source on GitHub ↗

Base class of the light weight implementation of Ion values.

Source from the content-addressed store, hash-verified

32 * Ion values.
33 */
34abstract class IonValueLite
35 implements _Private_IonValue
36{
37 private static final int TYPE_ANNOTATION_HASH_SIGNATURE =
38 "TYPE ANNOTATION".hashCode();
39
40 /**
41 * this hold all the various boolean flags we have
42 * in a single int. Use set_flag(), clear_flag(), is_true()
43 * and the associated int flag to check the various flags.
44 * This is to avoid the overhead java seems to impose
45 * for a boolean value - it should be a bit, but it seems
46 * to be an int (4 bytes for 1 bit seems excessive).
47 */
48 protected static final int IS_LOCKED = 0x01;
49 protected static final int IS_SYSTEM_VALUE = 0x02;
50 protected static final int IS_NULL_VALUE = 0x04;
51 protected static final int IS_BOOL_TRUE = 0x08;
52 protected static final int IS_IVM = 0x10;
53 protected static final int IS_AUTO_CREATED = 0x20;
54 protected static final int IS_SYMBOL_PRESENT = 0x40;
55 /**
56 * Symbol ID present refers to there being the <i>possibility</i> that the IonValueLite, or it's contained sub graph
57 * <i>(e.g. if it is a {@link IonContainerLite} based sub type)</i> contains one or more defined
58 * Symbol ID's (SID)'s. This flag is used to track lifecycle, such that operations that require SID's are purged
59 * from the IonValueLite and it's contained sub-DOM can conduct a fast evaluation rather than having to do a full
60 * contained graph traversal on each and every invocation.
61 */
62 protected static final int IS_SYMBOL_ID_PRESENT = 0x80;
63
64 private static final int ELEMENT_MASK = 0xff;
65 protected static final int ELEMENT_SHIFT = 8; // low 8 bits is flag, upper 24 (or 48 is element id)
66
67 // This value was chosen somewhat arbitrarily; it can/should be changed if it is found to be insufficient.
68 static final int CONTAINER_STACK_INITIAL_CAPACITY = 16;
69
70 // 'withCharsetAscii' is only specified for consistency with the behavior of the previous implementation of
71 // toString. Technically users are not allowed to rely on a canonical encoding, but in practice they often do.
72 private static final IonTextWriterBuilder DEFAULT_TO_STRING_WRITER_BUILDER =
73 ((_Private_IonTextWriterBuilder) IonTextWriterBuilder.standard())
74 .withInvalidSidsAllowed(true)
75 .withCharsetAscii()
76 .immutable();
77
78
79 /**
80 * Used by subclasses to retrieve metadata set by
81 * {@link #_setMetadata(int, int, int)}.
82 * @param mask the location of the metadata to retrieve.
83 * @param shift the number of bits to right-shift the metadata so that
84 * it starts at bit index 0.
85 * @return the metadata from _flags at the given mask.
86 */
87 protected final int _getMetadata(int mask, int shift) {
88 return (_flags & mask) >>> shift;
89 }
90
91 /**

Callers

nothing calls this directly

Calls 5

standardMethod · 0.95
withCharsetAsciiMethod · 0.80
hashCodeMethod · 0.65
immutableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…