Top Fields Constructors Methods
com.amazon.ion.impl.lite

pack-priv final Class IonStructLite

extends IonContainerLite
implements IonStruct
Class Inheritance
All Implemented Interfaces
com.amazon.ion.IonStruct, com.amazon.ion.IonContainer, java.lang.Iterable, com.amazon.ion.IonValue, java.lang.Cloneable
Imports
com.amazon.ion.ContainedValueException, .IonStruct, .IonType, .IonValue, .SymbolToken, .ValueFactory, .ValueVisitor, .UnknownSymbolException, com.amazon.ion.impl._Private_CurriedValueFactory, java.io.PrintWriter, java.util.Arrays, .HashMap, .HashSet, .Iterator, .Map, .Map.Entry, .Set

Field Summary

Modifier and TypeField and Description
private Map<String, Integer>
public int
private static final int
private boolean
Inherited from com.amazon.ion.impl.lite.IonContainerLite:
_child_count_childrenINITIAL_SIZEionSystemNEXT_SIZESTRUCT_INITIAL_SIZEstructuralModificationCount

Constructor Summary

AccessConstructor and Description
pack-priv
IonStructLite(ContainerlessContext context, boolean isNull)

private

Method Summary

Modifier and TypeMethod and Description
private void
_add(String
may be null
fieldName
,
IonValueLite
must be validated and have field name or id set
child
)

Validates the child and checks locks.

public void
accept(ValueVisitor
will have one of its visit methods called.
visitor
)

Implements abstract com.amazon.ion.impl.lite.IonContainerLite.accept.

Implements com.amazon.ion.IonValue.accept.

Entry point for visitor pattern.

public boolean
public ValueFactory
add(final String fieldName)

Implements com.amazon.ion.IonStruct.add.

Provides a factory that when invoked constructs a new value and adds it to this struct using the given fieldName.

public void
add(String
the name of the new field.
fieldName
,
IonValue
the value of the new field.
value
)

Implements com.amazon.ion.IonStruct.add.

Adds a new field to this struct.

public void
add(SymbolToken
the name of the new field.
fieldName
,
IonValue
the value of the new field.
child
)

Implements com.amazon.ion.IonStruct.add.

Adds a new field to this struct using a given name and/or SID.

private void
add_field(String fieldName, int newFieldIdx)

pack-priv void
afterIteratorRemove(IonValueLite
the value that was removed.
value
,
int
the container index of the value that was removed.
idx
)

Overrides com.amazon.ion.impl.lite.IonContainerLite.afterIteratorRemove.

Called after a value is removed from the SequenceContentIterator.

pack-priv void
beforeIteratorRemove(IonValueLite
the value that will be removed.
value
,
int
the container index of the value that will be removed.
idx
)

Overrides com.amazon.ion.impl.lite.IonContainerLite.beforeIteratorRemove.

Called before a value is removed from the SequenceContentIterator.

private void
public void
clear()

Overrides com.amazon.ion.impl.lite.IonContainerLite.clear.

Implements com.amazon.ion.IonContainer.clear.

Clears the contents of this container (if any) and set it to empty.

public IonStructLite
public IonStruct
cloneAndRemove(String...
the names of the fields to remove. A null field name causes removal of fields with unknown names.
fieldNames
)

Implements com.amazon.ion.IonStruct.cloneAndRemove.

Clones this struct, excluding certain fields.

public IonStruct
cloneAndRetain(String...
the names of the fields to retain. Nulls are not allowed.
fieldNames
)

Implements com.amazon.ion.IonStruct.cloneAndRetain.

Clones this struct, including only certain fields.

public boolean
containsKey(Object
field name whose presence in this struct is to be tested
fieldName
)

Implements com.amazon.ion.IonStruct.containsKey.

Determines whether this struct contains one or more fields for the specified field name (i.e., key).

public boolean
containsValue(Object
value whose presence in this struct is to be tested
value
)

Implements com.amazon.ion.IonStruct.containsValue.

Determines whether this struct contains one or more fields with the specified value.

private IonStruct
doClone(boolean keep, String... fieldNames)

public void
private boolean
fieldMapIsActive(int proposedSize)

private int
private int
find_last_duplicate(String fieldName, int existing_idx)

pack-priv void
forceMaterializationOfLazyState()

Overrides com.amazon.ion.impl.lite.IonContainerLite.forceMaterializationOfLazyState.

Force any lazy state to be materialized (if applicable).

public IonValue
get(String
the desired field.
fieldName
)

Implements com.amazon.ion.IonStruct.get.

Gets the value of a field in this struct.

public IonType
pack-priv int
private static boolean

Returns:

true if field.getFieldName() is in fields.
isListedField
(IonValue
must not be null. It is not required to have a field name.
field
,
String[]
must not be null, and must not contain and nulls.
fields
)

private void
patch_map_elements_helper(int removed_idx)

public ValueFactory
put(final String fieldName)

Implements com.amazon.ion.IonStruct.put.

Provides a factory that when invoked constructs a new value and puts it into this struct using the given fieldName.

public void
put(String
the name of the new field.
fieldName
,
IonValue
the value of the new field.
value
)

Implements com.amazon.ion.IonStruct.put.

put is "make this value the one and only value associated with this fieldName".

public void
putAll(Map<? extends String, ? extends IonValue> m)

Implements com.amazon.ion.IonStruct.putAll.

Copies all of the mappings from the specified map to this struct.

public IonValue
remove(String
must not be null.
fieldName
)

Implements com.amazon.ion.IonStruct.remove.

Removes a field by name, returning a value that was previously associated with the field, or null if this struct contained no such field.

public boolean
remove(IonValue
the element to be removed from this container, if present.
element
)

Overrides com.amazon.ion.impl.lite.IonContainerLite.remove.

Implements com.amazon.ion.IonContainer.remove.

Removes the given element from this container.

private void
remove_field(String fieldName, int lowest_idx, int copies)

private void
remove_field_from_field_map(String fieldName, int idx)

public boolean
removeAll(String...
the names of the fields to remove.
fieldNames
)

Implements com.amazon.ion.IonStruct.removeAll.

Removes from this struct all fields with names in the given list.

public boolean
retainAll(String...
the names of the fields to retain.
fieldNames
)

Implements com.amazon.ion.IonStruct.retainAll.

Retains only the fields in this struct that have one of the given names.

pack-priv IonValueLite
shallowClone(IonContext
the context applicable to the value's parent.
context
)

Implements abstract com.amazon.ion.impl.lite.IonValueLite.shallowClone.

Clones the value's annotations and field name (if any).

private boolean
there_is_only_one(String fieldName, int existing_idx)

protected void
transitionToLargeSize(int size)

Overrides com.amazon.ion.impl.lite.IonContainerLite.transitionToLargeSize.

This is overridden in IonStructLite to add the HashMap of field names when the struct becomes moderately large.

public String
private static void
validateFieldName(String fieldName)

Ensures that a given field name is valid.

Inherited from com.amazon.ion.impl.lite.IonContainerLite:
addadd_childdeepClonegetget_childget_child_countgetContextContainergetContextForIndexgetContextSymbolTablegetSysteminitialSizeisEmptyiteratorlistIteratorlistIteratormake_initial_size_arraymake_next_size_arraymakeNullnextSizepatch_elements_helperremove_childscalarHashCodeset_childsizevalidateNewChildwriteBodyTo

Field Detail

_field_mapback to summary
private Map<String, Integer> _field_map
_field_map_duplicate_countback to summary
public int _field_map_duplicate_count
HASH_SIGNATUREback to summary
private static final int HASH_SIGNATURE
hasNullFieldNameback to summary
private boolean hasNullFieldName

Constructor Detail

IonStructLiteback to summary
pack-priv IonStructLite(ContainerlessContext context, boolean isNull)
IonStructLiteback to summary
private IonStructLite(IonStructLite existing, IonContext context)

Method Detail

_addback to summary
private void _add(String fieldName, IonValueLite child)

Validates the child and checks locks.

Parameters
fieldName:String

may be null

child:IonValueLite

must be validated and have field name or id set

acceptback to summary
public void accept(ValueVisitor visitor) throws Exception

Implements abstract com.amazon.ion.impl.lite.IonContainerLite.accept.

Implements com.amazon.ion.IonValue.accept.

Doc from com.amazon.ion.IonValue.accept.

Entry point for visitor pattern. Implementations of this method by concrete classes will simply call the appropriate visit method on the visitor. For example, instances of IonBool will invoke ValueVisitor#visit(IonBool).

Parameters
visitor:ValueVisitor

will have one of its visit methods called.

Annotations
@Override
Exceptions
Exception:
any exception thrown by the visitor is propagated.
addback to summary
public boolean add(IonValue child) throws NullPointerException, IllegalArgumentException, ContainedValueException

Overrides com.amazon.ion.impl.lite.IonContainerLite.add.

Annotations
@Override
addback to summary
public ValueFactory add(final String fieldName)

Implements com.amazon.ion.IonStruct.add.

Doc from com.amazon.ion.IonStruct.add.

Provides a factory that when invoked constructs a new value and adds it to this struct using the given fieldName.

These two lines are equivalent:

    str.add("f").newInt(3);
    str.add("f", str.getSystem().newInt(3));
addback to summary
public void add(String fieldName, IonValue value)

Implements com.amazon.ion.IonStruct.add.

Doc from com.amazon.ion.IonStruct.add.

Adds a new field to this struct. If this is null.struct, then it becomes a single-field struct.

If a field with the given name already exists in this struct, this call will result in repeated fields.

Parameters
fieldName:String

the name of the new field.

value:IonValue

the value of the new field.

addback to summary
public void add(SymbolToken fieldName, IonValue child)

Implements com.amazon.ion.IonStruct.add.

Doc from com.amazon.ion.IonStruct.add.

Adds a new field to this struct using a given name and/or SID. If this is null.struct, then it becomes a single-field struct.

If a field with the given name already exists in this struct, this call will result in repeated fields.

This is an "expert method": correct use requires deep understanding of the Ion binary format. You almost certainly don't want to use it.

Parameters
fieldName:SymbolToken

the name of the new field.

child:IonValue

the value of the new field.

add_fieldback to summary
private void add_field(String fieldName, int newFieldIdx)
afterIteratorRemoveback to summary
pack-priv void afterIteratorRemove(IonValueLite value, int idx)

Overrides com.amazon.ion.impl.lite.IonContainerLite.afterIteratorRemove.

Doc from com.amazon.ion.impl.lite.IonContainerLite.afterIteratorRemove.

Called after a value is removed from the SequenceContentIterator. May be overridden by subclasses that require custom behavior.

Parameters
value:IonValueLite

the value that was removed.

idx:int

the container index of the value that was removed.

Annotations
@Override
beforeIteratorRemoveback to summary
pack-priv void beforeIteratorRemove(IonValueLite value, int idx)

Overrides com.amazon.ion.impl.lite.IonContainerLite.beforeIteratorRemove.

Doc from com.amazon.ion.impl.lite.IonContainerLite.beforeIteratorRemove.

Called before a value is removed from the SequenceContentIterator. May be overridden by subclasses that require custom behavior.

Parameters
value:IonValueLite

the value that will be removed.

idx:int

the container index of the value that will be removed.

Annotations
@Override
build_field_mapback to summary
private void build_field_map()
clearback to summary
public void clear()

Overrides com.amazon.ion.impl.lite.IonContainerLite.clear.

Implements com.amazon.ion.IonContainer.clear.

Doc from com.amazon.ion.IonContainer.clear.

Clears the contents of this container (if any) and set it to empty. If this container is an Ion null value, set it to empty.

Use makeNull to make this container null rather than empty.

Warning

This method is not support for instances of IonDatagram.

Annotations
@Override
cloneback to summary
public IonStructLite clone()

Overrides com.amazon.ion.impl.lite.IonContainerLite.clone.

Implements com.amazon.ion.IonStruct.clone, com.amazon.ion.IonContainer.clone, com.amazon.ion.IonValue.clone.

Doc from com.amazon.ion.IonValue.clone.

Creates a copy of this value and all of its children. The cloned value may use the same shared symbol tables, but it will have an independent local symbol table if necessary. The cloned value will be modifiable regardless of whether this instance isReadOnly().

The cloned value will be created in the context of the same ValueFactory as this instance; if you want a copy using a different factory, then use ValueFactory#clone(IonValue) instead.

Returns:IonStructLite

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
cloneAndRemoveback to summary
public IonStruct cloneAndRemove(String... fieldNames)

Implements com.amazon.ion.IonStruct.cloneAndRemove.

Doc from com.amazon.ion.IonStruct.cloneAndRemove.

Clones this struct, excluding certain fields. This can be more efficient than cloning the struct and removing fields later on.

Parameters
fieldNames:String[]

the names of the fields to remove. A null field name causes removal of fields with unknown names.

cloneAndRetainback to summary
public IonStruct cloneAndRetain(String... fieldNames)

Implements com.amazon.ion.IonStruct.cloneAndRetain.

Doc from com.amazon.ion.IonStruct.cloneAndRetain.

Clones this struct, including only certain fields. This can be more efficient than cloning the struct and removing fields later on.

Parameters
fieldNames:String[]

the names of the fields to retain. Nulls are not allowed.

containsKeyback to summary
public boolean containsKey(Object fieldName)

Implements com.amazon.ion.IonStruct.containsKey.

Doc from com.amazon.ion.IonStruct.containsKey.

Determines whether this struct contains one or more fields for the specified field name (i.e., key). If this struct is an Ion null value, it will behave like an empty struct.

Parameters
fieldName:Object

field name whose presence in this struct is to be tested

Returns:boolean

true if this struct contains a field for the specified field name

containsValueback to summary
public boolean containsValue(Object value)

Implements com.amazon.ion.IonStruct.containsValue.

Doc from com.amazon.ion.IonStruct.containsValue.

Determines whether this struct contains one or more fields with the specified value. If this struct is an Ion null value, it will behave like an empty struct. This uses reference equality to compare the specified value with the value of the struct fields.

Parameters
value:Object

value whose presence in this struct is to be tested

Returns:boolean

true if this struct contains a field for the specified value

doCloneback to summary
private IonStruct doClone(boolean keep, String... fieldNames)
dumpback to summary
public void dump(PrintWriter out)

Overrides com.amazon.ion.impl.lite.IonValueLite.dump.

Implements com.amazon.ion.impl._Private_IonValue.dump.

Annotations
@Override
fieldMapIsActiveback to summary
private boolean fieldMapIsActive(int proposedSize)
find_field_helperback to summary
private int find_field_helper(String fieldName)
find_last_duplicateback to summary
private int find_last_duplicate(String fieldName, int existing_idx)
forceMaterializationOfLazyStateback to summary
pack-priv void forceMaterializationOfLazyState()

Overrides com.amazon.ion.impl.lite.IonContainerLite.forceMaterializationOfLazyState.

Doc from com.amazon.ion.impl.lite.IonContainerLite.forceMaterializationOfLazyState.

Force any lazy state to be materialized (if applicable).

Annotations
@Override
getback to summary
public IonValue get(String fieldName)

Implements com.amazon.ion.IonStruct.get.

Doc from com.amazon.ion.IonStruct.get.

Gets the value of a field in this struct. If the field name appears more than once, one of the fields will be selected arbitrarily. For example, calling get("a") on the struct:

    { a:1, b:2, a:3 }
will return either 1 or 3.
Parameters
fieldName:String

the desired field.

Returns:IonValue

the value of the field, or null if it doesn't exist in this struct, or if this is null.struct.

getTypeSlowback to summary
public IonType getTypeSlow()

Implements abstract com.amazon.ion.impl.lite.IonValueLite.getTypeSlow.

Returns:IonType

Doc from com.amazon.ion.impl.lite.IonValueLite.getTypeSlow.

the value's type.

Annotations
@Override
hashSignatureback to summary
pack-priv int hashSignature()

Implements abstract com.amazon.ion.impl.lite.IonValueLite.hashSignature.

Returns:int

Doc from com.amazon.ion.impl.lite.IonValueLite.hashSignature.

the constant hash signature unique to the value's type.

Annotations
@Override
isListedFieldback to summary
private static boolean isListedField(IonValue field, String[] fields)
Parameters
field:IonValue

must not be null. It is not required to have a field name.

fields:String[]

must not be null, and must not contain and nulls.

Returns:boolean

true if field.getFieldName() is in fields.

patch_map_elements_helperback to summary
private void patch_map_elements_helper(int removed_idx)
putback to summary
public ValueFactory put(final String fieldName)

Implements com.amazon.ion.IonStruct.put.

Doc from com.amazon.ion.IonStruct.put.

Provides a factory that when invoked constructs a new value and puts it into this struct using the given fieldName.

These two lines are equivalent:

    str.put("f").newInt(3);
    str.put("f", str.getSystem().newInt(3));
putback to summary
public void put(String fieldName, IonValue value)

Implements com.amazon.ion.IonStruct.put.

put is "make this value the one and only value associated with this fieldName". The side effect is that if there were multiple fields with this name when put is complete there will only be the one value in the collection.

