/** * This file is part of ObjectFabric (http://objectfabric.org). * * ObjectFabric is licensed under the Apache License, Version 2.0, the terms * of which may be found at http://www.apache.org/licenses/LICENSE-2.0.html. * * Copyright ObjectFabric Inc. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.objectfabric.generated; //============================================================================== // // THIS FILE HAS BEEN GENERATED BY OBJECTFABRIC // //============================================================================== @SuppressWarnings({ "hiding", "unchecked", "static-access", "unused", "cast", "rawtypes" }) public class SimpleClass extends org.objectfabric.TGenerated { public SimpleClass(org.objectfabric.Resource resource) { this(resource, new Version(FIELD_COUNT), FIELD_COUNT); } protected SimpleClass(org.objectfabric.Resource resource, org.objectfabric.TObject.Version shared, int length) { super(resource, shared, FIELD_COUNT); } public SimpleClass(SimpleClass toCopy) { this(toCopy.resource()); text(toCopy.text()); int0(toCopy.int0()); int1(toCopy.int1()); int2(toCopy.int2()); int3(toCopy.int3()); map(toCopy.map()); } public static final org.objectfabric.TType TYPE = new org.objectfabric.TType(org.objectfabric.generated.SimpleObjectModel.instance(), org.objectfabric.generated.SimpleObjectModel.ORG_OBJECTFABRIC_GENERATED_SIMPLECLASS_CLASS_ID); public final java.lang.String text() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, TEXT_INDEX); java.lang.String value = v != null ? v._text : null; endRead_(outer, inner); return value; } public final void text(java.lang.String value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._text = value; v.setBit(TEXT_INDEX); endWrite_(outer, inner); } public final int int0() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, INT0_INDEX); int value = v != null ? v._int0 : 0; endRead_(outer, inner); return value; } public final void int0(int value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._int0 = value; v.setBit(INT0_INDEX); endWrite_(outer, inner); } public final int int1() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, INT1_INDEX); int value = v != null ? v._int1 : 0; endRead_(outer, inner); return value; } public final void int1(int value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._int1 = value; v.setBit(INT1_INDEX); endWrite_(outer, inner); } public final int int2() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, INT2_INDEX); int value = v != null ? v._int2 : 0; endRead_(outer, inner); return value; } public final void int2(int value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._int2 = value; v.setBit(INT2_INDEX); endWrite_(outer, inner); } public final int int3() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, INT3_INDEX); int value = v != null ? v._int3 : 0; endRead_(outer, inner); return value; } public final void int3(int value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._int3 = value; v.setBit(INT3_INDEX); endWrite_(outer, inner); } public final org.objectfabric.TMap map() { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startRead_(outer); Version v = (Version) getVersion32_(inner, MAP_INDEX); org.objectfabric.TMap value = v != null ? v._map : null; endRead_(outer, inner); return value; } public final void map(org.objectfabric.TMap value) { if (value.resource() != resource()) wrongResource_(); org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._map = value; v.setBit(MAP_INDEX); endWrite_(outer, inner); } public static final int TEXT_INDEX = 0; public static final java.lang.String TEXT_NAME = "text"; public static final org.objectfabric.TType TEXT_TYPE = org.objectfabric.Immutable.STRING.type(); public static final int INT0_INDEX = 1; public static final java.lang.String INT0_NAME = "int0"; public static final org.objectfabric.TType INT0_TYPE = org.objectfabric.Immutable.INTEGER.type(); public static final int INT1_INDEX = 2; public static final java.lang.String INT1_NAME = "int1"; public static final org.objectfabric.TType INT1_TYPE = org.objectfabric.Immutable.INTEGER.type(); public static final int INT2_INDEX = 3; public static final java.lang.String INT2_NAME = "int2"; public static final org.objectfabric.TType INT2_TYPE = org.objectfabric.Immutable.INTEGER.type(); public static final int INT3_INDEX = 4; public static final java.lang.String INT3_NAME = "int3"; public static final org.objectfabric.TType INT3_TYPE = org.objectfabric.Immutable.INTEGER.type(); public static final int MAP_INDEX = 5; public static final java.lang.String MAP_NAME = "map"; public static final org.objectfabric.TType MAP_TYPE = org.objectfabric.TMap.TYPE; public static final int FIELD_COUNT = 6; public static java.lang.String fieldName(int index) { switch (index) { case TEXT_INDEX: return TEXT_NAME; case INT0_INDEX: return INT0_NAME; case INT1_INDEX: return INT1_NAME; case INT2_INDEX: return INT2_NAME; case INT3_INDEX: return INT3_NAME; case MAP_INDEX: return MAP_NAME; default: throw new IllegalArgumentException(); } } public static org.objectfabric.TType fieldType(int index) { switch (index) { case TEXT_INDEX: return TEXT_TYPE; case INT0_INDEX: return INT0_TYPE; case INT1_INDEX: return INT1_TYPE; case INT2_INDEX: return INT2_TYPE; case INT3_INDEX: return INT3_TYPE; case MAP_INDEX: return MAP_TYPE; default: throw new IllegalArgumentException(); } } @Override protected org.objectfabric.TObject.Version createVersion_() { Version version = new Version(0); version.setObject(this); return version; } @Override protected int classId_() { return org.objectfabric.generated.SimpleObjectModel.ORG_OBJECTFABRIC_GENERATED_SIMPLECLASS_CLASS_ID; } @Override protected org.objectfabric.ObjectModel objectModel_() { return org.objectfabric.generated.SimpleObjectModel.instance(); } protected static class Version extends org.objectfabric.TIndexed.Version32 { public java.lang.String _text; public int _int0; public int _int1; public int _int2; public int _int3; public org.objectfabric.TMap _map; static { } public Version(int length) { super(length); } @Override public java.lang.String getFieldName(int index) { return fieldName(index); } @Override public org.objectfabric.TType getFieldType(int index) { return fieldType(index); } @Override public java.lang.Object getAsObject(int index) { switch (index) { case TEXT_INDEX: return _text; case INT0_INDEX: return _int0; case INT1_INDEX: return _int1; case INT2_INDEX: return _int2; case INT3_INDEX: return _int3; case MAP_INDEX: return _map; default: return super.getAsObject(index); } } @Override public void setAsObject(int index, java.lang.Object value) { switch (index) { case TEXT_INDEX: _text = (java.lang.String) value; break; case INT0_INDEX: _int0 = ((java.lang.Integer) value).intValue(); break; case INT1_INDEX: _int1 = ((java.lang.Integer) value).intValue(); break; case INT2_INDEX: _int2 = ((java.lang.Integer) value).intValue(); break; case INT3_INDEX: _int3 = ((java.lang.Integer) value).intValue(); break; case MAP_INDEX: _map = (org.objectfabric.TMap) value; break; default: super.setAsObject(index, value); break; } } @Override public void merge(org.objectfabric.TObject.Version next) { SimpleClass.Version source = (SimpleClass.Version) next; if (source.hasBits()) { if (source.getBit(TEXT_INDEX)) _text = source._text; if (source.getBit(INT0_INDEX)) _int0 = source._int0; if (source.getBit(INT1_INDEX)) _int1 = source._int1; if (source.getBit(INT2_INDEX)) _int2 = source._int2; if (source.getBit(INT3_INDEX)) _int3 = source._int3; if (source.getBit(MAP_INDEX)) _map = source._map; } super.merge(next); } @Override public void writeWrite(org.objectfabric.Writer writer, int index) { if (writer.interrupted()) writer.resume(); switch (index) { case TEXT_INDEX: { writer.writeString(_text); if (writer.interrupted()) { writer.interrupt(null); return; } break; } case INT0_INDEX: { if (!writer.canWriteInteger()) { writer.interrupt(null); return; } writer.writeInteger(_int0); break; } case INT1_INDEX: { if (!writer.canWriteInteger()) { writer.interrupt(null); return; } writer.writeInteger(_int1); break; } case INT2_INDEX: { if (!writer.canWriteInteger()) { writer.interrupt(null); return; } writer.writeInteger(_int2); break; } case INT3_INDEX: { if (!writer.canWriteInteger()) { writer.interrupt(null); return; } writer.writeInteger(_int3); break; } case MAP_INDEX: { writer.writeTObject(_map); if (writer.interrupted()) { writer.interrupt(null); return; } break; } default: { super.writeWrite(writer, index); if (writer.interrupted()) { writer.interrupt(null); return; } break; } } } @Override public void readWrite(org.objectfabric.Reader reader, int index, java.lang.Object[] versions) { if (reader.interrupted()) reader.resume(); switch (index) { case TEXT_INDEX: { java.lang.String value = reader.readString(); if (reader.interrupted()) { reader.interrupt(null); return; } for (int i = versions.length - 1; i >= 0; i--) ((Version) versions[i])._text = value; break; } case INT0_INDEX: { if (!reader.canReadInteger()) { reader.interrupt(null); return; } int value = reader.readInteger(); for (int i = versions.length - 1; i >= 0; i--) ((Version) versions[i])._int0 = value; break; } case INT1_INDEX: { if (!reader.canReadInteger()) { reader.interrupt(null); return; } int value = reader.readInteger(); for (int i = versions.length - 1; i >= 0; i--) ((Version) versions[i])._int1 = value; break; } case INT2_INDEX: { if (!reader.canReadInteger()) { reader.interrupt(null); return; } int value = reader.readInteger(); for (int i = versions.length - 1; i >= 0; i--) ((Version) versions[i])._int2 = value; break; } case INT3_INDEX: { if (!reader.canReadInteger()) { reader.interrupt(null); return; } int value = reader.readInteger(); for (int i = versions.length - 1; i >= 0; i--) ((Version) versions[i])._int3 = value; break; } case MAP_INDEX: { java.lang.Object value = reader.readTObject(); if (reader.interrupted()) { reader.interrupt(null); return; } for (int i = versions.length - 1; i >= 0; i--) { java.lang.Object v = value instanceof org.objectfabric.TObject[] ? ((org.objectfabric.TObject[]) value)[i] : value; ((Version) versions[i])._map = (org.objectfabric.TMap) v; } break; } default: { super.readWrite(reader, index, versions); if (reader.interrupted()) { reader.interrupt(null); return; } break; } } } } }