use of com.amazon.ion.impl._Private_Utils.newSymbolToken in project ion-java by amzn.
the class IonValueLite method getFieldNameSymbol.
public final SymbolToken getFieldNameSymbol(SymbolTableProvider symbolTableProvider) {
int sid = _fieldId;
String text = _fieldName;
if (text != null) {
if (sid == UNKNOWN_SYMBOL_ID) {
SymbolToken tok = symbolTableProvider.getSymbolTable().find(text);
if (tok != null) {
return tok;
}
}
} else if (sid > 0) {
text = symbolTableProvider.getSymbolTable().findKnownSymbol(sid);
} else if (sid != 0) {
// not a struct field
return null;
}
return _Private_Utils.newSymbolToken(text, sid);
}
use of com.amazon.ion.impl._Private_Utils.newSymbolToken in project ion-java by amzn.
the class StructTest method testBadAddSymbolToken.
@Test
public void testBadAddSymbolToken() {
IonStruct value = system().newNullStruct();
IonBool nullBool = system().newNullBool();
try {
value.add((SymbolToken) null, nullBool);
fail("Expected NullPointerException");
} catch (NullPointerException e) {
}
SymbolToken is = _Private_Utils.newSymbolToken("f", 1);
try {
value.add(is, null);
fail("Expected NullPointerException");
} catch (NullPointerException e) {
}
IonValue contained = value.add("g").newNull();
try {
value.add(is, contained);
fail("Expected exception");
} catch (ContainedValueException e) {
}
IonValue dg = system().newDatagram();
try {
value.add(is, dg);
fail("Expected exception");
} catch (IllegalArgumentException e) {
}
is = new FakeSymbolToken(null, UNKNOWN_SYMBOL_ID);
try {
value.add(is, nullBool);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
}
is = new FakeSymbolToken(null, -2);
try {
value.add(is, nullBool);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
}
value.remove(contained);
assertTrue(value.isEmpty());
}
Aggregations