Parameters
fieldName:String

Doc from com.amazon.ion.IonStruct.put.

the name of the new field.

value:IonValue

Doc from com.amazon.ion.IonStruct.put.

the value of the new field.

putAllback to summary
public void putAll(Map<? extends String, ? extends IonValue> m)

Implements com.amazon.ion.IonStruct.putAll.

Doc from com.amazon.ion.IonStruct.putAll.

Copies all of the mappings from the specified map to this struct. The effect of this call is equivalent to that of calling put(k, v) on this struct once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

If a key in the map maps to null, then all fields with that name will be removed from this struct.

removeback to summary
public IonValue remove(String fieldName)

Implements com.amazon.ion.IonStruct.remove.

Doc from com.amazon.ion.IonStruct.remove.

Removes a field by name, returning a value that was previously associated with the field, or null if this struct contained no such field.

Because Ion structs may have repeated fields, additional fields with the given name may still exist after this method returns.

If this struct is an Ion null value or empty, then this method returns null and has no effect.

Parameters
fieldName:String

must not be null.

Returns:IonValue

previous value associated with the specified field name, or null if there was no such field.

removeback to summary
public boolean remove(IonValue element)

Overrides com.amazon.ion.impl.lite.IonContainerLite.remove.

Implements com.amazon.ion.IonContainer.remove.

Doc from com.amazon.ion.IonContainer.remove.

Removes the given element from this container. If this is an Ion null value, then this method returns false.

Note that, unlike Collection#remove(Object), this method uses object identity, not Object#equals(Object), to find the element. That is, the given instance is removed, not other similarly "equal" instances.

Parameters
element:IonValue

the element to be removed from this container, if present.

Returns:boolean

true if this container contained the specified element.

Annotations
@Override
remove_fieldback to summary
private void remove_field(String fieldName, int lowest_idx, int copies)
remove_field_from_field_mapback to summary
private void remove_field_from_field_map(String fieldName, int idx)
removeAllback to summary
public boolean removeAll(String... fieldNames)

Implements com.amazon.ion.IonStruct.removeAll.

Doc from com.amazon.ion.IonStruct.removeAll.

Removes from this struct all fields with names in the given list. If multiple fields with a given name exist in this struct, they will all be removed.

If this struct is an Ion null value or empty, then this method returns false and has no effect.

Parameters
fieldNames:String[]

the names of the fields to remove.

Returns:boolean

true if this struct changed as a result of this call.

retainAllback to summary
public boolean retainAll(String... fieldNames)

Implements com.amazon.ion.IonStruct.retainAll.

Doc from com.amazon.ion.IonStruct.retainAll.

Retains only the fields in this struct that have one of the given names. In other words, removes all fields with names that are not in fieldNames.

If this struct is an Ion null value or empty, then this method returns false and has no effect.

Parameters
fieldNames:String[]

the names of the fields to retain.

Returns:boolean

true if this struct changed as a result of this call.

shallowCloneback to summary
pack-priv IonValueLite shallowClone(IonContext context)

Implements abstract com.amazon.ion.impl.lite.IonValueLite.shallowClone.

Doc from com.amazon.ion.impl.lite.IonValueLite.shallowClone.

Clones the value's annotations and field name (if any). For scalars, also clones the value. For containers, leaves the cloned container empty rather than cloning the children.

Parameters
context:IonContext

the context applicable to the value's parent.

Returns:IonValueLite

a shallow clone of this value.

Annotations
@Override
there_is_only_oneback to summary
private boolean there_is_only_one(String fieldName, int existing_idx)
transitionToLargeSizeback to summary
protected void transitionToLargeSize(int size)

Overrides com.amazon.ion.impl.lite.IonContainerLite.transitionToLargeSize.

Doc from com.amazon.ion.impl.lite.IonContainerLite.transitionToLargeSize.

This is overridden in IonStructLite to add the HashMap of field names when the struct becomes moderately large.

Annotations
@Override
validateback to summary
public String validate()

Overrides com.amazon.ion.impl.lite.IonValueLite.validate.

Implements com.amazon.ion.impl._Private_IonValue.validate.

Annotations
@Override
validateFieldNameback to summary
private static void validateFieldName(String fieldName)

Ensures that a given field name is valid. Used as a helper for methods that have that precondition.

Exceptions
NullPointerException:
if the fieldName is null.