
io.ciera.tool.sql.loader.impl.EventInstanceSerializerImpl Maven / Gradle / Ivy
package io.ciera.tool.sql.loader.impl;
import io.ciera.runtime.instanceloading.AttributeChangedDelta;
import io.ciera.runtime.instanceloading.InstanceCreatedDelta;
import io.ciera.runtime.summit.application.IRunContext;
import io.ciera.runtime.summit.classes.IInstanceIdentifier;
import io.ciera.runtime.summit.classes.InstanceIdentifier;
import io.ciera.runtime.summit.classes.ModelInstance;
import io.ciera.runtime.summit.exceptions.EmptyInstanceException;
import io.ciera.runtime.summit.exceptions.InstancePopulationException;
import io.ciera.runtime.summit.exceptions.XtumlException;
import io.ciera.runtime.summit.types.IWhere;
import io.ciera.runtime.summit.types.IXtumlType;
import io.ciera.runtime.summit.types.StringUtil;
import io.ciera.runtime.summit.types.UniqueId;
import io.ciera.tool.Sql;
import io.ciera.tool.sql.loader.AttributeSerializer;
import io.ciera.tool.sql.loader.EventInstanceSerializer;
import io.ciera.tool.sql.loader.InstanceSerializer;
import io.ciera.tool.sql.loader.impl.InstanceSerializerImpl;
public class EventInstanceSerializerImpl extends ModelInstance implements EventInstanceSerializer {
public static final String KEY_LETTERS = "EventInstanceSerializer";
public static final EventInstanceSerializer EMPTY_EVENTINSTANCESERIALIZER = new EmptyEventInstanceSerializer();
private Sql context;
// constructors
private EventInstanceSerializerImpl( Sql context ) {
this.context = context;
ref_loader_name = "";
ref_loader_package = "";
ref_class_name = "";
R3015_is_a_InstanceSerializer_inst = InstanceSerializerImpl.EMPTY_INSTANCESERIALIZER;
}
private EventInstanceSerializerImpl( Sql context, UniqueId instanceId, String ref_loader_name, String ref_loader_package, String ref_class_name ) {
super(instanceId);
this.context = context;
this.ref_loader_name = ref_loader_name;
this.ref_loader_package = ref_loader_package;
this.ref_class_name = ref_class_name;
R3015_is_a_InstanceSerializer_inst = InstanceSerializerImpl.EMPTY_INSTANCESERIALIZER;
}
public static EventInstanceSerializer create( Sql context ) throws XtumlException {
EventInstanceSerializer newEventInstanceSerializer = new EventInstanceSerializerImpl( context );
if ( context.addInstance( newEventInstanceSerializer ) ) {
newEventInstanceSerializer.getRunContext().addChange(new InstanceCreatedDelta(newEventInstanceSerializer, KEY_LETTERS));
return newEventInstanceSerializer;
}
else throw new InstancePopulationException( "Instance already exists within this population." );
}
public static EventInstanceSerializer create( Sql context, String ref_loader_name, String ref_loader_package, String ref_class_name ) throws XtumlException {
return create(context, UniqueId.random(), ref_loader_name, ref_loader_package, ref_class_name);
}
public static EventInstanceSerializer create( Sql context, UniqueId instanceId, String ref_loader_name, String ref_loader_package, String ref_class_name ) throws XtumlException {
EventInstanceSerializer newEventInstanceSerializer = new EventInstanceSerializerImpl( context, instanceId, ref_loader_name, ref_loader_package, ref_class_name );
if ( context.addInstance( newEventInstanceSerializer ) ) {
return newEventInstanceSerializer;
}
else throw new InstancePopulationException( "Instance already exists within this population." );
}
// attributes
private String ref_loader_name;
@Override
public String getLoader_name() throws XtumlException {
checkLiving();
return ref_loader_name;
}
@Override
public void setLoader_name(String ref_loader_name) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_loader_name, this.ref_loader_name)) {
final String oldValue = this.ref_loader_name;
this.ref_loader_name = ref_loader_name;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_loader_name", oldValue, this.ref_loader_name));
}
}
private String ref_loader_package;
@Override
public String getLoader_package() throws XtumlException {
checkLiving();
return ref_loader_package;
}
@Override
public void setLoader_package(String ref_loader_package) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_loader_package, this.ref_loader_package)) {
final String oldValue = this.ref_loader_package;
this.ref_loader_package = ref_loader_package;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_loader_package", oldValue, this.ref_loader_package));
}
}
private String ref_class_name;
@Override
public String getClass_name() throws XtumlException {
checkLiving();
return ref_class_name;
}
@Override
public void setClass_name(String ref_class_name) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_class_name, this.ref_class_name)) {
final String oldValue = this.ref_class_name;
this.ref_class_name = ref_class_name;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_class_name", oldValue, this.ref_class_name));
}
}
// instance identifiers
@Override
public IInstanceIdentifier getId1() {
try {
return new InstanceIdentifier(getLoader_name(), getLoader_package(), getClass_name());
}
catch ( XtumlException e ) {
getRunContext().getLog().error(e);
System.exit(1);
return null;
}
}
// operations
@Override
public void render() throws XtumlException {
String class_name = ( context().STRING().substr( self().getClass_name(), 0, context().STRING().indexof( self().getClass_name(), "_" ) ) + "Impl." ) + context().STRING().substr( self().getClass_name(), context().STRING().indexof( self().getClass_name(), "_" ) + 1, -1 );
context().T().include( "loader/t.eventinstanceserializer.java", class_name, self() );
}
@Override
public void render_def() throws XtumlException {
context().T().push_buffer();
AttributeSerializer attr_serializer = self().R3015_is_a_InstanceSerializer().R3002_serializes_data_value_using_AttributeSerializer().any();
AttributeSerializer prev_attr_serializer = attr_serializer.R3003_follows_AttributeSerializer();
while ( !prev_attr_serializer.isEmpty() ) {
attr_serializer = prev_attr_serializer;
prev_attr_serializer = attr_serializer.R3003_follows_AttributeSerializer();
}
while ( !attr_serializer.isEmpty() ) {
attr_serializer.render();
attr_serializer = attr_serializer.R3003_precedes_AttributeSerializer();
if ( !attr_serializer.isEmpty() ) {
context().T().include( "loader/t.attributeserializer.sep.java" );
}
}
String attribute_serializers = context().T().body();
String class_name = ( context().STRING().substr( self().getClass_name(), 0, context().STRING().indexof( self().getClass_name(), "_" ) ) + "Impl." ) + context().STRING().substr( self().getClass_name(), context().STRING().indexof( self().getClass_name(), "_" ) + 1, -1 );
context().T().pop_buffer();
context().T().include( "loader/t.eventinstanceserializer.def.java", attribute_serializers, class_name, self() );
}
@Override
public void render_init() throws XtumlException {
context().T().include( "loader/t.eventinstanceserializer.init.java" );
}
// static operations
// events
// selections
private InstanceSerializer R3015_is_a_InstanceSerializer_inst;
@Override
public void setR3015_is_a_InstanceSerializer( InstanceSerializer inst ) {
R3015_is_a_InstanceSerializer_inst = inst;
}
@Override
public InstanceSerializer R3015_is_a_InstanceSerializer() throws XtumlException {
return R3015_is_a_InstanceSerializer_inst;
}
@Override
public IRunContext getRunContext() {
return context().getRunContext();
}
@Override
public Sql context() {
return context;
}
@Override
public String getKeyLetters() {
return KEY_LETTERS;
}
@Override
public EventInstanceSerializer self() {
return this;
}
@Override
public EventInstanceSerializer oneWhere(IWhere condition) throws XtumlException {
if (null == condition) throw new XtumlException("Null condition passed to selection.");
if (condition.evaluate(this)) return this;
else return EMPTY_EVENTINSTANCESERIALIZER;
}
}
class EmptyEventInstanceSerializer extends ModelInstance implements EventInstanceSerializer {
// attributes
public String getLoader_name() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public void setLoader_name( String ref_loader_name ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
public String getLoader_package() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public void setLoader_package( String ref_loader_package ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
public String getClass_name() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public void setClass_name( String ref_class_name ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
// operations
public void render() throws XtumlException {
throw new EmptyInstanceException( "Cannot invoke operation on empty instance." );
}
public void render_def() throws XtumlException {
throw new EmptyInstanceException( "Cannot invoke operation on empty instance." );
}
public void render_init() throws XtumlException {
throw new EmptyInstanceException( "Cannot invoke operation on empty instance." );
}
// selections
@Override
public InstanceSerializer R3015_is_a_InstanceSerializer() {
return InstanceSerializerImpl.EMPTY_INSTANCESERIALIZER;
}
@Override
public String getKeyLetters() {
return EventInstanceSerializerImpl.KEY_LETTERS;
}
@Override
public EventInstanceSerializer self() {
return this;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public EventInstanceSerializer oneWhere(IWhere condition) throws XtumlException {
if (null == condition) throw new XtumlException("Null condition passed to selection.");
return EventInstanceSerializerImpl.EMPTY_EVENTINSTANCESERIALIZER;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy